diff --git a/README.md b/README.md index 5b57997..62e17be 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,12 @@ [![Latest Stable Version](https://img.shields.io/packagist/v/lmc/coding-standard.svg?style=flat-square)](https://packagist.org/packages/lmc/coding-standard) -PHP coding standard used in [Alma Career Czechia](https://www.almacareer.com/) (formerly LMC) products. +PHP coding standard used in [Alma Career Czechia][Alma Career] (formerly LMC) products. -Standard is based on [PSR-12](https://www.php-fig.org/psr/psr-12/) and adds +The standard is based on [PSR-12][psr-12] and partially [PER 2.0][per-2] and adds various checks to make sure the code is readable, follows the same conventions, and does not contain common mistakes. -We use [EasyCodingStandard] to define and execute checks created for both [PHP-CS-Fixer] and [PHP_CodeSniffer]. +We use [EasyCodingStandard][ecs] to define and execute checks created for both [PHP-CS-Fixer] and [PHP_CodeSniffer]. ## Installation @@ -59,7 +59,7 @@ Now you will be able to run the fix using `composer analyze` and execute automat ### Add custom checks or override default settings -On top of default code-style rules you are free to add any rules from [PHP-CS-Fixer] or [PHP_CodeSniffer]. +On top of the default code-style rules, you are free to add any rules from [PHP-CS-Fixer] or [PHP_CodeSniffer]. If needed, you can also override some default settings. ```php @@ -83,12 +83,12 @@ return ECSConfig::configure() /* (...) */ ``` -See [EasyCodingStandard docs](https://github.com/symplify/easy-coding-standard#configuration) for more configuration options. +See [EasyCodingStandard docs][ecs-docs] for more configuration options. ### Exclude (skip) checks or files -You can configure your `ecs.php` to entirely skip some files, disable specific checks or suppress specific errors. +You can configure your `ecs.php` file to entirely skip some files, disable specific checks, or suppress specific errors. ```php match // @see https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues/5894 @@ -393,10 +377,6 @@ // Require \Stringable interface in classes implementing __toString() method // > it may probably be a phpstan rule, more than cs rule - since it needs a class hierarchy to solve this // @see https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues/6235 - PropertyTypeHintSniff::class, - - ParameterTypeHintSniff::class, - ReturnTypeHintSniff::class, // Multi-line arguments list in function/method declaration must have a trailing comma RequireTrailingCommaInDeclarationSniff::class, @@ -531,18 +511,6 @@ // Allow single line closures ScopeClosingBraceSniff::class . '.ContentBefore' => null, - // Skip unwanted rules from PropertyTypeHintSniff - PropertyTypeHintSniff::class . '.' . PropertyTypeHintSniff::CODE_MISSING_TRAVERSABLE_TYPE_HINT_SPECIFICATION => null, - PropertyTypeHintSniff::class . '.' . PropertyTypeHintSniff::CODE_MISSING_ANY_TYPE_HINT => null, - - // Skip unwanted rules from ParameterTypeHintSniff - ParameterTypeHintSniff::class . '.' . ParameterTypeHintSniff::CODE_MISSING_TRAVERSABLE_TYPE_HINT_SPECIFICATION => null, - ParameterTypeHintSniff::class . '.' . ParameterTypeHintSniff::CODE_MISSING_ANY_TYPE_HINT => null, - - // Skip unwanted rules from ReturnTypeHintSniff - ReturnTypeHintSniff::class . '.' . ReturnTypeHintSniff::CODE_MISSING_TRAVERSABLE_TYPE_HINT_SPECIFICATION => null, - ReturnTypeHintSniff::class . '.' . ReturnTypeHintSniff::CODE_MISSING_ANY_TYPE_HINT => null, - // We use declare(strict_types=1); after opening tag BlankLineAfterOpeningTagFixer::class => null, ]); diff --git a/tests/Integration/Fixtures/NewPhpFeatures.correct.php.inc b/tests/Integration/Fixtures/NewPhpFeatures.correct.php.inc index c6e2726..f2962dd 100644 --- a/tests/Integration/Fixtures/NewPhpFeatures.correct.php.inc +++ b/tests/Integration/Fixtures/NewPhpFeatures.correct.php.inc @@ -4,8 +4,11 @@ namespace Lmc\CodingStandard\Integration\Fixtures; class NewPhpFeatures { - public function __construct(private string $someString) // RequireConstructorPropertyPromotionSniff + private string $someString; + + public function __construct(string $someString) { + $this->someString = $someString; } public function php80features( diff --git a/tests/Integration/Fixtures/NewPhpFeatures.wrong.php.inc b/tests/Integration/Fixtures/NewPhpFeatures.wrong.php.inc index 49d1d08..3435f7e 100644 --- a/tests/Integration/Fixtures/NewPhpFeatures.wrong.php.inc +++ b/tests/Integration/Fixtures/NewPhpFeatures.wrong.php.inc @@ -6,7 +6,7 @@ class NewPhpFeatures { private string $someString; - public function __construct(string $someString) // RequireConstructorPropertyPromotionSniff + public function __construct(string $someString) { $this->someString = $someString; }