Skip to content

validate @var declaration of static variables #14198

Description

@claudepache

Feature request

function say_HELLO() {
    /** @var string $name */
    static $name = "world";
    echo 'HELLO ', strtoupper($name), "\n";
    $name = [ ]; // <--- should report “Static variable $name (string) does not accept array{}”.
}

say_HELLO();
say_HELLO(); // <-- because a runtime error will occur here, and PHPStan doesn’t detect it

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

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions