psalm icon indicating copy to clipboard operation
psalm copied to clipboard

Implode of literal-string should be inferred as literal-string

Open VincentLanglet opened this issue 2 months ago • 1 comments

Cf rfc: https://wiki.php.net/rfc/is_literal

Cf phpstan: https://phpstan.org/r/ca885493-b98a-4192-9e9b-eccabeda173a

Psalm snippet https://psalm.dev/r/36ad98d72b

VincentLanglet avatar Apr 17 '24 09:04 VincentLanglet

I found these snippets:

https://psalm.dev/r/36ad98d72b
<?php

/** @param array<literal-string> $string */
function test(array $string): void
{
    /** @psalm-trace $a */
    $a = implode('e', $string);
}
Psalm output (using commit 08afc45):

INFO: Trace - 7:5 - $a: string

INFO: UnusedVariable - 7:5 - $a is never referenced or the value is not used

psalm-github-bot[bot] avatar Apr 17 '24 09:04 psalm-github-bot[bot]