php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #73001 Backport PHP7 array_column object traversal
Submitted: 2016-09-02 08:16 UTC Modified: 2016-09-04 10:28 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: 131 dot php at cloudyks dot org Assigned: cmb (profile)
Status: Closed Package: Arrays related
PHP Version: 5.6.25 OS: all
Private report: No CVE-ID: None
 [2016-09-02 08:16 UTC] 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)



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-09-04 10:28 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2016-09-04 10:28 UTC] cmb@php.net
> 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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 11:01:34 2024 UTC