File tree Expand file tree Collapse file tree
rules/PHPUnit90/Rector/MethodCall Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -92,6 +92,10 @@ public function refactor(Node $node): ?Node
9292 return null ;
9393 }
9494
95+ if (count ($ node ->getArgs ()) < 2 ) {
96+ return null ;
97+ }
98+
9599 // when second argument is string: do nothing
96100 $ secondArgType = $ this ->getType ($ node ->getArgs ()[1 ]->value );
97101 if ($ secondArgType instanceof StringType) {
Original file line number Diff line number Diff line change 77use PhpParser \Node ;
88use PhpParser \Node \Expr \MethodCall ;
99use PhpParser \Node \Expr \StaticCall ;
10- use PhpParser \Node \Expr \Variable ;
1110use PhpParser \Node \Stmt \ClassMethod ;
1211use PHPStan \Reflection \ClassReflection ;
1312use PHPStan \Type \ObjectType ;
@@ -34,22 +33,7 @@ public function __construct(
3433
3534 public function isInTestClass (Node $ node ): bool
3635 {
37- if ($ node instanceof MethodCall && (! $ node ->var instanceof Variable || ! $ this ->nodeNameResolver ->isName (
38- $ node ->var ,
39- 'this '
40- ))) {
41- $ classReflection = $ this ->reflectionResolver ->resolveClassReflectionSourceObject ($ node );
42-
43- // fluent call PHPUnit methods
44- if ($ classReflection instanceof ClassReflection && str_starts_with (
45- $ classReflection ->getName (),
46- 'PHPUnit \\'
47- )) {
48- $ classReflection = $ this ->reflectionResolver ->resolveClassReflection ($ node );
49- }
50- } else {
51- $ classReflection = $ this ->reflectionResolver ->resolveClassReflection ($ node );
52- }
36+ $ classReflection = $ this ->reflectionResolver ->resolveClassReflection ($ node );
5337
5438 if (! $ classReflection instanceof ClassReflection) {
5539 return false ;
You can’t perform that action at this time.
0 commit comments