Skip to content

Error on DirectInstanceOverMockArgRector #9620

Closed

Description

@samsonasik

Bug Report

Subject Details
Rector version dev-main

Minimal PHP Code Causing Issue

Running bin/rector on rector-src got error:

 [ERROR] Could not process                                                                                              
         "/Users/samsonasik/www/rector-src/rules/Carbon/Rector/FuncCall/DateFuncCallToCarbonRector.php" file, due to:   
         "System error: "Scope not available on "PhpParser\Node\ArrayItem" node. Fix scope refresh on changed nodes     
         first"                                                                                                         
                                                                                                                        
         Stack trace:                                                                                                   
         #0 vendor/rector/rector-phpunit/rules/CodeQuality/Rector/CallLike/DirectInstanceOverMockArgRector.php(91):     
         Rector\PHPStan\ScopeFetcher::fetch(Object(PhpParser\Node\ArrayItem))                                           
         #1 src/Rector/AbstractRector.php(136):                                                                         
         Rector\PHPUnit\CodeQuality\Rector\CallLike\DirectInstanceOverMockArgRector->refactor(Object(PhpParser\Node\Arr 
         ayItem))                                                                                                       
         #2 src/PhpParser/NodeTraverser/RectorNodeTraverser.php(226):                                                   
         Rector\Rector\AbstractRector->enterNode(Object(PhpParser\Node\ArrayItem))                                      
         #3 src/PhpParser/NodeTraverser/RectorNodeTraverser.php(150):                                                   
         Rector\PhpParser\NodeTraverser\RectorNodeTraverser->traverseArray(Array)                                       
         #4 src/PhpParser/NodeTraverser/RectorNodeTraverser.php(198):                                                   
         Rector\PhpParser\NodeTraverser\RectorNodeTraverser->traverseNode(Object(PhpParser\Node\Expr\List_))            
         #5 src/PhpParser/NodeTraverser/RectorNodeTraverser.php(262):                                       

Expected Behaviour

It should not error. I will look into it.

Activity

  1. samsonasik commented on Jan 26, 2026

    @samsonasik
    MemberAuthor
  2. samsonasik commented on Jan 26, 2026

    @samsonasik
    MemberAuthor

    Resolved on rector-src rectorphp/rector-src#7858
    Failing fixture proof on rector-phpunit rectorphp/rector-phpunit#616

  3. TomasVotruba commented on Jan 26, 2026

    @TomasVotruba
    Member

    👍

  4. github-actions commented on Sep 13, 2026

    @github-actions
    Contributor

    This issue has been automatically locked because it has been closed for 150 days. Please open a new issue if you have a similar problem.

  5. locked as resolved and limited conversation to collaborators on Sep 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions