diff --git a/src/app/Console/Kernel.php b/src/app/Console/Kernel.php index d8bc1d2..440377b 100644 --- a/src/app/Console/Kernel.php +++ b/src/app/Console/Kernel.php @@ -1,5 +1,7 @@ load(__DIR__.'/Commands'); + $this->load(__DIR__ . '/Commands'); require base_path('routes/console.php'); } diff --git a/src/app/Exceptions/Handler.php b/src/app/Exceptions/Handler.php index 8e7fbd1..ffdc187 100644 --- a/src/app/Exceptions/Handler.php +++ b/src/app/Exceptions/Handler.php @@ -1,5 +1,7 @@ expectsJson()) { return route('login'); } + + return null; } } diff --git a/src/app/Http/Middleware/EncryptCookies.php b/src/app/Http/Middleware/EncryptCookies.php index 867695b..a293077 100644 --- a/src/app/Http/Middleware/EncryptCookies.php +++ b/src/app/Http/Middleware/EncryptCookies.php @@ -1,5 +1,7 @@ configureRateLimiting(); diff --git a/src/composer.json b/src/composer.json index 2b0c115..deb8cde 100644 --- a/src/composer.json +++ b/src/composer.json @@ -18,7 +18,9 @@ "laravel/sail": "^1.0.1", "mockery/mockery": "^1.4.4", "nunomaduro/collision": "^5.10", - "phpunit/phpunit": "^9.5.10" + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^9.5.10", + "symplify/easy-coding-standard": "^12.0" }, "autoload": { "psr-4": { @@ -45,6 +47,27 @@ ], "post-create-project-cmd": [ "@php artisan key:generate --ansi" + ], + "phpunit": [ + "vendor/bin/phpunit --configuration phpunit.xml --coverage-text" + ], + "phpstan": [ + "vendor/bin/phpstan --configuration=./phpstan.neon" + ], + "ecs-all": [ + "vendor/bin/ecs check app tests --clear-cache" + ], + "ecs-app": [ + "vendor/bin/ecs check app --clear-cache" + ], + "ecs-test": [ + "vendor/bin/ecs check tests --clear-cache" + ], + "ecs-app-fix": [ + "vendor/bin/ecs check app --fix --clear-cache" + ], + "ecs-test-fix": [ + "vendor/bin/ecs check tests --fix --clear-cache" ] }, "extra": { diff --git a/src/composer.lock b/src/composer.lock index 35395b1..bf555d7 100644 --- a/src/composer.lock +++ b/src/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c61ff82cbf0142a401a48a8161e1595a", + "content-hash": "4b7d3a485c235d8fb1a0f5a92ac7b777", "packages": [ { "name": "asm89/stack-cors", @@ -6241,6 +6241,68 @@ }, "time": "2022-02-21T01:04:05+00:00" }, + { + "name": "phpstan/phpstan", + "version": "1.10.33", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "03b1cf9f814ba0863c4e9affea49a4d1ed9a2ed1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/03b1cf9f814ba0863c4e9affea49a4d1ed9a2ed1", + "reference": "03b1cf9f814ba0863c4e9affea49a4d1ed9a2ed1", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", + "issues": "https://github.com/phpstan/phpstan/issues", + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" + } + ], + "time": "2023-09-04T12:20:53+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "9.2.17", @@ -7621,6 +7683,64 @@ ], "time": "2020-09-28T06:39:44+00:00" }, + { + "name": "symplify/easy-coding-standard", + "version": "12.0.8", + "source": { + "type": "git", + "url": "https://github.com/easy-coding-standard/easy-coding-standard.git", + "reference": "99d87d188acc712dd6655ee946569f823cfeff69" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/easy-coding-standard/easy-coding-standard/zipball/99d87d188acc712dd6655ee946569f823cfeff69", + "reference": "99d87d188acc712dd6655ee946569f823cfeff69", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "conflict": { + "friendsofphp/php-cs-fixer": "<3.0", + "squizlabs/php_codesniffer": "<3.6", + "symplify/coding-standard": "<11.3" + }, + "bin": [ + "bin/ecs" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Use Coding Standard with 0-knowledge of PHP-CS-Fixer and PHP_CodeSniffer", + "keywords": [ + "Code style", + "automation", + "fixer", + "static analysis" + ], + "support": { + "issues": "https://github.com/easy-coding-standard/easy-coding-standard/issues", + "source": "https://github.com/easy-coding-standard/easy-coding-standard/tree/12.0.8" + }, + "funding": [ + { + "url": "https://www.paypal.me/rectorphp", + "type": "custom" + }, + { + "url": "https://github.com/tomasvotruba", + "type": "github" + } + ], + "time": "2023-09-08T10:17:14+00:00" + }, { "name": "theseer/tokenizer", "version": "1.2.1", @@ -7681,5 +7801,5 @@ "php": "^7.3|^8.0" }, "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/src/ecs.php b/src/ecs.php new file mode 100644 index 0000000..56d6307 --- /dev/null +++ b/src/ecs.php @@ -0,0 +1,49 @@ +sets([ + SetList::COMMON, + SetList::STRICT, + SetList::CLEAN_CODE, + SetList::PSR_12 + ]); + + $ecsConfig->skip([ +// // Rule Set Skip from PHP_CS_FIXER + PhpCsFixer\Fixer\Phpdoc\PhpdocNoEmptyReturnFixer::class, +// PhpCsFixer\Fixer\Phpdoc\PhpdocTrimFixer::class, +// PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer::class, +// PhpCsFixer\Fixer\CastNotation\CastSpacesFixer::class, // Always add space after casting +// PhpCsFixer\Fixer\ClassNotation\NoBlankLinesAfterClassOpeningFixer::class, + PhpCsFixer\Fixer\ControlStructure\YodaStyleFixer::class, // NO Yoda!!! +// PhpCsFixer\Fixer\ControlStructure\TrailingCommaInMultilineFixer::class, // Always add comma at the end +// PhpCsFixer\Fixer\FunctionNotation\MethodArgumentSpaceFixer::class, +// PhpCsFixer\Fixer\Phpdoc\NoEmptyPhpdocFixer::class, +// PhpCsFixer\Fixer\Phpdoc\PhpdocSeparationFixer::class, + PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer::class, // Unnecessary tag checking +// PhpCsFixer\Fixer\StringNotation\SingleQuoteFixer::class, // Always use Single quote over Double +// PhpCsFixer\Fixer\Whitespace\ArrayIndentationFixer::class, +// PhpCsFixer\Fixer\Whitespace\LineEndingFixer::class, // Skip, Always use LF for line ending +// PhpCsFixer\Fixer\Whitespace\NoWhitespaceInBlankLineFixer::class, // No whitespace in blank lines(end) +// PhpCsFixer\Fixer\Whitespace\SingleBlankLineAtEofFixer::class, // Always add a blank line at the eof +// Symplify\CodingStandard\Fixer\ArrayNotation\ArrayOpenerAndCloserNewlineFixer::class, // Skip for now// + PhpCsFixer\Fixer\ClassNotation\SingleTraitInsertPerStatementFixer::class, + ]); + + // Adding Specific rule, Disabled for now + $ecsConfig->rules([ + PhpCsFixer\Fixer\Basic\EncodingFixer::class, + ]); + + // B. standalone rule + $ecsConfig->ruleWithConfiguration(ArraySyntaxFixer::class, [ + 'syntax' => 'short', + ]); +}; diff --git a/src/phpstan.neon b/src/phpstan.neon new file mode 100644 index 0000000..9cbb74a --- /dev/null +++ b/src/phpstan.neon @@ -0,0 +1,9 @@ +parameters: + level: 7 + paths: + - app + - tests + + ignoreErrors: + # TODO: Laravel 8 - PhpStan Errors + - '/Method App\\Http\\Middleware\\RedirectIfAuthenticated::handle\(\) has parameter \$guards with no type specified./' diff --git a/src/tests/CreatesApplication.php b/src/tests/CreatesApplication.php index 547152f..5dd115e 100644 --- a/src/tests/CreatesApplication.php +++ b/src/tests/CreatesApplication.php @@ -1,19 +1,22 @@ make(Kernel::class)->bootstrap(); diff --git a/src/tests/Feature/ExampleTest.php b/src/tests/Feature/ExampleTest.php index 4ae02bc..698f4a1 100644 --- a/src/tests/Feature/ExampleTest.php +++ b/src/tests/Feature/ExampleTest.php @@ -1,8 +1,9 @@ get('/'); diff --git a/src/tests/TestCase.php b/src/tests/TestCase.php index 2932d4a..5341116 100644 --- a/src/tests/TestCase.php +++ b/src/tests/TestCase.php @@ -1,5 +1,7 @@ assertTrue(true); }