【问题标题】:Visual Studio Code php inteliphense problemVisual Studio Code php inteliphense 问题
【发布时间】:2021-10-01 06:01:09
【问题描述】:

我有一个有 2 个功能的类:

  • 1 个函数在同一个类中使用 $this-> 调用另一个函数
  • 问题是 Visual Studio 代码,因为说是 Undefined method 'setCookieCountCart'. inteliphense(1013),但函数定义正确且代码工作

class SmartAppIndexController extends \SmartModExtLib\FrontendShared\AbstractController {


    public function Run() {

        $this->setCookieCountCart($cntProducts);

    }

     private function setCookieCountCart($cnt) : void {
           //-- code...
           return;
     }
}

【问题讨论】:

  • 你试过重启vscode吗?你能提供那个扩展的日志吗?
  • 我愿意...但是同样的事情发生了,你能告诉我如何给你看日志吗?
  • vscode 输出窗口应该有一个选择输入来查看日志。通常应该有来自扩展的日志和来自 intelephense 的日志。
  • 只有这些出现:[Info - 9:20:47 AM] Writing state to c:\Users\BoBiTza\AppData\Roaming\Code\User\workspaceStorage\feb10b1fbebdc161c57e1b9919635f6d\bmewburn.vscode-intelephense-client\667cf2d1. [Info - 9:20:47 AM] Indexing started. [Info - 9:20:47 AM] Wrote state in 0.5s. [Info - 9:20:48 AM] Indexing ended. 17 files indexed in 0s.
  • 也许是这个? [2021-10-07 09:32:23.483] [exthost] [error] TypeError: Cannot read private member from an object whose class did not declare it 但是声明了类: class SmartAppIndexController extends \SmartModExtLib\FrontendShared\AbstractController {

标签: php visual-studio-code


【解决方案1】:

setCookieCountCart 在类SmartAppIndexController 中被声明为私有。私有方法只能在其类内部访问。将其更改为公开或致电您的Run(),因为它已经公开。

如果你在另一个类中扩展SmartAppIndexController,如果方法受到保护,它也可以工作。

【讨论】:

  • 我公开了同样的问题..
猜你喜欢
  • 2022-01-07
  • 1970-01-01
  • 2022-01-24
  • 2020-02-04
  • 1970-01-01
  • 1970-01-01
  • 2019-08-19
  • 2021-11-14
  • 2022-01-17
相关资源
最近更新 更多