|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-09-06 17:41 UTC] svn@php.net
[2009-09-06 17:42 UTC] felipe@php.net
[2009-10-09 14:25 UTC] svn@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 19 15:00:02 2025 UTC |
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