Skip to content

Commit 48be9c9

Browse files
paxalondrejmirtes
authored andcommitted
Do not report errors in deprecated scope
1 parent f18541b commit 48be9c9

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

src/Rules/Deprecations/TypeHintDeprecatedInClassMethodSignatureRule.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ public function getNodeType(): string
3434
*/
3535
public function processNode(Node $node, Scope $scope): array
3636
{
37+
if (DeprecatedScopeHelper::isScopeDeprecated($scope)) {
38+
return [];
39+
}
40+
3741
/** @var MethodReflection $method */
3842
$method = $scope->getFunction();
3943
if (!$method instanceof MethodReflection) {

tests/Rules/Deprecations/TypeHintDeprecatedInClassMethodSignatureRuleTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public function test(): void
2323
["Parameter \$property4 of method TypeHintDeprecatedInFunctionSignature\Foo::setProperties() has typehint with deprecated class TypeHintDeprecatedInFunctionSignature\VerboseDeprecatedProperty:\nI'll be back", 13],
2424
['Parameter $property6 of method TypeHintDeprecatedInFunctionSignature\Foo::setProperties() has typehint with deprecated class TypeHintDeprecatedInFunctionSignature\DeprecatedProperty.', 13],
2525
['Return type of method TypeHintDeprecatedInFunctionSignature\Foo::setProperties() has typehint with deprecated class TypeHintDeprecatedInFunctionSignature\DeprecatedProperty.', 13],
26+
['Parameter $property of method TypeHintDeprecatedInFunctionSignature\FooImplNoOverride::oops() has typehint with deprecated class TypeHintDeprecatedInFunctionSignature\DeprecatedProperty.', 50],
2627
]
2728
);
2829
}

tests/Rules/Deprecations/data/typehint-deprecated-class-definition.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ class Property
3333

3434
interface IThinkYourStucked
3535
{
36+
3637
/**
3738
* @param Property|DeprecatedProperty $property
3839
*/
3940
public function oops($property): void;
41+
4042
}

tests/Rules/Deprecations/data/typehint-deprecated-class.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function setProperties(
3232

3333
}
3434

35-
class FooImplNoOverride implements IThinkYourStucked
35+
class FooImplOverride implements IThinkYourStucked
3636
{
3737

3838
/**
@@ -43,3 +43,24 @@ public function oops($property): void
4343
}
4444

4545
}
46+
47+
class FooImplNoOverride implements IThinkYourStucked
48+
{
49+
50+
public function oops($property): void
51+
{
52+
}
53+
54+
}
55+
56+
/**
57+
* @deprecated
58+
*/
59+
class DeprecatedClass
60+
{
61+
62+
public function bar(DeprecatedProperty $property)
63+
{
64+
}
65+
66+
}

0 commit comments

Comments
 (0)