rector: Default error handler is not helping

Bug Report

Subject Details
Rector version 0.11.2
Installed as composer dependency

Minimal PHP Code Causing Issue

dev@phpstorm ~/Code/sw6 $ ../vendor/bin/rector process custom/plugins/FroshPlatformMailArchive/src/Controller/Api/MailResendController.php     
 4/4 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

                                                                                                                        
 [OK] Rector is done!                                                                                                   
                                                                                                                        

Expected Behaviour

See the error and not a green OK. Maybe change it to warning with an help text to use -vvv

dev@phpstorm ~/Code/sw6 $ ../vendor/bin/rector process custom/plugins/FroshPlatformMailArchive/src/Controller/Api/MailResendController.php  -vv
[parsing] custom/plugins/FroshPlatformMailArchive/src/Controller/Api/MailResendController.php

In IdentifierNotFound.php line 24:
                                                                                                                                                               
  [PHPStan\BetterReflection\Reflector\Exception\IdentifierNotFound]                                                                                            
  PHPStan\BetterReflection\Reflection\ReflectionClass "Symfony\Bundle\FrameworkBundle\Controller\AbstractController" could not be found in the located source  
                                                                                                                                                               

Exception trace:
  at phar:///home/dev/Code/FroshPluginUploader/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/Reflector/Exception/IdentifierNotFound.php:24
 PHPStan\BetterReflection\Reflector\Exception\IdentifierNotFound::fromIdentifier() at phar:///home/dev/Code/FroshPluginUploader/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/Reflector/ClassReflector.php:47
 PHPStan\BetterReflection\Reflector\ClassReflector->reflect() at phar:///home/dev/Code/FroshPluginUploader/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/Reflector/MemoizingClassReflector.php:29
 PHPStan\Reflection\BetterReflection\Reflector\MemoizingClassReflector->reflect() at phar:///home/dev/Code/FroshPluginUploader/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/Reflection/ReflectionClass.php:645
 PHPStan\BetterReflection\Reflection\ReflectionClass->getParentClass() at phar:///home/dev/Code/FroshPluginUploader/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/Reflection/Adapter/ReflectionClass.php:368
 PHPStan\BetterReflection\Reflection\Adapter\ReflectionClass->getParentClass() at phar:///home/dev/Code/FroshPluginUploader/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/ClassReflection.php:161
 PHPStan\Reflection\ClassReflection->getParentClass() at phar:///home/dev/Code/FroshPluginUploader/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/PhpDoc/PhpDocBlock.php:196
 PHPStan\PhpDoc\PhpDocBlock::getParentReflections() at phar:///home/dev/Code/FroshPluginUploader/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/PhpDoc/PhpDocBlock.php:178
 PHPStan\PhpDoc\PhpDocBlock::resolveParentPhpDocBlocks() at phar:///home/dev/Code/FroshPluginUploader/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/PhpDoc/PhpDocBlock.php:146
 PHPStan\PhpDoc\PhpDocBlock::resolvePhpDocBlockTree() at phar:///home/dev/Code/FroshPluginUploader/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/PhpDoc/PhpDocBlock.php:128
 PHPStan\PhpDoc\PhpDocBlock::resolvePhpDocBlockForMethod() at phar:///home/dev/Code/FroshPluginUploader/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/PhpDoc/PhpDocInheritanceResolver.php:32
 PHPStan\PhpDoc\PhpDocInheritanceResolver->resolvePhpDocForMethod() at phar:///home/dev/Code/FroshPluginUploader/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php:2876
 PHPStan\Analyser\NodeScopeResolver->getPhpDocs() at phar:///home/dev/Code/FroshPluginUploader/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php:367
 PHPStan\Analyser\NodeScopeResolver->processStmtNode() at phar:///home/dev/Code/FroshPluginUploader/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php:252
 PHPStan\Analyser\NodeScopeResolver->processStmtNodes() at phar:///home/dev/Code/FroshPluginUploader/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php:491
 PHPStan\Analyser\NodeScopeResolver->processStmtNode() at phar:///home/dev/Code/FroshPluginUploader/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php:252
 PHPStan\Analyser\NodeScopeResolver->processStmtNodes() at phar:///home/dev/Code/FroshPluginUploader/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php:457
 PHPStan\Analyser\NodeScopeResolver->processStmtNode() at phar:///home/dev/Code/FroshPluginUploader/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php:220
 PHPStan\Analyser\NodeScopeResolver->processNodes() at /home/dev/Code/FroshPluginUploader/vendor/rector/rector/packages/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php:130
 Rector\NodeTypeResolver\PHPStan\Scope\PHPStanNodeScopeResolver->processNodes() at /home/dev/Code/FroshPluginUploader/vendor/rector/rector/packages/NodeTypeResolver/NodeScopeAndMetadataDecorator.php:78
 Rector\NodeTypeResolver\NodeScopeAndMetadataDecorator->decorateNodesFromFile() at /home/dev/Code/FroshPluginUploader/vendor/rector/rector/src/Application/FileProcessor.php:48
 Rector\Core\Application\FileProcessor->parseFileInfoToLocalCache() at /home/dev/Code/FroshPluginUploader/vendor/rector/rector/src/Application/FileProcessor/PhpFileProcessor.php:107
 Rector\Core\Application\FileProcessor\PhpFileProcessor->Rector\Core\Application\FileProcessor\{closure}() at /home/dev/Code/FroshPluginUploader/vendor/rector/rector/src/Application/FileProcessor/PhpFileProcessor.php:179
 Rector\Core\Application\FileProcessor\PhpFileProcessor->tryCatchWrapper() at /home/dev/Code/FroshPluginUploader/vendor/rector/rector/src/Application/FileProcessor/PhpFileProcessor.php:108
 Rector\Core\Application\FileProcessor\PhpFileProcessor->process() at /home/dev/Code/FroshPluginUploader/vendor/rector/rector/src/Application/ApplicationFileProcessor.php:70
 Rector\Core\Application\ApplicationFileProcessor->processFiles() at /home/dev/Code/FroshPluginUploader/vendor/rector/rector/src/Application/ApplicationFileProcessor.php:56
 Rector\Core\Application\ApplicationFileProcessor->run() at /home/dev/Code/FroshPluginUploader/vendor/rector/rector/src/Console/Command/ProcessCommand.php:130
 Rector\Core\Console\Command\ProcessCommand->execute() at /home/dev/Code/FroshPluginUploader/vendor/rector/rector/vendor/symfony/console/Command/Command.php:230
 RectorPrefix20210514\Symfony\Component\Console\Command\Command->run() at /home/dev/Code/FroshPluginUploader/vendor/rector/rector/vendor/symfony/console/Application.php:826
 RectorPrefix20210514\Symfony\Component\Console\Application->doRunCommand() at /home/dev/Code/FroshPluginUploader/vendor/rector/rector/vendor/symfony/console/Application.php:251
 RectorPrefix20210514\Symfony\Component\Console\Application->doRun() at /home/dev/Code/FroshPluginUploader/vendor/rector/rector/src/Console/ConsoleApplication.php:72
 Rector\Core\Console\ConsoleApplication->doRun() at /home/dev/Code/FroshPluginUploader/vendor/rector/rector/vendor/symfony/console/Application.php:152
 RectorPrefix20210514\Symfony\Component\Console\Application->run() at /home/dev/Code/FroshPluginUploader/vendor/rector/rector/bin/rector.php:52
 require_once() at /home/dev/Code/FroshPluginUploader/vendor/rector/rector/bin/rector:5

process [-n|--dry-run] [-a|--autoload-file AUTOLOAD-FILE] [-o|--output-format [OUTPUT-FORMAT]] [--no-progress-bar] [--no-diffs] [--output-file OUTPUT-FILE] [--cache-debug] [--clear-cache] [--] [<source>...]
```

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16 (11 by maintainers)

Commits related to this issue

Most upvoted comments

Hi, this is actually something Rector cannot handle, as it’s syntax issue that breaks php-parser.

I don’t see how this is connected to the warnings, removing the exceptions fixed it. It runs fine with the deprecation warnings still there?

vendor/bin/rector process test.php -vvv --debug
 0/1 [░░░░░░░░░░░░░░░░░░░░░░░░░░░░]   0% < 1 sec/< 1 sec 48.5 MiB[parsing] test.php
PHP Deprecated:  Array and string offset access syntax with curly braces is deprecated in /mnt/c/Users/user/Desktop/a/vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/String.php on line 529
[...]
Deprecated: Array and string offset access syntax with curly braces is deprecated in /mnt/c/Users/user/Desktop/a/vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/String.php on line 537
[refactoring] test.php
    [applying] Rector\Renaming\Rector\Name\RenameClassRector
    [applying] Rector\PHPOffice\Rector\StaticCall\AddRemovedDefaultValuesRector
PHP Deprecated:  Array and string offset access syntax with curly braces is deprecated in /mnt/c/Users/user/Desktop/a/vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation.php on line 2189
[...]
Deprecated: Array and string offset access syntax with curly braces is deprecated in /mnt/c/Users/user/Desktop/a/vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel5/Worksheet.php on line 907
    [applying] Rector\PHPOffice\Rector\MethodCall\ChangeConditionalReturnedCellRector
    [applying] Rector\PHPOffice\Rector\MethodCall\ChangeConditionalGetConditionRector
    [applying] Rector\PHPOffice\Rector\MethodCall\ChangeConditionalSetConditionRector
    [applying] Rector\PHPOffice\Rector\MethodCall\RemoveSetTempDirOnExcelWriterRector
    [applying] Rector\PHPOffice\Rector\MethodCall\ChangeDuplicateStyleArrayToApplyFromArrayRector
    [applying] Rector\PHPOffice\Rector\MethodCall\GetDefaultStyleToGetParentRector
    [applying] Rector\PHPOffice\Rector\MethodCall\IncreaseColumnIndexRector
    [applying] Rector\Renaming\Rector\MethodCall\RenameMethodRector
[post rectors] test.php
[print] test.php

1 file with changes
===================

1) test.php

    ---------- begin diff ----------
--- Original
+++ New
@@ @@

 include 'vendor/autoload.php';

-$obj = new \PHPExcel_Writer_Excel2007(new \PHPExcel());
+$obj = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx(new \PhpOffice\PhpSpreadsheet\Spreadsheet());
 $obj->setPreCalculateFormulas(true);
    ----------- end diff -----------

Applied rules:
 * RenameClassRector



 [OK] 1 file has been changed by Rector

Lines removed:

https://github.com/PHPOffice/PHPExcel/blob/1.8/Classes/PHPExcel/Writer/PDF/DomPDF.php#L8 https://github.com/PHPOffice/PHPExcel/blob/1.8/Classes/PHPExcel/Writer/PDF/mPDF.php#L8 https://github.com/PHPOffice/PHPExcel/blob/1.8/Classes/PHPExcel/Writer/PDF/tcPDF.php#L9

I’m only complaining that the exceptions were thrown but were not shown on screen - makes it confusing and hard to debug. Not a major issue ofc.

It´s all about clear communication. Nothing wrong but just the message could be clearer here.

I could provide something. Had the same issues some days ago.