-
-
Notifications
You must be signed in to change notification settings - Fork 324
Class imports in traits are not considered when parsing annotations #335
Copy link
Copy link
Closed
Description
When using annotation based dependency injection on a property of a Trait (accessibility does not matter: private, protected, public), it seems no aliases can be used:
With the FQCN, it works
namespace Project\Traits;
trait MyTrait
{
/**
* @Inject
* @var \Fully\Quallified\Class\Name
*/
private $propertyName;
}When using an alias, an error message is generated:
namespace Project\Traits;
use Fully\Quallified\Class\Name as AliasName
trait MyTrait
{
/**
* @Inject
* @var AliasName
*/
private $propertyName;
}Error-message: The @var annotation on Class::propertyName contains a non existent class "AliasName". Did you maybe forget to add a "use" statement for this annotation?", which seem to origin here
I "guess" the parsing of use statements of the declaring class does not consider stuff that are defined in a trait?
I think not only the declaring class of the property should be considered, but also the traits that are used by that class with ReflectionClass.getTraits()
Reactions are currently unavailable