I'm having a very strange syntax error inside of a class when trying to access a static method of a class variable.
class VendorImport {
//$factory is an instance of another class with a static method get()
protected $factory;
public function getInstance() {
//method 1 works
$factory = $this->factory;
return $factory::get();
//method 2 throws a syntax error
return $this->factory::get();
}
}
What is the proper syntax for method 2?
$this->{factory::get()}. What is the EXACT error message you're getting?"syntax error, unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM)", which is very clear but doesn't explain the reason.