rectorphp / rector

Instant Upgrades and Automated Refactoring of any PHP 5.3+ code
https://getrector.com
MIT License
8.74k stars 687 forks source link

Rector fails on Nextcloud server #8841

Closed provokateurin closed 4 weeks ago

provokateurin commented 1 month ago

I had to cut off the logs as the comment was to long for GH.

The error occurs with https://github.com/nextcloud/server/pull/48355 (just clone, composer i and composer rector to reproduce).

$ composer rector
> rector --config=build/rector.php --debug && composer cs:fix
[file] /home/jld3103/src/github.com/nextcloud/server/console.php
...
[file] /home/jld3103/src/github.com/nextcloud/server/themes/example/defaults.php

 [ERROR] Could not process "/home/jld3103/src/github.com/nextcloud/server/lib/private/Preview/WatcherConnector.php"     
         file, due to:                                                                                                  
         "System error: "Node "PhpParser\Node\Expr\Closure" with is missing scope required for scope refresh"           

         Stack trace:                                                                                                   
         #0 vendor-bin/rector/vendor/rector/rector/src/Rector/AbstractRector.php(298):                                  
         Rector\Application\ChangedNodeScopeRefresher->refresh()                                                        
         #1 vendor-bin/rector/vendor/rector/rector/src/Rector/AbstractRector.php(288):                                  
         Rector\Rector\AbstractRector->refreshScopeNodes()                                                              
         #2 vendor-bin/rector/vendor/rector/rector/src/Rector/AbstractRector.php(167):                                  
         Rector\Rector\AbstractRector->postRefactorProcess()                                                            
         #3 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(114):        
         Rector\Rector\AbstractRector->enterNode()                                                                      
         #4 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(198):        
         PhpParser\NodeTraverser->traverseNode()                                                                        
         #5 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(105):        
         PhpParser\NodeTraverser->traverseArray()                                                                       
         #6 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(134):        
         PhpParser\NodeTraverser->traverseNode()                                                                        
         #7 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(198):        
         PhpParser\NodeTraverser->traverseNode()                                                                        
         #8 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(105):        
         PhpParser\NodeTraverser->traverseArray()                                                                       
         #9 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(198):        
         PhpParser\NodeTraverser->traverseNode()                                                                        
         #10 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(105):       
         PhpParser\NodeTraverser->traverseArray()                                                                       
         #11 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(198):       
         PhpParser\NodeTraverser->traverseNode()                                                                        
         #12 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(105):       
         PhpParser\NodeTraverser->traverseArray()                                                                       
         #13 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(198):       
         PhpParser\NodeTraverser->traverseNode()                                                                        
         #14 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(105):       
         PhpParser\NodeTraverser->traverseArray()                                                                       
         #15 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(198):       
         PhpParser\NodeTraverser->traverseNode()                                                                        
         #16 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(85):        
         PhpParser\NodeTraverser->traverseArray()                                                                       
         #17 vendor-bin/rector/vendor/rector/rector/src/PhpParser/NodeTraverser/RectorNodeTraverser.php(47):            
         PhpParser\NodeTraverser->traverse()                                                                            
         #18 vendor-bin/rector/vendor/rector/rector/src/Application/FileProcessor.php(113):                             
         Rector\PhpParser\NodeTraverser\RectorNodeTraverser->traverse()                                                 
         #19 vendor-bin/rector/vendor/rector/rector/src/Application/ApplicationFileProcessor.php(184):                  
         Rector\Application\FileProcessor->processFile()                                                                
         #20 vendor-bin/rector/vendor/rector/rector/src/Application/ApplicationFileProcessor.php(161):                  
         Rector\Application\ApplicationFileProcessor->processFile()                                                     
         #21 vendor-bin/rector/vendor/rector/rector/src/Application/ApplicationFileProcessor.php(138):                  
         Rector\Application\ApplicationFileProcessor->processFiles()                                                    
         #22 vendor-bin/rector/vendor/rector/rector/src/Console/Command/ProcessCommand.php(149):                        
         Rector\Application\ApplicationFileProcessor->run()                                                             
         #23 vendor-bin/rector/vendor/rector/rector/vendor/symfony/console/Command/Command.php(327):                    
         Rector\Console\Command\ProcessCommand->execute()                                                               
         #24 vendor-bin/rector/vendor/rector/rector/vendor/symfony/console/Application.php(960):                        
         RectorPrefix202409\Symfony\Component\Console\Command\Command->run()                                            
         #25 vendor-bin/rector/vendor/rector/rector/vendor/symfony/console/Application.php(333):                        
         RectorPrefix202409\Symfony\Component\Console\Application->doRunCommand()                                       
         #26 vendor-bin/rector/vendor/rector/rector/src/Console/ConsoleApplication.php(53):                             
         RectorPrefix202409\Symfony\Component\Console\Application->doRun()                                              
         #27 vendor-bin/rector/vendor/rector/rector/vendor/symfony/console/Application.php(216):                        
         Rector\Console\ConsoleApplication->doRun()                                                                     
         #28 vendor-bin/rector/vendor/rector/rector/bin/rector.php(130):                                                
         RectorPrefix202409\Symfony\Component\Console\Application->run()                                                
         #29 vendor-bin/rector/vendor/rector/rector/bin/rector(5): require_once('...')                                  
         #30 lib/composer/bin/rector(119): include('...')                                                               
         #31 {main}". On line: 55                                                                                       

 [ERROR] Could not process "/home/jld3103/src/github.com/nextcloud/server/tests/lib/Files/Node/FileTest.php" file, due  
         to:                                                                                                            
         "System error: "Node "PhpParser\Node\Expr\Closure" with is missing scope required for scope refresh"           

         Stack trace:                                                                                                   
         #0 vendor-bin/rector/vendor/rector/rector/src/Rector/AbstractRector.php(298):                                  
         Rector\Application\ChangedNodeScopeRefresher->refresh()                                                        
         #1 vendor-bin/rector/vendor/rector/rector/src/Rector/AbstractRector.php(288):                                  
         Rector\Rector\AbstractRector->refreshScopeNodes()                                                              
         #2 vendor-bin/rector/vendor/rector/rector/src/Rector/AbstractRector.php(167):                                  
         Rector\Rector\AbstractRector->postRefactorProcess()                                                            
         #3 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(114):        
         Rector\Rector\AbstractRector->enterNode()                                                                      
         #4 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(134):        
         PhpParser\NodeTraverser->traverseNode()                                                                        
         #5 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(198):        
         PhpParser\NodeTraverser->traverseNode()                                                                        
         #6 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(105):        
         PhpParser\NodeTraverser->traverseArray()                                                                       
         #7 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(198):        
         PhpParser\NodeTraverser->traverseNode()                                                                        
         #8 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(105):        
         PhpParser\NodeTraverser->traverseArray()                                                                       
         #9 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(198):        
         PhpParser\NodeTraverser->traverseNode()                                                                        
         #10 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(105):       
         PhpParser\NodeTraverser->traverseArray()                                                                       
         #11 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(198):       
         PhpParser\NodeTraverser->traverseNode()                                                                        
         #12 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(85):        
         PhpParser\NodeTraverser->traverseArray()                                                                       
         #13 vendor-bin/rector/vendor/rector/rector/src/PhpParser/NodeTraverser/RectorNodeTraverser.php(47):            
         PhpParser\NodeTraverser->traverse()                                                                            
         #14 vendor-bin/rector/vendor/rector/rector/src/Application/FileProcessor.php(113):                             
         Rector\PhpParser\NodeTraverser\RectorNodeTraverser->traverse()                                                 
         #15 vendor-bin/rector/vendor/rector/rector/src/Application/ApplicationFileProcessor.php(184):                  
         Rector\Application\FileProcessor->processFile()                                                                
         #16 vendor-bin/rector/vendor/rector/rector/src/Application/ApplicationFileProcessor.php(161):                  
         Rector\Application\ApplicationFileProcessor->processFile()                                                     
         #17 vendor-bin/rector/vendor/rector/rector/src/Application/ApplicationFileProcessor.php(138):                  
         Rector\Application\ApplicationFileProcessor->processFiles()                                                    
         #18 vendor-bin/rector/vendor/rector/rector/src/Console/Command/ProcessCommand.php(149):                        
         Rector\Application\ApplicationFileProcessor->run()                                                             
         #19 vendor-bin/rector/vendor/rector/rector/vendor/symfony/console/Command/Command.php(327):                    
         Rector\Console\Command\ProcessCommand->execute()                                                               
         #20 vendor-bin/rector/vendor/rector/rector/vendor/symfony/console/Application.php(960):                        
         RectorPrefix202409\Symfony\Component\Console\Command\Command->run()                                            
         #21 vendor-bin/rector/vendor/rector/rector/vendor/symfony/console/Application.php(333):                        
         RectorPrefix202409\Symfony\Component\Console\Application->doRunCommand()                                       
         #22 vendor-bin/rector/vendor/rector/rector/src/Console/ConsoleApplication.php(53):                             
         RectorPrefix202409\Symfony\Component\Console\Application->doRun()                                              
         #23 vendor-bin/rector/vendor/rector/rector/vendor/symfony/console/Application.php(216):                        
         Rector\Console\ConsoleApplication->doRun()                                                                     
         #24 vendor-bin/rector/vendor/rector/rector/bin/rector.php(130):                                                
         RectorPrefix202409\Symfony\Component\Console\Application->run()                                                
         #25 vendor-bin/rector/vendor/rector/rector/bin/rector(5): require_once('...')                                  
         #26 lib/composer/bin/rector(119): include('...')                                                               
         #27 {main}". On line: 55                                                                                       

 [ERROR] Could not process "/home/jld3103/src/github.com/nextcloud/server/tests/lib/Files/Node/HookConnectorTest.php"   
         file, due to:                                                                                                  
         "System error: "Node "PhpParser\Node\Expr\Closure" with is missing scope required for scope refresh"           

         Stack trace:                                                                                                   
         #0 vendor-bin/rector/vendor/rector/rector/src/Rector/AbstractRector.php(298):                                  
         Rector\Application\ChangedNodeScopeRefresher->refresh()                                                        
         #1 vendor-bin/rector/vendor/rector/rector/src/Rector/AbstractRector.php(288):                                  
         Rector\Rector\AbstractRector->refreshScopeNodes()                                                              
         #2 vendor-bin/rector/vendor/rector/rector/src/Rector/AbstractRector.php(167):                                  
         Rector\Rector\AbstractRector->postRefactorProcess()                                                            
         #3 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(114):        
         Rector\Rector\AbstractRector->enterNode()                                                                      
         #4 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(198):        
         PhpParser\NodeTraverser->traverseNode()                                                                        
         #5 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(105):        
         PhpParser\NodeTraverser->traverseArray()                                                                       
         #6 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(134):        
         PhpParser\NodeTraverser->traverseNode()                                                                        
         #7 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(198):        
         PhpParser\NodeTraverser->traverseNode()                                                                        
         #8 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(105):        
         PhpParser\NodeTraverser->traverseArray()                                                                       
         #9 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(198):        
         PhpParser\NodeTraverser->traverseNode()                                                                        
         #10 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(105):       
         PhpParser\NodeTraverser->traverseArray()                                                                       
         #11 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(198):       
         PhpParser\NodeTraverser->traverseNode()                                                                        
         #12 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(105):       
         PhpParser\NodeTraverser->traverseArray()                                                                       
         #13 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(198):       
         PhpParser\NodeTraverser->traverseNode()                                                                        
         #14 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(85):        
         PhpParser\NodeTraverser->traverseArray()                                                                       
         #15 vendor-bin/rector/vendor/rector/rector/src/PhpParser/NodeTraverser/RectorNodeTraverser.php(47):            
         PhpParser\NodeTraverser->traverse()                                                                            
         #16 vendor-bin/rector/vendor/rector/rector/src/Application/FileProcessor.php(113):                             
         Rector\PhpParser\NodeTraverser\RectorNodeTraverser->traverse()                                                 
         #17 vendor-bin/rector/vendor/rector/rector/src/Application/ApplicationFileProcessor.php(184):                  
         Rector\Application\FileProcessor->processFile()                                                                
         #18 vendor-bin/rector/vendor/rector/rector/src/Application/ApplicationFileProcessor.php(161):                  
         Rector\Application\ApplicationFileProcessor->processFile()                                                     
         #19 vendor-bin/rector/vendor/rector/rector/src/Application/ApplicationFileProcessor.php(138):                  
         Rector\Application\ApplicationFileProcessor->processFiles()                                                    
         #20 vendor-bin/rector/vendor/rector/rector/src/Console/Command/ProcessCommand.php(149):                        
         Rector\Application\ApplicationFileProcessor->run()                                                             
         #21 vendor-bin/rector/vendor/rector/rector/vendor/symfony/console/Command/Command.php(327):                    
         Rector\Console\Command\ProcessCommand->execute()                                                               
         #22 vendor-bin/rector/vendor/rector/rector/vendor/symfony/console/Application.php(960):                        
         RectorPrefix202409\Symfony\Component\Console\Command\Command->run()                                            
         #23 vendor-bin/rector/vendor/rector/rector/vendor/symfony/console/Application.php(333):                        
         RectorPrefix202409\Symfony\Component\Console\Application->doRunCommand()                                       
         #24 vendor-bin/rector/vendor/rector/rector/src/Console/ConsoleApplication.php(53):                             
         RectorPrefix202409\Symfony\Component\Console\Application->doRun()                                              
         #25 vendor-bin/rector/vendor/rector/rector/vendor/symfony/console/Application.php(216):                        
         Rector\Console\ConsoleApplication->doRun()                                                                     
         #26 vendor-bin/rector/vendor/rector/rector/bin/rector.php(130):                                                
         RectorPrefix202409\Symfony\Component\Console\Application->run()                                                
         #27 vendor-bin/rector/vendor/rector/rector/bin/rector(5): require_once('...')                                  
         #28 lib/composer/bin/rector(119): include('...')                                                               
         #29 {main}". On line: 55                                                                                       

 [ERROR] Could not process "/home/jld3103/src/github.com/nextcloud/server/tests/lib/Files/Node/NodeTest.php" file, due  
         to:                                                                                                            
         "System error: "Node "PhpParser\Node\Expr\Closure" with is missing scope required for scope refresh"           

         Stack trace:                                                                                                   
         #0 vendor-bin/rector/vendor/rector/rector/src/Rector/AbstractRector.php(298):                                  
         Rector\Application\ChangedNodeScopeRefresher->refresh()                                                        
         #1 vendor-bin/rector/vendor/rector/rector/src/Rector/AbstractRector.php(288):                                  
         Rector\Rector\AbstractRector->refreshScopeNodes()                                                              
         #2 vendor-bin/rector/vendor/rector/rector/src/Rector/AbstractRector.php(167):                                  
         Rector\Rector\AbstractRector->postRefactorProcess()                                                            
         #3 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(114):        
         Rector\Rector\AbstractRector->enterNode()                                                                      
         #4 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(134):        
         PhpParser\NodeTraverser->traverseNode()                                                                        
         #5 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(198):        
         PhpParser\NodeTraverser->traverseNode()                                                                        
         #6 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(105):        
         PhpParser\NodeTraverser->traverseArray()                                                                       
         #7 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(198):        
         PhpParser\NodeTraverser->traverseNode()                                                                        
         #8 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(105):        
         PhpParser\NodeTraverser->traverseArray()                                                                       
         #9 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(198):        
         PhpParser\NodeTraverser->traverseNode()                                                                        
         #10 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(105):       
         PhpParser\NodeTraverser->traverseArray()                                                                       
         #11 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(198):       
         PhpParser\NodeTraverser->traverseNode()                                                                        
         #12 vendor-bin/rector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(85):        
         PhpParser\NodeTraverser->traverseArray()                                                                       
         #13 vendor-bin/rector/vendor/rector/rector/src/PhpParser/NodeTraverser/RectorNodeTraverser.php(47):            
         PhpParser\NodeTraverser->traverse()                                                                            
         #14 vendor-bin/rector/vendor/rector/rector/src/Application/FileProcessor.php(113):                             
         Rector\PhpParser\NodeTraverser\RectorNodeTraverser->traverse()                                                 
         #15 vendor-bin/rector/vendor/rector/rector/src/Application/ApplicationFileProcessor.php(184):                  
         Rector\Application\FileProcessor->processFile()                                                                
         #16 vendor-bin/rector/vendor/rector/rector/src/Application/ApplicationFileProcessor.php(161):                  
         Rector\Application\ApplicationFileProcessor->processFile()                                                     
         #17 vendor-bin/rector/vendor/rector/rector/src/Application/ApplicationFileProcessor.php(138):                  
         Rector\Application\ApplicationFileProcessor->processFiles()                                                    
         #18 vendor-bin/rector/vendor/rector/rector/src/Console/Command/ProcessCommand.php(149):                        
         Rector\Application\ApplicationFileProcessor->run()                                                             
         #19 vendor-bin/rector/vendor/rector/rector/vendor/symfony/console/Command/Command.php(327):                    
         Rector\Console\Command\ProcessCommand->execute()                                                               
         #20 vendor-bin/rector/vendor/rector/rector/vendor/symfony/console/Application.php(960):                        
         RectorPrefix202409\Symfony\Component\Console\Command\Command->run()                                            
         #21 vendor-bin/rector/vendor/rector/rector/vendor/symfony/console/Application.php(333):                        
         RectorPrefix202409\Symfony\Component\Console\Application->doRunCommand()                                       
         #22 vendor-bin/rector/vendor/rector/rector/src/Console/ConsoleApplication.php(53):                             
         RectorPrefix202409\Symfony\Component\Console\Application->doRun()                                              
         #23 vendor-bin/rector/vendor/rector/rector/vendor/symfony/console/Application.php(216):                        
         Rector\Console\ConsoleApplication->doRun()                                                                     
         #24 vendor-bin/rector/vendor/rector/rector/bin/rector.php(130):                                                
         RectorPrefix202409\Symfony\Component\Console\Application->run()                                                
         #25 vendor-bin/rector/vendor/rector/rector/bin/rector(5): require_once('...')                                  
         #26 lib/composer/bin/rector(119): include('...')                                                               
         #27 {main}". On line: 55                                                                                       

Script rector --config=build/rector.php --debug && composer cs:fix handling the rector event returned with error code 1
TomasVotruba commented 1 month ago

Thank you for your report!

We'll need an isolated failing demo link from: http://getrector.com/demo, that way we can reproduce the bug.

provokateurin commented 1 month ago

Ok I will try to do that. Rector only told me to enable --debug and report it here, so I did that.

samsonasik commented 4 weeks ago

I am closing it as no example reproducible code and config provided :). Feel free to re-open with provide reproducible code and config example :)