Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PhpStorm Path not found inspection

Tags:

php

ide

phpstorm

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?

like image 412
Matej Vrzala M4 Avatar asked Jan 24 '26 16:01

Matej Vrzala M4


1 Answers

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.

like image 187
LazyOne Avatar answered Jan 27 '26 08:01

LazyOne



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!