Skip to content

Constant string in str_repeat #6679

@staabm

Description

@staabm

Feature request

When building sql queries, sometimes str_repeat is used to build IN sql-expressions.

$array = [1,2,3]; // our array
$in  = str_repeat('?,', count($array) - 1) . '?';
$sql = "SELECT * FROM table WHERE column IN ($in)";

Given constant arguments, str_repeat should return a ConstantString which would allow query analysis.

https://phpstan.org/r/33728aab-b9fb-4567-953e-0027dd26ee6b

I will work on it, just leaving it here so it is not forgotten

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions