所以我现在有一个类,并希望通过将类实例作为函数调用来使类调用更清晰,就像调用时输出字符串的__toString
魔术方法,而不是能够调用{ {1}}作为一个函数,并将其调用。
像:
$instance()
基本上我希望能够链接类函数并切断一个通过从实例调用函数来调用的链。
我想要的语法:
class MyClass {
public function __onCall() {
echo 'This was called when the user called the instance!';
}
}
$instance = new MyClass();
$instance();
//opts: This was called when the user called the instance!
语法我有:
$Class('Some String')->SomeFunction()->AnotherFunction();
: - )