Is there a variable/magic Property that contains "this class" inside a class, for purposes of new
?
I want:
trait foo {
public function __construct( $x ) {
// ... do stuff ...
}
static function init( $x ) {
return new __THISCLASS__( $x ); // <--- whuzzat?
}
)
class A {
use foo;
}
class B {
use foo;
}
The reason I'm doing this is that the function is actually contained in a Trait that is used by multiple classes, so I need the common code to be able to figure out what class it's running in and create the corresponding object.
A::init()
should return an A
object, and B::init()
a B
object.
Running PHP 7.3