php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69751 Change Error message of sprintf/printf for missing/typo position specifier
Submitted: 2015-06-03 11:59 UTC Modified: 2021-01-06 16:20 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: Hoffmann dot P at gmx dot net Assigned:
Status: Verified Package: Strings related
PHP Version: 5.5.25 OS: Linux 3.13.0-53-generic
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2015-06-03 11:59 UTC] Hoffmann dot P at gmx dot net
Description:
------------
I suggest a more comprehensible error message (see suggestion in "Expected result"). The current error message was missunderstood by me as "The number of arguments of the function is zero (and must be greater than zero)". Instead it was the number of the position specifier argument that was missing (type, "$" and "1" where reversed).

Test script:
---------------
sprintf("%$1s, %2$s %1$s", "Sir", "Yes");

Expected result:
----------------
Missing position specifier number in /home/ber/Code/Kompetenztest/org/ValiditätEingabe/class_test.php on line $line

Actual result:
--------------
Argument number must be greater than zero in /home/ber/Code/Kompetenztest/org/ValiditätEingabe/class_test.php on line $line

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-06-04 12:04 UTC] cmb@php.net
-Package: SPL related +Package: Strings related
 [2015-06-04 12:04 UTC] cmb@php.net
See <http://3v4l.org/CPIng> for a corrected test script.
 [2021-01-06 16:14 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2021-01-06 16:14 UTC] cmb@php.net
Yes, that error message is not right.  You also get the same error
message if the argnum is greater than INT_MAX[1].

[1] <https://3v4l.org/gs2fF>
 [2021-01-06 16:20 UTC] cmb@php.net
-Type: Feature/Change Request +Type: Bug
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue May 18 20:01:23 2021 UTC