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

Unexpected item 'parameters › checkAlwaysTrueLooseComparison' #7141

Closed
internalsystemerror opened this issue Apr 28, 2022 · 9 comments
Closed
Labels

Comments

@internalsystemerror
Copy link

internalsystemerror commented Apr 28, 2022

Bug Report

Subject Details
Rector version 0.12.22

Minimal PHP Code Causing Issue

I'm not able to reproduce this using the demo, however this is extremely similar to #7133 and appears to be caused by phpstan/phpstan-strict-rules. The specific error:

PHP Fatal error:  Uncaught _PHPStan_c0c409264\Nette\Schema\ValidationException: Unexpected item 'parameters › checkAlwaysTrueLooseComparison', did you mean 'checkAlwaysTrueStrictComparison'? in phar:///home/ise/projects/creativecow/stratum-monorepo-php/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/schema/src/Schema/Processor.php:75

I will update this as I investigate to try and get further information. The only place I can find checkAlwaysTrueLooseComparison is in the file rules.neon in the strict-rules package.

This was introduced in phpstan/phpstan-strict-rules@f3ca646 and released in v1.2.1. Rolling back to v1.2.0 fixes the issue.

Expected Behaviour

No error

@samsonasik
Copy link
Member

it seems phpstan.phar from vendor is read early before autoload, it possibly solvable by flip autoload in bin/rector.php:

rector/bin/rector.php

Lines 31 to 32 in 0e76f19

$autoloadIncluder->loadIfExistsAndNotLoadedYet(__DIR__ . '/../vendor/scoper-autoload.php');
$autoloadIncluder->autoloadProjectAutoloaderFile();

into:

$autoloadIncluder->autoloadProjectAutoloaderFile();
$autoloadIncluder->loadIfExistsAndNotLoadedYet(__DIR__ . '/../vendor/scoper-autoload.php');

@internalsystemerror could you verify if that solve it?

@internalsystemerror
Copy link
Author

internalsystemerror commented Apr 28, 2022

@internalsystemerror could you verify if that solve it?

@samsonasik Sadly not, same error.

@samsonasik
Copy link
Member

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.

@internalsystemerror
Copy link
Author

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.

@samsonasik
Copy link
Member

samsonasik commented Apr 28, 2022

@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

@internalsystemerror
Copy link
Author

internalsystemerror commented Apr 28, 2022

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.

@samsonasik
Copy link
Member

The vendor prefixed seems include phpstan bootstrap from existing vendor itself:

'9b38cf48e83f5d8f60375221cd213eee' => $vendorDir . '/phpstan/phpstan/bootstrap.php',

@jordisala1991
Copy link

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?

@samsonasik
Copy link
Member

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.

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