Skip to content

static<Class> incorrectly resolved as static (Class is lost) #15378

Closed
phpstan/phpstan-src
#6826

Description

@LastDragon-ru

Bug report

In the following code the $cursor->a will be resolved as NodeCursor<BNode>|null , but it is NodeCursor<ANode>|null.

/**
 * @template TNode of object
 */
class NodeCursor {
    /**
     * @var static<ANode>
     */
    public ?self $a = null;

    /**
     * @var static
     */
    public ?self $b = null; 
}

$node   = new BNode();
$cursor = new NodeCursor($node);

Code snippet that reproduces the problem

https://phpstan.org/r/19702469-8eb3-4a54-9f11-51b5ff49860d

Expected output

$cursor->a should be NodeCursor<ANode>|null

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

😃

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

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