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

Changes in type aliases don't properly invalidate the cache of files importing them #9622

Closed
stof opened this issue Jul 12, 2023 · 4 comments

Comments

@stof
Copy link
Contributor

stof commented Jul 12, 2023

Bug report

  1. Create a file with a class defining a phpstan type alias with an array shape like array{user?: string}
  2. Create a second file with a class importing that type and using it for its method argument.
  3. In both classes, create a method taking that type alias as argument. Inside the method, write code accessing the user key without account for it being potentially undefined.
  4. Generate the baseline file containing those 2 errors (one per file)
  5. Edit the type alias to be the shape array{user: string}
  6. Run phpstan again
  7. See that the errors from the file defining the type alias is properly reported as an unmatched ignored error but the error from the second file is not
  8. Run phpstan clear-result-cache
  9. Run phpstan again
  10. See that both ignored errors are reported as unmatched

Code snippet that reproduces the problem

No response

Expected output

I would expect a change in a type alias in a class to properly invalidate the result cache of files in which that type was imported and referenced, so that I don't need to clear the result cache to get a reliable output when using imported types.

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

No response

@mergeable
Copy link

mergeable bot commented Jul 12, 2023

This bug report is missing a link to reproduction at phpstan.org/try.

It will most likely be closed after manual review.

@stof
Copy link
Contributor Author

stof commented Jul 12, 2023

I cannot build a reproduction in the playground as the reproducer involves using multiple files and the cache.

@ondrejmirtes
Copy link
Member

Reproduced: phpstan/phpstan-src@0fa6903
Fixed: phpstan/phpstan-src@553c4b1

@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 Aug 14, 2023
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