在这一刻,我可以通过添加
@property
声明高于我的类定义,如下所示。但当我运行应用程序时,它会返回
Call to a member function showTest() on boolean
例外这是因为我没有以那种方式声明名称空间或其他东西吗?
// Default class inside 'root/src/Controller/'
/**
* Class AppController
*
* @property testControl $testControl
*
* @package App\Controller
*/
class AppController extends Controller
{
public function initialize() {
parent::initialize();
}
public function beforeFilter(Event $event) : void
{
$this->testControl->showTest();
}
}
// The class inside folder 'root/library/'
class testControl
{
public function showTest() {
die("test");
}
}