2
require_once APP . DS . 'controllers' . DS . $this->controller . '.php';

I'm including controller. It has default value set and it always has to find something. In real world it works, but this inspection is still shinning in my IDE and I would like to solve it somehow.

Inspection says this

Path '/media/matej/space/www/rs/app/controllers/$this->controller' not found

How can I explain it, that I am aware of what is happening? Is there some comment to solve this issue?

1 Answer 1

10

You are using very dynamic code here .. which cannot be evaluated properly in IDE using static analysis alone (as you are using $this->controller which can be anything during run time).

Two options here:

  1. Suppress warning for this line only -- just place /** @noinspection PhpIncludeInspection */ on a line before that.

    This option makes sense only if you have very little of such suppressions in your code, otherwise half of the file will be suppression comments :)

  2. Just turn off such inspection completely -- adding such suppression comments all the time (often) looks ugly and not a desired way in general.

    For that: Settings | Editor | Inspections | PHP | General --> Unresolved include. It could be done for whole project or for some custom scope only.

1
  • 2nd one help me with the newest update of php strome. But anyway its not recommended to hide issues.
    – ManulMad
    Commented Apr 25, 2023 at 9:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.