1--TEST-- 2Indirect method call by array - Calling __call() and __callStatic() 3--FILE-- 4<?php 5 6class foo { 7 public function __call($a, $b) { 8 printf("From %s:\n", __METHOD__); 9 var_dump($a); 10 var_dump($this); 11 } 12 static public function __callStatic($a, $b) { 13 printf("From %s:\n", __METHOD__); 14 var_dump($a); 15 var_dump($this); 16 } 17} 18 19$arr = array('foo', 'abc'); 20try { 21 $arr(); 22} catch (Throwable $e) { 23 echo "Exception: " . $e->getMessage() . "\n"; 24} 25$foo = new foo; 26$arr = array($foo, 'abc'); 27$arr(); 28 29 30?> 31--EXPECTF-- 32From foo::__callStatic: 33string(3) "abc" 34Exception: Using $this when not in object context 35From foo::__call: 36string(3) "abc" 37object(foo)#%d (0) { 38} 39