__callStatic()
PHPに関する簡単な質問。
class Test{
public static function __callStatic($method, $arguments){
echo $method . PHP_EOL;
}
public function __call($method, $arguments){
echo $method . PHP_EOL;
}
}
$test = new Test();
$test->foo();
$test->{'hello-world'}();
Test::bar();
Test::{'goodbye-universe'}();
期待される出力:
foo
hello-world
bar
goodbye-universe
実際の出力:
foo
hello-world
bar
PHP Parse error: syntax error, unexpected '{', expecting T_STRING or T_VARIABLE or '$' in - on line 18
この構文は許可されておらず、機能も使用できません__callStatic()
か?
注:一時変数なしで逃げようとしています。以下が機能します。
$goodbyeUniverse = 'goodbye-universe';
Test::$goodbyeUniverse();
しかし、私はそれを避けようとしています。