Skip to content

Why is there a check to resolve types in the targets namespace prior to the Use clauses? #87

@drdamour

Description

@drdamour

given this:

namespace yyy;

use Some\Namespace\SomeDependency;

class X{

    /**
     * @Inject
     * @var SomeDependency
     */
    protected $serviceFactory = null;

}

I've found that the classDefintion is attempting to resolve a class "yyy\SomeDependency" prior to attempting to resolve "Some\Namespace\SomeDependency" .

The code (PhpDocParser::getPropertyType) seems to attempt to resolve the type from the namespace of the injection target prior to the fully qualified name coming form a use statement.

Is this the correct behaviour? I would think that the use statement forces the SomeDependency alias to resolve to Some\Namespace\SomeDependency for the entire class defintion (or better code scoped under that use statement) such that it could never point to a "yyy\SomeDependency" type. Although i may be wrong with PHP's naming resolution here...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions