Skip to content

Commit 75ba75e

Browse files
committed
Using only two constants to signal use type intent.
1 parent 0492145 commit 75ba75e

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

ext/standard/array.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ PHP_MINIT_FUNCTION(array) /* {{{ */
129129

130130
REGISTER_LONG_CONSTANT("ARRAY_FILTER_USE_BOTH", ARRAY_FILTER_USE_BOTH, CONST_CS | CONST_PERSISTENT);
131131
REGISTER_LONG_CONSTANT("ARRAY_FILTER_USE_KEY", ARRAY_FILTER_USE_KEY, CONST_CS | CONST_PERSISTENT);
132-
REGISTER_LONG_CONSTANT("ARRAY_FILTER_USE_VALUE", ARRAY_FILTER_USE_VALUE, CONST_CS | CONST_PERSISTENT);
133132

134133
return SUCCESS;
135134
}
@@ -4202,7 +4201,7 @@ PHP_FUNCTION(array_filter)
42024201
zval *retval = NULL;
42034202
zval *key = NULL;
42044203
zend_bool have_callback = 0;
4205-
long use_type = ARRAY_FILTER_USE_VALUE;
4204+
long use_type = 0;
42064205
char *string_key;
42074206
zend_fcall_info fci = empty_fcall_info;
42084207
zend_fcall_info_cache fci_cache = empty_fcall_info_cache;
@@ -4242,7 +4241,7 @@ PHP_FUNCTION(array_filter)
42424241
int key_type = zend_hash_get_current_key_ex(Z_ARRVAL_P(array), &string_key, &string_key_len, &num_key, 0, &pos);
42434242

42444243
if (have_callback) {
4245-
if (use_type != ARRAY_FILTER_USE_VALUE) {
4244+
if (use_type) {
42464245
MAKE_STD_ZVAL(key);
42474246
/* Set up the key */
42484247
switch (key_type) {
@@ -4266,7 +4265,7 @@ PHP_FUNCTION(array_filter)
42664265
int retval_true = zend_is_true(retval);
42674266

42684267
zval_ptr_dtor(&retval);
4269-
if (use_type != ARRAY_FILTER_USE_VALUE) {
4268+
if (use_type) {
42704269
zval_ptr_dtor(&key);
42714270
}
42724271
if (!retval_true) {

ext/standard/php_array.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ PHPAPI int php_multisort_compare(const void *a, const void *b TSRMLS_DC);
119119

120120
#define ARRAY_FILTER_USE_BOTH 1
121121
#define ARRAY_FILTER_USE_KEY 2
122-
#define ARRAY_FILTER_USE_VALUE 3
123122

124123
ZEND_BEGIN_MODULE_GLOBALS(array)
125124
int *multisort_flags[2];

ext/standard/tests/array/array_filter_variation10.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ $mixed = array(1 => 'a', 2 => 'b', 'a' => 1, 'b' => 2);
4242

4343
var_dump(array_filter($mixed, 'is_numeric', ARRAY_FILTER_USE_KEY));
4444

45-
var_dump(array_filter($mixed, 'is_numeric', ARRAY_FILTER_USE_VALUE));
45+
var_dump(array_filter($mixed, 'is_numeric', 0));
4646

4747
var_dump(array_filter($mixed, 'is_numeric', ARRAY_FILTER_USE_BOTH));
4848

0 commit comments

Comments
 (0)