Skip to content

(s)printf basic param type validation #9818

@kkmuffme

Description

@kkmuffme

When the first param of (s)printf is a literal string (otherwise not possible to validate in psalm):

https://psalm.dev/r/7749cadcab

  • for %d (or %1$d) the corresponding param must be type int (as string will be returned as 0 and float as int)
  • this applies not only to "d" but to [bcdouxX]
  • if placeholder is any of [eEfFgGhH] type should be float
  • if placeholder is s should be type string (if we want to be less strict allow int|float|string like now)

Would be the next step after #9817

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions