#45909 [Opn->Fbk]: Ambiguous parameters for preg_*
ID: 45909
Updated by: jani@php.net
Reported By: wrzasq at gmail dot com
-Status: Open
+Status: Feedback
Bug Type: PCRE related
Operating System: Debian GNU/Linux 2.6.24 x86_64
PHP Version: 5.2.6
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5.3-latest.tar.gz
For Windows (zip):
http://snaps.php.net/win32/php5.3-win32-latest.zip
For Windows (installer):
http://snaps.php.net/win32/php5.3-win32-installer-latest.msi
Previous Comments:
------------------------------------------------------------------------
[2008-08-25 16:38:27] wrzasq at gmail dot com
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] =>
)
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=45909&edit=1
Thread (3 messages)