php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49483 preg_replace 'subject' parameter listed as optional
Submitted: 2009-09-06 11:53 UTC Modified: 2009-09-06 17:42 UTC
From: janne dot raiskila at gmail dot com Assigned: felipe (profile)
Status: Closed Package: Reflection related
PHP Version: 5.3SVN-2009-09-06 (snap) OS: Windows Vista SP2 32-bit
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: janne dot raiskila at gmail dot com
New email:
PHP Version: OS:

 

 [2009-09-06 11:53 UTC] janne dot raiskila at gmail dot com
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


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-09-06 17:41 UTC] svn@php.net
Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&revision=288111
Log: - Fixed bug #49483 (preg_replace 'subject' parameter listed as optional)
 [2009-09-06 17:42 UTC] felipe@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 [2009-10-09 14:25 UTC] svn@php.net
Automatic comment from SVN on behalf of pajoye
Revision: http://svn.php.net/viewvc/?view=revision&revision=289418
Log: - Merge: Fixed bug #49483 (preg_replace 'subject' parameter listed as optional)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 06:01:30 2024 UTC