Reputation: 68416
$this->property = 'SomeClass';
$x = new $this->property(); // works
$x = $this->property::create(); // fails (parse error)
Is this a bug in PHP?
Can a static method be called using the property, without assigning the value to a new variable, and using that variable instead?
Upvotes: 0
Views: 75
Reputation: 4021
It's been entered as a bug for a few months and is still in Open status, so I'm gonna go with yes.
https://bugs.php.net/bug.php?id=61397
Similarly,
https://bugs.php.net/bug.php?id=54095
Upvotes: 1
Reputation: 160833
Use call_user_func
$x = call_user_func(array($this->property, 'create'));
Upvotes: 2