|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2020-07-13 12:21 UTC] sjon@php.net
Description: ------------ I'm not 100% sure this is a bug but both array_walk and array filter throw warnings when variables are passed by reference. Either the message is inverted (they don't accept variables by reference) or it's incorrectly thrown Originally found as https://3v4l.org/WH94Q Test script: --------------- $ids = array("8479"); $newIds = array_filter($ids, function(&$n) { $n = intVal($n); }); Expected result: ---------------- no warning Actual result: -------------- Warning: {closure}(): Argument #1 ($n) must be passed by reference, value given in /in/WH94Q on line 7 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 07:00:01 2025 UTC |
Aha, so this fix would be for the user to write ``` $newIds = array_filter($ids, function($n) { return intval($n); }); ``` or in this case, simply `$newIds = array_filter($ids, 'intval');`. Does the same reasoning apply to https://3v4l.org/ZCgRe ? It seems internal functions that accept references will function correctly but still throw the same warning.