Skip to content

Commit 85247f9

Browse files
committed
[dx] Rename DeprecatedAnnotationToDeprecatedAttributeRector for PHP 8.5 to explicit ClassConstDeprecatedAttributeRector
1 parent 184dd02 commit 85247f9

File tree

5 files changed

+22
-16
lines changed

5 files changed

+22
-16
lines changed

config/set/php85.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Rector\Php85\Rector\Class_\SleepToSerializeRector;
1212
use Rector\Php85\Rector\Class_\WakeupToUnserializeRector;
1313
use Rector\Php85\Rector\ClassMethod\NullDebugInfoReturnRector;
14-
use Rector\Php85\Rector\Const_\DeprecatedAnnotationToDeprecatedAttributeRector;
14+
use Rector\Php85\Rector\Const_\ClassConstDeprecatedAttributeRector;
1515
use Rector\Php85\Rector\FuncCall\ArrayKeyExistsNullToEmptyStringRector;
1616
use Rector\Php85\Rector\FuncCall\ChrArgModuloRector;
1717
use Rector\Php85\Rector\FuncCall\OrdSingleByteRector;
@@ -35,7 +35,7 @@
3535
ArrayFirstLastRector::class,
3636
RemoveFinfoBufferContextArgRector::class,
3737
NullDebugInfoReturnRector::class,
38-
DeprecatedAnnotationToDeprecatedAttributeRector::class,
38+
ClassConstDeprecatedAttributeRector::class,
3939
ColonAfterSwitchCaseRector::class,
4040
ArrayKeyExistsNullToEmptyStringRector::class,
4141
ChrArgModuloRector::class,

rules-tests/Php85/Rector/Const_/DeprecatedAnnotationToDeprecatedAttributeRector/DeprecatedAnnotationToDeprecatedAttributeRectorTest.php renamed to rules-tests/Php85/Rector/Const_/ClassConstDeprecatedAttributeRector/ClassConstDeprecatedAttributeRectorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
declare(strict_types=1);
44

5-
namespace Rector\Tests\Php85\Rector\Const_\DeprecatedAnnotationToDeprecatedAttributeRector;
5+
namespace Rector\Tests\Php85\Rector\Const_\ClassConstDeprecatedAttributeRector;
66

77
use Iterator;
88
use PHPUnit\Framework\Attributes\DataProvider;
99
use 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

rules-tests/Php85/Rector/Const_/DeprecatedAnnotationToDeprecatedAttributeRector/Fixture/basic.php.inc renamed to rules-tests/Php85/Rector/Const_/ClassConstDeprecatedAttributeRector/Fixture/basic.php.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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')]
2222
const CONSTANT = 'some reason';

rules-tests/Php85/Rector/Const_/DeprecatedAnnotationToDeprecatedAttributeRector/config/configured_rule.php renamed to rules-tests/Php85/Rector/Const_/ClassConstDeprecatedAttributeRector/config/configured_rule.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
declare(strict_types=1);
44

55
use Rector\Config\RectorConfig;
6-
use Rector\Php85\Rector\Const_\DeprecatedAnnotationToDeprecatedAttributeRector;
6+
use Rector\Php85\Rector\Const_\ClassConstDeprecatedAttributeRector;
77
use Rector\ValueObject\PhpVersion;
88

99
return static function (RectorConfig $rectorConfig): void {
10-
$rectorConfig->rule(DeprecatedAnnotationToDeprecatedAttributeRector::class);
10+
$rectorConfig->rule(ClassConstDeprecatedAttributeRector::class);
1111
$rectorConfig->phpVersion(PhpVersion::PHP_85);
1212
};

rules/Php85/Rector/Const_/DeprecatedAnnotationToDeprecatedAttributeRector.php renamed to rules/Php85/Rector/Const_/ClassConstDeprecatedAttributeRector.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
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+
}
3538
CODE_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+
}
4046
CODE_SAMPLE
4147
),
4248
]);

0 commit comments

Comments
 (0)