我有一个具有两个函数的类:
在同一个class
Undefined method 'setCookieCountCart'. inteliphense(1013),但是函数是按顺序定义的,并且代码工作是。
class SmartAppIndexController extends \SmartModExtLib\FrontendShared\AbstractController {
public function Run() {
$this->setCookieCountCart($cntProducts);
}
private function setCookieCountCart($cnt) : void {
//-- code...
return;
}
}


发布于 2021-10-07 13:51:33
setCookieCountCart在类SmartAppIndexController中声明为私有。只能在其类中访问私有方法。将其更改为public或调用您的Run(),因为它已经公开。
如果要在另一个类中扩展SmartAppIndexController,则如果该方法受到保护,它也将工作。
https://stackoverflow.com/questions/69401175
复制相似问题