File tree 3 files changed +20
-5
lines changed
tests/PHPStan/Rules/DeadCode/data
3 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -585,17 +585,14 @@ private function processStmtNode(
585
585
if (!$ scope ->isInClass ()) {
586
586
throw new \PHPStan \ShouldNotHappenException ();
587
587
}
588
- if ($ scope ->isInTrait ()) {
589
- return ;
590
- }
591
588
if ($ scope ->getClassReflection ()->getName () !== $ classReflection ->getName ()) {
592
589
return ;
593
590
}
594
- if ($ node instanceof Node \Stmt \Property) {
591
+ if ($ node instanceof Node \Stmt \Property && ! $ scope -> isInTrait () ) {
595
592
$ properties [] = $ node ;
596
593
return ;
597
594
}
598
- if ($ node instanceof Node \Stmt \ClassMethod) {
595
+ if ($ node instanceof Node \Stmt \ClassMethod && ! $ scope -> isInTrait () ) {
599
596
$ methods [] = $ node ;
600
597
return ;
601
598
}
Original file line number Diff line number Diff line change @@ -19,11 +19,23 @@ public function setFoo($prop1)
19
19
$ this ->prop1 = $ prop1 ;
20
20
}
21
21
22
+ public function getProp3 ()
23
+ {
24
+ return $ this ->prop3 ;
25
+ }
26
+
22
27
}
23
28
24
29
class ClassUsingTrait
25
30
{
26
31
27
32
use FooTrait;
28
33
34
+ private $ prop3 ;
35
+
36
+ public function __construct (string $ prop3 )
37
+ {
38
+ $ this ->prop3 = $ prop3 ;
39
+ }
40
+
29
41
}
Original file line number Diff line number Diff line change @@ -138,6 +138,7 @@ private function doBar()
138
138
public function doBaz ()
139
139
{
140
140
$ this ->doFoo ();
141
+ $ this ->doLorem ();
141
142
}
142
143
143
144
}
@@ -147,4 +148,9 @@ class UsingFooTrait
147
148
148
149
use FooTrait;
149
150
151
+ private function doLorem ()
152
+ {
153
+
154
+ }
155
+
150
156
}
You can’t perform that action at this time.
0 commit comments