Skip to content

nullable phpstan-type modification #13654

@wnuQq

Description

@wnuQq

Bug report

I ran into an issue where, if my variable is of a custom array-shape type and is nullable, PHPStan ignores the fact that a method ensures the variable is not null and raises an issue as if it could still be null when the variable is modified in place.
https://phpstan.org/r/308bb1cc-13b6-4e93-8c18-ef35289155ea

However, when it will be passed to another method it looks like phpstan knows that it cannot be null: https://phpstan.org/r/fde7bad2-54c0-430c-9ce6-1a22da5bd98f

Code snippet that reproduces the problem

https://phpstan.org/r/308bb1cc-13b6-4e93-8c18-ef35289155ea

Expected output

Assuring variable is not null is taken into account.

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