I use traits to implement some Taggable behavior in a Symfony application, using Doctrine2 to save and annotate to configure it.
The main annoyance that I have is that in this symptom my IDE has no idea about the type of $ this-> tags and generates a bunch of warnings. I have pretty OCD about having my code registered here, so it is very easy for other developers to pick up.
trait TaggableMethods { protected $tags;
My problem, as far as I can tell, is that I cannot define the $ tags property in the property, because I need to override the annotations.
I can avoid defining $ tags altogether in TagGableMethods methods, but for me it breaks the encapsulation or at least makes the code a little harder to read.
I can set up persistence using either Jam or XML, but all of my other objects use annotations.
So, I am looking for a way to avoid the start notification that is generated that Symfony turns into a ContextErrorException, killing my script at design time.
This is probably due to the fact that we can use traits to map the relationship of manyToOne to doctrine2? and Traits - property conflict with parent class "
Also, the behavior for the inherited methods mentioned in โ PHP 5.4: why do classes override trait methods with a different signature? โ Sounds very close to what I want for a property - can anyone explain why there is a difference between properties and methods ?
source share