From:             wrzasq at gmail dot com
Operating system: Debian GNU/Linux 2.6.24 x86_64
PHP version:      5.2.6
PHP Bug Type:     PCRE related
Bug description:  Ambiguous parameters for preg_*

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 bug report at http://bugs.php.net/?id=45909&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=45909&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=45909&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=45909&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=45909&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=45909&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=45909&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=45909&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=45909&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=45909&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=45909&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=45909&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=45909&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=45909&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=45909&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=45909&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=45909&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=45909&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=45909&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=45909&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=45909&r=mysqlcfg

Reply via email to