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

class-string|string type is not simplified to string #5607

Closed
mvorisek opened this issue Sep 8, 2021 · 3 comments
Closed

class-string|string type is not simplified to string #5607

mvorisek opened this issue Sep 8, 2021 · 3 comments
Labels
Milestone

Comments

@mvorisek
Copy link
Contributor

mvorisek commented Sep 8, 2021

Bug report

Starting with the latest phpstan release the following fix is needed: https://github.com/atk4/ui/pull/1657/files

But I belive it is wrong as class-string|string type should be simplified to string as before.

Also, as shown in the code snippet below, it is still/correctly simplified when declared as phpdoc.

Code snippet that reproduces the problem

https://phpstan.org/r/7757dd83-d27f-4978-88fc-ff5dea43fcc8

https://github.com/atk4/ui/actions

Expected output

 Line | Error
 -- | --
- 8 | Property Cl::$u (A\|null) does not accept default value of type array<int\|string, class-string\|string>.
+ 8 | Property Cl::$u (A\|null) does not accept default value of type array<int\|string, string>.
 20 | Parameter #1 $x of method Cl::mm() expects array<int\|string, string>, null given.
@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone Sep 9, 2021
@phpstan-bot
Copy link
Contributor

@mvorisek After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
- 8: Property Cl::$u (A|null) does not accept default value of type array<int|string, class-string|string>.
+ 8: Property Cl::$u (A|null) does not accept default value of type array<int|string, string>.
 20: Parameter #1 $x of method Cl::mm() expects array<int|string, string>, null given.
Full report
Line Error
8 `Property Cl::$u (A
20 `Parameter #1 $x of method Cl::mm() expects array<int

@mvorisek
Copy link
Contributor Author

fixed, thanks

@github-actions
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 Feb 12, 2022
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