diff --git a/src/Rules/Deprecations/FetchingDeprecatedConstRule.php b/src/Rules/Deprecations/FetchingDeprecatedConstRule.php index 6d63da7..05eb34c 100644 --- a/src/Rules/Deprecations/FetchingDeprecatedConstRule.php +++ b/src/Rules/Deprecations/FetchingDeprecatedConstRule.php @@ -9,7 +9,6 @@ use PHPStan\Rules\Rule; use PHPStan\Rules\RuleErrorBuilder; use function sprintf; -use const PHP_VERSION_ID; /** * @implements Rule @@ -23,19 +22,10 @@ class FetchingDeprecatedConstRule implements Rule /** @var DeprecatedScopeHelper */ private $deprecatedScopeHelper; - /** @var array */ - private $deprecatedConstants = []; - public function __construct(ReflectionProvider $reflectionProvider, DeprecatedScopeHelper $deprecatedScopeHelper) { $this->reflectionProvider = $reflectionProvider; $this->deprecatedScopeHelper = $deprecatedScopeHelper; - - // phpcs:ignore SlevomatCodingStandard.ControlStructures.EarlyExit.EarlyExitNotUsed - if (PHP_VERSION_ID >= 70300) { - $this->deprecatedConstants['FILTER_FLAG_SCHEME_REQUIRED'] = 'Use of constant %s is deprecated since PHP 7.3.'; - $this->deprecatedConstants['FILTER_FLAG_HOST_REQUIRED'] = 'Use of constant %s is deprecated since PHP 7.3.'; - } } public function getNodeType(): string @@ -64,15 +54,6 @@ public function processNode(Node $node, Scope $scope): array ]; } - if (isset($this->deprecatedConstants[$constantReflection->getName()])) { - return [ - RuleErrorBuilder::message(sprintf( - $this->deprecatedConstants[$constantReflection->getName()], - $constantReflection->getName() - ))->identifier('constant.deprecated')->build(), - ]; - } - return []; } diff --git a/tests/Rules/Deprecations/FetchingDeprecatedConstRuleTest.php b/tests/Rules/Deprecations/FetchingDeprecatedConstRuleTest.php index 08c95c4..76207c1 100644 --- a/tests/Rules/Deprecations/FetchingDeprecatedConstRuleTest.php +++ b/tests/Rules/Deprecations/FetchingDeprecatedConstRuleTest.php @@ -31,27 +31,27 @@ public function testFetchingDeprecatedConst(): void if (PHP_VERSION_ID >= 70300) { $expectedErrors[] = [ - 'Use of constant FILTER_FLAG_SCHEME_REQUIRED is deprecated since PHP 7.3.', + 'Use of constant FILTER_FLAG_SCHEME_REQUIRED is deprecated.', 5, ]; $expectedErrors[] = [ - 'Use of constant FILTER_FLAG_HOST_REQUIRED is deprecated since PHP 7.3.', + 'Use of constant FILTER_FLAG_HOST_REQUIRED is deprecated.', 6, ]; $expectedErrors[] = [ - 'Use of constant FILTER_FLAG_SCHEME_REQUIRED is deprecated since PHP 7.3.', + 'Use of constant FILTER_FLAG_SCHEME_REQUIRED is deprecated.', 7, ]; $expectedErrors[] = [ - 'Use of constant FILTER_FLAG_HOST_REQUIRED is deprecated since PHP 7.3.', + 'Use of constant FILTER_FLAG_HOST_REQUIRED is deprecated.', 8, ]; $expectedErrors[] = [ - 'Use of constant FILTER_FLAG_SCHEME_REQUIRED is deprecated since PHP 7.3.', + 'Use of constant FILTER_FLAG_SCHEME_REQUIRED is deprecated.', 37, ]; $expectedErrors[] = [ - 'Use of constant FILTER_FLAG_HOST_REQUIRED is deprecated since PHP 7.3.', + 'Use of constant FILTER_FLAG_HOST_REQUIRED is deprecated.', 38, ]; }