Skip to content

Differing behaviors when requiring or including relatively vs using __DIR__ #12203

@la-magra

Description

@la-magra

Bug report

When using a require or an include to a file that does not exist correctly sends a fileNotFound.
But when prepending the path with __DIR__ like require __DIR__.'/../test.php' the error is no longer displayed.

Maybe related to phpstan/phpstan-src@098fb94 ?

Code snippet that reproduces the problem

https://phpstan.org/r/d1e81908-1e6f-42ac-bce6-5064571045f2

Expected output

The two requires should send a fileNotFound error when the file does not exist.

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

Thank you for helping us write better code.

And the fact that we can do composer require --dev phpstan/phpstan and not contaminate vendor/ with dependencies that inevitably will conflict with something else is just: :chef's kiss: .

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions