File tree 2 files changed +24
-0
lines changed
tests/Rules/StrictCalls/data
2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 7
7
use PHPStan \Analyser \Scope ;
8
8
use PHPStan \Rules \Rule ;
9
9
use PHPStan \Rules \RuleLevelHelper ;
10
+ use PHPStan \Testing \PHPStanTestCase ;
11
+ use PHPStan \Testing \TypeInferenceTestCase ;
10
12
use PHPStan \Type \ErrorType ;
11
13
use PHPStan \Type \Type ;
14
+ use function in_array ;
12
15
use function sprintf ;
13
16
14
17
class DynamicCallOnStaticMethodsRule implements Rule
@@ -53,6 +56,14 @@ static function (Type $type) use ($name): bool {
53
56
54
57
$ methodReflection = $ type ->getMethod ($ name , $ scope );
55
58
if ($ methodReflection ->isStatic ()) {
59
+ $ prototype = $ methodReflection ->getPrototype ();
60
+ if (in_array ($ prototype ->getDeclaringClass ()->getName (), [
61
+ TypeInferenceTestCase::class,
62
+ PHPStanTestCase::class,
63
+ ], true )) {
64
+ return [];
65
+ }
66
+
56
67
return [sprintf (
57
68
'Dynamic call to static method %s::%s(). ' ,
58
69
$ methodReflection ->getDeclaringClass ()->getDisplayName (),
Original file line number Diff line number Diff line change @@ -46,3 +46,16 @@ function () {
46
46
$ classUsingTrait ->foo ();
47
47
$ classUsingTrait ->bar ();
48
48
};
49
+
50
+ class FooTest extends \PHPStan \Testing \TypeInferenceTestCase
51
+ {
52
+
53
+ public function doFoo (): void
54
+ {
55
+ self ::gatherAssertTypes (__FILE__ );
56
+ $ this ->gatherAssertTypes (__FILE__ );
57
+ self ::getContainer ();
58
+ $ this ->getContainer ();
59
+ }
60
+
61
+ }
You can’t perform that action at this time.
0 commit comments