Req #81595 [Opn]: Arguments count should be checked prior individual argument type

From: Date: Mon, 08 Nov 2021 09:03:23 +0000
Subject: Req #81595 [Opn]: Arguments count should be checked prior individual argument type
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-237596@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81595&edit=1 ID: 81595 Updated by: nikic@php.net Reported by: michael dot vorisek at email dot cz Summary: Arguments count should be checked prior individual argument type Status: Open Type: Feature/Change Request Package: *General Issues Operating System: any PHP Version: 7.4.25 Block user comment: N Private report: N New Comment: Why is this order better? Previous Comments: ------------------------------------------------------------------------ [2021-11-06 14:15:06] 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=81595&edit=1

« previous php.bugs (#237596) next »