Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve __DIR__ / __FILE__ when const/variable is used for include #7585

Merged
merged 4 commits into from Feb 4, 2022

Conversation

tomasz-kusy
Copy link

@tomasz-kusy tomasz-kusy commented Feb 4, 2022

Fixes #7584

@orklah orklah added the release:feature The PR will be included in 'Features' section of the release notes label Feb 4, 2022
@orklah
Copy link
Collaborator

orklah commented Feb 4, 2022

Thanks! Congrats for your first PR!

@weirdan weirdan merged commit b06fb93 into vimeo:4.x Feb 4, 2022
@weirdan
Copy link
Collaborator

weirdan commented Feb 4, 2022

Thanks!

@VincentLanglet
Copy link
Contributor

Now __DIR__ is resolved, I ends with multiple errors similar to the issue
#3886 with the code

if (file_exists($file = __DIR__.'/custom_bootstrap.php')) {
    require_once $file;
}

Wouldn't it be possible for psalm to not report an error in this situation ?

Since the file with the code is autogenerated, and sometimes there is a custom_bootstrap, sometimes there isn't, I cannot add a psalm-suppress comment (because it will sometimes be reported as unused).
Any recommendation in this situation @orklah ?

@orklah
Copy link
Collaborator

orklah commented Feb 22, 2022

Probably related to #3241 and #4788

If the expression is too complex, Psalm can't see you're requiring the same thing.

If you have control over the code generation, consider introducing a local variable before the file_exists, this may help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:feature The PR will be included in 'Features' section of the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UnresolvableInclude when include uses __DIR__ assigned to const or variable
4 participants