|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2019-06-14 22:20 UTC] nikic@php.net
[2019-06-21 15:11 UTC] kalle@php.net
-Status: Open
+Status: Feedback
[2019-06-30 04:22 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 08:00:01 2025 UTC |
Description: ------------ When a function has optional parameters, the use of `Z_PARAM_OPTIONAL` is required. Forgetting to add this macro leads to a `TypeError` with a message about the given required argument instead of the missing argument. Test script: --------------- PHP_FUNCTION(test_it) { zend_long code; char *phrase; size_t phrase_len; ZEND_PARSE_PARAMETERS_START_EX(ZEND_PARSE_PARAMS_THROW, 1, 2) Z_PARAM_LONG(code) Z_PARAM_STRING(phrase, phrase_len) ZEND_PARSE_PARAMETERS_END_EX(); //... } <?php test_it(100); ?> Expected result: ---------------- Fatal error: Uncaught TypeError: test_it() expects parameter 2 to be string, null given Actual result: -------------- Fatal error: Uncaught TypeError: test_it() expects parameter 1 to be integer, integer given