php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #81595 Arguments count should be checked prior individual argument type
Submitted: 2021-11-06 14:15 UTC Modified: 2024-07-20 09:10 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: michael dot vorisek at email dot cz Assigned: cmb (profile)
Status: Duplicate Package: *General Issues
PHP Version: 7.4.25 OS: any
Private report: No CVE-ID: None
 [2021-11-06 14:15 UTC] michael dot vorisek at email dot cz
Description:
------------
If arguments count does not match, it should be reported instead of trying to check the arguments type first.

https://3v4l.org/X53qH

Test script:
---------------
function test(int $a, string $b) {
}

try {
    test(1);
} catch (Error $e) { echo $e->getMessage() . "\n"; }

try {
    test('test');
} catch (Error $e) { echo $e->getMessage() . "\n"; }

Expected result:
----------------
Too few arguments to function test(), 1 passed in /in/X53qH on line 7 and exactly 2 expected
Too few arguments to function test(), 1 passed in /in/X53qH on line 7 and exactly 2 expected

Actual result:
--------------
Too few arguments to function test(), 1 passed in /in/X53qH on line 7 and exactly 2 expected
test(): Argument #1 ($a) must be of type int, string given, called in /in/X53qH on line 11

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-11-08 09:03 UTC] nikic@php.net
Why is this order better?
 [2024-07-19 21:44 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2024-07-19 21:44 UTC] cmb@php.net
Are you still interested in this feature request, Michael?  If so,
please open a ticket on Github.  I hope we can archive this spam
tracker soon.
 [2024-07-20 09:10 UTC] cmb@php.net
-Status: Feedback +Status: Duplicate
 [2024-07-20 09:10 UTC] cmb@php.net
Closing in favor of <https://github.com/php/php-src/issues/15037>.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 22:01:27 2024 UTC