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

mixed type is not reported on PHP 7.4 #6861

Closed
szepeviktor opened this issue Mar 18, 2022 · 2 comments
Closed

mixed type is not reported on PHP 7.4 #6861

szepeviktor opened this issue Mar 18, 2022 · 2 comments

Comments

@szepeviktor
Copy link
Contributor

Bug report

mixed type was introduced in PHP 8.0.

I cannot set PHP version in playground.

parameters:
  phpVersion: 70400 # PHP 7.4

Code snippet that reproduces the problem

https://phpstan.org/r/f561d4fe-243a-4df0-9f8d-6b26c99cff8b

Expected output

An error that Args\mixed is missing.

When run on PHP 7.4:

PHP Fatal error:  Uncaught TypeError: Typed property Args\register_meta::$default must be an instance of Args\mixed, int used
@ondrejmirtes
Copy link
Member

This will be solved in PHPStan 2.0 being released at some point in 2024, thanks to upgrade to nikic/php-parser 5.0. From the upgrade guide:

Type hints are interpreted as a class Name or as a built-in Identifier depending on PHP version, for example int is treated as a class name on PHP 5.6 and as a built-in on PHP 7.0.

Work in progress: phpstan/phpstan-src#2839

Result diff of your code snippet:

@@ @@
-No errors
+PHP 8.0 – 8.1
+==========
+
+No errors
+
+PHP 7.1 – 7.4 (2 errors)
+==========
+
+ 9: Property Args\register_meta::$default has unknown class Args\mixed as its type.
+13: Property Args\register_meta::$default (Args\mixed) does not accept int.

Copy link

github-actions bot commented Feb 2, 2024

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 Feb 2, 2024
ondrejmirtes added a commit to phpstan/phpstan-src that referenced this issue Sep 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants