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

Predefined constants of wrong php version are used #9246

Closed
erikvanderschaaf opened this issue Apr 26, 2023 · 3 comments
Closed

Predefined constants of wrong php version are used #9246

erikvanderschaaf opened this issue Apr 26, 2023 · 3 comments
Labels
Milestone

Comments

@erikvanderschaaf
Copy link

erikvanderschaaf commented Apr 26, 2023

Bug report

It seems that the wrong constants are used for analyzing the code. I run php version 8.2.4 on my local environment, but our production environment is on php 7.3.33. So I've put phpVersion: 70333 in our phpstan.neon file, and it's also in the platform section of our composer.json.

Since the password constants have been changed from int to string in php 7.4 it yields an error on the password_hash function.

Parameter #2 $algo of function password_hash expects int, string given.

https://www.php.net/password_hash
https://www.php.net/manual/en/password.constants.php

Code snippet that reproduces the problem

https://phpstan.org/r/3a20f288-2c07-4fab-ab05-0b2e3512eb7e

Expected output

Since we use the PASSWORD_BCRYPT constant in our code, we would expect no errors for this line of code.

Did PHPStan help you today? Did it make you happy in any way?

We've implemented phpstan on our projects as of today, we're sure it will make our code better in the future

@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone Jun 27, 2023
@phpstan-bot
Copy link
Contributor

@erikvanderschaaf After the latest push in 1.11.x, PHPStan now reports different result with your code snippet:

@@ @@
-PHP 7.4 – 8.2
-==========
-
-No errors
-
-PHP 7.2 – 7.3 (1 error)
-==========
-
-3: Parameter #2 $algo of function password_hash expects int, string given.
+No errors

@ondrejmirtes
Copy link
Member

Fixed phpstan/phpstan-src@fc4e589

Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants