Add E_STRICT when defining a required function parameter after an optional parameter
| From: | John Bafford | Date: | Wed, 24 Nov 2010 17:28:38 +0000 |
| Subject: | Add E_STRICT when defining a required function parameter after an optional parameter | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-50474@lists.php.net to get a copy of this message | ||
Hi,
I filed a bug report with an attached patch that adds an E_STRICT warning when defining a function
with a required parameter after an optional function parameter, for example:
function foo($optional = 1, $required) {}
Although doing this works, code written like that is probably making a faulty assumption somewhere,
and emitting this error would help raise the quality of php code.
The bug and patch are here: http://bugs.php.net/bug.php?id=53399
The patch applies against both the PHP 5.3 branch, and trunk. I'm not sure I'd advocate
including it in PHP 5.3, but I'd definitely like to see it in 5.4. The patch also includes two
tests, and fixes this problem in the Zend/tests/call_user_func_005.phpt test, which is the only test
I found that fails as a result.
At some point in the future, I would like to make this a more severe error than an E_STRICT, but
I'd rather not immediately break code that (until now) worked without warning.
Thoughts/comments?
-John
--
John Bafford
http://bafford.com/