File tree Expand file tree Collapse file tree 5 files changed +22
-16
lines changed
rules-tests/Php85/Rector/Const_/ClassConstDeprecatedAttributeRector
rules/Php85/Rector/Const_ Expand file tree Collapse file tree 5 files changed +22
-16
lines changed Original file line number Diff line number Diff line change 1111use Rector \Php85 \Rector \Class_ \SleepToSerializeRector ;
1212use Rector \Php85 \Rector \Class_ \WakeupToUnserializeRector ;
1313use Rector \Php85 \Rector \ClassMethod \NullDebugInfoReturnRector ;
14- use Rector \Php85 \Rector \Const_ \DeprecatedAnnotationToDeprecatedAttributeRector ;
14+ use Rector \Php85 \Rector \Const_ \ClassConstDeprecatedAttributeRector ;
1515use Rector \Php85 \Rector \FuncCall \ArrayKeyExistsNullToEmptyStringRector ;
1616use Rector \Php85 \Rector \FuncCall \ChrArgModuloRector ;
1717use Rector \Php85 \Rector \FuncCall \OrdSingleByteRector ;
3535 ArrayFirstLastRector::class,
3636 RemoveFinfoBufferContextArgRector::class,
3737 NullDebugInfoReturnRector::class,
38- DeprecatedAnnotationToDeprecatedAttributeRector ::class,
38+ ClassConstDeprecatedAttributeRector ::class,
3939 ColonAfterSwitchCaseRector::class,
4040 ArrayKeyExistsNullToEmptyStringRector::class,
4141 ChrArgModuloRector::class,
Original file line number Diff line number Diff line change 22
33declare (strict_types=1 );
44
5- namespace Rector \Tests \Php85 \Rector \Const_ \DeprecatedAnnotationToDeprecatedAttributeRector ;
5+ namespace Rector \Tests \Php85 \Rector \Const_ \ClassConstDeprecatedAttributeRector ;
66
77use Iterator ;
88use PHPUnit \Framework \Attributes \DataProvider ;
99use Rector \Testing \PHPUnit \AbstractRectorTestCase ;
1010
11- final class DeprecatedAnnotationToDeprecatedAttributeRectorTest extends AbstractRectorTestCase
11+ final class ClassConstDeprecatedAttributeRectorTest extends AbstractRectorTestCase
1212{
1313 #[DataProvider('provideData ' )]
1414 public function test (string $ filePath ): void
Original file line number Diff line number Diff line change 11<?php
22
3- namespace Rector \Tests \Php85 \Rector \Const_ \DeprecatedAnnotationToDeprecatedAttributeRector ;
3+ namespace Rector \Tests \Php85 \Rector \Const_ \ClassConstDeprecatedAttributeRector ;
44
55/**
66 * @deprecated use new constant
@@ -16,7 +16,7 @@ const UNUSED = 'ignored';
1616-----
1717<?php
1818
19- namespace Rector \Tests \Php85 \Rector \Const_ \DeprecatedAnnotationToDeprecatedAttributeRector ;
19+ namespace Rector \Tests \Php85 \Rector \Const_ \ClassConstDeprecatedAttributeRector ;
2020
2121#[\Deprecated(message: 'use new constant ' )]
2222const CONSTANT = 'some reason ' ;
Original file line number Diff line number Diff line change 33declare (strict_types=1 );
44
55use Rector \Config \RectorConfig ;
6- use Rector \Php85 \Rector \Const_ \DeprecatedAnnotationToDeprecatedAttributeRector ;
6+ use Rector \Php85 \Rector \Const_ \ClassConstDeprecatedAttributeRector ;
77use Rector \ValueObject \PhpVersion ;
88
99return static function (RectorConfig $ rectorConfig ): void {
10- $ rectorConfig ->rule (DeprecatedAnnotationToDeprecatedAttributeRector ::class);
10+ $ rectorConfig ->rule (ClassConstDeprecatedAttributeRector ::class);
1111 $ rectorConfig ->phpVersion (PhpVersion::PHP_85 );
1212};
Original file line number Diff line number Diff line change 1616/**
1717 * @see \Rector\Tests\Php85\Rector\Const_\DeprecatedAnnotationToDeprecatedAttributeRector\DeprecatedAnnotationToDeprecatedAttributeRectorTest
1818 */
19- final class DeprecatedAnnotationToDeprecatedAttributeRector extends AbstractRector implements MinPhpVersionInterface
19+ final class ClassConstDeprecatedAttributeRector extends AbstractRector implements MinPhpVersionInterface
2020{
2121 public function __construct (
2222 private readonly DeprecatedAnnotationToDeprecatedAttributeConverter $ deprecatedAnnotationToDeprecatedAttributeConverter ,
@@ -25,18 +25,24 @@ public function __construct(
2525
2626 public function getRuleDefinition (): RuleDefinition
2727 {
28- return new RuleDefinition ('Change @deprecated annotation to Deprecated attribute ' , [
28+ return new RuleDefinition ('Change @deprecated annotation to Deprecated attribute for class constants ' , [
2929 new CodeSample (
3030 <<<'CODE_SAMPLE'
31- /**
32- * @deprecated 1.0.0 Use SomeOtherConstant instead
33- */
34- const SomeConstant = 'irrelevant';
31+ class SomeClass
32+ {
33+ /**
34+ * @deprecated 1.0.0 Use SomeOtherConstant instead
35+ */
36+ const SomeConstant = 'irrelevant';
37+ }
3538CODE_SAMPLE
3639 ,
3740 <<<'CODE_SAMPLE'
38- #[\Deprecated(message: 'Use SomeOtherConstant instead', since: '1.0.0')]
39- const SomeConstant = 'irrelevant';
41+ class SomeClass
42+ {
43+ #[\Deprecated(message: 'Use SomeOtherConstant instead', since: '1.0.0')]
44+ const SomeConstant = 'irrelevant';
45+ }
4046CODE_SAMPLE
4147 ),
4248 ]);
You can’t perform that action at this time.
0 commit comments