简体   繁体   English

PhpStorm 在同一目录中找不到类

[英]PhpStorm does not find classes in the same directory

I'm running PhpStorm Version 2021.3.2 on Arch Linux.我在 Arch Linux 上运行 PhpStorm 版本 2021.3.2。 Right now, I'm working on a project with all files located in one folder.现在,我正在处理一个所有文件都位于一个文件夹中的项目。

conways-game-of-life-php/
├── index.html
├── index.php
├── main.css
├── main.js
└── Universe.class.php

I have included the Universe.class.php which looks like this我已经包含了看起来像这样的Universe.class.php

class Universe{

    protected int $height;
    protected int $width;
    public array $universe;

    public function __construct($height,$width)
    {
        $this->height = $height;
        $this->width = $width;
        $this->universe = [];

    }
}

the standard way:标准方式:

include "Universe.class.php";
$universe = new Universe(5,20);

Even though the including of the class seems right, PhpStorm doesn't recognizes $universe = new Universe();尽管该类的包含似乎是正确的,但 PhpStorm 无法识别$universe = new Universe(); as a valid class.作为一个有效的类。 I also tinkered arround with namespaces but I think this is overkill for this kind of project.我还对命名空间进行了修改,但我认为这对于这类项目来说太过分了。

How can I get PhpStorm to give me autocompletion for methods located in my class?如何让 PhpStorm 为我的班级中的方法自动补全?

In my case repairing the IDE helped.就我而言,修复 IDE 有所帮助。 Go to File > Repair IDE .转到File > Repair IDE In the bottom right of your window after each other, five dialog boxes will appear.在你的窗口右下角一个接一个地出现五个对话框。 After executing all step and restarting the IDE, everything works again like a charm!执行完所有步骤并重新启动 IDE 后,一切都像魅力一样再次运行!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM