But upgrading to rector-prefix v0.7 is causing problems:
composer require rector/rector-prefixed:0.7 --dev
vendor/bin/rector process web/core/modules/aggregator/src/Plugin/views/row/Rss.php --set deadcode --dry-run
[ERROR] Could not process "web/core/modules/aggregator/src/Plugin/views/row/Rss.php" file, due to: "Class '_HumbugBox46c80243413c\JetBrains\PHPStormStub\PhpStormStubsMap' not found".
[ERROR] Could not process "web/core/modules/aggregator/src/Plugin/views/row/Rss.php" file, due to: "Call to a member function hasByType() on null".
report from command line with --debugvendor/bin/rector process web/core/modules/aggregator/src/Plugin/views/row/Rss.php --set deadcode --dry-run --debug
File "/Users/shaal/code/test/my_site_name_dir/vendor/autoload.php" is about to be loaded in "_HumbugBox46c80243413c\AutoloadIncluder::includeCwdVendorAutoloadIfExists()" on line 53"
File "/Users/shaal/code/test/my_site_name_dir/vendor/rector/rector-prefixed/../../autoload.php" is about to be loaded in "_HumbugBox46c80243413c\AutoloadIncluder::autoloadProjectAutoloaderFile()" on line 86"
File "phar://rector.phar/vendor/autoload.php" is about to be loaded in "_HumbugBox46c80243413c\AutoloadIncluder::includeDependencyOrRepositoryVendorAutoloadIfExists()" on line 65"
File "/Users/shaal/code/test/my_site_name_dir/vendor/autoload.php" is about to be loaded in "_HumbugBox46c80243413c\AutoloadIncluder::includeCwdVendorAutoloadIfExists()" on line 53"
File "/Users/shaal/code/test/my_site_name_dir/vendor/rector/rector-prefixed/../../autoload.php" is about to be loaded in "_HumbugBox46c80243413c\AutoloadIncluder::autoloadProjectAutoloaderFile()" on line 86"
File "phar://rector.phar/vendor/autoload.php" is about to be loaded in "_HumbugBox46c80243413c\AutoloadIncluder::includeDependencyOrRepositoryVendorAutoloadIfExists()" on line 65"
Rector v0.7.0
Config file: rector.yml
[parsing] web/core/modules/aggregator/src/Plugin/views/row/Rss.php
PHP Fatal error: Uncaught Error: Class '_HumbugBox46c80243413c\JetBrains\PHPStormStub\PhpStormStubsMap' not found in phar:///Users/shaal/code/test/my_site_name_dir/vendor/rector/rector-prefixed/rector/vendor/ondrejmirtes/better-reflection/src/SourceLocator/SourceStubber/PhpStormStubsSourceStubber.php:67
Stack trace:
#0 phar:///Users/shaal/code/test/my_site_name_dir/vendor/rector/rector-prefixed/rector/vendor/ondrejmirtes/better-reflection/src/SourceLocator/Type/PhpInternalSourceLocator.php(38): _HumbugBox46c80243413c\Roave\BetterReflection\SourceLocator\SourceStubber\PhpStormStubsSourceStubber->generateClassStub('key')
#1 phar:///Users/shaal/code/test/my_site_name_dir/vendor/rector/rector-prefixed/rector/vendor/ondrejmirtes/better-reflection/src/SourceLocator/Type/PhpInternalSourceLocator.php(31): _HumbugBox46c80243413c\Roave\BetterReflection\SourceLocator\Type\PhpInternalSourceLocator->getClassSource(Object(_HumbugBox46c80243413c\Roave\BetterReflection\Identifier\Identifier))
#2 phar:///Users/shaal/code/test/my_site_name_dir in phar:///Users/shaal/code/test/my_site_name_dir/vendor/rector/rector-prefixed/rector/vendor/ondrejmirtes/better-reflection/src/SourceLocator/SourceStubber/PhpStormStubsSourceStubber.php on line 67
Fatal error: Uncaught Error: Class '_HumbugBox46c80243413c\JetBrains\PHPStormStub\PhpStormStubsMap' not found in phar:///Users/shaal/code/test/my_site_name_dir/vendor/rector/rector-prefixed/rector/vendor/ondrejmirtes/better-reflection/src/SourceLocator/SourceStubber/PhpStormStubsSourceStubber.php:67
Stack trace:
#0 phar:///Users/shaal/code/test/my_site_name_dir/vendor/rector/rector-prefixed/rector/vendor/ondrejmirtes/better-reflection/src/SourceLocator/Type/PhpInternalSourceLocator.php(38): _HumbugBox46c80243413c\Roave\BetterReflection\SourceLocator\SourceStubber\PhpStormStubsSourceStubber->generateClassStub('key')
#1 phar:///Users/shaal/code/test/my_site_name_dir/vendor/rector/rector-prefixed/rector/vendor/ondrejmirtes/better-reflection/src/SourceLocator/Type/PhpInternalSourceLocator.php(31): _HumbugBox46c80243413c\Roave\BetterReflection\SourceLocator\Type\PhpInternalSourceLocator->getClassSource(Object(_HumbugBox46c80243413c\Roave\BetterReflection\Identifier\Identifier))
#2 phar:///Users/shaal/code/test/my_site_name_dir in phar:///Users/shaal/code/test/my_site_name_dir/vendor/rector/rector-prefixed/rector/vendor/ondrejmirtes/better-reflection/src/SourceLocator/SourceStubber/PhpStormStubsSourceStubber.php on line 67
On additional testing locally, I found that when I install rector/rector v0.7 in a separate directory, outside of Drupal project, works as expected with no errors.
But rector/rector-prefixed v0.7 - throw the error messages on top of this issue.
I just compared how rector.phar vs. phpstan.phar looks like:
Rector:
PhpStormStubsMap.php - NOT inside prefixed _HumbugBox namespace
PhpStormStubsSourceStubber.php - uses PhpStormStubsMap prefixed with _HumbugBox, leading to the error in OP.
PHPStan:
PhpStormStubsMap.php - inside prefixed _HumbugBox namespace
PhpStormStubsSourceStubber.php - uses PhpStormStubsMap prefixed with _HumbugBox, so it's consistent and does not lead to an error.
@TomasVotruba You should be able to debug these issues yourself, if you consider Rector's PHAR file first-class citizen. Of course if the cause is in PHPStan itself, I'm happy to help you. But in this case it doesn't seem PHPStan's fault.
I've solved it by adding it as a dependency + renaming stubs as you recommended.
Locally it works... but in Travis CI it fails, on missing rectorphp/rector/compiler/bin/../../vendor/je tbrains/phpstorm-stubs directory... no idea why :/
Current Behaviour
Installing Drupal8 and adding rector-prefixed 0.6.13 works as expected Steps to replicate:
composer create-project drupal/recommended-project drupal8
cd drupal8
composer require rector/rector-prefixed:0.6.13 --dev
vendor/bin/rector process web/core/modules/aggregator/src/Plugin/views/row/Rss.php --set deadcode --dry-run
The output is correct and it display the diff of berfore/after the rector
But upgrading to rector-prefix v0.7 is causing problems:
composer require rector/rector-prefixed:0.7 --dev
vendor/bin/rector process web/core/modules/aggregator/src/Plugin/views/row/Rss.php --set deadcode --dry-run
report from command line with --debug
vendor/bin/rector process web/core/modules/aggregator/src/Plugin/views/row/Rss.php --set deadcode --dry-run --debug
Minimal PHP Code Causing Issue
```phpRelated issues: https://github.com/rectorphp/rector/issues/2749 https://github.com/rectorphp/rector/pull/2816
Could you send Github Action just for this so we have it covered?
I am not familiar with Github Action. How do I send it?
Basically copy this file: https://github.com/rectorphp/rector/blob/36ffd477634cb7318aff008a7259c11bc577579f/.github/workflows/test_with_doctrine.yaml#L20-L33
and replace
run
part with your commandsOn additional testing locally, I found that when I install
rector/rector
v0.7 in a separate directory, outside of Drupal project, works as expected with no errors. Butrector/rector-prefixed
v0.7 - throw the error messages on top of this issue.I'd love to look at it. Failing CI is needed.
Well... currently CI is failing but not because of Rector... I still can't figure out how to set it up correctly / or debug it.
@ondrejmirtes Hi Ondra, the
PhpStormStubsMap
is still there. Any idea why?I just compared how rector.phar vs. phpstan.phar looks like:
Rector:
PhpStormStubsMap.php - NOT inside prefixed _HumbugBox namespace PhpStormStubsSourceStubber.php - uses PhpStormStubsMap prefixed with _HumbugBox, leading to the error in OP.
PHPStan:
PhpStormStubsMap.php - inside prefixed _HumbugBox namespace PhpStormStubsSourceStubber.php - uses PhpStormStubsMap prefixed with _HumbugBox, so it's consistent and does not lead to an error.
This PhpStormStubsMap is not whitelisted from prefixing thanks to this line (https://github.com/phpstan/phpstan-src/blob/e18b3b47c8e1b91f1844dd3c91d961e912476d86/compiler/build/scoper.inc.php#L16-L18) so I guess that Rector's PHP-Scoper prefixing process is somehow broken.
@TomasVotruba You should be able to debug these issues yourself, if you consider Rector's PHAR file first-class citizen. Of course if the cause is in PHPStan itself, I'm happy to help you. But in this case it doesn't seem PHPStan's fault.
@shaal I made the CI fail finally: https://github.com/rectorphp/rector-prefixed/runs/470008289
@ondrejmirtes Thanks for the check. I have exact the same lines in
scoper.inc.php
:https://github.com/rectorphp/rector/blob/37cd497baff6a6ff0aacb485732bb8db0dfd2fe6/compiler/build/scoper.inc.php#L22-L30
Or is there any difference?
I don't know, try debugging to see why it's happening what's happening...
How do you debug scoper? I don't use xdebug and I have troubles just using it. Error messages are very random to me
So according to CI: https://travis-ci.org/rectorphp/rector/builds/655444246?utm_source=github_status&utm_medium=notification
The
PhpStormStubsMap.php
is not there at all :DI've solved it by adding it as a dependency + renaming stubs as you recommended.
Locally it works... but in Travis CI it fails, on missing
rectorphp/rector/compiler/bin/../../vendor/je tbrains/phpstorm-stubs
directory... no idea why :/https://travis-ci.org/rectorphp/rector/builds/655482789#L322