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

Incorrect InvalidLiteralArgument when usage dirname() #9196

Open
vjik opened this issue Jan 29, 2023 · 3 comments
Open

Incorrect InvalidLiteralArgument when usage dirname() #9196

vjik opened this issue Jan 29, 2023 · 3 comments
Labels

Comments

@vjik
Copy link
Contributor

vjik commented Jan 29, 2023

function test(): bool {
    $path = dirname(__DIR__, 4);
    return strlen($path) > 6 && str_contains($path, 'vendor');
}

For no duplicate dirname(__DIR__, 4) I use variable $path, but psalm throw InvalidLiteralArgument. Seems, it's incorrect.

https://psalm.dev/r/3603178ff0

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/3603178ff0
<?php

function test(): bool {
    $path = dirname(__DIR__, 4);
    return strlen($path) > 6 && str_contains($path, 'vendor');
}
Psalm output (using commit aec0edc):

ERROR: InvalidLiteralArgument - 5:46 - Argument 1 of str_contains expects a non-literal value, but '/var/www' provided

@weirdan weirdan added the bug label Jan 29, 2023
@weirdan
Copy link
Collaborator

weirdan commented Feb 14, 2023

Simplified: https://psalm.dev/r/760dffc723

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/760dffc723
<?php
$d = __DIR__;
echo str_contains($d, "psalm");
Psalm output (using commit dd13930):

ERROR: InvalidLiteralArgument - 3:19 - Argument 1 of str_contains expects a non-literal value, but '/var/www/vhosts/psalm.dev/httpdocs/src' provided

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants