Bug #79868 [Fbk->Asn]: Sorting with array_unique gives unwanted result

From: Date: Sat, 18 Jul 2020 16:37:57 +0000
Subject: Bug #79868 [Fbk->Asn]: Sorting with array_unique gives unwanted result
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-228111@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79868&edit=1

 ID:                 79868
 User updated by:    dries at vints dot io
 Reported by:        dries at vints dot io
 Summary:            Sorting with array_unique gives unwanted result
-Status:             Feedback
+Status:             Assigned
 Type:               Bug
 Package:            *General Issues
 Operating System:   macOS Catalina 10.15.5
 PHP Version:        8.0.0alpha2
 Assigned To:        sjon
 Block user comment: N
 Private report:     N

 New Comment:

@sjon I can't, I don't dispute the new behavior makes more sense. This was a side effect
we didn't forsee. I'm reporting this as a change in behavior after Nikita confirmed this
wasn't suppose to change: https://twitter.com/nikita_ppv/status/1284143520962486273


Previous Comments:
------------------------------------------------------------------------
[2020-07-18 11:26:26] sjon@php.net

can you explain why "Illuminate\Routing" should be sorted before
"Illuminate\Auth" ?

------------------------------------------------------------------------
[2020-07-17 15:22:28] dries at vints dot io

Description:
------------
Sorting with array_unique returns different results than in previous PHP versions. I suspect this is
because of https://wiki.php.net/rfc/stable_sorting

If you run the test script from below it'll return the result seeing in https://3v4l.org/9sbAq

Test script:
---------------
var_dump(array_unique([
    'Illuminate\Routing\Middleware\SubstituteBindings',
    'Illuminate\Auth\Middleware\Authorize:edit,post',
], SORT_REGULAR));

Expected result:
----------------
array(2) {
  [0]=>
  string(48) "Illuminate\Routing\Middleware\SubstituteBindings"
  [1]=>
  string(46) "Illuminate\Auth\Middleware\Authorize:edit,post"
}

Actual result:
--------------
array(2) {
  [1]=>
  string(46) "Illuminate\Auth\Middleware\Authorize:edit,post"
  [0]=>
  string(48) "Illuminate\Routing\Middleware\SubstituteBindings"
}


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=79868&edit=1


Thread (7 messages)

« previous php.bugs (#228111) next »