Skip to content

Commit 44130cf

Browse files
authored
[TASK] Make aliased class deprecation notices visible to tools (#1559)
Resolves #1553
1 parent 88dbd0f commit 44130cf

2 files changed

Lines changed: 19 additions & 7 deletions

File tree

src/Rule/Rule.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,15 @@
99
use function Safe\class_alias;
1010

1111
if (!\class_exists(Rule::class, false) && !\interface_exists(Rule::class, false)) {
12-
/**
13-
* @deprecated in v9.2, will be removed in v10.0. Use `Property\Declaration` instead, which is a direct
14-
* replacement.
15-
*/
1612
class_alias(Declaration::class, Rule::class);
13+
// The test is expected to evaluate to false,
14+
// but allows for the deprecation notice to be picked up by IDEs like PHPStorm.
15+
// @phpstan-ignore-next-line booleanAnd.alwaysTrue
16+
if (!\class_exists(Rule::class, false) && !\interface_exists(Rule::class, false)) {
17+
/**
18+
* @deprecated in v9.2, will be removed in v10.0. Use `Property\Declaration` instead, which is a direct
19+
* replacement.
20+
*/
21+
class Rule {}
22+
}
1723
}

src/RuleSet/RuleContainer.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,14 @@
77
use function Safe\class_alias;
88

99
if (!\class_exists(RuleContainer::class, false) && !\interface_exists(RuleContainer::class, false)) {
10-
/**
11-
* @deprecated in v9.2, will be removed in v10.0. Use `DeclarationList` instead, which is a direct replacement.
12-
*/
1310
class_alias(DeclarationList::class, RuleContainer::class);
11+
// The test is expected to evaluate to false,
12+
// but allows for the deprecation notice to be picked up by IDEs like PHPStorm.
13+
// @phpstan-ignore-next-line booleanAnd.alwaysTrue
14+
if (!\class_exists(RuleContainer::class, false) && !\interface_exists(RuleContainer::class, false)) {
15+
/**
16+
* @deprecated in v9.2, will be removed in v10.0. Use `DeclarationList` instead, which is a direct replacement.
17+
*/
18+
interface RuleContainer {}
19+
}
1420
}

0 commit comments

Comments
 (0)