Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit cbbbaa9

Browse files
Khartirondrejmirtes
authored andcommitted
add test for deprecation inheritance in trait
1 parent a22b36b commit cbbbaa9

File tree

4 files changed

+55
-1
lines changed

4 files changed

+55
-1
lines changed

‎composer.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
],
88
"require": {
99
"php": "^7.2 || ^8.0",
10-
"phpstan/phpstan": "^1.10"
10+
"phpstan/phpstan": "^1.10.3"
1111
},
1212
"require-dev": {
1313
"php-parallel-lint/php-parallel-lint": "^1.2",

‎tests/Rules/Deprecations/CallToDeprecatedMethodRuleTest.php‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ public function testDeprecatedMethodCall(): void
4242
"Call to deprecated method deprecatedWithDescription() of class CheckDeprecatedMethodCall\\Foo:\nCall a different method instead.",
4343
15,
4444
],
45+
[
46+
"Call to deprecated method prophesize() of class CheckDeprecatedMethodCall\\UsingDeprecatedMethodFromTrait:\nUse TraitReplacingDeprecatedMethod::prophesize()",
47+
64,
48+
],
4549
]
4650
);
4751
}

‎tests/Rules/Deprecations/data/call-to-deprecated-method-definition.php‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,32 @@ public function deprecatedFoo()
6565
}
6666

6767
}
68+
69+
abstract class MethodMovedToTraitClass
70+
{
71+
/** @deprecated Use TraitReplacingDeprecatedMethod::prophesize() */
72+
protected function prophesize(): void
73+
{
74+
echo 'Base';
75+
}
76+
}
77+
78+
trait TraitCallingDeprecatedMethod
79+
{
80+
protected function prophesize(): void
81+
{
82+
echo 'Trait';
83+
}
84+
}
85+
86+
trait TraitReplacingDeprecatedMethod
87+
{
88+
/**
89+
* @not-deprecated
90+
*/
91+
protected function prophesize(): void
92+
{
93+
echo 'Trait';
94+
}
95+
}
96+

‎tests/Rules/Deprecations/data/call-to-deprecated-method.php‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,24 @@ public function foo()
5353
}
5454

5555
}
56+
57+
58+
final class UsingDeprecatedMethodFromTrait extends MethodMovedToTraitClass
59+
{
60+
use TraitCallingDeprecatedMethod;
61+
62+
public function callProphesize(): void
63+
{
64+
$this->prophesize();
65+
}
66+
}
67+
68+
final class UsingTraitReplacementForDeprecatedMethod extends MethodMovedToTraitClass
69+
{
70+
use TraitReplacingDeprecatedMethod;
71+
72+
public function callProphesize(): void
73+
{
74+
$this->prophesize();
75+
}
76+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /