Error on self::class on non final classes
Summary:
Error when using `class_meth(self::class, ...)` on a nonfinal class.
While this is not unsafe behavior, it does have unintuitive behavior associated with it. Typically, uses of self::, parent::, and static:: are context forwarding https://www.php.net/manual/en/language.oop5.late-static-bindings.php. However, because self::class resolves (currently) to a string, when we grab it, it loses all of its calling context when we perform the call.
More concretely:
self::foo() and class_meth(self::class, 'foo')() have different behavior when it comes to class context forwarding. This has the biggest implications when discussing function pointers. It would be strange that (self::foo<>)() and self::foo<>() would have different behaviors.
Reviewed By: Wilfred
Differential Revision:
D20638089
fbshipit-source-id:
3d157bf5c2c18e6dffbd350d974c2487a6e7ba4e