66
77use PhpParser \Node ;
88use PhpParser \Node \Stmt \Const_ ;
9+ use PhpParser \Node \Stmt \Trait_ ;
910use Rector \PhpAttribute \DeprecatedAnnotationToDeprecatedAttributeConverter ;
1011use Rector \Rector \AbstractRector ;
11- use Rector \ValueObject \PhpVersionFeature ;
12+ use Rector \ValueObject \PhpVersion ;
1213use Rector \VersionBonding \Contract \MinPhpVersionInterface ;
1314use Symplify \RuleDocGenerator \ValueObject \CodeSample \CodeSample ;
1415use Symplify \RuleDocGenerator \ValueObject \RuleDefinition ;
1516
1617/**
17- * @see \Rector\Tests\Php85\Rector\Const_\DeprecatedAnnotationToDeprecatedAttributeRector\DeprecatedAnnotationToDeprecatedAttributeRectorTest
18+ * @see https://wiki.php.net/rfc/attributes-on-constants
19+ * @see https://wiki.php.net/rfc/deprecated_traits
20+ *
21+ * @see \Rector\Tests\Php85\Rector\Const_\ConstAndTraitDeprecatedAttributeRector\ConstAndTraitDeprecatedAttributeRectorTest
1822 */
19- final class DeprecatedAnnotationToDeprecatedAttributeRector extends AbstractRector implements MinPhpVersionInterface
23+ final class ConstAndTraitDeprecatedAttributeRector extends AbstractRector implements MinPhpVersionInterface
2024{
2125 public function __construct (
2226 private readonly DeprecatedAnnotationToDeprecatedAttributeConverter $ deprecatedAnnotationToDeprecatedAttributeConverter ,
@@ -25,7 +29,7 @@ public function __construct(
2529
2630 public function getRuleDefinition (): RuleDefinition
2731 {
28- return new RuleDefinition ('Change @deprecated annotation to Deprecated attribute ' , [
32+ return new RuleDefinition ('Change @deprecated annotation to #[ Deprecated] attribute for constants ' , [
2933 new CodeSample (
3034 <<<'CODE_SAMPLE'
3135/**
@@ -44,11 +48,11 @@ public function getRuleDefinition(): RuleDefinition
4448
4549 public function getNodeTypes (): array
4650 {
47- return [Const_::class];
51+ return [Const_::class, Trait_::class ];
4852 }
4953
5054 /**
51- * @param Const_ $node
55+ * @param Const_|Trait_ $node
5256 */
5357 public function refactor (Node $ node ): ?Node
5458 {
@@ -57,6 +61,6 @@ public function refactor(Node $node): ?Node
5761
5862 public function provideMinPhpVersion (): int
5963 {
60- return PhpVersionFeature:: DEPRECATED_ATTRIBUTE_ON_CONSTANT ;
64+ return PhpVersion:: PHP_85 ;
6165 }
6266}
0 commit comments