|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-08-25 18:14 UTC] jani@php.net
[2008-09-02 01:00 UTC] php-bugs at lists dot php dot net
[2008-10-18 19:53 UTC] felipe@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 18 19:00:01 2025 UTC |
Description: ------------ Before I look into manual I often just check parameters list for functions/methods from command line which usualy is enought for me. Today I wanted to check preg_replace() parameters list to see which of them is $limit, but unfortunately PHP seems to not export parameters names for preg_replace() (as well as for other PCRE functions - checked preg_match() also, didn't have time for more). Parameters are all named $paramX (where X is number in order). Additionaly they are all marked as required even if they are not. Reproduce code: --------------- php --rf preg_replace php --rf preg_match php -r '$f = new ReflectionFunction("preg_replace"); print_r($f->getParameters());' Expected result: ---------------- Function [ <internal:pcre> function preg_replace ] { - Parameters [5] { Parameter #0 [ <required> $pattern ] Parameter #1 [ <required> $replacement ] Parameter #2 [ <required> $subject ] Parameter #3 [ <optional> $limit ] Parameter #4 [ <optional> &$count ] } } Function [ <internal:pcre> function preg_match ] { - Parameters [3] { Parameter #0 [ <required> $pattern ] Parameter #1 [ <required> $subject ] Parameter #2 [ <optional> &$matches ] } } Array ( [0] => ReflectionParameter Object ( [name] => pattern ) [1] => ReflectionParameter Object ( [name] => replacement ) [2] => ReflectionParameter Object ( [name] => subject ) [3] => ReflectionParameter Object ( [name] => limit ) [4] => ReflectionParameter Object ( [name] => count ) ) Actual result: -------------- Function [ <internal:pcre> function preg_replace ] { - Parameters [5] { Parameter #0 [ <required> $param0 ] Parameter #1 [ <required> $param1 ] Parameter #2 [ <required> $param2 ] Parameter #3 [ <required> $param3 ] Parameter #4 [ <required> &$param4 ] } } Function [ <internal:pcre> function preg_match ] { - Parameters [3] { Parameter #0 [ <required> $param0 ] Parameter #1 [ <required> $param1 ] Parameter #2 [ <required> &$param2 ] } } Array ( [0] => ReflectionParameter Object ( [name] => ) [1] => ReflectionParameter Object ( [name] => ) [2] => ReflectionParameter Object ( [name] => ) [3] => ReflectionParameter Object ( [name] => ) [4] => ReflectionParameter Object ( [name] => ) )