File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
tests/Rules/StrictCalls/data Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 77use PHPStan \Analyser \Scope ;
88use PHPStan \Rules \Rule ;
99use PHPStan \Rules \RuleLevelHelper ;
10+ use PHPStan \Testing \PHPStanTestCase ;
11+ use PHPStan \Testing \TypeInferenceTestCase ;
1012use PHPStan \Type \ErrorType ;
1113use PHPStan \Type \Type ;
14+ use function in_array ;
1215use function sprintf ;
1316
1417class DynamicCallOnStaticMethodsRule implements Rule
@@ -53,6 +56,14 @@ static function (Type $type) use ($name): bool {
5356
5457 $ methodReflection = $ type ->getMethod ($ name , $ scope );
5558 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+
5667 return [sprintf (
5768 'Dynamic call to static method %s::%s(). ' ,
5869 $ methodReflection ->getDeclaringClass ()->getDisplayName (),
Original file line number Diff line number Diff line change @@ -46,3 +46,16 @@ function () {
4646 $ classUsingTrait ->foo ();
4747 $ classUsingTrait ->bar ();
4848};
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