Doc #77321 [Opn->Nab]: array_filter combined with references

From: Date: Thu, 20 Dec 2018 16:56:55 +0000
Subject: Doc #77321 [Opn->Nab]: array_filter combined with references
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-16224@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77321&edit=1

 ID:                 77321
 Updated by:         requinix@php.net
 Reported by:        php at kingsquare dot nl
 Summary:            array_filter combined with references
-Status:             Open
+Status:             Not a bug
 Type:               Documentation Problem
 Package:            Arrays related
-PHP Version:        7.3.0
+PHP Version:        7.0.0
 Block user comment: N
 Private report:     N

 New Comment:

array_filter never supported by-ref values. The fact that it worked in PHP 5 was a bug, and it was
fixed in PHP 7 when much of the engine changed.


Previous Comments:
------------------------------------------------------------------------
[2018-12-20 09:06:12] php at kingsquare dot nl

Description:
------------
This is probably on purpose, but there is an undocumented backwards compatibility issue betwee PHP5
and PHP7. I know this might be a bit late to the party, but still.

It involves the differnce in using array_filter and references. 

Test script:
---------------
<?php
// also see https://3v4l.org/Z2HnL
$input = [1, 2];
var_dump(array_filter($input, function(& $value) {
    if ($value % 2 === 0) {
        return false;
    }
    $value++;
    return true;
}));

Expected result:
----------------
As the changelog doesn't seem to mention anything related to this I would expect them to be the
same result [(int)2].

Actual result:
--------------
PHP5: [2]
PHP7: [1]



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=77321&edit=1


Thread (5 messages)

« previous php.doc.bugs (#16224) next »