🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

Require test fails on linux when path contains DIRECTORY_SEPARATOR #14944

Description

@jorrit

Bug report

I use the following syntax to include files:

require __DIR__.DIRECTORY_SEPARATOR.'bootstrap.php';

After upgrading from 2.2.2 to 2.2.3, I get this phpstan error:

  8      Path in require() __DIR__ . \DIRECTORY_SEPARATOR . 'bootstrap.php' is  
         not a file or it does not exist.                                       
         🪪  require.fileNotFound          

This error only occurs on Linux, not on Windows.
require errors are hard to reproduce on the playground because there no files exist.
I created a PR with a modified test on phpstan/phpstan-src#6027 to demonstrate the problem. From the error message there is seems that on Linux DIRECTORY_SEPARATOR is a backslash.

I don't know why my version shows DIRECTORY_SEPARATOR in the error message and the test results of the PR show the resolved path.

Code snippet that reproduces the problem

phpstan/phpstan-src#6027

Expected output

No errors.

Did PHPStan help you today? Did it make you happy in any way?

PHPStan is a life saver.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions