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.
Merge pull request #33 from frugan-dev/master
Code refactoring (maintained support for PHP v7.4)
- Loading branch information
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,43 @@ | ||
{ | ||
"name": "dbfx/laravel-strapi", | ||
"description": "Laravel wrapper for using the Strapi headless CMS", | ||
"license": "MIT", | ||
"keywords": [ | ||
"laravel", | ||
"strapi", | ||
"laravel-strapi", | ||
"strapi-cms", | ||
"laravel-package" | ||
], | ||
"homepage": "https://github.com/dbfx/laravel-strapi", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Dave Blakey", | ||
"email": "[email protected]", | ||
"role": "Developer" | ||
} | ||
], | ||
"homepage": "https://github.com/dbfx/laravel-strapi", | ||
"require": { | ||
"php": "^7.3|^7.4|^8.0|^8.1|^8.2", | ||
"laravel/framework": "^8|^9|^10", | ||
"spatie/laravel-package-tools": "^1.4.3", | ||
"illuminate/contracts": "^8.37|^9.0|^10" | ||
"php": "^7.4 || ^8.0", | ||
"illuminate/contracts": "^8.37 || ^9.0 || ^10", | ||
"laravel/framework": "^8 || ^9 || ^10", | ||
"spatie/laravel-package-tools": "^1.4.3" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^9.6", | ||
"orchestra/testbench": "^6.0" | ||
"brianium/paratest": "^6.2", | ||
"ergebnis/composer-normalize": "^2.42", | ||
"friendsofphp/php-cs-fixer": "^3.48", | ||
"nunomaduro/collision": "^5.3 || ^6.0", | ||
"orchestra/testbench": "^6.15", | ||
"phpro/grumphp-shim": "^1.13", | ||
"phpunit/phpunit": "^9.3", | ||
"rector/rector": "^0.19.5", | ||
"roave/security-advisories": "dev-latest", | ||
"spatie/laravel-ray": "^1.9", | ||
"vimeo/psalm": "^5.7" | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable": true, | ||
"autoload": { | ||
"psr-4": { | ||
"Dbfx\\LaravelStrapi\\": "src", | ||
|
@@ -38,24 +49,26 @@ | |
"Dbfx\\LaravelStrapi\\Tests\\": "tests" | ||
} | ||
}, | ||
"scripts": { | ||
"psalm": "vendor/bin/psalm", | ||
"test": "./vendor/bin/testbench package:test --parallel --no-coverage", | ||
"test-coverage": "vendor/bin/phpunit --coverage-html coverage" | ||
}, | ||
"config": { | ||
"allow-plugins": { | ||
"ergebnis/composer-normalize": true, | ||
"phpro/grumphp-shim": true | ||
}, | ||
"sort-packages": true | ||
}, | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"Dbfx\\LaravelStrapi\\LaravelStrapiServiceProvider" | ||
], | ||
"aliases": { | ||
"LaravelStrapi": "Dbfx\\LaravelStrapi\\LaravelStrapiFacade" | ||
} | ||
}, | ||
"providers": [ | ||
"Dbfx\\LaravelStrapi\\LaravelStrapiServiceProvider" | ||
] | ||
} | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable": true | ||
"scripts": { | ||
"psalm": "vendor/bin/psalm", | ||
"test": "./vendor/bin/testbench package:test --parallel --no-coverage", | ||
"test-coverage": "vendor/bin/phpunit --coverage-html coverage" | ||
} | ||
} |
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.