Skip to content

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

@stof

Description

@stof

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions