public static function __callStatic($method, $params)
{
$instance = SomeModel::class;
$c = new $instance;
return $c->$method(...array_values($params));
But I notice the new keyword does not work with the special ::class constant.
$instance = new SomeModel::class;
Does not work.
So question is, is this a completely wrong use case for the special ::class constant?
Should I just use:
$instance = new SomeModel();
In the above use case, or is the way I used correct in the working example? Thanks.
Yeah ::class will return the full path of the class as a string. So it's not giving back the reference of the class
The special ::class constant is available as of PHP 5.5.0, and allows for fully qualified class name resolution at compile time, this is useful for namespaced classes:
You can create a class using the following actions
$instance = new SomeModel();
$instance = new SomeModel;
$class = SomeModel::class;
$instance = new $class();