2011-06-14 10:05:37 +08:00
|
|
|
--TEST--
|
|
|
|
Indirect method call by array - Calling __call() and __callStatic()
|
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
|
|
|
|
class foo {
|
|
|
|
public function __call($a, $b) {
|
|
|
|
printf("From %s:\n", __METHOD__);
|
|
|
|
var_dump($a);
|
|
|
|
var_dump($this);
|
|
|
|
}
|
|
|
|
static public function __callStatic($a, $b) {
|
|
|
|
printf("From %s:\n", __METHOD__);
|
|
|
|
var_dump($a);
|
|
|
|
var_dump($this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$arr = array('foo', 'abc');
|
2016-06-16 07:30:23 +08:00
|
|
|
try {
|
|
|
|
$arr();
|
|
|
|
} catch (Throwable $e) {
|
|
|
|
echo "Exception: " . $e->getMessage() . "\n";
|
|
|
|
}
|
2011-06-14 10:05:37 +08:00
|
|
|
$foo = new foo;
|
|
|
|
$arr = array($foo, 'abc');
|
|
|
|
$arr();
|
|
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
--EXPECTF--
|
|
|
|
From foo::__callStatic:
|
|
|
|
string(3) "abc"
|
2016-06-16 07:30:23 +08:00
|
|
|
Exception: Using $this when not in object context
|
2011-06-14 10:05:37 +08:00
|
|
|
From foo::__call:
|
|
|
|
string(3) "abc"
|
|
|
|
object(foo)#%d (0) {
|
|
|
|
}
|
|
|
|
|