From:
Operating system: all
PHP version: trunk-SVN-2010-11-24 (SVN)
Package: Scripting Engine problem
Bug Type: Feature/Change Request
Bug description:Add E_STRICT when defining a required funcparameter after an
optional parameter
Description:
------------
PHP does not emit a warning of any kind when defining a function with a
required
parameter after an optional parameter. For example:
function foo($optional = 1, $required) {}
It doesn't make sense to define a required parameter after an optional one,
since
that effectively makes all preceding optional parameters required. Since
this is
an error that can produce bugs and other warnings if one is not careful
(calling
the above function with less than two parameters will cause warnings to be
emitted
for the missing $required parameter), PHP should emit a warning of some
kind
when
functions like this are defined.
The attached patch includes the following changes:
* add an E_STRICT warning when such a function is defined. (The warning
will
only
appear when E_STRICT is included in the php.ini, since it happens at script
compile time, before error_reporting can be called.)
* add Zend/tests/func_optarg1.phpt and Zend/tests/func_optarg2.phpt to test
for
the presence and absence of the warning
* Fixes Zend/tests/call_user_func_005.phpt, which fails with the warning
added.
--
Edit bug report at http://bugs.php.net/bug.php?id=53399&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=53399&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=53399&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=53399&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=53399&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=53399&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=53399&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=53399&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=53399&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=53399&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=53399&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=53399&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=53399&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=53399&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=53399&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53399&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=53399&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=53399&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=53399&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=53399&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=53399&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=53399&r=mysqlcfg