I'm wondering if this is possible in PHP:
trait SomeTrait
{
public function someMethod() { /* ... */ }
}
class Parent
{
use SomeTrait;
}
class Child extends Parent
{
/* Do something to rename someMethod() to someOtherMethod() */
use someMethod as someOtherMethod; // Example
public function someMethod()
{
// Do something different than SomeTrait::someMethod()
}
}
In my actual use-case, the Parent class is a parent to several children (and none of them actually use the someMethod() that comes from the trait applied to the parent class. The Parent class is also part of an external library, so I cannot directly modify the source code.
The Child class in my actual use-case also relies on protected properties from the Parent class, so I'm fairly certain that I need to keep the inheritance.
Is this actually possible, or do I just need to deal with it, and use a different method name on the Child class in question?