Doc #73267 [Asn->Csd]: Order by callback changed

From: Date: Sat, 08 Oct 2016 09:12:33 +0000
Subject: Doc #73267 [Asn->Csd]: Order by callback changed
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-14000@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=73267&edit=1 ID: 73267 Updated by: cmb@php.net Reported by: me at evertpot dot com Summary: Order by callback changed -Status: Assigned +Status: Closed Type: Documentation Problem Package: Arrays related PHP Version: 7.1.0RC3 Assigned To: cmb Block user comment: N Private report: N Previous Comments: ------------------------------------------------------------------------ [2016-10-08 09:12:19] cmb@php.net Automatic comment from SVN on behalf of cmb Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=340377 Log: Fix #73267: Order by callback changed ------------------------------------------------------------------------ [2016-10-08 09:10:45] cmb@php.net Indeed, the sorting order has changed, but that is an implementation detail that should not be relied upon anyway, because: | If two members compare as equal, their relative order in the | sorted array is undefined. That's already documented for all? other sorting functions, but has been forgotten for array_multisort(). Adding a note to the changelog or migration guide regarding a behavioral change of undefined behavior wouldn't make sense (the behavior is still undefined). ------------------------------------------------------------------------ [2016-10-07 21:21:11] me at evertpot dot com Description: ------------ Hey guys, I noticed one of my unittests failing on PHP 7.1. Took me a bit to figure out what was going on, but ended up figuring out that if you sort-by-callback, PHP 7.1 has a different order. The use-case might sound a bit weird, and I'm certainly not suggesting that this is a bug. I merely wanted to suggest that maybe this might be added to the "Backwards compatibility changed" document. Test script: --------------- https://3v4l.org/DWujs <?php $foo = [1,1]; $bar = [ function() use (&$k) { echo "first!"; }, function() use (&$k) { echo "second!"; }, ]; array_multisort($foo, SORT_NUMERIC, $bar); $bar[0](); ?> ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=73267&edit=1

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