Req #73001 [Opn->Csd]: Backport PHP7 array_column object traversal

From: Date: Sun, 04 Sep 2016 10:28:05 +0000
Subject: Req #73001 [Opn->Csd]: Backport PHP7 array_column object traversal
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-203781@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=73001&edit=1 ID: 73001 Updated by: cmb@php.net Reported by: 131 dot php at cloudyks dot org Summary: Backport PHP7 array_column object traversal -Status: Open +Status: Closed Type: Feature/Change Request Package: Arrays related Operating System: all PHP Version: 5.6.25 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: > This has been fixed in 7.0.0 It has not been fixed, but rather an improvement has been made to the function, and improvements are usually not backported. > as the function is defined, it does not allow my code to > override it anymore, as in php <= 5.4 In my opinion, it is always problematic to use polyfills. Consider to use wrappers instead. Something like: <?php function my_array_column(…) { if (function_exists('array_column') && version_compare(phpversion(), '7.0.0', '>')) { return array_colum(…); } else { // fallback code } } For efficiency, the conditional could be put outside of the function definition. Previous Comments: ------------------------------------------------------------------------ [2016-09-02 08:16:32] 131 dot php at cloudyks dot org Description: ------------ Lot of my code will break due to PHP 5.5-5.6 array_column current behavior. This has been fixed in 7.0.0 "Added the ability for the input parameter to be an array of objects. ". Is there some way for php 5.6 to backport this behavior ? (as the function is defined, it does not allow my code to override it anymore, as in php <= 5.4) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=73001&edit=1

« previous php.bugs (#203781) next »