File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed
rules-tests/CodeQuality/Rector/MethodCall/ScalarArgumentToExpectedParamTypeRector/Fixture
rules/CodeQuality/Reflection Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rector \PHPUnit \Tests \CodeQuality \Rector \MethodCall \ScalarArgumentToExpectedParamTypeRector \Fixture ;
4+
5+ use Behat \Behat \Context \Context ;
6+ use Rector \PHPUnit \Tests \CodeQuality \Rector \MethodCall \ScalarArgumentToExpectedParamTypeRector \Source \SomeClassWithSetter ;
7+
8+ final class LocalCall implements Context
9+ {
10+ public function test ()
11+ {
12+ $ result = $ this ->sumUp ('1 ' , '2 ' );
13+ }
14+
15+ private function sumUp (int $ a , int $ b ): int
16+ {
17+ return $ a + $ b ;
18+ }
19+ }
20+
21+ ?>
22+ -----
23+ <?php
24+
25+ namespace Rector \PHPUnit \Tests \CodeQuality \Rector \MethodCall \ScalarArgumentToExpectedParamTypeRector \Fixture ;
26+
27+ use Behat \Behat \Context \Context ;
28+ use Rector \PHPUnit \Tests \CodeQuality \Rector \MethodCall \ScalarArgumentToExpectedParamTypeRector \Source \SomeClassWithSetter ;
29+
30+ final class LocalCall implements Context
31+ {
32+ public function test ()
33+ {
34+ $ result = $ this ->sumUp (1 , 2 );
35+ }
36+
37+ private function sumUp (int $ a , int $ b ): int
38+ {
39+ return $ a + $ b ;
40+ }
41+ }
42+
43+ ?>
Original file line number Diff line number Diff line change 1414use PHPStan \Type \MixedType ;
1515use PHPStan \Type \ObjectType ;
1616use PHPStan \Type \StaticType ;
17+ use PHPStan \Type \ThisType ;
1718use PHPStan \Type \Type ;
1819use Rector \Enum \ClassName ;
1920use Rector \NodeTypeResolver \NodeTypeResolver ;
@@ -72,6 +73,10 @@ public function resolveCallParameterTypes(MethodCall|StaticCall $call): ?array
7273 $ methodName = $ call ->name ->toString ();
7374
7475 $ callerType = $ this ->nodeTypeResolver ->getType ($ call instanceof MethodCall ? $ call ->var : $ call ->class );
76+ if ($ callerType instanceof ThisType) {
77+ $ callerType = $ callerType ->getStaticObjectType ();
78+ }
79+
7580 if (! $ callerType instanceof ObjectType) {
7681 return null ;
7782 }
You can’t perform that action at this time.
0 commit comments