Page 1 of 1

Add trait support

PostPosted: February 8th, 2017, 8:41 am
by davidbcn
Mostly I found that support for traits is a little bit crippled.

[1] Autocomplete when adding trait to class does not populate with traits in the same namespace. You need to use full namespace ("\Drupal\fdf\MyCustomTrait" instead of "MyCustomTrait" directly).

[2] Autocomplete when adding traits will let you use anything, including interfaces and classes. It should only populate with traits and show error when "using" inside a class is pointing to something that is not a trait.

[3] Methods "inherited" by a class through a trait are not seen by Intellisense. I had to resort to creating stub interfaces for Intellisense to pick the methods in the traits.

It would be great to see support for traits improved.

Re: Add trait support

PostPosted: February 8th, 2017, 8:56 am
by davidbcn
UPDATE: Looks like some of the issues are due to the fact that PHP Tools needs use statement in trait to have full namespace.

Re: Add trait support

PostPosted: February 8th, 2017, 12:35 pm
by Jakub Misek
Hi David,

Thanks for the feedback. We've fixed [1] and [2]. So these will be in next update.

We'll improve other traits features in a future updates as well.

Best,
Jakub

Re: Add trait support

PostPosted: February 9th, 2017, 12:54 pm
by Miloslav Beno
Hello,

Please check the latest preview. It contains [1] and [2] fixes.

Thanks!