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

Fix and update PHPStan to 1.3.x #945

Merged
merged 2 commits into from
Jan 4, 2022

Conversation

ondrejmirtes
Copy link
Contributor

This PR solves the failures from #939.

The problem here is quite tricky - PHPStan complains about some PHP classes that don't exist when running on PHP 8.1, because on PHP 8.0.x these really don't exist. PHPStan uses config.platform.php to determine the PHP version to test against.

At the same time it's funny that PHPStan doesn't complain about the same problems when running on PHP 8.0. That's because PHPStan itself loads these classes as stubs so that BetterReflection Adapter layer can work. And since PHPStan sees these classes as defined by the user, it considers them as existing.

I can't make PHPStan fail with the same errors when running on PHP 8.0, because I can't sensibly differentiate between these PHPStan-related stubs, and actual user-defined polyfills...

Here I fixed it with the same approach I use in phpstan-src - it tells PHPStan to ignore the setting from config.platform.php.


return [
'parameters' => [
'phpVersion' => PHP_VERSION_ID,
Copy link
Member

@Ocramius Ocramius Jan 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also drop config.platform.php from composer.json: the reason it was added was to prevent invalid @dependabot upgrades, but we can get rid of it, if it has such an influence on other tools too...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, "php": "~8.0.12 || ~8.1.0" might be sufficient to keep valid dependencies.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, the changed dropped composer/package-versions-deprecated and installed ocramius/package-versions, not sure why is that :) 8812e7b

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Massive improvement, I'd say 🤣

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funny.

I've already removed composer/package-versions-deprecated in bae419a

But it returned back in: 24320f8

@Ocramius Ocramius added this to the 5.1.0 milestone Jan 4, 2022
@Ocramius Ocramius added dependencies Pull requests that update a dependency file enhancement labels Jan 4, 2022
@Ocramius Ocramius self-assigned this Jan 4, 2022
Copy link
Member

@Ocramius Ocramius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ondrejmirtes!

@Ocramius Ocramius changed the title Fix and update PHPStan Fix and update PHPStan to 1.3.x Jan 4, 2022
@Ocramius Ocramius merged commit 50970c3 into Roave:5.1.x Jan 4, 2022
@ondrejmirtes ondrejmirtes deleted the phpstan-php-version branch January 4, 2022 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants