-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
135 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--TEST-- | ||
GH-9775: Backed enum in array_unique() | ||
--FILE-- | ||
<?php | ||
|
||
enum Test: string | ||
{ | ||
case AUTHENTICATED = 'authenticated'; | ||
case COURSES_ADMIN = 'courses.admin'; | ||
case BUNDLES_ADMIN = 'bundles.admin'; | ||
case COURSES_REPORTING_ACCESS = 'courses-reporting.access'; | ||
case B2B_DASHBOARD_ACCESS = 'b2b-dashboard.access'; | ||
case INSTRUCTORS_ADMIN = 'instructors.admin'; | ||
case USERS_ADMIN = 'users.admin'; | ||
case COUPONS_ADMIN = 'coupons.admin'; | ||
} | ||
|
||
$instructorsAdmin = Test::INSTRUCTORS_ADMIN; | ||
|
||
$data = [ | ||
Test::COURSES_ADMIN, | ||
Test::COURSES_REPORTING_ACCESS, | ||
Test::BUNDLES_ADMIN, | ||
Test::USERS_ADMIN, | ||
Test::B2B_DASHBOARD_ACCESS, | ||
Test::B2B_DASHBOARD_ACCESS, | ||
Test::INSTRUCTORS_ADMIN, | ||
&$instructorsAdmin, | ||
Test::COUPONS_ADMIN, | ||
Test::AUTHENTICATED, | ||
]; | ||
|
||
$data = array_unique($data, flags: SORT_REGULAR); | ||
|
||
var_dump($data); | ||
|
||
?> | ||
--EXPECT-- | ||
array(8) { | ||
[0]=> | ||
enum(Test::COURSES_ADMIN) | ||
[1]=> | ||
enum(Test::COURSES_REPORTING_ACCESS) | ||
[2]=> | ||
enum(Test::BUNDLES_ADMIN) | ||
[3]=> | ||
enum(Test::USERS_ADMIN) | ||
[4]=> | ||
enum(Test::B2B_DASHBOARD_ACCESS) | ||
[6]=> | ||
enum(Test::INSTRUCTORS_ADMIN) | ||
[8]=> | ||
enum(Test::COUPONS_ADMIN) | ||
[9]=> | ||
enum(Test::AUTHENTICATED) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--TEST-- | ||
GH-9775: Pure enum in array_unique() | ||
--FILE-- | ||
<?php | ||
|
||
enum Test | ||
{ | ||
case AUTHENTICATED; | ||
case COURSES_ADMIN; | ||
case BUNDLES_ADMIN; | ||
case COURSES_REPORTING_ACCESS; | ||
case B2B_DASHBOARD_ACCESS; | ||
case INSTRUCTORS_ADMIN; | ||
case USERS_ADMIN; | ||
case COUPONS_ADMIN; | ||
} | ||
|
||
$instructorsAdmin = Test::INSTRUCTORS_ADMIN; | ||
|
||
$data = [ | ||
Test::COURSES_ADMIN, | ||
Test::COURSES_REPORTING_ACCESS, | ||
Test::BUNDLES_ADMIN, | ||
Test::USERS_ADMIN, | ||
Test::B2B_DASHBOARD_ACCESS, | ||
Test::B2B_DASHBOARD_ACCESS, | ||
Test::INSTRUCTORS_ADMIN, | ||
&$instructorsAdmin, | ||
Test::COUPONS_ADMIN, | ||
Test::AUTHENTICATED, | ||
]; | ||
|
||
$data = array_unique($data, flags: SORT_REGULAR); | ||
|
||
var_dump($data); | ||
|
||
?> | ||
--EXPECT-- | ||
array(8) { | ||
[0]=> | ||
enum(Test::COURSES_ADMIN) | ||
[1]=> | ||
enum(Test::COURSES_REPORTING_ACCESS) | ||
[2]=> | ||
enum(Test::BUNDLES_ADMIN) | ||
[3]=> | ||
enum(Test::USERS_ADMIN) | ||
[4]=> | ||
enum(Test::B2B_DASHBOARD_ACCESS) | ||
[6]=> | ||
enum(Test::INSTRUCTORS_ADMIN) | ||
[8]=> | ||
enum(Test::COUPONS_ADMIN) | ||
[9]=> | ||
enum(Test::AUTHENTICATED) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters