From a3e876c2e6e01607b327bcbca1f08bef63f1ed8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Wer=C5=82os?= Date: Sun, 6 Jul 2025 09:32:59 +0200 Subject: [PATCH 1/4] Use FCT constants --- .dev-tools/composer.json | 2 +- .dev-tools/composer.lock | 36 +++++++++--------- src/Fixer/NoUselessWriteVisibilityFixer.php | 29 ++++++-------- .../PhpdocNoIncorrectVarAnnotationFixer.php | 10 +---- src/Fixer/ReadonlyPromotedPropertiesFixer.php | 38 ++++++++----------- tests/AutoReview/SrcCodeTest.php | 12 +++--- 6 files changed, 53 insertions(+), 74 deletions(-) diff --git a/.dev-tools/composer.json b/.dev-tools/composer.json index fc4825f1..10c7ba70 100644 --- a/.dev-tools/composer.json +++ b/.dev-tools/composer.json @@ -16,7 +16,7 @@ "shipmonk/phpstan-rules": "^4.1.4", "squizlabs/php_codesniffer": "^3.13.2", "tomasvotruba/type-coverage": "^2.0.2", - "vimeo/psalm": "^6.12" + "vimeo/psalm": "^6.12.1" }, "autoload": { "psr-4": { diff --git a/.dev-tools/composer.lock b/.dev-tools/composer.lock index ace501f2..d711c7e5 100644 --- a/.dev-tools/composer.lock +++ b/.dev-tools/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "52bc6ed7538d86ec86cb832d332c1464", + "content-hash": "cc29da6bc114fd14f8df10b0cfcbe6c9", "packages": [ { "name": "amphp/amp", @@ -1221,21 +1221,21 @@ }, { "name": "kubawerlos/php-cs-fixer-custom-fixers", - "version": "v3.28.0", + "version": "v3.29.0", "source": { "type": "git", "url": "https://github.com/kubawerlos/php-cs-fixer-custom-fixers.git", - "reference": "6115bffca3b8d1bfbd7eff7bdd5df1ffb3c8eddc" + "reference": "1623c499adce2c131dafa5b6dd2eb496bb53f3c7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/kubawerlos/php-cs-fixer-custom-fixers/zipball/6115bffca3b8d1bfbd7eff7bdd5df1ffb3c8eddc", - "reference": "6115bffca3b8d1bfbd7eff7bdd5df1ffb3c8eddc" + "url": "https://api.github.com/repos/kubawerlos/php-cs-fixer-custom-fixers/zipball/1623c499adce2c131dafa5b6dd2eb496bb53f3c7", + "reference": "1623c499adce2c131dafa5b6dd2eb496bb53f3c7" }, "require": { "ext-filter": "*", "ext-tokenizer": "*", - "friendsofphp/php-cs-fixer": "^3.76", + "friendsofphp/php-cs-fixer": "^3.77", "php": "^7.4 || ^8.0" }, "type": "library", @@ -1579,16 +1579,16 @@ }, { "name": "php-cs-fixer/shim", - "version": "v3.76.0", + "version": "v3.77.0", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/shim.git", - "reference": "b6804c2a1a4fbff582446a44ad678ae1689df1c3" + "reference": "4ddab11b872f575afcf852181e92906d75575203" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/shim/zipball/b6804c2a1a4fbff582446a44ad678ae1689df1c3", - "reference": "b6804c2a1a4fbff582446a44ad678ae1689df1c3" + "url": "https://api.github.com/repos/PHP-CS-Fixer/shim/zipball/4ddab11b872f575afcf852181e92906d75575203", + "reference": "4ddab11b872f575afcf852181e92906d75575203" }, "require": { "ext-json": "*", @@ -2107,16 +2107,16 @@ }, { "name": "sanmai/pipeline", - "version": "6.18", + "version": "6.19", "source": { "type": "git", "url": "https://github.com/sanmai/pipeline.git", - "reference": "d9fbdf2a4a363f44f4d8155f71766f35d49b8fb2" + "reference": "3707180c66dd6b3b9c4b5f9fe26155325812037d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sanmai/pipeline/zipball/d9fbdf2a4a363f44f4d8155f71766f35d49b8fb2", - "reference": "d9fbdf2a4a363f44f4d8155f71766f35d49b8fb2" + "url": "https://api.github.com/repos/sanmai/pipeline/zipball/3707180c66dd6b3b9c4b5f9fe26155325812037d", + "reference": "3707180c66dd6b3b9c4b5f9fe26155325812037d" }, "require": { "php": ">=8.2" @@ -2994,16 +2994,16 @@ }, { "name": "vimeo/psalm", - "version": "6.12.0", + "version": "6.12.1", "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "cf420941d061a57050b6c468ef2c778faf40aee2" + "reference": "e71404b0465be25cf7f8a631b298c01c5ddd864f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vimeo/psalm/zipball/cf420941d061a57050b6c468ef2c778faf40aee2", - "reference": "cf420941d061a57050b6c468ef2c778faf40aee2" + "url": "https://api.github.com/repos/vimeo/psalm/zipball/e71404b0465be25cf7f8a631b298c01c5ddd864f", + "reference": "e71404b0465be25cf7f8a631b298c01c5ddd864f" }, "require": { "amphp/amp": "^3", diff --git a/src/Fixer/NoUselessWriteVisibilityFixer.php b/src/Fixer/NoUselessWriteVisibilityFixer.php index 519ba921..5bce55ae 100644 --- a/src/Fixer/NoUselessWriteVisibilityFixer.php +++ b/src/Fixer/NoUselessWriteVisibilityFixer.php @@ -15,6 +15,7 @@ use PhpCsFixer\FixerDefinition\FixerDefinition; use PhpCsFixer\FixerDefinition\FixerDefinitionInterface; use PhpCsFixer\Tokenizer\CT; +use PhpCsFixer\Tokenizer\FCT; use PhpCsFixer\Tokenizer\Token; use PhpCsFixer\Tokenizer\Tokens; @@ -23,19 +24,11 @@ */ final class NoUselessWriteVisibilityFixer extends AbstractFixer { - /** @var non-empty-array> */ - private array $predecessorKindMap; - - public function __construct() - { - if (\defined('T_PUBLIC_SET')) { - $this->predecessorKindMap = [ - \T_PUBLIC_SET => [\T_PUBLIC, CT::T_CONSTRUCTOR_PROPERTY_PROMOTION_PUBLIC], - \T_PROTECTED_SET => [\T_PROTECTED, CT::T_CONSTRUCTOR_PROPERTY_PROMOTION_PROTECTED], - \T_PRIVATE_SET => [\T_PRIVATE, CT::T_CONSTRUCTOR_PROPERTY_PROMOTION_PRIVATE], - ]; - } - } + private const array PREDECESSOR_KIND_MAP = [ + FCT::T_PUBLIC_SET => [\T_PUBLIC, CT::T_CONSTRUCTOR_PROPERTY_PROMOTION_PUBLIC], + FCT::T_PROTECTED_SET => [\T_PROTECTED, CT::T_CONSTRUCTOR_PROPERTY_PROMOTION_PROTECTED], + FCT::T_PRIVATE_SET => [\T_PRIVATE, CT::T_CONSTRUCTOR_PROPERTY_PROMOTION_PRIVATE], + ]; public function getDefinition(): FixerDefinitionInterface { @@ -61,7 +54,7 @@ public function getPriority(): int public function isCandidate(Tokens $tokens): bool { - return \defined('T_PUBLIC_SET') && $tokens->isAnyTokenKindsFound(\array_keys($this->predecessorKindMap)); + return $tokens->isAnyTokenKindsFound([FCT::T_PUBLIC_SET, FCT::T_PROTECTED_SET, FCT::T_PRIVATE_SET]); } public function isRisky(): bool @@ -71,14 +64,14 @@ public function isRisky(): bool public function fix(\SplFileInfo $file, Tokens $tokens): void { - foreach ($tokens->findGivenKind(\array_keys($this->predecessorKindMap)) as $kind => $elements) { + foreach ($tokens->findGivenKind([FCT::T_PUBLIC_SET, FCT::T_PROTECTED_SET, FCT::T_PRIVATE_SET]) as $kind => $elements) { foreach (\array_keys($elements) as $index) { - $this->fixVisibility($tokens, $index, $kind, $kind === \T_PUBLIC_SET); + self::fixVisibility($tokens, $index, $kind, $kind === \T_PUBLIC_SET); } } } - private function fixVisibility(Tokens $tokens, int $index, int $kind, bool $makePublicIfNone): void + private static function fixVisibility(Tokens $tokens, int $index, int $kind, bool $makePublicIfNone): void { $prevIndex = $tokens->getPrevMeaningfulToken($index); \assert(\is_int($prevIndex)); @@ -87,7 +80,7 @@ private function fixVisibility(Tokens $tokens, int $index, int $kind, bool $make \assert(\is_int($prevIndex)); } - if (!$tokens[$prevIndex]->isGivenKind($this->predecessorKindMap[$kind])) { + if (!$tokens[$prevIndex]->isGivenKind(self::PREDECESSOR_KIND_MAP[$kind])) { if ($makePublicIfNone) { $prevDeciderIndex = $tokens->getPrevTokenOfKind($index, ['(', ';', '{']); \assert(\is_int($prevDeciderIndex)); diff --git a/src/Fixer/PhpdocNoIncorrectVarAnnotationFixer.php b/src/Fixer/PhpdocNoIncorrectVarAnnotationFixer.php index fd855f3b..0aac3f31 100644 --- a/src/Fixer/PhpdocNoIncorrectVarAnnotationFixer.php +++ b/src/Fixer/PhpdocNoIncorrectVarAnnotationFixer.php @@ -17,6 +17,7 @@ use PhpCsFixer\FixerDefinition\FixerDefinitionInterface; use PhpCsFixer\Preg; use PhpCsFixer\Tokenizer\CT; +use PhpCsFixer\Tokenizer\FCT; use PhpCsFixer\Tokenizer\Token; use PhpCsFixer\Tokenizer\Tokens; use PhpCsFixerCustomFixers\TokenRemover; @@ -94,14 +95,7 @@ public function fix(\SplFileInfo $file, Tokens $tokens): void private static function removeForClassElement(Tokens $tokens, int $index, int $propertyStartIndex): void { - $tokenKinds = [\T_NS_SEPARATOR, \T_STATIC, \T_STRING, \T_WHITESPACE, CT::T_ARRAY_TYPEHINT, CT::T_NULLABLE_TYPE, CT::T_TYPE_ALTERNATION]; - - if (\defined('T_READONLY')) { - $tokenKinds[] = CT::T_TYPE_INTERSECTION; - $tokenKinds[] = \T_READONLY; - } - - $variableIndex = $tokens->getTokenNotOfKindsSibling($propertyStartIndex, 1, $tokenKinds); + $variableIndex = $tokens->getTokenNotOfKindsSibling($propertyStartIndex, 1, [\T_NS_SEPARATOR, \T_STATIC, \T_STRING, \T_WHITESPACE, CT::T_ARRAY_TYPEHINT, CT::T_NULLABLE_TYPE, CT::T_TYPE_ALTERNATION, CT::T_TYPE_INTERSECTION, FCT::T_READONLY]); \assert(\is_int($variableIndex)); if (!$tokens[$variableIndex]->isGivenKind(\T_VARIABLE)) { diff --git a/src/Fixer/ReadonlyPromotedPropertiesFixer.php b/src/Fixer/ReadonlyPromotedPropertiesFixer.php index 50c322d6..7b1074e9 100644 --- a/src/Fixer/ReadonlyPromotedPropertiesFixer.php +++ b/src/Fixer/ReadonlyPromotedPropertiesFixer.php @@ -16,6 +16,7 @@ use PhpCsFixer\FixerDefinition\VersionSpecification; use PhpCsFixer\FixerDefinition\VersionSpecificCodeSample; use PhpCsFixer\Tokenizer\CT; +use PhpCsFixer\Tokenizer\FCT; use PhpCsFixer\Tokenizer\Token; use PhpCsFixer\Tokenizer\Tokens; use PhpCsFixerCustomFixers\Analyzer\ConstructorAnalyzer; @@ -43,23 +44,14 @@ final class ReadonlyPromotedPropertiesFixer extends AbstractFixer [\T_COALESCE_EQUAL, '??='], [\T_CONCAT_EQUAL, '.='], ]; - - /** @var list */ - private array $promotedPropertyVisibilityKinds; - - public function __construct() - { - $this->promotedPropertyVisibilityKinds = [ - CT::T_CONSTRUCTOR_PROPERTY_PROMOTION_PRIVATE, - CT::T_CONSTRUCTOR_PROPERTY_PROMOTION_PROTECTED, - CT::T_CONSTRUCTOR_PROPERTY_PROMOTION_PUBLIC, - ]; - if (\defined('T_PUBLIC_SET')) { - $this->promotedPropertyVisibilityKinds[] = \T_PUBLIC_SET; - $this->promotedPropertyVisibilityKinds[] = \T_PROTECTED_SET; - $this->promotedPropertyVisibilityKinds[] = \T_PRIVATE_SET; - } - } + private const array PROMOTED_PROPERTY_VISIBILITY_KINDS = [ + CT::T_CONSTRUCTOR_PROPERTY_PROMOTION_PRIVATE, + CT::T_CONSTRUCTOR_PROPERTY_PROMOTION_PROTECTED, + CT::T_CONSTRUCTOR_PROPERTY_PROMOTION_PUBLIC, + FCT::T_PUBLIC_SET, + FCT::T_PROTECTED_SET, + FCT::T_PRIVATE_SET, + ]; public function getDefinition(): FixerDefinitionInterface { @@ -92,7 +84,7 @@ public function getPriority(): int public function isCandidate(Tokens $tokens): bool { - return \defined('T_READONLY') && $tokens->isAnyTokenKindsFound($this->promotedPropertyVisibilityKinds); + return $tokens->isAnyTokenKindsFound(self::PROMOTED_PROPERTY_VISIBILITY_KINDS); } public function isRisky(): bool @@ -126,7 +118,7 @@ public function fix(\SplFileInfo $file, Tokens $tokens): void \assert(\is_int($constructorOpenParenthesisIndex)); $constructorCloseParenthesisIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $constructorOpenParenthesisIndex); - $this->fixParameters( + self::fixParameters( $tokens, $classOpenBraceIndex, $classCloseBraceIndex, @@ -146,7 +138,7 @@ private static function isClassReadonly(Tokens $tokens, int $index): bool return $tokens[$index]->isGivenKind(\T_READONLY); } - private function fixParameters( + private static function fixParameters( Tokens $tokens, int $classOpenBraceIndex, int $classCloseBraceIndex, @@ -158,7 +150,7 @@ private function fixParameters( continue; } - $insertIndex = $this->getInsertIndex($tokens, $index); + $insertIndex = self::getInsertIndex($tokens, $index); if ($insertIndex === null) { continue; } @@ -177,7 +169,7 @@ private function fixParameters( } } - private function getInsertIndex(Tokens $tokens, int $index): ?int + private static function getInsertIndex(Tokens $tokens, int $index): ?int { $insertIndex = null; @@ -189,7 +181,7 @@ private function getInsertIndex(Tokens $tokens, int $index): ?int if ($tokens[$index]->isGivenKind(\T_READONLY)) { return null; } - if ($insertIndex === null && $tokens[$index]->isGivenKind($this->promotedPropertyVisibilityKinds)) { + if ($insertIndex === null && $tokens[$index]->isGivenKind(self::PROMOTED_PROPERTY_VISIBILITY_KINDS)) { $insertIndex = $index; } } diff --git a/tests/AutoReview/SrcCodeTest.php b/tests/AutoReview/SrcCodeTest.php index b691050e..a151d29f 100644 --- a/tests/AutoReview/SrcCodeTest.php +++ b/tests/AutoReview/SrcCodeTest.php @@ -89,9 +89,9 @@ public function testFixerSupportsAllFilesByDefault(): void /** * @param class-string $className * - * @dataProvider provideThereIsNoPregFunctionUsedDirectlyCases + * @dataProvider provideThereIsNoDisallowedFunctionUsedDirectlyCases */ - public function testThereIsNoPregFunctionUsedDirectly(string $className): void + public function testThereIsNoDisallowedFunctionUsedDirectly(string $className): void { $reflectionClass = new \ReflectionClass($className); @@ -113,8 +113,8 @@ public function testThereIsNoPregFunctionUsedDirectly(string $className): void $stringTokens, ); $strings = \array_unique($strings); - $message = \sprintf('Class %s must not use preg_*, it shall use Preg::* instead.', $className); + $message = \sprintf('Class %s must not use preg_*, it shall use Preg::* instead.', $className); self::assertNotContains('preg_filter', $strings, $message); self::assertNotContains('preg_grep', $strings, $message); self::assertNotContains('preg_match', $strings, $message); @@ -122,18 +122,18 @@ public function testThereIsNoPregFunctionUsedDirectly(string $className): void self::assertNotContains('preg_replace', $strings, $message); self::assertNotContains('preg_replace_callback', $strings, $message); self::assertNotContains('preg_split', $strings, $message); + + self::assertNotContains('defined', $strings); } /** * @return iterable */ - public static function provideThereIsNoPregFunctionUsedDirectlyCases(): iterable + public static function provideThereIsNoDisallowedFunctionUsedDirectlyCases(): iterable { $finder = Finder::create() ->files() ->in(__DIR__ . '/../../src') - ->notName('php-cs-fixer.config.*.php') - ->notName('run') ->sortByName(); /** @var SplFileInfo $file */ From 384037c598bde63b77f18b146aad28a2b5a59c39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Wer=C5=82os?= Date: Sun, 6 Jul 2025 09:38:13 +0200 Subject: [PATCH 2/4] Remove const types --- src/Fixer/NoUselessWriteVisibilityFixer.php | 2 +- src/Fixer/ReadonlyPromotedPropertiesFixer.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Fixer/NoUselessWriteVisibilityFixer.php b/src/Fixer/NoUselessWriteVisibilityFixer.php index 5bce55ae..0429aa8a 100644 --- a/src/Fixer/NoUselessWriteVisibilityFixer.php +++ b/src/Fixer/NoUselessWriteVisibilityFixer.php @@ -24,7 +24,7 @@ */ final class NoUselessWriteVisibilityFixer extends AbstractFixer { - private const array PREDECESSOR_KIND_MAP = [ + private const PREDECESSOR_KIND_MAP = [ FCT::T_PUBLIC_SET => [\T_PUBLIC, CT::T_CONSTRUCTOR_PROPERTY_PROMOTION_PUBLIC], FCT::T_PROTECTED_SET => [\T_PROTECTED, CT::T_CONSTRUCTOR_PROPERTY_PROMOTION_PROTECTED], FCT::T_PRIVATE_SET => [\T_PRIVATE, CT::T_CONSTRUCTOR_PROPERTY_PROMOTION_PRIVATE], diff --git a/src/Fixer/ReadonlyPromotedPropertiesFixer.php b/src/Fixer/ReadonlyPromotedPropertiesFixer.php index 7b1074e9..a3a6ca47 100644 --- a/src/Fixer/ReadonlyPromotedPropertiesFixer.php +++ b/src/Fixer/ReadonlyPromotedPropertiesFixer.php @@ -44,7 +44,7 @@ final class ReadonlyPromotedPropertiesFixer extends AbstractFixer [\T_COALESCE_EQUAL, '??='], [\T_CONCAT_EQUAL, '.='], ]; - private const array PROMOTED_PROPERTY_VISIBILITY_KINDS = [ + private const PROMOTED_PROPERTY_VISIBILITY_KINDS = [ CT::T_CONSTRUCTOR_PROPERTY_PROMOTION_PRIVATE, CT::T_CONSTRUCTOR_PROPERTY_PROMOTION_PROTECTED, CT::T_CONSTRUCTOR_PROPERTY_PROMOTION_PUBLIC, From 18753349d958c9309ce6aeb24cabd034884e0263 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Wer=C5=82os?= Date: Mon, 14 Jul 2025 19:09:01 +0200 Subject: [PATCH 3/4] Add Psalm stub --- .dev-tools/composer.json | 2 +- .dev-tools/composer.lock | 10 +++++----- .dev-tools/psalm.xml | 4 ++++ .dev-tools/psalm_stub.php | 21 +++++++++++++++++++++ 4 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 .dev-tools/psalm_stub.php diff --git a/.dev-tools/composer.json b/.dev-tools/composer.json index 10c7ba70..5cdac3b4 100644 --- a/.dev-tools/composer.json +++ b/.dev-tools/composer.json @@ -16,7 +16,7 @@ "shipmonk/phpstan-rules": "^4.1.4", "squizlabs/php_codesniffer": "^3.13.2", "tomasvotruba/type-coverage": "^2.0.2", - "vimeo/psalm": "^6.12.1" + "vimeo/psalm": "^6.13.0" }, "autoload": { "psr-4": { diff --git a/.dev-tools/composer.lock b/.dev-tools/composer.lock index d711c7e5..0f1b039b 100644 --- a/.dev-tools/composer.lock +++ b/.dev-tools/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "cc29da6bc114fd14f8df10b0cfcbe6c9", + "content-hash": "ab0b2efbd9f8b7f3444da6ac50cd0e93", "packages": [ { "name": "amphp/amp", @@ -2994,16 +2994,16 @@ }, { "name": "vimeo/psalm", - "version": "6.12.1", + "version": "6.13.0", "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "e71404b0465be25cf7f8a631b298c01c5ddd864f" + "reference": "70cdf647255a1362b426bb0f522a85817b8c791c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vimeo/psalm/zipball/e71404b0465be25cf7f8a631b298c01c5ddd864f", - "reference": "e71404b0465be25cf7f8a631b298c01c5ddd864f" + "url": "https://api.github.com/repos/vimeo/psalm/zipball/70cdf647255a1362b426bb0f522a85817b8c791c", + "reference": "70cdf647255a1362b426bb0f522a85817b8c791c" }, "require": { "amphp/amp": "^3", diff --git a/.dev-tools/psalm.xml b/.dev-tools/psalm.xml index 4fc196dd..e92d3fbb 100644 --- a/.dev-tools/psalm.xml +++ b/.dev-tools/psalm.xml @@ -15,6 +15,10 @@ + + + + diff --git a/.dev-tools/psalm_stub.php b/.dev-tools/psalm_stub.php new file mode 100644 index 00000000..c51607c1 --- /dev/null +++ b/.dev-tools/psalm_stub.php @@ -0,0 +1,21 @@ + Date: Mon, 14 Jul 2025 19:22:50 +0200 Subject: [PATCH 4/4] Add T_ATTRIBUTE to Psalm stub --- .dev-tools/psalm_stub.php | 1 + src/Fixer/PhpdocNoIncorrectVarAnnotationFixer.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.dev-tools/psalm_stub.php b/.dev-tools/psalm_stub.php index c51607c1..3c21f86a 100644 --- a/.dev-tools/psalm_stub.php +++ b/.dev-tools/psalm_stub.php @@ -12,6 +12,7 @@ namespace PhpCsFixer\Tokenizer { final class FCT { + public const int T_ATTRIBUTE = \T_ATTRIBUTE; public const int T_PRIVATE_SET = \T_PRIVATE_SET; public const int T_PROTECTED_SET = \T_PROTECTED_SET; public const int T_PUBLIC_SET = \T_PUBLIC_SET; diff --git a/src/Fixer/PhpdocNoIncorrectVarAnnotationFixer.php b/src/Fixer/PhpdocNoIncorrectVarAnnotationFixer.php index e72e7f6d..13c92f56 100644 --- a/src/Fixer/PhpdocNoIncorrectVarAnnotationFixer.php +++ b/src/Fixer/PhpdocNoIncorrectVarAnnotationFixer.php @@ -97,7 +97,7 @@ private static function getIndexAfterPhpDoc(Tokens $tokens, int $index): ?int { $nextIndex = $tokens->getNextMeaningfulToken($index); - while ($nextIndex !== null && \defined('T_ATTRIBUTE') && $tokens[$nextIndex]->isGivenKind(\T_ATTRIBUTE)) { + while ($nextIndex !== null && $tokens[$nextIndex]->isGivenKind(FCT::T_ATTRIBUTE)) { $nextIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_ATTRIBUTE, $nextIndex); $nextIndex = $tokens->getNextMeaningfulToken($nextIndex); }