In PHP you can call a class\'s static method from an object instance (which is contained in an array) like this:
$myArray[\'instanceOfMyClass\']::staticMetho
This is a really interesting problem, it may even be a bug in PHP itself.
For a work around, use the KISS principle.
class RunCode
{
private $myArray;
public function __construct(){
$this->myArray = array();
$this->myArray['instanceOfMyClass'] = new MyClass;
$instance = $this->myArray['instanceOfMyClass']
$instance::staticMethod();
}
}
Hope this helps!
You will have to break up the one liner using a temporary variable, e.g.
$inst = $this->myArray['instanceOfMyClass'];
$inst::staticMethod()
This is one of many cases where PHP's compiler is not clever enough to understand nested expressions. The PHP devs have been improving this recently but there is still work to do.
You actually can use "->" to call static method:
$this->myArray['instanceOfMyClass']->staticMethod();