Hi Internals after quite a long time,
There is an issue in the tracker (#61033 and somewhat related #64239)
about magic constants behaviour in aliased trait methods. Stefan
classified #61033 as a "feature not a bug" however he suggested to start
a discussion about it.
So here's the case: how to get current running method name when in an
aliased trait method:
trait T {
public function method() {
// FUNCTION is "method"
}
}
class C {
use T { method as m; }
public function method() {}
}
This is all nice and dandy but imagine (among other things) that you
want to return a callback to itself from such a method. How would you go
about it?
Returning [$this, FUNCTION] would be most obvious but it's obviously
not what we want. Apart from using debug_backtrace (which has it's own
issues; #64239 being one) I don't see any way of doing it.
So: is this a feature or a bug?
And if it really is a feature then either we need another magic const
(like suggested in #64239) or (preferably IMO) a method to resolve
method name at runtime (a counterpart to get_called_class()
- say
get_called_method()).
Cheers
Marcin