Doc #77321 [NEW]: array_filter combined with references
From: php at kingsquare dot nl
Operating system:
PHP version: 7.3.0
Package: Arrays related
Bug Type: Documentation Problem
Bug description:array_filter combined with references
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 bug report at https://bugs.php.net/bug.php?id=77321&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77321&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77321&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77321&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=77321&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=77321&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=77321&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=77321&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=77321&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=77321&r=support
Expected behavior: https://bugs.php.net/fix.php?id=77321&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=77321&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=77321&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=77321&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77321&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=77321&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=77321&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=77321&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77321&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=77321&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=77321&r=mysqlcfg
Thread (5 messages)
- php at kingsquare dot nl