{"id":13607813,"url":"https://github.com/ergebnis/phpstan-rules","last_synced_at":"2026-01-27T11:10:02.697Z","repository":{"id":33274925,"uuid":"157371183","full_name":"ergebnis/phpstan-rules","owner":"ergebnis","description":"👓 Provides a composer package with rules for phpstan/phpstan.","archived":false,"fork":false,"pushed_at":"2024-05-01T09:50:37.000Z","size":3426,"stargazers_count":330,"open_issues_count":5,"forks_count":19,"subscribers_count":6,"default_branch":"main","last_synced_at":"2024-05-01T11:41:19.648Z","etag":null,"topics":["phpstan","phpstan-rules"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ergebnis.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["ergebnis","localheinz"]}},"created_at":"2018-11-13T11:42:12.000Z","updated_at":"2024-05-07T10:31:21.923Z","dependencies_parsed_at":"2023-12-21T11:39:47.546Z","dependency_job_id":"87540d43-5f4b-4048-b984-eadd7f094e13","html_url":"https://github.com/ergebnis/phpstan-rules","commit_stats":{"total_commits":453,"total_committers":14,"mean_commits":"32.357142857142854","dds":"0.49227373068432667","last_synced_commit":"ad7bb31ca59c06aa4e690598c12061def085324b"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ergebnis%2Fphpstan-rules","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ergebnis%2Fphpstan-rules/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ergebnis%2Fphpstan-rules/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ergebnis%2Fphpstan-rules/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ergebnis","download_url":"https://codeload.github.com/ergebnis/phpstan-rules/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247556815,"owners_count":20958034,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["phpstan","phpstan-rules"],"created_at":"2024-08-01T19:01:21.826Z","updated_at":"2026-01-27T11:10:02.690Z","avatar_url":"https://github.com/ergebnis.png","language":"PHP","funding_links":["https://github.com/sponsors/ergebnis","https://github.com/sponsors/localheinz"],"categories":["PHP"],"sub_categories":[],"readme":"# phpstan-rules\n\n[![Integrate](https://github.com/ergebnis/phpstan-rules/workflows/Integrate/badge.svg)](https://github.com/ergebnis/phpstan-rules/actions)\n[![Merge](https://github.com/ergebnis/phpstan-rules/workflows/Merge/badge.svg)](https://github.com/ergebnis/phpstan-rules/actions)\n[![Release](https://github.com/ergebnis/phpstan-rules/workflows/Release/badge.svg)](https://github.com/ergebnis/phpstan-rules/actions)\n[![Renew](https://github.com/ergebnis/phpstan-rules/workflows/Renew/badge.svg)](https://github.com/ergebnis/phpstan-rules/actions)\n\n[![Code Coverage](https://codecov.io/gh/ergebnis/phpstan-rules/branch/main/graph/badge.svg)](https://codecov.io/gh/ergebnis/phpstan-rules)\n\n[![Latest Stable Version](https://poser.pugx.org/ergebnis/phpstan-rules/v/stable)](https://packagist.org/packages/ergebnis/phpstan-rules)\n[![Total Downloads](https://poser.pugx.org/ergebnis/phpstan-rules/downloads)](https://packagist.org/packages/ergebnis/phpstan-rules)\n[![Monthly Downloads](http://poser.pugx.org/ergebnis/phpstan-rules/d/monthly)](https://packagist.org/packages/ergebnis/phpstan-rules)\n\nThis project provides a [`composer`](https://getcomposer.org) package with rules for [`phpstan/phpstan`](https://github.com/phpstan/phpstan).\n\n## Installation\n\nRun\n\n```sh\ncomposer require --dev ergebnis/phpstan-rules\n```\n\n## Usage\n\nAll of the [rules](https://github.com/ergebnis/phpstan-rules#rules) provided (and used) by this library are included in [`rules.neon`](rules.neon).\n\nWhen you are using [`phpstan/extension-installer`](https://github.com/phpstan/extension-installer), `rules.neon` will be automatically included.\n\nOtherwise you need to include `rules.neon` in your `phpstan.neon`:\n\n```neon\nincludes:\n\t- vendor/ergebnis/phpstan-rules/rules.neon\n```\n\n:bulb: You probably want to use these rules on top of the rules provided by:\n\n- [`phpstan/phpstan`](https://github.com/phpstan/phpstan)\n- [`phpstan/phpstan-deprecation-rules`](https://github.com/phpstan/phpstan-deprecation-rules)\n- [`phpstan/phpstan-strict-rules`](https://github.com/phpstan/phpstan-strict-rules)\n\n## Rules\n\nThis package provides the following rules for use with [`phpstan/phpstan`](https://github.com/phpstan/phpstan):\n\n- [`Ergebnis\\PHPStan\\Rules\\CallLikes\\NoNamedArgumentRule`](https://github.com/ergebnis/phpstan-rules#calllikesnonamedargumentrule)\n- [`Ergebnis\\PHPStan\\Rules\\Classes\\FinalRule`](https://github.com/ergebnis/phpstan-rules#classesfinalrule)\n- [`Ergebnis\\PHPStan\\Rules\\Classes\\NoExtendsRule`](https://github.com/ergebnis/phpstan-rules#classesnoextendsrule)\n- [`Ergebnis\\PHPStan\\Rules\\Classes\\PHPUnit\\Framework\\TestCaseWithSuffixRule`](https://github.com/ergebnis/phpstan-rules#classesphpunitframeworktestcasewithsuffixrule)\n- [`Ergebnis\\PHPStan\\Rules\\Closures\\NoNullableReturnTypeDeclarationRule`](https://github.com/ergebnis/phpstan-rules#closuresnonullablereturntypedeclarationrule)\n- [`Ergebnis\\PHPStan\\Rules\\Closures\\NoParameterPassedByReferenceRule`](https://github.com/ergebnis/phpstan-rules#closuresnoparameterpassedbyreferencerule)\n- [`Ergebnis\\PHPStan\\Rules\\Closures\\NoParameterWithNullableTypeDeclarationRule`](https://github.com/ergebnis/phpstan-rules#closuresnoparameterwithnullabletypedeclarationrule)\n- [`Ergebnis\\PHPStan\\Rules\\Closures\\NoParameterWithNullDefaultValueRule`](https://github.com/ergebnis/phpstan-rules#closuresnoparameterwithnulldefaultvaluerule)\n- [`Ergebnis\\PHPStan\\Rules\\Expressions\\NoAssignByReferenceRule`](https://github.com/ergebnis/phpstan-rules#expressionsnoassignbyreferencerule)\n- [`Ergebnis\\PHPStan\\Rules\\Expressions\\NoCompactRule`](https://github.com/ergebnis/phpstan-rules#expressionsnocompactrule)\n- [`Ergebnis\\PHPStan\\Rules\\Expressions\\NoErrorSuppressionRule`](https://github.com/ergebnis/phpstan-rules#expressionsnoerrorsuppressionrule)\n- [`Ergebnis\\PHPStan\\Rules\\Expressions\\NoEvalRule`](https://github.com/ergebnis/phpstan-rules#expressionsnoevalrule)\n- [`Ergebnis\\PHPStan\\Rules\\Expressions\\NoIssetRule`](https://github.com/ergebnis/phpstan-rules#expressionsnoissetrule)\n- [`Ergebnis\\PHPStan\\Rules\\Files\\DeclareStrictTypesRule`](https://github.com/ergebnis/phpstan-rules#filesdeclarestricttypesrule)\n- [`Ergebnis\\PHPStan\\Rules\\Files\\NoPhpstanIgnoreRule`](https://github.com/ergebnis/phpstan-rules#filesnophpstanignorerule)\n- [`Ergebnis\\PHPStan\\Rules\\Functions\\NoNullableReturnTypeDeclarationRule`](https://github.com/ergebnis/phpstan-rules#functionsnonullablereturntypedeclarationrule)\n- [`Ergebnis\\PHPStan\\Rules\\Functions\\NoParameterPassedByReferenceRule`](https://github.com/ergebnis/phpstan-rules#functionsnoparameterpassedbyreferencerule)\n- [`Ergebnis\\PHPStan\\Rules\\Functions\\NoParameterWithNullableTypeDeclarationRule`](https://github.com/ergebnis/phpstan-rules#functionsnoparameterwithnullabletypedeclarationrule)\n- [`Ergebnis\\PHPStan\\Rules\\Functions\\NoParameterWithNullDefaultValueRule`](https://github.com/ergebnis/phpstan-rules#functionsnoparameterwithnulldefaultvaluerule)\n- [`Ergebnis\\PHPStan\\Rules\\Functions\\NoReturnByReferenceRule`](https://github.com/ergebnis/phpstan-rules#functionsnoreturnbyreferencerule)\n- [`Ergebnis\\PHPStan\\Rules\\Methods\\FinalInAbstractClassRule`](https://github.com/ergebnis/phpstan-rules#methodsfinalinabstractclassrule)\n- [`Ergebnis\\PHPStan\\Rules\\Methods\\InvokeParentHookMethodRule`](https://github.com/ergebnis/phpstan-rules#methodsinvokeparenthookmethodrule)\n- [`Ergebnis\\PHPStan\\Rules\\Methods\\NoConstructorParameterWithDefaultValueRule`](https://github.com/ergebnis/phpstan-rules#methodsnoconstructorparameterwithdefaultvaluerule)\n- [`Ergebnis\\PHPStan\\Rules\\Methods\\NoNullableReturnTypeDeclarationRule`](https://github.com/ergebnis/phpstan-rules#methodsnonullablereturntypedeclarationrule)\n- [`Ergebnis\\PHPStan\\Rules\\Methods\\NoParameterPassedByReferenceRule`](https://github.com/ergebnis/phpstan-rules#methodsnoparameterpassedbyreferencerule)\n- [`Ergebnis\\PHPStan\\Rules\\Methods\\NoParameterWithContainerTypeDeclarationRule`](https://github.com/ergebnis/phpstan-rules#methodsnoparameterwithcontainertypedeclarationrule)\n- [`Ergebnis\\PHPStan\\Rules\\Methods\\NoParameterWithNullableTypeDeclarationRule`](https://github.com/ergebnis/phpstan-rules#methodsnoparameterwithnullabletypedeclarationrule)\n- [`Ergebnis\\PHPStan\\Rules\\Methods\\NoParameterWithNullDefaultValueRule`](https://github.com/ergebnis/phpstan-rules#methodsnoparameterwithnulldefaultvaluerule)\n- [`Ergebnis\\PHPStan\\Rules\\Methods\\NoReturnByReferenceRule`](https://github.com/ergebnis/phpstan-rules#methodsnoreturnbyreferencerule)\n- [`Ergebnis\\PHPStan\\Rules\\Methods\\PrivateInFinalClassRule`](https://github.com/ergebnis/phpstan-rules#methodsprivateinfinalclassrule)\n- [`Ergebnis\\PHPStan\\Rules\\Statements\\NoSwitchRule`](https://github.com/ergebnis/phpstan-rules#statementsnoswitchrule)\n\n\n### CallLikes\n\n#### `CallLikes\\NoNamedArgumentRule`\n\nThis rule reports an error when an anonymous function, a function, or a method is invoked using a [named argument](https://www.php.net/manual/en/functions.arguments.php#functions.named-arguments).\n\n##### Disabling the rule\n\nYou can set the `enabled` parameter to `false` to disable this rule.\n\n```neon\nparameters:\n\tergebnis:\n\t\tnoNamedArgument:\n\t\t\tenabled: false\n```\n\n### Classes\n\n#### `Classes\\FinalRule`\n\nThis rule reports an error when a non-anonymous class is not `final`.\n\n:bulb: This rule ignores classes that\n\n- use `@Entity`, `@ORM\\Entity`, or `@ORM\\Mapping\\Entity` annotations\n- use `Doctrine\\ORM\\Mapping\\Entity` attributes\n\non the class level.\n\n##### Disabling the rule\n\nYou can set the `enabled` parameter to `false` to disable this rule.\n\n```neon\nparameters:\n\tergebnis:\n\t\tfinal:\n\t\t\tenabled: false\n```\n\n##### Disallowing `abstract` classes\n\nBy default, this rule allows to declare `abstract` classes.\n\nYou can set the `allowAbstractClasses` parameter to `false` to disallow abstract classes.\n\n```neon\nparameters:\n\tergebnis:\n\t\tfinal:\n\t\t\tallowAbstractClasses: false\n```\n\n##### Excluding classes from inspection\n\nYou can set the `classesNotRequiredToBeAbstractOrFinal` parameter to a list of class names that you want to exclude from inspection.\n\n```neon\nparameters:\n\tergebnis:\n\t\tfinal:\n\t\t\tclassesNotRequiredToBeAbstractOrFinal:\n\t\t\t\t- Foo\\Bar\\NeitherAbstractNorFinal\n\t\t\t\t- Bar\\Baz\\NeitherAbstractNorFinal\n```\n\n#### `Classes\\NoExtendsRule`\n\nThis rule reports an error when a class extends another class.\n\n##### Defaults\n\nBy default, this rule allows the following classes to be extended:\n\n- [`PHPUnit\\Framework\\TestCase`](https://github.com/sebastianbergmann/phpunit/blob/6.0.0/src/Framework/TestCase.php)\n\n##### Disabling the rule\n\nYou can set the `enabled` parameter to `false` to disable this rule.\n\n```neon\nparameters:\n\tergebnis:\n\t\tnoExtends:\n\t\t\tenabled: false\n```\n\n##### Allowing classes to be extended\n\nYou can set the `classesAllowedToBeExtended` parameter to a list of class names that you want to allow to be extended.\n\n```neon\nparameters:\n\tergebnis:\n\t\tnoExtends:\n\t\t\tclassesAllowedToBeExtended:\n\t\t\t\t- Ergebnis\\PHPStan\\Rules\\Test\\Integration\\AbstractTestCase\n\t\t\t\t- Ergebnis\\PHPStan\\Rules\\Test\\Integration\\AbstractTestCase\n```\n\n#### `Classes\\PHPUnit\\Framework\\TestCaseWithSuffixRule`\n\nThis rule reports an error when a concrete class is a sub-class of `PHPUnit\\Framework\\TestCase` but does not have a `Test` suffix.\n\n##### Disabling the rule\n\nYou can set the `enabled` parameter to `false` to disable this rule.\n\n```neon\nparameters:\n\tergebnis:\n\t\ttestCaseWithSuffix:\n\t\t\tenabled: false\n```\n\n### Closures\n\n#### `Closures\\NoNullableReturnTypeDeclarationRule`\n\nThis rule reports an error when a closure uses a nullable return type declaration.\n\n##### Disabling the rule\n\nYou can set the `enabled` parameter to `false` to disable this rule.\n\n```neon\nparameters:\n\tergebnis:\n\t\tnoNullableReturnTypeDeclaration:\n\t\t\tenabled: false\n```\n\n#### `Closures\\NoParameterPassedByReferenceRule`\n\nThis rule reports an error when a closure has a parameter that is [passed by reference](https://www.php.net/manual/en/language.references.pass.php).\n\n##### Disabling the rule\n\nYou can set the `enabled` parameter to `false` to disable this rule.\n\n```neon\nparameters:\n\tergebnis:\n\t\tnoParameterPassedByReference:\n\t\t\tenabled: false\n```\n\n#### `Closures\\NoParameterWithNullableTypeDeclarationRule`\n\nThis rule reports an error when a closure has a parameter with a nullable type declaration.\n\n##### Disabling the rule\n\nYou can set the `enabled` parameter to `false` to disable this rule.\n\n```neon\nparameters:\n\tergebnis:\n\t\tnoParameterWithNullableTypeDeclaration:\n\t\t\tenabled: false\n```\n\n#### `Closures\\NoParameterWithNullDefaultValueRule`\n\nThis rule reports an error when a closure has a parameter with `null` as default value.\n\n##### Disabling the rule\n\nYou can set the `enabled` parameter to `false` to disable this rule.\n\n```neon\nparameters:\n\tergebnis:\n\t\tnoParameterWithNullDefaultValue:\n\t\t\tenabled: false\n```\n\n### Expressions\n\n#### `Expressions\\NoAssignByReferenceRule`\n\nThis rule reports an error when [a variable is assigned by reference](https://www.php.net/manual/en/language.references.whatdo.php#language.references.whatdo.assign).\n\n##### Disabling the rule\n\nYou can set the `enabled` parameter to `false` to disable this rule.\n\n```neon\nparameters:\n\tergebnis:\n\t\tnoAssignByReference:\n\t\t\tenabled: false\n```\n\n#### `Expressions\\NoCompactRule`\n\nThis rule reports an error when the function [`compact()`](https://www.php.net/compact) is used.\n\n##### Disabling the rule\n\nYou can set the `enabled` parameter to `false` to disable this rule.\n\n```neon\nparameters:\n\tergebnis:\n\t\tnoCompact:\n\t\t\tenabled: false\n```\n\n#### `Expressions\\NoErrorSuppressionRule`\n\nThis rule reports an error when [`@`](https://www.php.net/manual/en/language.operators.errorcontrol.php) is used to suppress errors.\n\n##### Disabling the rule\n\nYou can set the `enabled` parameter to `false` to disable this rule.\n\n```neon\nparameters:\n\tergebnis:\n\t\tnoErrorSuppression:\n\t\t\tenabled: false\n```\n\n#### `Expressions\\NoEvalRule`\n\nThis rule reports an error when the language construct [`eval()`](https://www.php.net/eval) is used.\n\n##### Disabling the rule\n\nYou can set the `enabled` parameter to `false` to disable this rule.\n\n```neon\nparameters:\n\tergebnis:\n\t\tnoEval:\n\t\t\tenabled: false\n```\n\n#### `Expressions\\NoIssetRule`\n\nThis rule reports an error when the language construct [`isset()`](https://www.php.net/isset) is used.\n\n##### Disabling the rule\n\nYou can set the `enabled` parameter to `false` to disable this rule.\n\n```neon\nparameters:\n\tergebnis:\n\t\tnoIsset:\n\t\t\tenabled: false\n```\n\n### Files\n\n#### `Files\\DeclareStrictTypesRule`\n\nThis rule reports an error when a non-empty file does not contain a `declare(strict_types=1)` declaration.\n\n##### Disabling the rule\n\nYou can set the `enabled` parameter to `false` to disable this rule.\n\n```neon\nparameters:\n\tergebnis:\n\t\tdeclareStrictTypes:\n\t\t\tenabled: false\n```\n\n#### `Files\\NoPhpstanIgnoreRule`\n\nThis rule reports an error when a `@phpstan-ignore`, `@phpstan-ignore-line`, or `@phpstan-ignore-next-line` tag is used to [ignore errors reported by `phpstan/phpstan`](https://phpstan.org/user-guide/ignoring-errors#ignoring-in-code-using-phpdocs).\n\n##### Disabling the rule\n\nYou can set the `enabled` parameter to `false` to disable this rule.\n\n```neon\nparameters:\n\tergebnis:\n\t\tnoPhpstanIgnore:\n\t\t\tenabled: false\n```\n\n### Functions\n\n#### `Functions\\NoNullableReturnTypeDeclarationRule`\n\nThis rule reports an error when a function uses a nullable return type declaration.\n\n##### Disabling the rule\n\nYou can set the `enabled` parameter to `false` to disable this rule.\n\n```neon\nparameters:\n\tergebnis:\n\t\tnoNullableReturnTypeDeclaration:\n\t\t\tenabled: false\n```\n\n#### `Functions\\NoParameterPassedByReferenceRule`\n\nThis rule reports an error when a function has a parameter that is [passed by reference](https://www.php.net/manual/en/language.references.pass.php).\n\n##### Disabling the rule\n\nYou can set the `enabled` parameter to `false` to disable this rule.\n\n```neon\nparameters:\n\tergebnis:\n\t\tnoParameterPassedByReference:\n\t\t\tenabled: false\n```\n\n#### `Functions\\NoParameterWithNullableTypeDeclarationRule`\n\nThis rule reports an error when a function has a parameter with a nullable type declaration.\n\n##### Disabling the rule\n\nYou can set the `enabled` parameter to `false` to disable this rule.\n\n```neon\nparameters:\n\tergebnis:\n\t\tnoParameterWithNullableTypeDeclaration:\n\t\t\tenabled: false\n```\n\n#### `Functions\\NoParameterWithNullDefaultValueRule`\n\nThis rule reports an error when a function has a parameter with `null` as default value.\n\n##### Disabling the rule\n\nYou can set the `enabled` parameter to `false` to disable this rule.\n\n```neon\nparameters:\n\tergebnis:\n\t\tnoParameterWithNullDefaultValue:\n\t\t\tenabled: false\n```\n\n#### `Functions\\NoReturnByReferenceRule`\n\nThis rule reports an error when a function [returns by reference](https://www.php.net/manual/en/language.references.return.php).\n\n##### Disabling the rule\n\nYou can set the `enabled` parameter to `false` to disable this rule.\n\n```neon\nparameters:\n\tergebnis:\n\t\tnoReturnByReference:\n\t\t\tenabled: false\n```\n\n### Methods\n\n#### `Methods\\FinalInAbstractClassRule`\n\nThis rule reports an error when a concrete `public` or `protected` method in an `abstract` class is not `final`.\n\n:bulb: This rule ignores\n\n- Doctrine embeddables\n- Doctrine entities\n\n##### Disabling the rule\n\nYou can set the `enabled` parameter to `false` to disable this rule.\n\n```neon\nparameters:\n\tergebnis:\n\t\tfinalInAbstractClass:\n\t\t\tenabled: false\n```\n\n#### `Methods\\InvokeParentHookMethodRule`\n\nThis rule reports an error when a hook method that overrides a hook method in a parent class does not invoke the overridden hook method in the expected order.\n\n##### Defaults\n\nBy default, this rule requires the following hook methods to be invoked before doing something in the overriding method:\n\n- [`Codeception\\PHPUnit\\TestCase::_setUp()`](https://github.com/Codeception/phpunit-wrapper/blob/9.0.0/src/TestCase.php#L11-L13)\n- [`Codeception\\PHPUnit\\TestCase::_setUpBeforeClass()`](https://github.com/Codeception/phpunit-wrapper/blob/9.0.0/src/TestCase.php#L25-L27)\n- [`Codeception\\Test\\Unit::_before()`](https://github.com/Codeception/Codeception/blob/4.2.2/src/Codeception/Test/Unit.php#L63-L65)\n- [`Codeception\\Test\\Unit::_setUp()`](https://github.com/Codeception/Codeception/blob/4.2.2/src/Codeception/Test/Unit.php#L34-L58)\n- [`PHPUnit\\Framework\\TestCase::assertPreConditions()`](https://github.com/sebastianbergmann/phpunit/blob/6.0.0/src/Framework/TestCase.php#L2073-L2075)\n- [`PHPUnit\\Framework\\TestCase::setUp()`](https://github.com/sebastianbergmann/phpunit/blob/6.0.0/src/Framework/TestCase.php#L2063-L2065)\n- [`PHPUnit\\Framework\\TestCase::setUpBeforeClass()`](https://github.com/sebastianbergmann/phpunit/blob/6.0.0/src/Framework/TestCase.php#L2055-L2057)\n\nBy default, this rule requires the following hook methods to be invoked after doing something in the overriding method:\n\n- [`Codeception\\PHPUnit\\TestCase::_tearDown()`](https://github.com/Codeception/phpunit-wrapper/blob/9.0.0/src/TestCase.php#L18-L20)\n- [`Codeception\\PHPUnit\\TestCase::_tearDownAfterClass()`](https://github.com/Codeception/phpunit-wrapper/blob/9.0.0/src/TestCase.php#L32-L34)\n- [`Codeception\\Test\\Unit::_after()`](https://github.com/Codeception/Codeception/blob/4.2.2/src/Codeception/Test/Unit.php#L75-L77)\n- [`Codeception\\Test\\Unit::_tearDown()`](https://github.com/Codeception/Codeception/blob/4.2.2/src/Codeception/Test/Unit.php#L67-L70)\n- [`PHPUnit\\Framework\\TestCase::assertPostConditions()`](https://github.com/sebastianbergmann/phpunit/blob/6.0.0/src/Framework/TestCase.php#L2083-L2085)\n- [`PHPUnit\\Framework\\TestCase::tearDown()`](https://github.com/sebastianbergmann/phpunit/blob/6.0.0/src/Framework/TestCase.php#L2091-L2093)\n- [`PHPUnit\\Framework\\TestCase::tearDownAfterClass()`](https://github.com/sebastianbergmann/phpunit/blob/6.0.0/src/Framework/TestCase.php#L2098-L2100)\n\n##### Disabling the rule\n\nYou can set the `enabled` parameter to `false` to disable this rule.\n\n```neon\nparameters:\n\tergebnis:\n\t\tinvokeParentHookMethod:\n\t\t\tenabled: false\n```\n\n##### Configuring methods to invoke the parent method in the right order:\n\nYou can set the `hookMethods` parameter to a list of hook methods:\n\n```neon\nparameters:\n\tergebnis:\n\t\tinvokeParentHookMethod:\n\t\t\thookMethods:\n\t\t\t\t- className: \"Example\\Test\\Functional\\AbstractCest\"\n\t\t\t\t\tmethodName: \"_before\"\n\t\t\t\t\thasContent: \"yes\"\n\t\t\t\t\tinvocation: \"first\"\n```\n\n- `className`: name of the class that declares the hook method\n- `methodName`: name of the hook method\n- `hasContent`: one of `\"yes\"`, `\"no\"`, `\"maybe\"`\n- `invocation`: one of `\"any\"` (needs to be invoked), `\"first\"` (needs to be invoked before all other statements in the overriding hook method, `\"last\"` (needs to be invoked after all other statements in the overriding hook method)\n\n#### `Methods\\NoConstructorParameterWithDefaultValueRule`\n\nThis rule reports an error when a constructor declared in\n\n- an anonymous class\n- a class\n\nhas a default value.\n\n##### Disabling the rule\n\nYou can set the `enabled` parameter to `false` to disable this rule.\n\n```neon\nparameters:\n\tergebnis:\n\t\tnoConstructorParameterWithDefaultValue:\n\t\t\tenabled: false\n```\n\n#### `Methods\\NoParameterPassedByReferenceRule`\n\nThis rule reports an error when a method has a parameter that is [passed by reference](https://www.php.net/manual/en/language.references.pass.php).\n\n##### Disabling the rule\n\nYou can set the `enabled` parameter to `false` to disable this rule.\n\n```neon\nparameters:\n\tergebnis:\n\t\tnoParameterPassedByReference:\n\t\t\tenabled: false\n```\n\n#### `Methods\\NoNullableReturnTypeDeclarationRule`\n\nThis rule reports an error when a method declared in\n\n- an anonymous class\n- a class\n- an interface\n\nuses a nullable return type declaration.\n\n##### Disabling the rule\n\nYou can set the `enabled` parameter to `false` to disable this rule.\n\n```neon\nparameters:\n\tergebnis:\n\t\tnoNullableReturnTypeDeclaration:\n\t\t\tenabled: false\n```\n\n#### `Methods\\NoParameterWithContainerTypeDeclarationRule`\n\nThis rule reports an error when a method has a type declaration for a known dependency injection container or service locator.\n\n##### Defaults\n\nBy default, this rule disallows the use of type declarations indicating an implementation of\n\n- [`Psr\\Container\\ContainerInterface`](https://github.com/php-fig/container/blob/1.0.0/src/ContainerInterface.php)\n\nis expected to be injected into a method.\n\n##### Disabling the rule\n\nYou can set the `enabled` parameter to `false` to disable this rule.\n\n```neon\nparameters:\n\tergebnis:\n\t\tnoParameterWithContainerTypeDeclaration:\n\t\t\tenabled: false\n```\n\n##### Configuring container interfaces\n\nYou can set the `interfacesImplementedByContainers` parameter to a list of interface names of additional containers and service locators.\n\n```neon\nparameters:\n\tergebnis:\n\t\tnoParameterWithContainerTypeDeclaration:\n\t\t\tinterfacesImplementedByContainers:\n\t\t\t\t- Fancy\\DependencyInjection\\ContainerInterface\n\t\t\t\t- Other\\ServiceLocatorInterface\n```\n\n##### Configuring methods allowed to use parameters with container type declarations\n\nYou can set the `methodsAllowedToUseContainerTypeDeclarations` parameter to a list of method names that are allowed to use parameters with container type declarations.\n\n```neon\nparameters:\n\tergebnis:\n\t\tnoParameterWithContainerTypeDeclaration:\n\t\t\tmethodsAllowedToUseContainerTypeDeclarations:\n\t\t\t\t- loadExtension\n```\n\n#### `Methods\\NoParameterWithNullableTypeDeclarationRule`\n\nThis rule reports an error when a method declared in\n\n- an anonymous class\n- a class\n- an interface\n\nhas a parameter with a nullable type declaration.\n\n##### Disabling the rule\n\nYou can set the `enabled` parameter to `false` to disable this rule.\n\n```neon\nparameters:\n\tergebnis:\n\t\tnoParameterWithNullableTypeDeclaration:\n\t\t\tenabled: false\n```\n\n#### `Methods\\NoParameterWithNullDefaultValueRule`\n\nThis rule reports an error when a method declared in\n\n- an anonymous class\n- a class\n- an interface\n\nhas a parameter with `null` as default value.\n\n##### Disabling the rule\n\nYou can set the `enabled` parameter to `false` to disable this rule.\n\n```neon\nparameters:\n\tergebnis:\n\t\tnoParameterWithNullDefaultValue:\n\t\t\tenabled: false\n```\n\n#### `Functions\\NoReturnByReferenceRule`\n\nThis rule reports an error when a method [returns by reference](https://www.php.net/manual/en/language.references.return.php).\n\n##### Disabling the rule\n\nYou can set the `enabled` parameter to `false` to disable this rule.\n\n```neon\nparameters:\n\tergebnis:\n\t\tnoReturnByReference:\n\t\t\tenabled: false\n```\n\n#### `Methods\\PrivateInFinalClassRule`\n\nThis rule reports an error when a method in a `final` class is `protected` but could be `private`.\n\n##### Disabling the rule\n\nYou can set the `enabled` parameter to `false` to disable this rule.\n\n```neon\nparameters:\n\tergebnis:\n\t\tprivateInFinalClass:\n\t\t\tenabled: false\n```\n\n### Statements\n\n#### `Statements\\NoSwitchRule`\n\nThis rule reports an error when the statement [`switch()`](https://www.php.net/manual/control-structures.switch.php) is used.\n\n##### Disabling the rule\n\nYou can set the `enabled` parameter to `false` to disable this rule.\n\n```neon\nparameters:\n\tergebnis:\n\t\tnoSwitch:\n\t\t\tenabled: false\n```\n\n## Disabling all rules\n\nYou can disable all rules using the `allRules` configuration parameter:\n\n```neon\nparameters:\n\tergebnis:\n\t\tallRules: false\n```\n\n## Enabling rules one-by-one\n\nIf you have disabled all rules using the `allRules` configuration parameter, you can re-enable individual rules with their corresponding configuration parameters:\n\n```neon\nparameters:\n\tergebnis:\n\t\tallRules: false\n\t\tprivateInFinalClass:\n\t\t\tenabled: true\n```\n\n## Changelog\n\nThe maintainers of this project record notable changes to this project in a [changelog](CHANGELOG.md).\n\n## Contributing\n\nThe maintainers of this project suggest following the [contribution guide](.github/CONTRIBUTING.md).\n\n## Code of Conduct\n\nThe maintainers of this project ask contributors to follow the [code of conduct](https://github.com/ergebnis/.github/blob/main/CODE_OF_CONDUCT.md).\n\n## General Support Policy\n\nThe maintainers of this project provide limited support.\n\nYou can support the maintenance of this project by [sponsoring @ergebnis](https://github.com/sponsors/ergebnis).\n\n## PHP Version Support Policy\n\nThis project supports PHP versions with [active and security support](https://www.php.net/supported-versions.php).\n\nThe maintainers of this project add support for a PHP version following its initial release and drop support for a PHP version when it has reached the end of security support.\n\n## Security Policy\n\nThis project has a [security policy](.github/SECURITY.md).\n\n## License\n\nThis project uses the [MIT license](LICENSE.md).\n\n## Credits\n\nThe method [`FinalRule::isWhitelistedClass()`](src/Classes/FinalRule.php) is inspired by the work on [`FinalClassFixer`](https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/2.15/src/Fixer/ClassNotation/FinalClassFixer.php) and [`FinalInternalClassFixer`](https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/2.15/src/Fixer/ClassNotation/FinalInternalClassFixer.php), contributed by [Dariusz Rumiński](https://github.com/keradus), [Filippo Tessarotto](https://github.com/Slamdunk), and [Spacepossum](https://github.com/SpacePossum) for [`friendsofphp/php-cs-fixer`](https://github.com/FriendsOfPHP/PHP-CS-Fixer) (originally licensed under MIT).\n\n## Social\n\nFollow [@localheinz](https://twitter.com/intent/follow?screen_name=localheinz) and [@ergebnis](https://twitter.com/intent/follow?screen_name=ergebnis) on Twitter.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fergebnis%2Fphpstan-rules","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fergebnis%2Fphpstan-rules","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fergebnis%2Fphpstan-rules/lists"}