generated from spatie/package-skeleton-laravel
-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code refactoring (maintained support for PHP v7.4)
Code review w/ GrumPHP tasks Added $queryData argument Removed createPopulateString method Cast cacheTime to integer Moved to PHP 7.4 minimum version Updated README Removed unnecessary createFilterString() method in favor of the more generic $queryData argument
- Loading branch information
1 parent
3a16b7c
commit 57ccdc3
Showing
17 changed files
with
432 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Laravel-Strapi helper. | ||
* | ||
* (ɔ) Dave Blakey https://github.com/dbfx | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE.md. | ||
*/ | ||
|
||
use PhpCsFixer\Config; | ||
use PhpCsFixer\ConfigurationException\InvalidConfigurationException; | ||
use PhpCsFixer\Finder; | ||
use PhpCsFixer\FixerFactory; | ||
use PhpCsFixer\RuleSet; | ||
|
||
$header = <<<'EOF' | ||
This file is part of the Laravel-Strapi helper. | ||
(ɔ) Dave Blakey https://github.com/dbfx | ||
This source file is subject to the MIT license that is bundled | ||
with this source code in the file LICENSE.md. | ||
EOF; | ||
|
||
// exclude will work only for directories, so if you need to exclude file, try notPath | ||
// directories passed as exclude() argument must be relative to the ones defined with the in() method | ||
$finder = Finder::create() | ||
->in([__DIR__]) | ||
->exclude(['vendor']) | ||
->append([__DIR__.'/.php-cs-fixer.dist.php']) | ||
; | ||
|
||
$config = (new Config()) | ||
->setCacheFile(sys_get_temp_dir().'/.php_cs.cache') | ||
->setRiskyAllowed(true) | ||
->setRules([ | ||
// https://mlocati.github.io/php-cs-fixer-configurator | ||
'@PHP74Migration:risky' => true, | ||
'@PHP74Migration' => true, | ||
'@PhpCsFixer' => true, | ||
// '@PhpCsFixer:risky' => true, | ||
'general_phpdoc_annotation_remove' => ['annotations' => ['expectedDeprecation']], | ||
'header_comment' => ['header' => $header], | ||
]) | ||
->setFinder($finder) | ||
; | ||
|
||
// special handling of fabbot.io service if it's using too old PHP CS Fixer version | ||
if (false !== getenv('FABBOT_IO')) { | ||
try { | ||
FixerFactory::create() | ||
->registerBuiltInFixers() | ||
->registerCustomFixers($config->getCustomFixers()) | ||
->useRuleSet(new RuleSet($config->getRules())) | ||
; | ||
} catch (InvalidConfigurationException $e) { | ||
$config->setRules([]); | ||
} catch (UnexpectedValueException $e) { | ||
$config->setRules([]); | ||
} catch (InvalidArgumentException $e) { | ||
$config->setRules([]); | ||
} | ||
} | ||
|
||
return $config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
grumphp: | ||
process_timeout: null | ||
tasks: | ||
composer: ~ | ||
|
||
composer_normalize: ~ | ||
|
||
phpcsfixer: | ||
config: .php-cs-fixer.dist.php | ||
|
||
#https://www.php.net/supported-versions.php | ||
phpversion: | ||
project: '7.4' | ||
|
||
psalm: | ||
config: psalm.xml.dist | ||
show_info: true | ||
|
||
#FIXME - upgrade to PHP 8.x | ||
#rector: ~ | ||
|
||
securitychecker_roave: | ||
run_always: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,39 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" executionOrder="random" failOnWarning="true" failOnRisky="true" failOnEmptyTestSuite="true" beStrictAboutOutputDuringTests="true"> | ||
<testsuites> | ||
<testsuite name="Dbfx Test Suite"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<coverage> | ||
<report> | ||
<html outputDirectory="build/coverage"/> | ||
<text outputFile="build/coverage.txt"/> | ||
<clover outputFile="build/logs/clover.xml"/> | ||
</report> | ||
</coverage> | ||
<logging> | ||
<junit outputFile="build/report.junit.xml"/> | ||
</logging> | ||
<php> | ||
<env name="STRAPI_URL" value="http://localhost:3000" /> | ||
</php> | ||
<phpunit | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" | ||
backupGlobals="false" | ||
backupStaticAttributes="false" | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
executionOrder="random" | ||
failOnWarning="true" | ||
failOnRisky="true" | ||
failOnEmptyTestSuite="true" | ||
beStrictAboutOutputDuringTests="true" | ||
verbose="true" | ||
> | ||
<testsuites> | ||
<testsuite name="Dbfx Test Suite"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<coverage> | ||
<include> | ||
<directory suffix=".php">./src</directory> | ||
</include> | ||
<report> | ||
<html outputDirectory="build/coverage"/> | ||
<text outputFile="build/coverage.txt"/> | ||
<clover outputFile="build/logs/clover.xml"/> | ||
</report> | ||
</coverage> | ||
<logging> | ||
<junit outputFile="build/report.junit.xml"/> | ||
</logging> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Laravel-Strapi helper. | ||
* | ||
* (ɔ) Dave Blakey https://github.com/dbfx | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE.md. | ||
*/ | ||
|
||
use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector; | ||
use Rector\Config\RectorConfig; | ||
use Rector\Set\ValueObject\LevelSetList; | ||
|
||
return RectorConfig::configure() | ||
->withPaths([ | ||
__DIR__.'/config', | ||
__DIR__.'/src', | ||
__DIR__.'/tests', | ||
]) | ||
->withRules([ | ||
InlineConstructorDefaultToPropertyRector::class, | ||
]) | ||
->withSets([ | ||
// define sets of rules | ||
LevelSetList::UP_TO_PHP_74, | ||
]) | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
<?php | ||
|
||
namespace Dbfx\LaravelStrapi\Exceptions; | ||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Laravel-Strapi helper. | ||
* | ||
* (ɔ) Dave Blakey https://github.com/dbfx | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE.md. | ||
*/ | ||
|
||
use RuntimeException; | ||
namespace Dbfx\LaravelStrapi\Exceptions; | ||
|
||
class NotFound extends RuntimeException | ||
{ | ||
} | ||
class NotFound extends \RuntimeException {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
<?php | ||
|
||
namespace Dbfx\LaravelStrapi\Exceptions; | ||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Laravel-Strapi helper. | ||
* | ||
* (ɔ) Dave Blakey https://github.com/dbfx | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE.md. | ||
*/ | ||
|
||
use RuntimeException; | ||
namespace Dbfx\LaravelStrapi\Exceptions; | ||
|
||
class PermissionDenied extends RuntimeException | ||
{ | ||
} | ||
class PermissionDenied extends \RuntimeException {} |
Oops, something went wrong.