-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Closed
Labels
Description
Description
Sometimes we created a Trait that is used in a lot of class, or only use a trait of a dependency package. I believe that this is so common today at PHP modern projects.
But I see a big opportunity of improvement on this. Today, when we want to implement some code lines before or after a parent class method is very easy, we just to do:
protected function parentMethod(mixed $fooAttribute): mixed
{
// do something here
$result = parent::parentMethod($fooAttribute);
// or do something here
return $result;
}
I believe that a similar behavior will be very nice on traits, but I don't found a correspondent code to do this with it.
Maybe the right suggestion to do this is:
protected function traitMethod(mixed $fooAttribute): mixed
{
// do something here
$result = trait::traitMethod($fooAttribute);
// or do something here
return $result;
}
Make sense or it's a bad idea?