4
votes

This is the line of code:

require_once dirname( __DIR__, 2 ) . '/vendor/autoload.php';

The code works, but PhpStorm complains with:

Path 'C:/project/src/Container/vendor/autoload.php' not found

The correct path is:

C:/project/src/vendor/autoload.php

If I use a relative path, PhpStorm doesn't complain:

require_once '../../vendor/autoload.php'; // no complaints

So it looks like PhpStorm is not recognizing the 2nd parameter of dirname($path, $levels), where I'm specifying to go up 2 levels.

dirname() is such a basic PHP function that I'm really surprised that PhpStorm doesn't recognize the $levels parameter.

I would prefer to keep inspections on. Is there a fix for this?

1
The levels parameter was added in PHP 7. Are you sure your web server's PHP engine is at version 7? - Honeyboy Wilson
In Settings->Languages&Frameworks->PHP I have "PHP language level" set to 7.2 - Kerry Randolph
what you end up doing, living with it.? - Camilo Casadiego

1 Answers

4
votes

dirname() levels aren't supported yet in PhpStorm, here's a link to a corresponding feature request that you can vote for: https://youtrack.jetbrains.com/issue/WI-35143. This would increase the issue priority & would move it up in a queue