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

Types specified in array-shapes are not properly enforced #6286

Closed
phinor opened this issue Jan 2, 2022 · 5 comments
Closed

Types specified in array-shapes are not properly enforced #6286

phinor opened this issue Jan 2, 2022 · 5 comments

Comments

@phinor
Copy link

phinor commented Jan 2, 2022

Bug report

PHPstan version: 1.3.0

When using a local type alias, phpstan does not enforce types in arrays.

Code snippet that reproduces the problem

https://phpstan.org/r/00c4b560-d9ba-4d5d-a7ff-15e9596e0565

Expected output

Line 16 should report an error since a string literal is being assigned and not an int as required by the local type alias.

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

Yes - very grateful for this tool!

@phinor
Copy link
Author

phinor commented Jan 2, 2022

After some experimenting, this seems to be an issue with the array shapes rather than the type aliases:

https://phpstan.org/r/8a532c07-8d53-4534-9db7-3d46dff1e6c0

@phinor phinor changed the title Local type alias doesn't enforce types in arrays Types specified in array-shapes are not properly enforced Jan 2, 2022
@ondrejmirtes
Copy link
Member

This is a duplicate of: #5804

I have a local branch where the error is reported but it needs a bit more polish.

@phinor
Copy link
Author

phinor commented Jan 13, 2022

I note that there has been progress on this. However, there are still some cases where the error is not reported properly.

Please see line 25 which does NOT cause an error, but which I believe should:

https://phpstan.org/r/cb93d18d-0970-4518-99c5-36debe37256d

@ondrejmirtes
Copy link
Member

@phinor Please open a new issue about it, 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 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants