| Subject | Details |
| :------------- | :-------------------------------------------------------------------- |
| Rector version | Rector 0.6.x-dev@262e8d8 |
| PHP version | 7.2.18 |
| Full Command | See below |
| Demo link | https://github.com/infection/infection |
| rector.yaml | See below |
$ php rector.phar process /Users/tfidry/Project/Humbug/infection/src/Config/Exception/InvalidConfigException.php --dry-run --set=dead-classes -vvv
rector.yaml
parameters:
paths:
- 'src'
- 'tests'
exclude_rectors:
- 'Rector\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector'
autoload_paths:
- 'vendor/autoload.php'
exclude_paths:
- 'tests/e2e/**/*'
Rector 0.6.x-dev@262e8d8
Config file: rector.yaml
[parsing] src/Config/Exception/InvalidConfigException.php
PHP Fatal error: Uncaught Error: Class '_HumbugBox60f4f031e4cc\JetBrains\PHPStormStub\PhpStormStubsMap' not found in phar:///path/to/infection/rector.phar/vendor/ondrejmirtes/better-reflection/src/SourceLocator/SourceStubber/PhpStormStubsSourceStubber.php:67
Stack trace:
#0 phar:///path/to/infection/rector.phar/vendor/ondrejmirtes/better-reflection/src/SourceLocator/Type/PhpInternalSourceLocator.php(38): _HumbugBox60f4f031e4cc\Roave\BetterReflection\SourceLocator\SourceStubber\PhpStormStubsSourceStubber->generateClassStub('self')
#1 phar:///path/to/infection/rector.phar/vendor/ondrejmirtes/better-reflection/src/SourceLocator/Type/PhpInternalSourceLocator.php(31): _HumbugBox60f4f031e4cc\Roave\BetterReflection\SourceLocator\Type\PhpInternalSourceLocator->getClassSource(Object(_HumbugBox60f4f031e4cc\Roave\BetterReflection\Identifier\Identifier))
#2 phar:///path/to/infection/rector.phar/vendor/ondrejmirtes/better-reflection/src/SourceLocator/Type/Abst in phar:///path/to/infection/rector.phar/vendor/ondrejmirtes/better-reflection/src/SourceLocator/SourceStubber/PhpStormStubsSourceStubber.php on line 67
Fatal error: Uncaught Error: Class '_HumbugBox60f4f031e4cc\JetBrains\PHPStormStub\PhpStormStubsMap' not found in phar:///path/to/infection/rector.phar/vendor/ondrejmirtes/better-reflection/src/SourceLocator/SourceStubber/PhpStormStubsSourceStubber.php:67
Stack trace:
#0 phar:///path/to/infection/rector.phar/vendor/ondrejmirtes/better-reflection/src/SourceLocator/Type/PhpInternalSourceLocator.php(38): _HumbugBox60f4f031e4cc\Roave\BetterReflection\SourceLocator\SourceStubber\PhpStormStubsSourceStubber->generateClassStub('self')
#1 phar:///path/to/infection/rector.phar/vendor/ondrejmirtes/better-reflection/src/SourceLocator/Type/PhpInternalSourceLocator.php(31): _HumbugBox60f4f031e4cc\Roave\BetterReflection\SourceLocator\Type\PhpInternalSourceLocator->getClassSource(Object(_HumbugBox60f4f031e4cc\Roave\BetterReflection\Identifier\Identifier))
#2 phar:///path/to/infection/rector.phar/vendor/ondrejmirtes/better-reflection/src/SourceLocator/Type/Abst in phar:///path/to/infection/rector.phar/vendor/ondrejmirtes/better-reflection/src/SourceLocator/SourceStubber/PhpStormStubsSourceStubber.php on line 67
I got a report from PHPStan that its PHAR had an issue with the jetbrains stubs: they were being removed by dg/composer-cleaner. So it might be related, I have no idea; the above command works fine with the non-prefixed version
Looks like this issue is from dev-master of PHPStan. Not sure why Rector uses that. I fixed it yesterday evening.
I probably realize why - building Rector PHAR consists of cloning and using phpstan-src. But it should check out a stable tag, not use master...
I understand now - the root issue is that I released ondrejmirtes/better-reflection 3.5.6 that breaks this by using newer jetbrains/phpstorm-stubs. These two commits fix that:
I'll probably start requiring ondrejmirtes/better-reflection without ^.
Again, this is why I think no one should use phpstan-src directly :)
And there's another one: https://github.com/phpstan/phpstan-src/commit/23d5ca04ab6213f53a0e6c2e77857b23a73aa41d
huh Hoa is such a pain... (for PHP-Scoper)
Yes, it is, but I realized, it doesn't have to be prefixed in the PHAR since PHPStan already knows how to do static reflection partially...
Any idea how to fix this?
You need to update your scoper.php.inc when prefixing PHPStan the same way I did.
Allright, I'll give a try to the unboxing :)
A way around until it's fixed is to downgrade. composer require --dev rector/rector-prefixed:0.6.13
@ondrejmirtes Just trying the update to PHPStan 0.12.8 and running only phpstan.phar doesn't work here. See failing Github action: https://github.com/rectorphp/rector/pull/2800/checks?check_run_id=425544838#step:5:6
It's not related to rector, nor rector scoping.
Even when I run:
vendor/bin/phpstan analyse src/Php
I get:
Note: Using configuration file /var/www/rector/phpstan.neon.
PHP Fatal error: Uncaught Error: Class '_HumbugBox4c23c5592d6a\JetBrains\PHPStormStub\PhpStormStubsMap' not found in phar:///var/www/rector/vendor/phpstan/phpstan/phpstan/vendor/ondrejmirtes/better-reflection/src/SourceLocator/SourceStubber/PhpStormStubsSourceStubber.php:67
Stack trace:
#0 phar:///var/www/rector/vendor/phpstan/phpstan/phpstan/vendor/ondrejmirtes/better-reflection/src/SourceLocator/Type/PhpInternalSourceLocator.php(38): _HumbugBox4c23c5592d6a\Roave\BetterReflection\SourceLocator\SourceStubber\PhpStormStubsSourceStubber->generateClassStub('T')
Any idea why?
That's currently fixed in PHPStan's dev-master. I should release a bugfix version.
Uff :) good to hear that
PHPStan 0.12.9 just released.
I bumped PHPStan version to 0.12.9 in https://github.com/rectorphp/rector/pull/2800,
but the error is still there:
Error: Class '_HumbugBoxebb6c51d1e3e\JetBrains\PHPStormStub\PhpStormStubsMap' not found
Paths:
phar:///var/www/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/SourceLocator/SourceStubber/PhpStormStubsSourceStubber.php:67
phar:///var/www/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/SourceLocator/Type/PhpInternalSourceLocator.php:38
phar:///var/www/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/SourceLocator/Type/PhpInternalSourceLocator.php:31
phar:///var/www/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/SourceLocator/Type/AbstractSourceLocator.php:38
phar:///var/www/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/SourceLocator/Type/MemoizingSourceLocator.php:31
phar:///var/www/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/Reflector/ClassReflector.php:37
phar:///var/www/rector/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/Reflector/MemoizingClassReflector.php:28
phar:///var/www/rector/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/BetterReflectionProvider.php:92
phar:///var/www/rector/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/ReflectionProvider/ChainReflectionProvider.php:25
phar:///var/www/rector/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/ReflectionProvider/MemoizingReflectionProvider.php:30
phar:///var/www/rector/vendor/phpstan/phpstan/phpstan.phar/src/Broker/Broker.php:53
Can you point me to which build step failed like this in #2800? I see that PHPStan itself works: https://github.com/rectorphp/rector/pull/2800/checks?check_run_id=427074168
It happens in unit tests.
https://github.com/rectorphp/rector/pull/2800/checks?check_run_id=427074203#step:6:60
Yes, you're right, I understand why. Try to manually include the file like this (https://github.com/phpstan/phpstan-src/blob/63707915d487f032574bf76d5cb25d42b73909b0/bin/phpstan#L58) in your tests bootstrap before I fix this in PHPStan itself. Thanks.
Thanks! I tried adding this:
require_once 'phar://vendor/phpstan/phpstan/phpstan.phar/vendor/jetbrains/phpstorm-stubs/PhpStormStubsMap.php';
It works sometimes, but run after Docker build fails
https://github.com/rectorphp/rector/runs/431264847
And external run too:
https://github.com/rectorphp/rector/commit/9e0ca0f2340d7eb250cca78d7117e4f23a6dcfb3#diff-c2ba69ed4d667444d40e5d2573d8bcb5
Seems like it can be only solved in PHPStan correctly. This is blocker for Rector releases last 2 weeks. Any ETA for fixed release?
The normal run should have been fixed in 0.12.9. If it isn鈥檛, show me a build log where it fails. But I don鈥檛 know about any issue now.
The unit test problem is a new one for me, I鈥檒l look at it next week. You can use 0.12.7 until then.
This one: https://github.com/rectorphp/rector/runs/430045396?check_suite_focus=true
It would be better to autolaod the file in PHPStan's composer.json. Now I have to duplicate bin/phpstan, that is sometimes loaded and sometimes not. That's why there is eaither class missing or loaded twice error.
Not sure why it's prefixed when scoper should skip it.
You'll have to apply the same fix as I do in PHPStan itself. Here's the explanation what happens: https://github.com/phpstan/phpstan/issues/2948#issuecomment-582285141
Here are the fixes for the normal run: https://github.com/phpstan/phpstan-src/blob/d1452fb3a6eead984070df6fa5fdec3a26b5ba4b/bin/phpstan#L58-L60 I think you have to do them in your bin/rector file too.
I have to come up with a fix to fix unit tests run, it will probably mean moving these lines to bootstrap.php but I'm not sure and will have to test it.
I think the problem is that file itself is not scoped, but the class usage it.
It's just not accidently used in PHPStan tests, so it passes.
But _HumbugBoxebb6c51d1e3e\JetBrains\PHPStormStub\PhpStormStubsMap actually exists in code, e.g.
public function (\_HumbugBoxebb6c51d1e3e\JetBrains\PHPStormStub\PhpStormStubsMap $phpStormStubsMap)
It needs to be de-scoped in scoper.php.inc in a way similar to this:
https://github.com/phpstan/phpstan-src/blob/d1452fb3a6eead984070df6fa5fdec3a26b5ba4b/compiler/build/scoper.inc.php#L107-L110
That is not what is happening, see my comment above.
I didn't see it before, just read it.
You'll have to apply the same fix as I do in PHPStan itself.
What exactly you mean? I've added include to bin/rector, but it didn't help
I've added exactly this line:
https://github.com/phpstan/phpstan-src/blob/d1452fb3a6eead984070df6fa5fdec3a26b5ba4b/bin/phpstan#L58
and it didn't work
See bin/rector https://github.com/rectorphp/rector/blob/cc75b8b0afd799e7429a836d2e31e0d1a2279cb8/bin/rector#L30
What should I do to make it work?
I'll look into fixing this properly after the weekend.
Thank you
Verifying the fixes in: https://github.com/rectorphp/rector/pull/2816
Do you know about any other issues I could test in that PR?
Basically this must be moved from inactive_workflows to workflows:
https://github.com/rectorphp/rector/commit/9e0ca0f2340d7eb250cca78d7117e4f23a6dcfb3#diff-c2ba69ed4d667444d40e5d2573d8bcb5
And this as well:
https://github.com/rectorphp/rector/commit/6ee4e7c65fe982a123bc6f797ffa03011a4c59e4
I just enabled those workflows, so you can just rebase on master
@ondrejmirtes I rebased and merged it and it looks good. Both failing workflows now pass.
Thank you :+1:
Cool, but beware, 0.12.10 isn鈥檛 released yet.
Sure.
No rush, but any ETA on this so I can plan Rector release accordingly?
Some time during the next week, Wednesday or Thursday :)
Purfect :) :+1:
Prefixed Rector is now build correctly as well :+1:
Just released :) https://github.com/phpstan/phpstan/releases/tag/0.12.10
Most helpful comment
That's currently fixed in PHPStan's dev-master. I should release a bugfix version.