diff --git a/README.md b/README.md index a27da36ce..1d674f566 100644 --- a/README.md +++ b/README.md @@ -83,18 +83,6 @@ Jump to: [Symfony-specific rules](#3-symfony-specific-rules), [Doctrine-specific ## Special rules -### MaximumIgnoredErrorCountRule - -Tired of ever growing ignored error count in your `phpstan.neon`? Set hard limit to keep them low: - -```yaml -parameters: - symplify: - maximumIgnoredErrorCount: 50 -``` - -
- ### NewOverSettersRule If a class is always created with the same set of setters, pass the values via constructor instead. It makes the object state explicit, safer and easier to test: diff --git a/config/phpstan-extensions.neon b/config/phpstan-extensions.neon index 1aa8de1e7..b5b649d83 100644 --- a/config/phpstan-extensions.neon +++ b/config/phpstan-extensions.neon @@ -5,7 +5,6 @@ parameters: symfonyReturnType: false laravelReturnType: false pathStrings: false - maximumIgnoredErrorCount: 0 # kept flat for backward compatibility, default to the %symplify.*% nested values symfonyReturnType: %symplify.symfonyReturnType% @@ -19,7 +18,6 @@ parametersSchema: symfonyReturnType: bool() laravelReturnType: bool() pathStrings: bool() - maximumIgnoredErrorCount: int() ]) symfonyReturnType: bool() diff --git a/config/services/services.neon b/config/services/services.neon index 3856d4350..ccbe9822f 100644 --- a/config/services/services.neon +++ b/config/services/services.neon @@ -1,12 +1,3 @@ -parameters: - # related to MaximumIgnoredErrorCountRule - # kept flat for backward compatibility, defaults to %symplify.maximumIgnoredErrorCount% - maximumIgnoredErrorCount: %symplify.maximumIgnoredErrorCount% - -parametersSchema: - # related to MaximumIgnoredErrorCountRule - maximumIgnoredErrorCount: int() - services: - Symplify\PHPStanRules\NodeTraverser\SimpleCallableNodeTraverser - Symplify\PHPStanRules\PhpDocParser\PhpDocNodeTraverser @@ -28,10 +19,3 @@ services: # symfony - Symplify\PHPStanRules\Symfony\Reflection\ClassConstructorTypesResolver - - # rules enabled by configuration - - - class: Symplify\PHPStanRules\Rules\MaximumIgnoredErrorCountRule - tags: [phpstan.rules.rule] - arguments: - limit: %maximumIgnoredErrorCount% diff --git a/phpstan.neon b/phpstan.neon index ba80c1d5e..b25bfb079 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -9,9 +9,6 @@ parameters: level: 8 - # custom configuration - maximumIgnoredErrorCount: 12 - paths: - src - config @@ -55,7 +52,6 @@ parameters: path: tests/ErrorFormatter/SymplifyErrorFormatterTest.php - '#Although PHPStan\\Node\\InClassNode is covered by backward compatibility promise, this instanceof assumption might break because (.*?) not guaranteed to always stay the same#' - - '#PHPStan\\DependencyInjection\\NeonAdapter#' # not useful - '#with generic class ReflectionAttribute (but )?does not specify its types#' diff --git a/src/Enum/RuleIdentifier.php b/src/Enum/RuleIdentifier.php index 3cde976f9..aedcf4285 100644 --- a/src/Enum/RuleIdentifier.php +++ b/src/Enum/RuleIdentifier.php @@ -64,8 +64,6 @@ final class RuleIdentifier public const string FORBIDDEN_NEW_INSTANCE = 'symplify.forbiddenNewInstance'; - public const string MAXIMUM_IGNORED_ERROR_COUNT = 'symplify.maximumIgnoredErrorCount'; - public const string STRING_FILE_ABSOLUTE_PATH_EXISTS = 'symplify.stringFileAbsolutePathExists'; public const string NO_JUST_PROPERTY_ASSIGN = 'symplify.noJustPropertyAssign'; diff --git a/src/Rules/MaximumIgnoredErrorCountRule.php b/src/Rules/MaximumIgnoredErrorCountRule.php deleted file mode 100644 index 3d28bc571..000000000 --- a/src/Rules/MaximumIgnoredErrorCountRule.php +++ /dev/null @@ -1,71 +0,0 @@ - - */ -final readonly class MaximumIgnoredErrorCountRule implements Rule -{ - public const string ERROR_MESSAGE = "Ignored error count %d in phpstan.neon surpassed maximum limit %d.\nInstead of ignoring more errors, fix them to keep your codebase fit."; - - private NeonAdapter $neonAdapter; - - public function __construct( - private int $limit = 0 - ) { - $this->neonAdapter = new NeonAdapter([]); - } - - /** - * @return class-string - */ - public function getNodeType(): string - { - // hack to run this rule just once - return CollectedDataNode::class; - } - - /** - * @param CollectedDataNode $node - */ - public function processNode(Node $node, Scope $scope): array - { - // not enabled yet, use " - if ($this->limit === 0) { - return []; - } - - $configFilePath = getcwd() . '/phpstan.neon'; - - // unable to find config - if (! file_exists($configFilePath)) { - return []; - } - - $phpstanNeon = $this->neonAdapter->load($configFilePath); - $ignoreErrors = $phpstanNeon['parameters']['ignoreErrors'] ?? []; - if (count($ignoreErrors) <= $this->limit) { - return []; - } - - $errorMessage = sprintf(self::ERROR_MESSAGE, count($ignoreErrors), $this->limit); - - $identifierRuleError = RuleErrorBuilder::message($errorMessage) - ->identifier(RuleIdentifier::MAXIMUM_IGNORED_ERROR_COUNT) - ->nonIgnorable() - ->build(); - - return [$identifierRuleError]; - } -} diff --git a/tests/Issues/InstantiateMaximumIgnoredErrorCountRuleTest.php b/tests/Issues/InstantiateMaximumIgnoredErrorCountRuleTest.php deleted file mode 100644 index 073f49bbd..000000000 --- a/tests/Issues/InstantiateMaximumIgnoredErrorCountRuleTest.php +++ /dev/null @@ -1,17 +0,0 @@ -assertInstanceOf(MaximumIgnoredErrorCountRule::class, $maximumIgnoredErrorCountRule); - } -}