Home > Back-end >  PhpStorm does not find classes in the same directory
PhpStorm does not find classes in the same directory

Time:05-31

I'm running PhpStorm Version 2021.3.2 on Arch Linux. 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

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(); 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?

CodePudding user response:

In my case repairing the IDE helped. Go to 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!

  • Related