1010use PhpParser \Node \Expr \StaticCall ;
1111use PhpParser \Node \Stmt \Class_ ;
1212use PhpParser \Node \Stmt \ClassMethod ;
13- use PhpParser \NodeTraverser ;
13+ use PhpParser \NodeVisitor ;
1414use Rector \PHPUnit \NodeAnalyzer \TestsNodeAnalyzer ;
1515use Rector \Rector \AbstractRector ;
1616use Symplify \RuleDocGenerator \ValueObject \CodeSample \CodeSample ;
@@ -24,7 +24,17 @@ final class PreferPHPUnitThisCallRector extends AbstractRector
2424 /**
2525 * @var string[]
2626 */
27- private const NON_ASSERT_STATIC_METHODS = ['createMock ' , 'atLeast ' , 'atLeastOnce ' , 'once ' , 'never ' ];
27+ private const NON_ASSERT_STATIC_METHODS = [
28+ 'createMock ' ,
29+ 'atLeast ' ,
30+ 'atLeastOnce ' ,
31+ 'once ' ,
32+ 'never ' ,
33+ 'expectException ' ,
34+ 'expectExceptionMessage ' ,
35+ 'expectExceptionCode ' ,
36+ 'expectExceptionMessageMatches ' ,
37+ ];
2838
2939 public function __construct (
3040 private readonly TestsNodeAnalyzer $ testsNodeAnalyzer ,
@@ -84,7 +94,7 @@ public function refactor(Node $node): ?Node
8494 $ this ->traverseNodesWithCallable ($ node , function (Node $ node ) use (&$ hasChanged ): int |null |MethodCall {
8595 $ isInsideStaticFunctionLike = ($ node instanceof ClassMethod && $ node ->isStatic ()) || ($ node instanceof Closure && $ node ->static );
8696 if ($ isInsideStaticFunctionLike ) {
87- return NodeTraverser ::DONT_TRAVERSE_CURRENT_AND_CHILDREN ;
97+ return NodeVisitor ::DONT_TRAVERSE_CURRENT_AND_CHILDREN ;
8898 }
8999
90100 if (! $ node instanceof StaticCall) {
0 commit comments