Reputation: 684
Gives an Error:
$this->model::byUserPermission()
Leads to: syntax error, unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM)
Works:
$facade = $this->model;
$facade::byUserPermission()
Is this a PHP Bug? Or can someone explain this to my, why that is happening (I am using php 5.6 and i am new to php. From my point of view, both are exactly the same). Thanks
Upvotes: 6
Views: 52
Reputation: 43700
The problem is that this statement $this->model::byUserPermission()
is ambiguous. And can be interpreted in multiple ways.
1) You could be trying to use the model
property of the class that you are in to call a class's static method. As you are attempting in your question.
2) You could also mean you want to access the property of the class returned by the static function byUserPermission()
in the model
class.
Upvotes: 2