Skip to content

@var annotations in the view files #4486

@b1rdex

Description

@b1rdex

Bug report

@var above use statement works correctly only when the referenced class matches the one imported in use. Is it possible to read all use statements to get the right class name? BTW, PhpStorm supports this correctly.

Code snippet that reproduces the problem

<?php
/**
 * @var ClassName2 $two
 * @var ClassName1 $one
 */

use \Some\Namespaced\ClassName1;
use \Some\Namespaced\ClassName2;

\PHPStan\dumpType($one); // yields Some\Namespaced\ClassName1 – perfect
\PHPStan\dumpType($two); // yields ClassName2 (not a FQCN, error)

https://phpstan.org/r/de78892f-e561-4b25-b54b-a8e1e0f93408

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