boesing / psalm-plugin-stringf

Psalm plugin to provide more details for `sprintf`, `printf`, `sscanf` and `fscanf` functions.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Amount of specifiers is not properly detected

boesing opened this issue · comments

class Foo
{
    private const MESSAGE = "%s,\n\n" .
    'Jada jada %s Foo barBaz qoo ook, foo. ' .
    "Yada yada, foo bar baz qoo %s!\n\n" .
    'YOLO test: %s';
    
    public function test(): string
    {
          return sprintf(self::MESSAGE, 'foo', 'bar', 'baz', 'ooq');
    }
}

Template passed to function sprintf requires 2 specifier but 4 are passed.


class Bar
{
    private const MESSAGE = "Foo bar baz: %s of %s with %s.\n\nFoo bar baz ooq: %s";
    
    public function test(): string
    {
          return sprintf(self::MESSAGE, 'foo', 'bar', 'baz', 'ooq');
    }
}

Template passed to function sprintf requires 2 specifier but 4 are passed.


class Baz
{
    private const MESSAGE = <<<'FOO'
        YADA YADA bar
        %s, %s, %s
        FOO;
    
    public function test(): string
    {
          return sprintf(self::MESSAGE, 'foo', 'bar', 'baz');
    }
}

Template passed to function sprintf requires 0 specifier but 3 are passed.