vladyslavstartsev / laravel-strict-coding-standard
PHP_CodeSniffer rules for Laravel to force the "right" design of the app
Installs: 3 743
Dependents: 0
Suggesters: 0
Security: 0
Stars: 44
Watchers: 2
Forks: 3
Type:phpcodesniffer-standard
Requires
- php: ^7.2 || ^8
- laravel/framework: ^7.30 || ^8.40.0 || ^9 || ^10
- slevomat/coding-standard: ^7.0
- squizlabs/php_codesniffer: ^3.6.0
Requires (Dev)
- doctrine/coding-standard: ^8.0
- ergebnis/composer-normalize: ^2.2
- php-parallel-lint/php-parallel-lint: ^1.2
- phpstan/phpstan: ^0.12.32
- phpstan/phpstan-phpunit: ^0.12.11
- phpstan/phpstan-strict-rules: 0.12.2
- phpunit/phpunit: ^9
- vimeo/psalm: ^3.8
README
PHP_CodeSniffer coding standards for Laravel, do force developers not to use bad design decisions that are supported by Laravel
Installing
composer require --dev vladyslavstartsev/laravel-strict-coding-standard
Sniffs included in this standard
LaravelStrictCodingStandard.Laravel.DisallowUseOfGlobalFunctions
-
checks for functions that are declared in
vendor/laravel/framework/src/Illuminate/Foundation/helpers.php
vendor/laravel/framework/src/Illuminate/Support/helpers.php
LaravelStrictCodingStandard.Laravel.DisallowUseOfFacades
- checks for usage of Laravel Facades (including Real-time facades)
- if not configured it will use default path for
Illuminate\Foundation\Application
instance atbootstrap/app.php
so for default Illuminate\Foundation\Application
instance use
<rule ref="LaravelStrictCodingStandard.Laravel.DisallowUseOfFacades"/>
to override, do this
<rule ref="LaravelStrictCodingStandard.Laravel.DisallowUseOfFacades"> <properties> <property name="laravelApplicationInstancePath" type="string" value=".nonDefaultFolder/application.php"/> </properties> </rule>
we need this instance, so we can get all Facades and Aliases that are potentially used in the app ( yes, this looks like dynamic code analysis, but that's the only way how to find out all Facades, if you have ideas how to do it statically, feel free to make PR)