Skip to content

Property is suddenly undefined #10477

@greew

Description

@greew

Bug report

I have class A which I can change, and class B which I don't have control over.

The output is this:

 ------ -----------------------------------------------
  Line   phpstan.php
 ------ -----------------------------------------------
  10     Dumped type: string
  12     Dumped type: mixed
  14     Access to an undefined property object::$foo.
 ------ -----------------------------------------------

I don't understand 2 things:

  1. Why the type of $this->foo is changed to mixed
  2. Why then $this->foo is suddenly undefined?

Code snippet that reproduces the problem

https://phpstan.org/r/40d3135d-7d52-4ebe-bb1c-7f23b4ecb4f4

Expected output

 ------ -----------------------------------------------
  Line   phpstan.php
 ------ -----------------------------------------------
  10     Dumped type: string
  12     Dumped type: string
 ------ -----------------------------------------------

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

Still love the tool!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions