Skip to content

Warning: printf(): Too few arguments #1889

Closed
phpstan/phpstan-src
#4478

Description

@Mariyo

Hello,

I've got strange issue with printf:

Static analysis returns [OK] No errors:
https://phpstan.org/r/9f50fcc7-89b2-4560-acd2-9c4a677d43d6

but PHP shows: Warning: printf(): Too few arguments:
http://sandbox.onlinephpfunctions.com/code/e596add638a9ec3b5bc7915e8cf5da011ce9dbe1

When I fix PHP code, I get error Call to printf contains 42 placeholders, 43 values given.
https://phpstan.org/r/07fe642b-8ee7-41ea-b005-8c99af7e118

Any ideas?

Activity

  1. ondrejmirtes commented on Feb 11, 2019

    @ondrejmirtes
    Member

    Hi, can you tell me what's the trailing % supposed to do?

  2. ondrejmirtes commented on Feb 11, 2019

    @ondrejmirtes
    Member
  3. Mariyo commented on Feb 11, 2019

    @Mariyo
    Author

    Yeah, that's the issue. However, I was wondering why PhpStan found this as issue and PHP not. Maybe you could also improve your tool to handle this strange behaviour of PHP.

    Anyways, thank you and good luck!

  4. staabm commented on Aug 7, 2022

    @staabm
    Contributor

    interessting.. when adding the 4th argument, you get a "Missing format specifier at end of string" error
    https://3v4l.org/5es30

  5. phpstan-bot commented on Feb 26, 2026

    @phpstan-bot
    Contributor

    Closed via merging phpstan/phpstan-src#4478

  6. github-actions commented on Mar 30, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  7. locked as resolved and limited conversation to collaborators on Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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