php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45909 Ambiguous parameters for preg_*
Submitted: 2008-08-25 16:38 UTC Modified: 2008-10-18 19:53 UTC
From: wrzasq at gmail dot com Assigned:
Status: Closed Package: PCRE related
PHP Version: 5.2.6 OS: Debian GNU/Linux 2.6.24 x86_64
Private report: No CVE-ID: None
 [2008-08-25 16:38 UTC] 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] =>
        )

)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-09-02 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2008-10-18 19:53 UTC] felipe@php.net
The information about arguments of each PCRE functions, and other extensions were improved in PHP 5.3.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Jan 27 12:01:24 2020 UTC