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: 2021-11-08 09:03 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: michael dot vorisek at email dot cz Assigned:
Status: Open Package: *General Issues
PHP Version: 7.4.25 OS: any
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [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

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-11-08 09:03 UTC] nikic@php.net
Why is this order better?
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Fri Dec 02 23:05:54 2022 UTC