Closed internalsystemerror closed 2 years ago
it seems phpstan.phar from vendor is read early before autoload, it possibly solvable by flip autoload in bin/rector.php
:
into:
$autoloadIncluder->autoloadProjectAutoloaderFile();
$autoloadIncluder->loadIfExistsAndNotLoadedYet(__DIR__ . '/../vendor/scoper-autoload.php');
@internalsystemerror could you verify if that solve it?
@internalsystemerror could you verify if that solve it?
@samsonasik Sadly not, same error.
Could you create sample repository for it? it may happen again when new parameter config added to next patch phpstan version so it should be solved by modify the use of autoload, or mark phpstan in scoped vendor as replaced via composer replace:
"replace": {
"phpstan/phpstan": "*"
}
before build scoped.
I'm currently experiencing a tight approaching deadline, and we run rector against our entire monorepo so it would take me some time to figure out an exact reproduction. Forcing "phpstan/phpstan-strict-rules": "1.2.0"
works for now until I can look at this again.
I did try a combination of ordering of those lines in bin/rector.php
but nothing seemed to resolve the issue.
@internalsystemerror please try latest dev-main for now as its phpstan vendor is now re-generated to latest phpstan:
composer config minimum-stability dev
composer config prefer-stable true
composer require --dev rector/rector:dev-main
Yep, that appears to have fixed it, thank you! As to how to solve it more permanently however, I would be interested in looking into this further, but work permitting.
The vendor prefixed seems include phpstan bootstrap from existing vendor itself: https://github.com/rectorphp/rector/blob/af9fe53cfa3c6f98c33ad47cbb0994f05ed2ef59/vendor/composer/autoload_files.php#L17
Saw same error on Sonata. I am also interested on a more permanent solution (I know it will be fixed on 0.12.23). My plan is to keep integrating rector on all Sonata repositories
If I understand correctly, this comes from the fact that rector ships its own vendor folder with phpstan installed on it, but that phpstan still looks for the phpstan configuration of the outside vendors, right?
Rector 0.12.23 released. I am closing it, if the new phpstan patch add new parameter again in the future, it may need a new release or use dev-main in the meantime if the phpstan prefixed vendor is still loaded first.
Bug Report
Minimal PHP Code Causing Issue
I'm not able to reproduce this using the demo, however this is extremely similar to https://github.com/rectorphp/rector/issues/7133 and appears to be caused by
phpstan/phpstan-strict-rules
. The specific error:I will update this as I investigate to try and get further information. The only place I can find
checkAlwaysTrueLooseComparison
is in the filerules.neon
in the strict-rules package.This was introduced in https://github.com/phpstan/phpstan-strict-rules/commit/f3ca6464eae640a556c69a02b3b77a2507475d2f and released in v1.2.1. Rolling back to v1.2.0 fixes the issue.
Expected Behaviour
No error