php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #51568 Incorrect return value description for preg_filter
Submitted: 2010-04-16 01:57 UTC Modified: 2010-04-16 10:25 UTC
From: bcollecutt at gmail dot com Assigned: salathe (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2010-04-16 01:57 UTC] bcollecutt at gmail dot com
Description:
------------
Documentation for preg_filter incorrectly says
"If matches are found, the new subject will be returned, otherwise subject will be 
returned unchanged or NULL if an error occurred."

preg_filter returns NULL if no match is found. Not the unchanged string.

Test script:
---------------
$subject = "this is a test";
$pattern = "/cat/i";
if(is_null(preg_filter($pattern,'dog',$subject)))
  echo "null";
else
  echo "not null";

Expected result:
----------------
null

Actual result:
--------------
null

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-16 10:19 UTC] salathe@php.net
Automatic comment from SVN on behalf of salathe
Revision: http://svn.php.net/viewvc/?view=revision&revision=298066
Log: clarify array_filter return value with no matches, fixes bug #51568
 [2010-04-16 10:25 UTC] salathe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: salathe
 [2010-04-16 10:25 UTC] salathe@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

Thank you for the correction, it seems that description was borrowed from 
preg_replace. Note that preg_filter returns an empty array, rather than NULL, if 
no matches were found. Apologies for the typo in the change message (I didn't fix 
array_filter!).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 21 19:01:34 2024 UTC