Skip to content

Commit 32c1931

Browse files
authored
standard: Add enum SortDirection (#21501)
RFC: https://wiki.php.net/rfc/sort_direction_enum
1 parent 3619caa commit 32c1931

File tree

9 files changed

+36
-5
lines changed

9 files changed

+36
-5
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ PHP NEWS
142142
. Fixed bug GH-13204 (glob() fails if square bracket is in current directory).
143143
(ndossche)
144144
. Add array size maximum to array_diff(). (ndossche)
145+
. Add enum SortDirection. (timwolla)
145146

146147
- Streams:
147148
. Added so_keepalive, tcp_keepidle, tcp_keepintvl and tcp_keepcnt stream

UPGRADING

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ PHP 8.6 UPGRADE NOTES
163163
7. New Classes and Interfaces
164164
========================================
165165

166+
- Standard:
167+
. enum SortDirection
168+
RFC: https://wiki.php.net/rfc/sort_direction_enum
169+
166170
========================================
167171
8. Removed Extensions and SAPIs
168172
========================================

ext/reflection/tests/ReflectionExtension_getClassNames_basic.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ foreach ($classNames as $className) {
1515
AssertionError
1616
Directory
1717
RoundingMode
18+
SortDirection
1819
StreamBucket
1920
__PHP_Incomplete_Class
2021
php_user_filter

ext/standard/array.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
/* }}} */
6161

6262
ZEND_DECLARE_MODULE_GLOBALS(array)
63+
PHPAPI zend_class_entry *sort_direction_ce;
6364

6465
/* {{{ php_array_init_globals */
6566
static void php_array_init_globals(zend_array_globals *array_globals)

ext/standard/basic_functions.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ PHP_MINIT_FUNCTION(basic) /* {{{ */
297297
assertion_error_ce = register_class_AssertionError(zend_ce_error);
298298

299299
rounding_mode_ce = register_class_RoundingMode();
300+
sort_direction_ce = register_class_SortDirection();
300301

301302
BASIC_MINIT_SUBMODULE(var)
302303
BASIC_MINIT_SUBMODULE(file)

ext/standard/basic_functions.stub.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@
9090
*/
9191
const SORT_FLAG_CASE = UNKNOWN;
9292

93+
enum SortDirection {
94+
case Ascending;
95+
case Descending;
96+
}
97+
9398
/**
9499
* @var int
95100
* @cvalue PHP_CASE_LOWER

ext/standard/basic_functions_arginfo.h

Lines changed: 12 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/standard/basic_functions_decl.h

Lines changed: 9 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/standard/php_array.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ PHPAPI bool php_array_pick_keys(php_random_algo_with_state engine, zval *input,
6363
#define ARRAY_FILTER_USE_BOTH 1
6464
#define ARRAY_FILTER_USE_KEY 2
6565

66+
extern PHPAPI zend_class_entry *sort_direction_ce;
67+
6668
ZEND_BEGIN_MODULE_GLOBALS(array)
6769
bucket_compare_func_t *multisort_func;
6870
bool compare_deprecation_thrown;

0 commit comments

Comments
 (0)