#49483 [Opn->Csd]: preg_replace 'subject' parameter listed as optional
ID: 49483
Updated by: felipe@php.net
Reported By: janne dot raiskila at gmail dot com
-Status: Open
+Status: Closed
Bug Type: Reflection related
Operating System: Windows Vista SP2 32-bit
PHP Version: 5.3SVN-2009-09-06 (snap)
-Assigned To:
+Assigned To: felipe
New Comment:
This bug has been fixed in SVN.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2009-09-06 17:41:35] svn@php.net
Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&revision=288111
Log: - Fixed bug #49483 (preg_replace 'subject' parameter listed as
optional)
------------------------------------------------------------------------
[2009-09-06 11:53:29] janne dot raiskila at gmail dot com
Description:
------------
According to reflection the third parameter to preg_replace (subject)
is optional. Calling preg_replace without a third argument, however,
issues a warning.
This bug is similar to #45909 (filed for PHP 5.2.6 in 2008, closed),
but the output has changed since (when most of the reflection bugs were
fixed for 5.3.0).
Reproduce code:
---------------
1)
php --rf preg_replace
2)
$fn = new ReflectionFunction("preg_replace");
printf("Total: %d\nRequired: %d\n",
$fn->getNumberOfParameters(),
$fn->getNumberOfRequiredParameters()
);
Expected result:
----------------
1)
>php --rf preg_replace
Function [ <internal:pcre> function preg_replace ] {
- Parameters [5] {
Parameter #0 [ <required> $regex ]
Parameter #1 [ <required> $replace ]
Parameter #2 [ <required> $subject ]
Parameter #3 [ <optional> $limit ]
Parameter #4 [ <optional> &$count ]
}
}
2)
Total: 5
Required: 3
Actual result:
--------------
1)
>php --rf preg_replace
Function [ <internal:pcre> function preg_replace ] {
- Parameters [5] {
Parameter #0 [ <required> $regex ]
Parameter #1 [ <required> $replace ]
Parameter #2 [ <optional> $subject ]
Parameter #3 [ <optional> $limit ]
Parameter #4 [ <optional> &$count ]
}
}
2)
Total: 5
Required: 2
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=49483&edit=1
Thread (2 messages)