Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In TokenIterator.php line 141: Unexpected token ":", expected ')' at offset 1182 #6863

Closed
sergey-telpuk opened this issue Dec 13, 2021 · 11 comments
Labels

Comments

@sergey-telpuk
Copy link

sergey-telpuk commented Dec 13, 2021

Config:

return static function (ContainerConfigurator $containerConfigurator): void {
    // get parameters
    $services = $containerConfigurator->services();

    $parameters = $containerConfigurator->parameters();

    $parameters->set(Option::AUTO_IMPORT_NAMES, true);
    $parameters->set(Option::PATHS, [
//        __DIR__ . '/app',
        __DIR__ . '/src',
    ]);

    $parameters->set(Option::SKIP, [
        // absolute directory
        __DIR__ . '/vendor',
        __DIR__ . '/tests',
    ]);
Error:
In TokenIterator.php line 141:
                                                     
  Unexpected token ":", expected ')' at offset 1182  
@samsonasik
Copy link
Member

Could you run with -vvv to see the possible path that cause it with printed stack trace and file that cause it? Thank you.

@sergey-telpuk
Copy link
Author

Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9003 (through xdebug.client_host/xdebug.client_port) :-(
Running 2.1.12 (2021-11-09 16:02:04) with PHP 8.0.13 on Linux / 5.13.0-22-generic
Reading ./composer.json (/app/composer.json)
Loading auth config from COMPOSER_AUTH
Loading config file ./composer.json (/app/composer.json)
Checked CA file /etc/pki/tls/certs/ca-bundle.crt does not exist or it is not a file.
Checked directory /etc/pki/tls/certs/ca-bundle.crt does not exist or it is not a directory.
Checked CA file /etc/ssl/certs/ca-certificates.crt: valid
Executing command (/app): git branch -a --no-color --no-abbrev -v
Executing command (/app): git rev-list master..BIG-74-backend-2fa-authentication---sms
Executing command (/app): git rev-list remotes/origin/master..BIG-74-backend-2fa-authentication---sms
Failed to initialize global composer: Composer could not find the config file: /home/road-runner/.composer/composer.json

Reading /app/vendor/composer/installed.json
Loading plugin PackageVersions\Installer (from composer/package-versions-deprecated)
> rector: rector process
Executing command (CWD): rector process
Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9003 (through xdebug.client_host/xdebug.client_port) :-(

                                                                                                                        
 [WARNING] Your project contains 1 configurable rector rules that are skipped as need to be configured to run.          
                                                                                                                        

 * Rector\Php55\Rector\String_\StringClassNameToClassConstantRector

 ! [NOTE] Do you want to run them?                                                                                      
 !        Configure them in `rector.php` with "...->configure(...);"                                                    

 10/10 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
                                                                                                                        
 [ERROR] Could not process "app/common/AnonymousClassb6ec136e3651ebeb09b602d7a413698e.php" file, due to:                
         "Internal error.". On line: 155                                                                                
                                                                                                                        

                                                                                                                        
 [ERROR] Could not process "app/common/AnonymousClass8ca7036f46b757b669ca896ed1dc986d.php" file, due to:                
         "Internal error.". On line: 155                                                                                
                                                                                                                        

Script rector process handling the rector event returned with error code 1

@sergey-telpuk
Copy link
Author

and why rector create Anonymous class, I dont want to have this behavior

@sergey-telpuk
Copy link
Author

Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9003 (through xdebug.client_host/xdebug.client_port) :-(
Running 2.1.12 (2021-11-09 16:02:04) with PHP 8.0.13 on Linux / 5.13.0-22-generic
Reading ./composer.json (/app/composer.json)
Loading auth config from COMPOSER_AUTH
Loading config file ./composer.json (/app/composer.json)
Checked CA file /etc/pki/tls/certs/ca-bundle.crt does not exist or it is not a file.
Checked directory /etc/pki/tls/certs/ca-bundle.crt does not exist or it is not a directory.
Checked CA file /etc/ssl/certs/ca-certificates.crt: valid
Executing command (/app): git branch -a --no-color --no-abbrev -v
Executing command (/app): git rev-list master..BIG-74-backend-2fa-authentication---sms
Executing command (/app): git rev-list remotes/origin/master..BIG-74-backend-2fa-authentication---sms
Failed to initialize global composer: Composer could not find the config file: /home/road-runner/.composer/composer.json

Reading /app/vendor/composer/installed.json
Loading plugin PackageVersions\Installer (from composer/package-versions-deprecated)
> rector: rector process
Executing command (CWD): rector process
Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9003 (through xdebug.client_host/xdebug.client_port) :-(

                                                                                                                        
 [WARNING] Your project contains 1 configurable rector rules that are skipped as need to be configured to run.          
                                                                                                                        

 * Rector\Php55\Rector\String_\StringClassNameToClassConstantRector

 ! [NOTE] Do you want to run them?                                                                                      
 !        Configure them in `rector.php` with "...->configure(...);"                                                    

  14/222 [▓░░░░░░░░░░░░░░░░░░░░░░░░░░░]   6%PHP Warning:  Undefined array key "AnonymousClass91bf4b49b3e826e0992d69ae1b89e500" in /app/vendor/rector/rector/vendor/nette/utils/src/Utils/Reflection.php on line 251
Warning: Undefined array key "AnonymousClass91bf4b49b3e826e0992d69ae1b89e500" in /app/vendor/rector/rector/vendor/nette/utils/src/Utils/Reflection.php on line 251
PHP Fatal error:  Uncaught TypeError: RectorPrefix20211209\Nette\Utils\Reflection::getUseStatements(): Return value must be of type array, null returned in /app/vendor/rector/rector/vendor/nette/utils/src/Utils/Reflection.php:251
Stack trace:
#0 /app/vendor/rector/rector/vendor/nette/utils/src/Utils/Reflection.php(224): RectorPrefix20211209\Nette\Utils\Reflection::getUseStatements()
#1 /app/vendor/rector/rector/rules/CodingStyle/ClassNameImport/ShortNameResolver.php(213): RectorPrefix20211209\Nette\Utils\Reflection::expandClassName()
#2 /app/vendor/rector/rector/rules/CodingStyle/ClassNameImport/ShortNameResolver.php(184): Rector\CodingStyle\ClassNameImport\ShortNameResolver->fqnizeShortNames()
#3 /app/vendor/rector/rector/rules/CodingStyle/ClassNameImport/ShortNameResolver.php(150): Rector\CodingStyle\ClassNameImport\ShortNameResolver->resolveFromStmtsDocBlocks()
#4 /app/vendor/rector/rector/rules/CodingStyle/ClassNameImport/ShortNameResolver.php(96): Rector\CodingStyle\ClassNameImport\ShortNameResolver->resolveForStmts()
#5 /app/vendor/rector/rector/rules/CodingStyle/ClassNameImport/ClassNameImportSkipVoter/FullyQualifiedNameClassNameImportSkipVoter.php(40): Rector\CodingStyle\ClassNameImport\ShortNameResolver->resolveFromFile()
#6 /app/vendor/rector/rector/rules/CodingStyle/ClassNameImport/ClassNameImportSkipper.php(37): Rector\CodingStyle\ClassNameImport\ClassNameImportSkipVoter\FullyQualifiedNameClassNameImportSkipVoter->shouldSkip()
#7 /app/vendor/rector/rector/rules/CodingStyle/Node/NameImporter.php(118): Rector\CodingStyle\ClassNameImport\ClassNameImportSkipper->shouldSkipNameForFullyQualifiedObjectType()
#8 /app/vendor/rector/rector/rules/CodingStyle/Node/NameImporter.php(86): Rector\CodingStyle\Node\NameImporter->importNameAndCollectNewUseStatement()
#9 /app/vendor/rector/rector/packages/PostRector/Rector/NameImportingPostRector.php(132): Rector\CodingStyle\Node\NameImporter->importName()
#10 /app/vendor/rector/rector/packages/PostRector/Rector/NameImportingPostRector.php(87): Rector\PostRector\Rector\NameImportingPostRector->processNodeName()
#11 /app/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(113): Rector\PostRector\Rector\NameImportingPostRector->enterNode()
#12 /app/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(133): PhpParser\NodeTraverser->traverseNode()
#13 /app/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(196): PhpParser\NodeTraverser->traverseNode()
#14 /app/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(105): PhpParser\NodeTraverser->traverseArray()
#15 /app/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(133): PhpParser\NodeTraverser->traverseNode()
#16 /app/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(196): PhpParser\NodeTraverser->traverseNode()
#17 /app/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(105): PhpParser\NodeTraverser->traverseArray()
#18 /app/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(196): PhpParser\NodeTraverser->traverseNode()
#19 /app/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(85): PhpParser\NodeTraverser->traverseArray()
#20 /app/vendor/rector/rector/packages/PostRector/Application/PostFileProcessor.php(66): PhpParser\NodeTraverser->traverse()
#21 /app/vendor/rector/rector/src/Application/FileProcessor/PhpFileProcessor.php(106): Rector\PostRector\Application\PostFileProcessor->traverse()
#22 /app/vendor/rector/rector/src/Application/ApplicationFileProcessor.php(96): Rector\Core\Application\FileProcessor\PhpFileProcessor->process()
#23 /app/vendor/rector/rector/src/Application/ApplicationFileProcessor.php(74): Rector\Core\Application\ApplicationFileProcessor->processFiles()
#24 /app/vendor/rector/rector/src/Console/Command/ProcessCommand.php(165): Rector\Core\Application\ApplicationFileProcessor->run()
#25 /app/vendor/rector/rector/vendor/symfony/console/Command/Command.php(296): Rector\Core\Console\Command\ProcessCommand->execute()
#26 /app/vendor/rector/rector/vendor/symfony/console/Application.php(897): RectorPrefix20211209\Symfony\Component\Console\Command\Command->run()
#27 /app/vendor/rector/rector/vendor/symfony/console/Application.php(300): RectorPrefix20211209\Symfony\Component\Console\Application->doRunCommand()
#28 /app/vendor/rector/rector/src/Console/ConsoleApplication.php(71): RectorPrefix20211209\Symfony\Component\Console\Application->doRun()
#29 /app/vendor/rector/rector/vendor/symfony/console/Application.php(196): Rector\Core\Console\ConsoleApplication->doRun()
#30 /app/vendor/rector/rector/bin/rector.php(56): RectorPrefix20211209\Symfony\Component\Console\Application->run()
#31 /app/vendor/rector/rector/bin/rector(5): require_once('...')
#32 {main}
  thrown in /app/vendor/rector/rector/vendor/nette/utils/src/Utils/Reflection.php on line 251
Fatal error: Uncaught TypeError: RectorPrefix20211209\Nette\Utils\Reflection::getUseStatements(): Return value must be of type array, null returned in /app/vendor/rector/rector/vendor/nette/utils/src/Utils/Reflection.php:251
Stack trace:
#0 /app/vendor/rector/rector/vendor/nette/utils/src/Utils/Reflection.php(224): RectorPrefix20211209\Nette\Utils\Reflection::getUseStatements()
#1 /app/vendor/rector/rector/rules/CodingStyle/ClassNameImport/ShortNameResolver.php(213): RectorPrefix20211209\Nette\Utils\Reflection::expandClassName()
#2 /app/vendor/rector/rector/rules/CodingStyle/ClassNameImport/ShortNameResolver.php(184): Rector\CodingStyle\ClassNameImport\ShortNameResolver->fqnizeShortNames()
#3 /app/vendor/rector/rector/rules/CodingStyle/ClassNameImport/ShortNameResolver.php(150): Rector\CodingStyle\ClassNameImport\ShortNameResolver->resolveFromStmtsDocBlocks()
#4 /app/vendor/rector/rector/rules/CodingStyle/ClassNameImport/ShortNameResolver.php(96): Rector\CodingStyle\ClassNameImport\ShortNameResolver->resolveForStmts()
#5 /app/vendor/rector/rector/rules/CodingStyle/ClassNameImport/ClassNameImportSkipVoter/FullyQualifiedNameClassNameImportSkipVoter.php(40): Rector\CodingStyle\ClassNameImport\ShortNameResolver->resolveFromFile()
#6 /app/vendor/rector/rector/rules/CodingStyle/ClassNameImport/ClassNameImportSkipper.php(37): Rector\CodingStyle\ClassNameImport\ClassNameImportSkipVoter\FullyQualifiedNameClassNameImportSkipVoter->shouldSkip()
#7 /app/vendor/rector/rector/rules/CodingStyle/Node/NameImporter.php(118): Rector\CodingStyle\ClassNameImport\ClassNameImportSkipper->shouldSkipNameForFullyQualifiedObjectType()
#8 /app/vendor/rector/rector/rules/CodingStyle/Node/NameImporter.php(86): Rector\CodingStyle\Node\NameImporter->importNameAndCollectNewUseStatement()
#9 /app/vendor/rector/rector/packages/PostRector/Rector/NameImportingPostRector.php(132): Rector\CodingStyle\Node\NameImporter->importName()
#10 /app/vendor/rector/rector/packages/PostRector/Rector/NameImportingPostRector.php(87): Rector\PostRector\Rector\NameImportingPostRector->processNodeName()
#11 /app/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(113): Rector\PostRector\Rector\NameImportingPostRector->enterNode()
#12 /app/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(133): PhpParser\NodeTraverser->traverseNode()
#13 /app/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(196): PhpParser\NodeTraverser->traverseNode()
#14 /app/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(105): PhpParser\NodeTraverser->traverseArray()
#15 /app/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(133): PhpParser\NodeTraverser->traverseNode()
#16 /app/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(196): PhpParser\NodeTraverser->traverseNode()
#17 /app/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(105): PhpParser\NodeTraverser->traverseArray()
#18 /app/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(196): PhpParser\NodeTraverser->traverseNode()
#19 /app/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(85): PhpParser\NodeTraverser->traverseArray()
#20 /app/vendor/rector/rector/packages/PostRector/Application/PostFileProcessor.php(66): PhpParser\NodeTraverser->traverse()
#21 /app/vendor/rector/rector/src/Application/FileProcessor/PhpFileProcessor.php(106): Rector\PostRector\Application\PostFileProcessor->traverse()
#22 /app/vendor/rector/rector/src/Application/ApplicationFileProcessor.php(96): Rector\Core\Application\FileProcessor\PhpFileProcessor->process()
#23 /app/vendor/rector/rector/src/Application/ApplicationFileProcessor.php(74): Rector\Core\Application\ApplicationFileProcessor->processFiles()
#24 /app/vendor/rector/rector/src/Console/Command/ProcessCommand.php(165): Rector\Core\Application\ApplicationFileProcessor->run()
#25 /app/vendor/rector/rector/vendor/symfony/console/Command/Command.php(296): Rector\Core\Console\Command\ProcessCommand->execute()
#26 /app/vendor/rector/rector/vendor/symfony/console/Application.php(897): RectorPrefix20211209\Symfony\Component\Console\Command\Command->run()
#27 /app/vendor/rector/rector/vendor/symfony/console/Application.php(300): RectorPrefix20211209\Symfony\Component\Console\Application->doRunCommand()
#28 /app/vendor/rector/rector/src/Console/ConsoleApplication.php(71): RectorPrefix20211209\Symfony\Component\Console\Application->doRun()
#29 /app/vendor/rector/rector/vendor/symfony/console/Application.php(196): Rector\Core\Console\ConsoleApplication->doRun()
#30 /app/vendor/rector/rector/bin/rector.php(56): RectorPrefix20211209\Symfony\Component\Console\Application->run()
#31 /app/vendor/rector/rector/bin/rector(5): require_once('...')
#32 {main}
  thrown in /app/vendor/rector/rector/vendor/nette/utils/src/Utils/Reflection.php on line 251
Script rector process handling the rector event returned with error code 255

@samsonasik
Copy link
Member

Could you create sample minimal repository to reproduce the issue? Thank you.

@TomasVotruba
Copy link
Member

TomasVotruba commented Dec 31, 2021

@sergey-telpuk This has been most likely fixed in rectorphp/rector-src#1480

Please the test latest dev-main and report reproducible repository, if this problem still occurs. That way we'll be able to see the troublesome code and isolate the fix 🤗

@sergey-telpuk
Copy link
Author

sergey-telpuk commented Dec 31, 2021

@TomasVotruba Hi, I have another one error in dev-main

  18/172 [▓▓░░░░░░░░░░░░░░░░░░░░░░░░░░]  10%PHP Fatal error:  Uncaught TypeError: RectorPrefix20211231\Nette\Utils\Reflection::getUseStatements(): Return value must be of type array, null returned in /app/vendor/rector/rector/vendor/nette/utils/src/Utils/Reflection.php:234
Stack trace:
#0 /app/vendor/rector/rector/vendor/nette/utils/src/Utils/Reflection.php(208): RectorPrefix20211231\Nette\Utils\Reflection::getUseStatements()
#1 /app/vendor/rector/rector/rules/CodingStyle/ClassNameImport/ShortNameResolver.php(213): RectorPrefix20211231\Nette\Utils\Reflection::expandClassName()

But after repeat run, rector I don't have. Try again and see this error

@TomasVotruba
Copy link
Member

Try the --debug run to find out more.
We'll need a reproducible repository to discover the cause.

@sergey-telpuk
Copy link
Author

sergey-telpuk commented Dec 31, 2021

@TomasVotruba

PHP Fatal error:  Uncaught TypeError: RectorPrefix20211231\Nette\Utils\Reflection::getUseStatements(): Return value must be of type array, null returned in /app/vendor/rector/rector/vendor/nette/utils/src/Utils/Reflection.php:234
Stack trace:
#0 /app/vendor/rector/rector/vendor/nette/utils/src/Utils/Reflection.php(208): RectorPrefix20211231\Nette\Utils\Reflection::getUseStatements()
#1 /app/vendor/rector/rector/rules/CodingStyle/ClassNameImport/ShortNameResolver.php(213): RectorPrefix20211231\Nette\Utils\Reflection::expandClassName()
#2 /app/vendor/rector/rector/rules/CodingStyle/ClassNameImport/ShortNameResolver.php(184): Rector\CodingStyle\ClassNameImport\ShortNameResolver->fqnizeShortNames()
#3 /app/vendor/rector/rector/rules/CodingStyle/ClassNameImport/ShortNameResolver.php(150): Rector\CodingStyle\ClassNameImport\ShortNameResolver->resolveFromStmtsDocBlocks()
#4 /app/vendor/rector/rector/rules/CodingStyle/ClassNameImport/ShortNameResolver.php(96): Rector\CodingStyle\ClassNameImport\ShortNameResolver->resolveForStmts()
#5 /app/vendor/rector/rector/rules/CodingStyle/ClassNameImport/ClassNameImportSkipVoter/FullyQualifiedNameClassNameImportSkipVoter.php(35): Rector\CodingStyle\ClassNameImport\ShortNameResolver->resolveFromFile()
#6 /app/vendor/rector/rector/rules/CodingStyle/ClassNameImport/ClassNameImportSkipper.php(37): Rector\CodingStyle\ClassNameImport\ClassNameImportSkipVoter\FullyQualifiedNameClassNameImportSkipVoter->shouldSkip()
#7 /app/vendor/rector/rector/rules/CodingStyle/Node/NameImporter.php(118): Rector\CodingStyle\ClassNameImport\ClassNameImportSkipper->shouldSkipNameForFullyQualifiedObjectType()
#8 /app/vendor/rector/rector/rules/CodingStyle/Node/NameImporter.php(86): Rector\CodingStyle\Node\NameImporter->importNameAndCollectNewUseStatement()
#9 /app/vendor/rector/rector/packages/PostRector/Rector/NameImportingPostRector.php(132): Rector\CodingStyle\Node\NameImporter->importName()
#10 /app/vendor/rector/rector/packages/PostRector/Rector/NameImportingPostRector.php(87): Rector\PostRector\Rector\NameImportingPostRector->processNodeName()
#11 /app/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(113): Rector\PostRector\Rector\NameImportingPostRector->enterNode()
#12 /app/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(133): PhpParser\NodeTraverser->traverseNode()
#13 /app/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(196): PhpParser\NodeTraverser->traverseNode()
#14 /app/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(105): PhpParser\NodeTraverser->traverseArray()
#15 /app/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(133): PhpParser\NodeTraverser->traverseNode()
#16 /app/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(196): PhpParser\NodeTraverser->traverseNode()
#17 /app/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(105): PhpParser\NodeTraverser->traverseArray()
#18 /app/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(196): PhpParser\NodeTraverser->traverseNode()
#19 /app/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(85): PhpParser\NodeTraverser->traverseArray()
#20 /app/vendor/rector/rector/packages/PostRector/Application/PostFileProcessor.php(66): PhpParser\NodeTraverser->traverse()
#21 /app/vendor/rector/rector/src/Application/FileProcessor/PhpFileProcessor.php(104): Rector\PostRector\Application\PostFileProcessor->traverse()
#22 /app/vendor/rector/rector/src/Application/ApplicationFileProcessor.php(174): Rector\Core\Application\FileProcessor\PhpFileProcessor->process()
#23 /app/vendor/rector/rector/src/Application/ApplicationFileProcessor.php(147): Rector\Core\Application\ApplicationFileProcessor->processFiles()
#24 /app/vendor/rector/rector/src/Console/Command/ProcessCommand.php(139): Rector\Core\Application\ApplicationFileProcessor->run()
#25 /app/vendor/rector/rector/vendor/symfony/console/Command/Command.php(282): Rector\Core\Console\Command\ProcessCommand->execute()
#26 /app/vendor/rector/rector/vendor/symfony/console/Application.php(853): RectorPrefix20211231\Symfony\Component\Console\Command\Command->run()
#27 /app/vendor/rector/rector/vendor/symfony/console/Application.php(289): RectorPrefix20211231\Symfony\Component\Console\Application->doRunCommand()
#28 /app/vendor/rector/rector/src/Console/ConsoleApplication.php(67): RectorPrefix20211231\Symfony\Component\Console\Application->doRun()
#29 /app/vendor/rector/rector/vendor/symfony/console/Application.php(187): Rector\Core\Console\ConsoleApplication->doRun()
#30 /app/vendor/rector/rector/bin/rector.php(56): RectorPrefix20211231\Symfony\Component\Console\Application->run()
#31 /app/vendor/rector/rector/bin/rector(5): require_once('...')
#32 {main}
  thrown in /app/vendor/rector/rector/vendor/nette/utils/src/Utils/Reflection.php on line 234
Fatal error: Uncaught TypeError: RectorPrefix20211231\Nette\Utils\Reflection::getUseStatements(): Return value must be of type array, null returned in /app/vendor/rector/rector/vendor/nette/utils/src/Utils/Reflection.php:234
Stack trace:
#0 /app/vendor/rector/rector/vendor/nette/utils/src/Utils/Reflection.php(208): RectorPrefix20211231\Nette\Utils\Reflection::getUseStatements()
#1 /app/vendor/rector/rector/rules/CodingStyle/ClassNameImport/ShortNameResolver.php(213): RectorPrefix20211231\Nette\Utils\Reflection::expandClassName()
#2 /app/vendor/rector/rector/rules/CodingStyle/ClassNameImport/ShortNameResolver.php(184): Rector\CodingStyle\ClassNameImport\ShortNameResolver->fqnizeShortNames()
#3 /app/vendor/rector/rector/rules/CodingStyle/ClassNameImport/ShortNameResolver.php(150): Rector\CodingStyle\ClassNameImport\ShortNameResolver->resolveFromStmtsDocBlocks()
#4 /app/vendor/rector/rector/rules/CodingStyle/ClassNameImport/ShortNameResolver.php(96): Rector\CodingStyle\ClassNameImport\ShortNameResolver->resolveForStmts()
#5 /app/vendor/rector/rector/rules/CodingStyle/ClassNameImport/ClassNameImportSkipVoter/FullyQualifiedNameClassNameImportSkipVoter.php(35): Rector\CodingStyle\ClassNameImport\ShortNameResolver->resolveFromFile()
#6 /app/vendor/rector/rector/rules/CodingStyle/ClassNameImport/ClassNameImportSkipper.php(37): Rector\CodingStyle\ClassNameImport\ClassNameImportSkipVoter\FullyQualifiedNameClassNameImportSkipVoter->shouldSkip()
#7 /app/vendor/rector/rector/rules/CodingStyle/Node/NameImporter.php(118): Rector\CodingStyle\ClassNameImport\ClassNameImportSkipper->shouldSkipNameForFullyQualifiedObjectType()
#8 /app/vendor/rector/rector/rules/CodingStyle/Node/NameImporter.php(86): Rector\CodingStyle\Node\NameImporter->importNameAndCollectNewUseStatement()
#9 /app/vendor/rector/rector/packages/PostRector/Rector/NameImportingPostRector.php(132): Rector\CodingStyle\Node\NameImporter->importName()
#10 /app/vendor/rector/rector/packages/PostRector/Rector/NameImportingPostRector.php(87): Rector\PostRector\Rector\NameImportingPostRector->processNodeName()
#11 /app/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(113): Rector\PostRector\Rector\NameImportingPostRector->enterNode()
#12 /app/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(133): PhpParser\NodeTraverser->traverseNode()
#13 /app/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(196): PhpParser\NodeTraverser->traverseNode()
#14 /app/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(105): PhpParser\NodeTraverser->traverseArray()
#15 /app/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(133): PhpParser\NodeTraverser->traverseNode()
#16 /app/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(196): PhpParser\NodeTraverser->traverseNode()
#17 /app/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(105): PhpParser\NodeTraverser->traverseArray()
#18 /app/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(196): PhpParser\NodeTraverser->traverseNode()
#19 /app/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(85): PhpParser\NodeTraverser->traverseArray()
#20 /app/vendor/rector/rector/packages/PostRector/Application/PostFileProcessor.php(66): PhpParser\NodeTraverser->traverse()
#21 /app/vendor/rector/rector/src/Application/FileProcessor/PhpFileProcessor.php(104): Rector\PostRector\Application\PostFileProcessor->traverse()
#22 /app/vendor/rector/rector/src/Application/ApplicationFileProcessor.php(174): Rector\Core\Application\FileProcessor\PhpFileProcessor->process()
#23 /app/vendor/rector/rector/src/Application/ApplicationFileProcessor.php(147): Rector\Core\Application\ApplicationFileProcessor->processFiles()
#24 /app/vendor/rector/rector/src/Console/Command/ProcessCommand.php(139): Rector\Core\Application\ApplicationFileProcessor->run()
#25 /app/vendor/rector/rector/vendor/symfony/console/Command/Command.php(282): Rector\Core\Console\Command\ProcessCommand->execute()
#26 /app/vendor/rector/rector/vendor/symfony/console/Application.php(853): RectorPrefix20211231\Symfony\Component\Console\Command\Command->run()
#27 /app/vendor/rector/rector/vendor/symfony/console/Application.php(289): RectorPrefix20211231\Symfony\Component\Console\Application->doRunCommand()
#28 /app/vendor/rector/rector/src/Console/ConsoleApplication.php(67): RectorPrefix20211231\Symfony\Component\Console\Application->doRun()
#29 /app/vendor/rector/rector/vendor/symfony/console/Application.php(187): Rector\Core\Console\ConsoleApplication->doRun()
#30 /app/vendor/rector/rector/bin/rector.php(56): RectorPrefix20211231\Symfony\Component\Console\Application->run()
#31 /app/vendor/rector/rector/bin/rector(5): require_once('...')
#32 {main}
  thrown in /app/vendor/rector/rector/vendor/nette/utils/src/Utils/Reflection.php on line 234
Script rector --debug handling the rector event returned with error code 255

@sergey-telpuk
Copy link
Author

sergey-telpuk commented Dec 31, 2021

I can't share my repo because it's NDA

<?php

declare(strict_types=1);

use Rector\CodingStyle\Rector\Assign\PHPStormVarAnnotationRector;
use Rector\CodingStyle\Rector\Assign\SplitDoubleAssignRector;
use Rector\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector;
use Rector\CodingStyle\Rector\Class_\AddArrayDefaultToArrayPropertyRector;
use Rector\CodingStyle\Rector\ClassConst\SplitGroupedConstantsAndPropertiesRector;
use Rector\CodingStyle\Rector\ClassConst\VarConstantCommentRector;
use Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector;
use Rector\CodingStyle\Rector\ClassMethod\NewlineBeforeNewAssignSetRector;
use Rector\CodingStyle\Rector\ClassMethod\RemoveDoubleUnderscoreInMethodNameRector;
use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector;
use Rector\CodingStyle\Rector\Encapsed\WrapEncapsedVariableInCurlyBracesRector;
use Rector\CodingStyle\Rector\FuncCall\CallUserFuncArrayToVariadicRector;
use Rector\CodingStyle\Rector\FuncCall\ConsistentImplodeRector;
use Rector\CodingStyle\Rector\FuncCall\ConsistentPregDelimiterRector;
use Rector\CodingStyle\Rector\FuncCall\VersionCompareFuncCallToConstantRector;
use Rector\CodingStyle\Rector\If_\NullableCompareToNullRector;
use Rector\CodingStyle\Rector\Include_\FollowRequireByDirRector;
use Rector\CodingStyle\Rector\Plus\UseIncrementAssignRector;
use Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector;
use Rector\CodingStyle\Rector\Property\AddFalseDefaultToBoolPropertyRector;
use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector;
use Rector\CodingStyle\Rector\String_\SymplifyQuoteEscapeRector;
use Rector\CodingStyle\Rector\Switch_\BinarySwitchToIfElseRector;
use Rector\CodingStyle\Rector\Ternary\TernaryConditionVariableAssignmentRector;
use Rector\CodingStyle\Rector\Use_\SeparateMultiUseImportsRector;
use Rector\Core\Configuration\Option;
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
use Rector\Set\ValueObject\SetList;
use Rector\Transform\Rector\FuncCall\FuncCallToConstFetchRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
    // get parameters
    $services = $containerConfigurator->services();

    $parameters = $containerConfigurator->parameters();

    $parameters->set(Option::AUTO_IMPORT_NAMES, true);
    $parameters->set(Option::PATHS, [
        __DIR__ . '/app',
        __DIR__ . '/src',
    ]);

    $parameters->set(Option::SKIP, [
        // absolute directory
        __DIR__ . '/vendor',
        __DIR__ . '/tests',
    ]);

    $containerConfigurator->import(SetList::PHP_80);
    $containerConfigurator->import(SetList::CODE_QUALITY);
    $containerConfigurator->import(SetList::EARLY_RETURN);
    $containerConfigurator->import(SetList::PSR_4);
    $containerConfigurator->import(SetList::TYPE_DECLARATION);
    $containerConfigurator->import(SetList::ORDER);
    $containerConfigurator->import(SetList::TYPE_DECLARATION_STRICT);
    $containerConfigurator->import(SetList::ACTION_INJECTION_TO_CONSTRUCTOR_INJECTION);

    $services->set(PHPStormVarAnnotationRector::class);
    $services->set(NullableCompareToNullRector::class);
    $services->set(BinarySwitchToIfElseRector::class);
    $services->set(ConsistentImplodeRector::class);
    $services->set(TernaryConditionVariableAssignmentRector::class);
    $services->set(SymplifyQuoteEscapeRector::class);
    $services->set(SplitGroupedConstantsAndPropertiesRector::class);
    $services->set(StringClassNameToClassConstantRector::class);
    $services->set(ConsistentPregDelimiterRector::class);
    $services->set(FollowRequireByDirRector::class);
    $services->set(CatchExceptionNameMatchingTypeRector::class);
    $services->set(UseIncrementAssignRector::class);
    $services->set(SplitDoubleAssignRector::class);
    $services->set(VarConstantCommentRector::class);
    $services->set(EncapsedStringsToSprintfRector::class);
    $services->set(WrapEncapsedVariableInCurlyBracesRector::class);
    $services->set(NewlineBeforeNewAssignSetRector::class);
    $services->set(AddArrayDefaultToArrayPropertyRector::class);
    $services->set(AddFalseDefaultToBoolPropertyRector::class);
    $services->set(MakeInheritedMethodVisibilitySameAsParentRector::class);
    $services->set(CallUserFuncArrayToVariadicRector::class);
    $services->set(VersionCompareFuncCallToConstantRector::class);
    $services->set(FuncCallToConstFetchRector::class)->configure(['php_sapi_name' => 'PHP_SAPI', 'pi' => 'M_PI']);
    $services->set(SeparateMultiUseImportsRector::class);
    $services->set(RemoveDoubleUnderscoreInMethodNameRector::class);
    $services->set(PostIncDecToPreIncDecRector::class);
    $services->set(NewlineAfterStatementRector::class);
};

@TomasVotruba
Copy link
Member

Not neccesary the whole repository. The breaking code is usually 3-5 lines.
That's where --debug option helps.

In the end, the Rector should run only on 1 file to see the error, e.g. vendor/bin/rector process src/Some/SpecificFile.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants