1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Fix GH-20194: null offset deprecation not emitted for writes (#20238)

Based on a patch from @ndossche
This commit is contained in:
Gina Peter Banyard
2025-10-29 18:36:10 +00:00
committed by GitHub
parent 0960689ba1
commit 9a1b8a785d
83 changed files with 1216 additions and 2344 deletions

View File

@@ -1106,6 +1106,11 @@ static void sccp_visit_instr(scdf_ctx *scdf, zend_op *opline, zend_ssa_op *ssa_o
if (op2) {
SKIP_IF_TOP(op2);
if (Z_TYPE_P(op2) == IS_NULL) {
/* Emits deprecation at run-time. */
SET_RESULT_BOT(result);
return;
}
}
/* We want to avoid keeping around intermediate arrays for each SSA variable in the

View File

@@ -5252,7 +5252,7 @@ ZEND_API bool zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op
case ZEND_INIT_ARRAY:
return (opline->op2_type != IS_UNUSED) && (t2 & (MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE));
case ZEND_ADD_ARRAY_ELEMENT:
return (opline->op2_type == IS_UNUSED) || (t2 & (MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE));
return (opline->op2_type == IS_UNUSED) || (t2 & (MAY_BE_NULL|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE));
case ZEND_STRLEN:
return (t1 & MAY_BE_ANY) != MAY_BE_STRING;
case ZEND_COUNT:

View File

@@ -48,6 +48,8 @@ var_dump(
Warning: A non-numeric value encountered in %s on line %d
Deprecated: Implicit conversion from float 3.14 to int loses precision in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
int(3)
string(4) "1foo"
bool(false)

View File

@@ -0,0 +1,15 @@
--TEST--
GH-20194: Using null as an array offset does not emit deprecation when resolved at compile time
--FILE--
<?php
$a = [null => 1];
echo $a[null];
?>
--EXPECTF--
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
1

View File

@@ -0,0 +1,17 @@
--TEST--
Do not leak when promoting null offset deprecation
--FILE--
<?php
set_error_handler(function ($errno, $errstr) {
throw new Exception($errstr);
});
try {
$a = ['foo' => 'bar', null => new stdClass];
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Exception: Using null as an array offset is deprecated, use an empty string instead

View File

@@ -0,0 +1,19 @@
--TEST--
No UAF on null offset deprecation with unset value
--FILE--
<?php
set_error_handler(function ($errno, $errstr) {
var_dump($errstr);
global $a;
unset($a);
});
$a = new stdClass;
$b = [0, null => $a];
echo "\nSuccess\n";
?>
--EXPECTF--
string(72) "Using null as an array offset is deprecated, use an empty string instead"
Success

View File

@@ -2255,9 +2255,6 @@ ZEND_API zend_result array_set_zval_key(HashTable *ht, zval *key, zval *value) /
case IS_STRING:
result = zend_symtable_update(ht, Z_STR_P(key), value);
break;
case IS_NULL:
result = zend_hash_update(ht, ZSTR_EMPTY_ALLOC(), value);
break;
case IS_RESOURCE:
zend_use_resource_as_offset(key);
result = zend_hash_index_update(ht, Z_RES_HANDLE_P(key), value);
@@ -2274,6 +2271,13 @@ ZEND_API zend_result array_set_zval_key(HashTable *ht, zval *key, zval *value) /
case IS_DOUBLE:
result = zend_hash_index_update(ht, zend_dval_to_lval_safe(Z_DVAL_P(key)), value);
break;
case IS_NULL:
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (UNEXPECTED(EG(exception))) {
return FAILURE;
}
result = zend_hash_update(ht, ZSTR_EMPTY_ALLOC(), value);
break;
default:
zend_illegal_container_offset(ZSTR_KNOWN(ZEND_STR_ARRAY), key, BP_VAR_W);
result = NULL;

View File

@@ -10175,9 +10175,7 @@ static bool zend_try_ct_eval_array(zval *result, zend_ast *ast) /* {{{ */
zend_long lval = zend_dval_to_lval_silent(Z_DVAL_P(key));
/* Incompatible float will generate an error, leave this to run-time */
if (!zend_is_long_compatible(Z_DVAL_P(key), lval)) {
zval_ptr_dtor_nogc(value);
zval_ptr_dtor(result);
return 0;
goto fail;
}
zend_hash_index_update(Z_ARRVAL_P(result), lval, value);
break;
@@ -10189,13 +10187,14 @@ static bool zend_try_ct_eval_array(zval *result, zend_ast *ast) /* {{{ */
zend_hash_index_update(Z_ARRVAL_P(result), 1, value);
break;
case IS_NULL:
zend_hash_update(Z_ARRVAL_P(result), ZSTR_EMPTY_ALLOC(), value);
break;
/* Null key will generate a warning at run-time. */
goto fail;
default:
zend_error_noreturn(E_COMPILE_ERROR, "Illegal offset type");
break;
}
} else if (!zend_hash_next_index_insert(Z_ARRVAL_P(result), value)) {
fail:
zval_ptr_dtor_nogc(value);
zval_ptr_dtor(result);
return 0;

View File

@@ -6278,7 +6278,21 @@ ZEND_VM_C_LABEL(num_index):
} else if ((OP2_TYPE & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(offset) == IS_REFERENCE)) {
offset = Z_REFVAL_P(offset);
ZEND_VM_C_GOTO(add_again);
} else if (Z_TYPE_P(offset) == IS_NULL) {
} else if (UNEXPECTED(Z_TYPE_P(offset) == IS_NULL)) {
zval tmp;
if (OP1_TYPE == IS_CV || OP1_TYPE == IS_VAR) {
ZVAL_COPY(&tmp, expr_ptr);
}
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (OP1_TYPE == IS_CV || OP1_TYPE == IS_VAR) {
/* A userland error handler can do funky things to the expression, so reset it */
zval_ptr_dtor(expr_ptr);
ZVAL_COPY_VALUE(expr_ptr, &tmp);
}
if (UNEXPECTED(EG(exception))) {
zval_ptr_dtor_nogc(expr_ptr);
HANDLE_EXCEPTION();
}
str = ZSTR_EMPTY_ALLOC();
ZEND_VM_C_GOTO(str_index);
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {

512
Zend/zend_vm_execute.h generated
View File

@@ -7944,7 +7944,21 @@ num_index:
} else if ((IS_CONST & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(offset) == IS_REFERENCE)) {
offset = Z_REFVAL_P(offset);
goto add_again;
} else if (Z_TYPE_P(offset) == IS_NULL) {
} else if (UNEXPECTED(Z_TYPE_P(offset) == IS_NULL)) {
zval tmp;
if (IS_CONST == IS_CV || IS_CONST == IS_VAR) {
ZVAL_COPY(&tmp, expr_ptr);
}
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (IS_CONST == IS_CV || IS_CONST == IS_VAR) {
/* A userland error handler can do funky things to the expression, so reset it */
zval_ptr_dtor(expr_ptr);
ZVAL_COPY_VALUE(expr_ptr, &tmp);
}
if (UNEXPECTED(EG(exception))) {
zval_ptr_dtor_nogc(expr_ptr);
HANDLE_EXCEPTION();
}
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
@@ -10423,7 +10437,21 @@ num_index:
} else if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(offset) == IS_REFERENCE)) {
offset = Z_REFVAL_P(offset);
goto add_again;
} else if (Z_TYPE_P(offset) == IS_NULL) {
} else if (UNEXPECTED(Z_TYPE_P(offset) == IS_NULL)) {
zval tmp;
if (IS_CONST == IS_CV || IS_CONST == IS_VAR) {
ZVAL_COPY(&tmp, expr_ptr);
}
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (IS_CONST == IS_CV || IS_CONST == IS_VAR) {
/* A userland error handler can do funky things to the expression, so reset it */
zval_ptr_dtor(expr_ptr);
ZVAL_COPY_VALUE(expr_ptr, &tmp);
}
if (UNEXPECTED(EG(exception))) {
zval_ptr_dtor_nogc(expr_ptr);
HANDLE_EXCEPTION();
}
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
@@ -11364,7 +11392,21 @@ num_index:
} else if ((IS_UNUSED & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(offset) == IS_REFERENCE)) {
offset = Z_REFVAL_P(offset);
goto add_again;
} else if (Z_TYPE_P(offset) == IS_NULL) {
} else if (UNEXPECTED(Z_TYPE_P(offset) == IS_NULL)) {
zval tmp;
if (IS_CONST == IS_CV || IS_CONST == IS_VAR) {
ZVAL_COPY(&tmp, expr_ptr);
}
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (IS_CONST == IS_CV || IS_CONST == IS_VAR) {
/* A userland error handler can do funky things to the expression, so reset it */
zval_ptr_dtor(expr_ptr);
ZVAL_COPY_VALUE(expr_ptr, &tmp);
}
if (UNEXPECTED(EG(exception))) {
zval_ptr_dtor_nogc(expr_ptr);
HANDLE_EXCEPTION();
}
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
@@ -12979,7 +13021,21 @@ num_index:
} else if ((IS_CV & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(offset) == IS_REFERENCE)) {
offset = Z_REFVAL_P(offset);
goto add_again;
} else if (Z_TYPE_P(offset) == IS_NULL) {
} else if (UNEXPECTED(Z_TYPE_P(offset) == IS_NULL)) {
zval tmp;
if (IS_CONST == IS_CV || IS_CONST == IS_VAR) {
ZVAL_COPY(&tmp, expr_ptr);
}
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (IS_CONST == IS_CV || IS_CONST == IS_VAR) {
/* A userland error handler can do funky things to the expression, so reset it */
zval_ptr_dtor(expr_ptr);
ZVAL_COPY_VALUE(expr_ptr, &tmp);
}
if (UNEXPECTED(EG(exception))) {
zval_ptr_dtor_nogc(expr_ptr);
HANDLE_EXCEPTION();
}
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
@@ -21281,7 +21337,21 @@ num_index:
} else if ((IS_CONST & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(offset) == IS_REFERENCE)) {
offset = Z_REFVAL_P(offset);
goto add_again;
} else if (Z_TYPE_P(offset) == IS_NULL) {
} else if (UNEXPECTED(Z_TYPE_P(offset) == IS_NULL)) {
zval tmp;
if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) {
ZVAL_COPY(&tmp, expr_ptr);
}
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) {
/* A userland error handler can do funky things to the expression, so reset it */
zval_ptr_dtor(expr_ptr);
ZVAL_COPY_VALUE(expr_ptr, &tmp);
}
if (UNEXPECTED(EG(exception))) {
zval_ptr_dtor_nogc(expr_ptr);
HANDLE_EXCEPTION();
}
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
@@ -21725,7 +21795,21 @@ num_index:
} else if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(offset) == IS_REFERENCE)) {
offset = Z_REFVAL_P(offset);
goto add_again;
} else if (Z_TYPE_P(offset) == IS_NULL) {
} else if (UNEXPECTED(Z_TYPE_P(offset) == IS_NULL)) {
zval tmp;
if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) {
ZVAL_COPY(&tmp, expr_ptr);
}
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) {
/* A userland error handler can do funky things to the expression, so reset it */
zval_ptr_dtor(expr_ptr);
ZVAL_COPY_VALUE(expr_ptr, &tmp);
}
if (UNEXPECTED(EG(exception))) {
zval_ptr_dtor_nogc(expr_ptr);
HANDLE_EXCEPTION();
}
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
@@ -22183,7 +22267,21 @@ num_index:
} else if ((IS_UNUSED & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(offset) == IS_REFERENCE)) {
offset = Z_REFVAL_P(offset);
goto add_again;
} else if (Z_TYPE_P(offset) == IS_NULL) {
} else if (UNEXPECTED(Z_TYPE_P(offset) == IS_NULL)) {
zval tmp;
if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) {
ZVAL_COPY(&tmp, expr_ptr);
}
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) {
/* A userland error handler can do funky things to the expression, so reset it */
zval_ptr_dtor(expr_ptr);
ZVAL_COPY_VALUE(expr_ptr, &tmp);
}
if (UNEXPECTED(EG(exception))) {
zval_ptr_dtor_nogc(expr_ptr);
HANDLE_EXCEPTION();
}
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
@@ -22590,7 +22688,21 @@ num_index:
} else if ((IS_CV & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(offset) == IS_REFERENCE)) {
offset = Z_REFVAL_P(offset);
goto add_again;
} else if (Z_TYPE_P(offset) == IS_NULL) {
} else if (UNEXPECTED(Z_TYPE_P(offset) == IS_NULL)) {
zval tmp;
if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) {
ZVAL_COPY(&tmp, expr_ptr);
}
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) {
/* A userland error handler can do funky things to the expression, so reset it */
zval_ptr_dtor(expr_ptr);
ZVAL_COPY_VALUE(expr_ptr, &tmp);
}
if (UNEXPECTED(EG(exception))) {
zval_ptr_dtor_nogc(expr_ptr);
HANDLE_EXCEPTION();
}
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
@@ -26533,7 +26645,21 @@ num_index:
} else if ((IS_CONST & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(offset) == IS_REFERENCE)) {
offset = Z_REFVAL_P(offset);
goto add_again;
} else if (Z_TYPE_P(offset) == IS_NULL) {
} else if (UNEXPECTED(Z_TYPE_P(offset) == IS_NULL)) {
zval tmp;
if (IS_VAR == IS_CV || IS_VAR == IS_VAR) {
ZVAL_COPY(&tmp, expr_ptr);
}
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (IS_VAR == IS_CV || IS_VAR == IS_VAR) {
/* A userland error handler can do funky things to the expression, so reset it */
zval_ptr_dtor(expr_ptr);
ZVAL_COPY_VALUE(expr_ptr, &tmp);
}
if (UNEXPECTED(EG(exception))) {
zval_ptr_dtor_nogc(expr_ptr);
HANDLE_EXCEPTION();
}
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
@@ -29085,7 +29211,21 @@ num_index:
} else if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(offset) == IS_REFERENCE)) {
offset = Z_REFVAL_P(offset);
goto add_again;
} else if (Z_TYPE_P(offset) == IS_NULL) {
} else if (UNEXPECTED(Z_TYPE_P(offset) == IS_NULL)) {
zval tmp;
if (IS_VAR == IS_CV || IS_VAR == IS_VAR) {
ZVAL_COPY(&tmp, expr_ptr);
}
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (IS_VAR == IS_CV || IS_VAR == IS_VAR) {
/* A userland error handler can do funky things to the expression, so reset it */
zval_ptr_dtor(expr_ptr);
ZVAL_COPY_VALUE(expr_ptr, &tmp);
}
if (UNEXPECTED(EG(exception))) {
zval_ptr_dtor_nogc(expr_ptr);
HANDLE_EXCEPTION();
}
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
@@ -31191,7 +31331,21 @@ num_index:
} else if ((IS_UNUSED & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(offset) == IS_REFERENCE)) {
offset = Z_REFVAL_P(offset);
goto add_again;
} else if (Z_TYPE_P(offset) == IS_NULL) {
} else if (UNEXPECTED(Z_TYPE_P(offset) == IS_NULL)) {
zval tmp;
if (IS_VAR == IS_CV || IS_VAR == IS_VAR) {
ZVAL_COPY(&tmp, expr_ptr);
}
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (IS_VAR == IS_CV || IS_VAR == IS_VAR) {
/* A userland error handler can do funky things to the expression, so reset it */
zval_ptr_dtor(expr_ptr);
ZVAL_COPY_VALUE(expr_ptr, &tmp);
}
if (UNEXPECTED(EG(exception))) {
zval_ptr_dtor_nogc(expr_ptr);
HANDLE_EXCEPTION();
}
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
@@ -33613,7 +33767,21 @@ num_index:
} else if ((IS_CV & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(offset) == IS_REFERENCE)) {
offset = Z_REFVAL_P(offset);
goto add_again;
} else if (Z_TYPE_P(offset) == IS_NULL) {
} else if (UNEXPECTED(Z_TYPE_P(offset) == IS_NULL)) {
zval tmp;
if (IS_VAR == IS_CV || IS_VAR == IS_VAR) {
ZVAL_COPY(&tmp, expr_ptr);
}
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (IS_VAR == IS_CV || IS_VAR == IS_VAR) {
/* A userland error handler can do funky things to the expression, so reset it */
zval_ptr_dtor(expr_ptr);
ZVAL_COPY_VALUE(expr_ptr, &tmp);
}
if (UNEXPECTED(EG(exception))) {
zval_ptr_dtor_nogc(expr_ptr);
HANDLE_EXCEPTION();
}
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
@@ -46127,7 +46295,21 @@ num_index:
} else if ((IS_CONST & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(offset) == IS_REFERENCE)) {
offset = Z_REFVAL_P(offset);
goto add_again;
} else if (Z_TYPE_P(offset) == IS_NULL) {
} else if (UNEXPECTED(Z_TYPE_P(offset) == IS_NULL)) {
zval tmp;
if (IS_CV == IS_CV || IS_CV == IS_VAR) {
ZVAL_COPY(&tmp, expr_ptr);
}
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (IS_CV == IS_CV || IS_CV == IS_VAR) {
/* A userland error handler can do funky things to the expression, so reset it */
zval_ptr_dtor(expr_ptr);
ZVAL_COPY_VALUE(expr_ptr, &tmp);
}
if (UNEXPECTED(EG(exception))) {
zval_ptr_dtor_nogc(expr_ptr);
HANDLE_EXCEPTION();
}
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
@@ -49967,7 +50149,21 @@ num_index:
} else if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(offset) == IS_REFERENCE)) {
offset = Z_REFVAL_P(offset);
goto add_again;
} else if (Z_TYPE_P(offset) == IS_NULL) {
} else if (UNEXPECTED(Z_TYPE_P(offset) == IS_NULL)) {
zval tmp;
if (IS_CV == IS_CV || IS_CV == IS_VAR) {
ZVAL_COPY(&tmp, expr_ptr);
}
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (IS_CV == IS_CV || IS_CV == IS_VAR) {
/* A userland error handler can do funky things to the expression, so reset it */
zval_ptr_dtor(expr_ptr);
ZVAL_COPY_VALUE(expr_ptr, &tmp);
}
if (UNEXPECTED(EG(exception))) {
zval_ptr_dtor_nogc(expr_ptr);
HANDLE_EXCEPTION();
}
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
@@ -51991,7 +52187,21 @@ num_index:
} else if ((IS_UNUSED & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(offset) == IS_REFERENCE)) {
offset = Z_REFVAL_P(offset);
goto add_again;
} else if (Z_TYPE_P(offset) == IS_NULL) {
} else if (UNEXPECTED(Z_TYPE_P(offset) == IS_NULL)) {
zval tmp;
if (IS_CV == IS_CV || IS_CV == IS_VAR) {
ZVAL_COPY(&tmp, expr_ptr);
}
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (IS_CV == IS_CV || IS_CV == IS_VAR) {
/* A userland error handler can do funky things to the expression, so reset it */
zval_ptr_dtor(expr_ptr);
ZVAL_COPY_VALUE(expr_ptr, &tmp);
}
if (UNEXPECTED(EG(exception))) {
zval_ptr_dtor_nogc(expr_ptr);
HANDLE_EXCEPTION();
}
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
@@ -55725,7 +55935,21 @@ num_index:
} else if ((IS_CV & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(offset) == IS_REFERENCE)) {
offset = Z_REFVAL_P(offset);
goto add_again;
} else if (Z_TYPE_P(offset) == IS_NULL) {
} else if (UNEXPECTED(Z_TYPE_P(offset) == IS_NULL)) {
zval tmp;
if (IS_CV == IS_CV || IS_CV == IS_VAR) {
ZVAL_COPY(&tmp, expr_ptr);
}
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (IS_CV == IS_CV || IS_CV == IS_VAR) {
/* A userland error handler can do funky things to the expression, so reset it */
zval_ptr_dtor(expr_ptr);
ZVAL_COPY_VALUE(expr_ptr, &tmp);
}
if (UNEXPECTED(EG(exception))) {
zval_ptr_dtor_nogc(expr_ptr);
HANDLE_EXCEPTION();
}
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
@@ -63368,7 +63592,21 @@ num_index:
} else if ((IS_CONST & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(offset) == IS_REFERENCE)) {
offset = Z_REFVAL_P(offset);
goto add_again;
} else if (Z_TYPE_P(offset) == IS_NULL) {
} else if (UNEXPECTED(Z_TYPE_P(offset) == IS_NULL)) {
zval tmp;
if (IS_CONST == IS_CV || IS_CONST == IS_VAR) {
ZVAL_COPY(&tmp, expr_ptr);
}
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (IS_CONST == IS_CV || IS_CONST == IS_VAR) {
/* A userland error handler can do funky things to the expression, so reset it */
zval_ptr_dtor(expr_ptr);
ZVAL_COPY_VALUE(expr_ptr, &tmp);
}
if (UNEXPECTED(EG(exception))) {
zval_ptr_dtor_nogc(expr_ptr);
HANDLE_EXCEPTION();
}
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
@@ -65847,7 +66085,21 @@ num_index:
} else if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(offset) == IS_REFERENCE)) {
offset = Z_REFVAL_P(offset);
goto add_again;
} else if (Z_TYPE_P(offset) == IS_NULL) {
} else if (UNEXPECTED(Z_TYPE_P(offset) == IS_NULL)) {
zval tmp;
if (IS_CONST == IS_CV || IS_CONST == IS_VAR) {
ZVAL_COPY(&tmp, expr_ptr);
}
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (IS_CONST == IS_CV || IS_CONST == IS_VAR) {
/* A userland error handler can do funky things to the expression, so reset it */
zval_ptr_dtor(expr_ptr);
ZVAL_COPY_VALUE(expr_ptr, &tmp);
}
if (UNEXPECTED(EG(exception))) {
zval_ptr_dtor_nogc(expr_ptr);
HANDLE_EXCEPTION();
}
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
@@ -66686,7 +66938,21 @@ num_index:
} else if ((IS_UNUSED & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(offset) == IS_REFERENCE)) {
offset = Z_REFVAL_P(offset);
goto add_again;
} else if (Z_TYPE_P(offset) == IS_NULL) {
} else if (UNEXPECTED(Z_TYPE_P(offset) == IS_NULL)) {
zval tmp;
if (IS_CONST == IS_CV || IS_CONST == IS_VAR) {
ZVAL_COPY(&tmp, expr_ptr);
}
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (IS_CONST == IS_CV || IS_CONST == IS_VAR) {
/* A userland error handler can do funky things to the expression, so reset it */
zval_ptr_dtor(expr_ptr);
ZVAL_COPY_VALUE(expr_ptr, &tmp);
}
if (UNEXPECTED(EG(exception))) {
zval_ptr_dtor_nogc(expr_ptr);
HANDLE_EXCEPTION();
}
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
@@ -68301,7 +68567,21 @@ num_index:
} else if ((IS_CV & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(offset) == IS_REFERENCE)) {
offset = Z_REFVAL_P(offset);
goto add_again;
} else if (Z_TYPE_P(offset) == IS_NULL) {
} else if (UNEXPECTED(Z_TYPE_P(offset) == IS_NULL)) {
zval tmp;
if (IS_CONST == IS_CV || IS_CONST == IS_VAR) {
ZVAL_COPY(&tmp, expr_ptr);
}
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (IS_CONST == IS_CV || IS_CONST == IS_VAR) {
/* A userland error handler can do funky things to the expression, so reset it */
zval_ptr_dtor(expr_ptr);
ZVAL_COPY_VALUE(expr_ptr, &tmp);
}
if (UNEXPECTED(EG(exception))) {
zval_ptr_dtor_nogc(expr_ptr);
HANDLE_EXCEPTION();
}
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
@@ -76503,7 +76783,21 @@ num_index:
} else if ((IS_CONST & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(offset) == IS_REFERENCE)) {
offset = Z_REFVAL_P(offset);
goto add_again;
} else if (Z_TYPE_P(offset) == IS_NULL) {
} else if (UNEXPECTED(Z_TYPE_P(offset) == IS_NULL)) {
zval tmp;
if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) {
ZVAL_COPY(&tmp, expr_ptr);
}
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) {
/* A userland error handler can do funky things to the expression, so reset it */
zval_ptr_dtor(expr_ptr);
ZVAL_COPY_VALUE(expr_ptr, &tmp);
}
if (UNEXPECTED(EG(exception))) {
zval_ptr_dtor_nogc(expr_ptr);
HANDLE_EXCEPTION();
}
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
@@ -76947,7 +77241,21 @@ num_index:
} else if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(offset) == IS_REFERENCE)) {
offset = Z_REFVAL_P(offset);
goto add_again;
} else if (Z_TYPE_P(offset) == IS_NULL) {
} else if (UNEXPECTED(Z_TYPE_P(offset) == IS_NULL)) {
zval tmp;
if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) {
ZVAL_COPY(&tmp, expr_ptr);
}
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) {
/* A userland error handler can do funky things to the expression, so reset it */
zval_ptr_dtor(expr_ptr);
ZVAL_COPY_VALUE(expr_ptr, &tmp);
}
if (UNEXPECTED(EG(exception))) {
zval_ptr_dtor_nogc(expr_ptr);
HANDLE_EXCEPTION();
}
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
@@ -77405,7 +77713,21 @@ num_index:
} else if ((IS_UNUSED & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(offset) == IS_REFERENCE)) {
offset = Z_REFVAL_P(offset);
goto add_again;
} else if (Z_TYPE_P(offset) == IS_NULL) {
} else if (UNEXPECTED(Z_TYPE_P(offset) == IS_NULL)) {
zval tmp;
if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) {
ZVAL_COPY(&tmp, expr_ptr);
}
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) {
/* A userland error handler can do funky things to the expression, so reset it */
zval_ptr_dtor(expr_ptr);
ZVAL_COPY_VALUE(expr_ptr, &tmp);
}
if (UNEXPECTED(EG(exception))) {
zval_ptr_dtor_nogc(expr_ptr);
HANDLE_EXCEPTION();
}
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
@@ -77812,7 +78134,21 @@ num_index:
} else if ((IS_CV & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(offset) == IS_REFERENCE)) {
offset = Z_REFVAL_P(offset);
goto add_again;
} else if (Z_TYPE_P(offset) == IS_NULL) {
} else if (UNEXPECTED(Z_TYPE_P(offset) == IS_NULL)) {
zval tmp;
if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) {
ZVAL_COPY(&tmp, expr_ptr);
}
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) {
/* A userland error handler can do funky things to the expression, so reset it */
zval_ptr_dtor(expr_ptr);
ZVAL_COPY_VALUE(expr_ptr, &tmp);
}
if (UNEXPECTED(EG(exception))) {
zval_ptr_dtor_nogc(expr_ptr);
HANDLE_EXCEPTION();
}
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
@@ -81755,7 +82091,21 @@ num_index:
} else if ((IS_CONST & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(offset) == IS_REFERENCE)) {
offset = Z_REFVAL_P(offset);
goto add_again;
} else if (Z_TYPE_P(offset) == IS_NULL) {
} else if (UNEXPECTED(Z_TYPE_P(offset) == IS_NULL)) {
zval tmp;
if (IS_VAR == IS_CV || IS_VAR == IS_VAR) {
ZVAL_COPY(&tmp, expr_ptr);
}
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (IS_VAR == IS_CV || IS_VAR == IS_VAR) {
/* A userland error handler can do funky things to the expression, so reset it */
zval_ptr_dtor(expr_ptr);
ZVAL_COPY_VALUE(expr_ptr, &tmp);
}
if (UNEXPECTED(EG(exception))) {
zval_ptr_dtor_nogc(expr_ptr);
HANDLE_EXCEPTION();
}
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
@@ -84307,7 +84657,21 @@ num_index:
} else if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(offset) == IS_REFERENCE)) {
offset = Z_REFVAL_P(offset);
goto add_again;
} else if (Z_TYPE_P(offset) == IS_NULL) {
} else if (UNEXPECTED(Z_TYPE_P(offset) == IS_NULL)) {
zval tmp;
if (IS_VAR == IS_CV || IS_VAR == IS_VAR) {
ZVAL_COPY(&tmp, expr_ptr);
}
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (IS_VAR == IS_CV || IS_VAR == IS_VAR) {
/* A userland error handler can do funky things to the expression, so reset it */
zval_ptr_dtor(expr_ptr);
ZVAL_COPY_VALUE(expr_ptr, &tmp);
}
if (UNEXPECTED(EG(exception))) {
zval_ptr_dtor_nogc(expr_ptr);
HANDLE_EXCEPTION();
}
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
@@ -86413,7 +86777,21 @@ num_index:
} else if ((IS_UNUSED & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(offset) == IS_REFERENCE)) {
offset = Z_REFVAL_P(offset);
goto add_again;
} else if (Z_TYPE_P(offset) == IS_NULL) {
} else if (UNEXPECTED(Z_TYPE_P(offset) == IS_NULL)) {
zval tmp;
if (IS_VAR == IS_CV || IS_VAR == IS_VAR) {
ZVAL_COPY(&tmp, expr_ptr);
}
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (IS_VAR == IS_CV || IS_VAR == IS_VAR) {
/* A userland error handler can do funky things to the expression, so reset it */
zval_ptr_dtor(expr_ptr);
ZVAL_COPY_VALUE(expr_ptr, &tmp);
}
if (UNEXPECTED(EG(exception))) {
zval_ptr_dtor_nogc(expr_ptr);
HANDLE_EXCEPTION();
}
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
@@ -88835,7 +89213,21 @@ num_index:
} else if ((IS_CV & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(offset) == IS_REFERENCE)) {
offset = Z_REFVAL_P(offset);
goto add_again;
} else if (Z_TYPE_P(offset) == IS_NULL) {
} else if (UNEXPECTED(Z_TYPE_P(offset) == IS_NULL)) {
zval tmp;
if (IS_VAR == IS_CV || IS_VAR == IS_VAR) {
ZVAL_COPY(&tmp, expr_ptr);
}
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (IS_VAR == IS_CV || IS_VAR == IS_VAR) {
/* A userland error handler can do funky things to the expression, so reset it */
zval_ptr_dtor(expr_ptr);
ZVAL_COPY_VALUE(expr_ptr, &tmp);
}
if (UNEXPECTED(EG(exception))) {
zval_ptr_dtor_nogc(expr_ptr);
HANDLE_EXCEPTION();
}
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
@@ -101349,7 +101741,21 @@ num_index:
} else if ((IS_CONST & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(offset) == IS_REFERENCE)) {
offset = Z_REFVAL_P(offset);
goto add_again;
} else if (Z_TYPE_P(offset) == IS_NULL) {
} else if (UNEXPECTED(Z_TYPE_P(offset) == IS_NULL)) {
zval tmp;
if (IS_CV == IS_CV || IS_CV == IS_VAR) {
ZVAL_COPY(&tmp, expr_ptr);
}
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (IS_CV == IS_CV || IS_CV == IS_VAR) {
/* A userland error handler can do funky things to the expression, so reset it */
zval_ptr_dtor(expr_ptr);
ZVAL_COPY_VALUE(expr_ptr, &tmp);
}
if (UNEXPECTED(EG(exception))) {
zval_ptr_dtor_nogc(expr_ptr);
HANDLE_EXCEPTION();
}
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
@@ -105189,7 +105595,21 @@ num_index:
} else if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(offset) == IS_REFERENCE)) {
offset = Z_REFVAL_P(offset);
goto add_again;
} else if (Z_TYPE_P(offset) == IS_NULL) {
} else if (UNEXPECTED(Z_TYPE_P(offset) == IS_NULL)) {
zval tmp;
if (IS_CV == IS_CV || IS_CV == IS_VAR) {
ZVAL_COPY(&tmp, expr_ptr);
}
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (IS_CV == IS_CV || IS_CV == IS_VAR) {
/* A userland error handler can do funky things to the expression, so reset it */
zval_ptr_dtor(expr_ptr);
ZVAL_COPY_VALUE(expr_ptr, &tmp);
}
if (UNEXPECTED(EG(exception))) {
zval_ptr_dtor_nogc(expr_ptr);
HANDLE_EXCEPTION();
}
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
@@ -107111,7 +107531,21 @@ num_index:
} else if ((IS_UNUSED & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(offset) == IS_REFERENCE)) {
offset = Z_REFVAL_P(offset);
goto add_again;
} else if (Z_TYPE_P(offset) == IS_NULL) {
} else if (UNEXPECTED(Z_TYPE_P(offset) == IS_NULL)) {
zval tmp;
if (IS_CV == IS_CV || IS_CV == IS_VAR) {
ZVAL_COPY(&tmp, expr_ptr);
}
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (IS_CV == IS_CV || IS_CV == IS_VAR) {
/* A userland error handler can do funky things to the expression, so reset it */
zval_ptr_dtor(expr_ptr);
ZVAL_COPY_VALUE(expr_ptr, &tmp);
}
if (UNEXPECTED(EG(exception))) {
zval_ptr_dtor_nogc(expr_ptr);
HANDLE_EXCEPTION();
}
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
@@ -110845,7 +111279,21 @@ num_index:
} else if ((IS_CV & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(offset) == IS_REFERENCE)) {
offset = Z_REFVAL_P(offset);
goto add_again;
} else if (Z_TYPE_P(offset) == IS_NULL) {
} else if (UNEXPECTED(Z_TYPE_P(offset) == IS_NULL)) {
zval tmp;
if (IS_CV == IS_CV || IS_CV == IS_VAR) {
ZVAL_COPY(&tmp, expr_ptr);
}
zend_error(E_DEPRECATED, "Using null as an array offset is deprecated, use an empty string instead");
if (IS_CV == IS_CV || IS_CV == IS_VAR) {
/* A userland error handler can do funky things to the expression, so reset it */
zval_ptr_dtor(expr_ptr);
ZVAL_COPY_VALUE(expr_ptr, &tmp);
}
if (UNEXPECTED(EG(exception))) {
zval_ptr_dtor_nogc(expr_ptr);
HANDLE_EXCEPTION();
}
str = ZSTR_EMPTY_ALLOC();
goto str_index;
} else if (Z_TYPE_P(offset) == IS_DOUBLE) {

View File

@@ -118,7 +118,7 @@ $stmt = null;
// 12. Only list arrays are allowed
$stmt = $link->prepare('SELECT label, ? AS anon, ? AS num FROM test WHERE id=?');
try {
$stmt->execute(['A'=>'abc', 2=>42, null=>$id]);
$stmt->execute(['A'=>'abc', 2=>42, ''=>$id]);
} catch (ValueError $e) {
echo '[008] '.$e->getMessage()."\n";
}

View File

@@ -21,18 +21,6 @@ var_dump(
)
);
var_dump(
preg_replace_callback_array(
[
'/a/' => 'b',
null => function () {
return 'ok';
},
],
'a'
)
);
// backslashes
var_dump(
@@ -92,9 +80,6 @@ var_dump(
Warning: preg_replace_callback_array(): Empty regular expression in %spreg_replace_callback_array_error.php on line %d
NULL
Warning: preg_replace_callback_array(): Empty regular expression in %spreg_replace_callback_array_error.php on line %d
NULL
Warning: preg_replace_callback_array(): Delimiter must not be alphanumeric, backslash, or NUL byte in %spreg_replace_callback_array_error.php on line %d
NULL

View File

@@ -1,10 +1,10 @@
--TEST--
SPL: ArrayIterator with NULL key
SPL: ArrayIterator with empty string key
--FILE--
<?php
$ar = new ArrayIterator(array(NULL=>NULL));
@var_dump($ar);
$ar = new ArrayIterator(array(''=>NULL));
var_dump($ar);
var_dump($ar->getArrayCopy());
?>

View File

@@ -1,17 +1,17 @@
--TEST--
SPL: ArrayIterator with NULL key
SPL: ArrayIterator with empty string key
--FILE--
<?php
$ar = new ArrayIterator(array(
NULL=>1,
''=>1,
"\0"=>2,
"\0\0"=>3,
"\0\0\0"=>4,
"\0*"=>5,
"\0*\0"=>6,
));
@var_dump($ar);
var_dump($ar);
var_dump($ar->getArrayCopy());
?>

View File

@@ -21,4 +21,6 @@ try {
?>
--EXPECTF--
Deprecated: Implicit conversion from float 2.5 to int loses precision in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Cannot access offset of type array on array

View File

@@ -5,7 +5,7 @@ Rohan Abraham (rohanabrahams@gmail.com)
TestFest London May 2009
--FILE--
<?php
$ar = array("one"=>1, "two"=>2, "three"=>array("four"=>4, "five"=>5, "six"=>array("seven"=>7)), "eight"=>8, -100 => 10, NULL => "null");
$ar = array("one"=>1, "two"=>2, "three"=>array("four"=>4, "five"=>5, "six"=>array("seven"=>7)), "eight"=>8, -100 => 10, '' => "null");
$it = new RecursiveArrayIterator($ar);
$it = new RecursiveIteratorIterator($it);
foreach($it as $k=>$v)

View File

@@ -18,7 +18,7 @@ $mixed_array = array(
array( "1" => "one", "2" => "two", "3" => "three", "4" => "four", "5" => "five" ),
array( 1 => "one", 2 => "two", 3 => 7, 4 => "four", 5 => "five" ),
array( "f" => "fff", "1" => "one", 4 => 6, "" => "blank", 2 => "float", "F" => "FFF",
"blank" => "", 3 => 3.7, 5 => 7, 6 => 8.6, '5' => "Five", "4name" => "jonny", "a" => NULL, NULL => 3 ),
"blank" => "", 3 => 3.7, 5 => 7, 6 => 8.6, '5' => "Five", "4name" => "jonny", "a" => NULL),
array( 12, "name", 'age', '45' ),
array( array("oNe", "tWo", 4), array(10, 20, 30, 40, 50), array() ),
array( "one" => 1, "one" => 2, "three" => 3, 3, 4, 3 => 33, 4 => 44, 5, 6,
@@ -202,7 +202,7 @@ array(12) {
[4]=>
int(6)
[""]=>
int(3)
string(5) "blank"
[2]=>
string(5) "float"
["F"]=>

View File

@@ -9,76 +9,28 @@ Test array_change_key_case() function : usage variations - different data types
echo "*** Testing array_change_key_case() : usage variations ***\n";
//get an unset variable
$unset_var = 10;
unset ($unset_var);
// heredoc string
$heredoc = <<<EOT
hello world
EOT;
// arrays of different data types to be passed to $input argument
$inputs = array(
// int data
/*1*/ 'int' => array(
$inputs = [
'int' => [
0 => 'zero',
1 => 'one',
12345 => 'positive',
-2345 => 'negative',
),
// null data
/*3*/ 'null uppercase' => array(
NULL => 'null 1',
),
'null lowercase' => array(
null => 'null 2',
),
// boolean data
/*4*/ 'bool lowercase' => array(
true => 'lowert',
false => 'lowerf',
),
'bool uppercase' => array(
TRUE => 'uppert',
FALSE => 'upperf',
),
// empty data
/*5*/ 'empty double quotes' => array(
"" => 'emptyd',
),
'empty single quotes' => array(
'' => 'emptys',
),
// string data
/*6*/ 'string' => array(
"stringd" => 'stringd',
],
'bool' => [
true => 'true',
false => 'false',
],
'string' => [
'strings' => 'strings',
$heredoc => 'stringh',
),
// undefined data
/*8*/ 'undefined' => array(
@$undefined_var => 'undefined',
),
// unset data
/*9*/ 'unset' => array(
@$unset_var => 'unset',
),
);
'' => 'emptys',
],
];
// loop through each sub-array of $inputs to check the behavior of array_change_key_case()
$iterator = 1;
foreach($inputs as $key => $input) {
echo "\n-- Iteration $iterator : $key data --\n";
echo "\n-- $key data --\n";
var_dump( array_change_key_case($input, CASE_UPPER) );
$iterator++;
};
echo "Done";
@@ -86,7 +38,7 @@ echo "Done";
--EXPECT--
*** Testing array_change_key_case() : usage variations ***
-- Iteration 1 : int data --
-- int data --
array(4) {
[0]=>
string(4) "zero"
@@ -98,65 +50,19 @@ array(4) {
string(8) "negative"
}
-- Iteration 2 : null uppercase data --
array(1) {
[""]=>
string(6) "null 1"
}
-- Iteration 3 : null lowercase data --
array(1) {
[""]=>
string(6) "null 2"
}
-- Iteration 4 : bool lowercase data --
-- bool data --
array(2) {
[1]=>
string(6) "lowert"
string(4) "true"
[0]=>
string(6) "lowerf"
string(5) "false"
}
-- Iteration 5 : bool uppercase data --
-- string data --
array(2) {
[1]=>
string(6) "uppert"
[0]=>
string(6) "upperf"
}
-- Iteration 6 : empty double quotes data --
array(1) {
[""]=>
string(6) "emptyd"
}
-- Iteration 7 : empty single quotes data --
array(1) {
["STRINGS"]=>
string(7) "strings"
[""]=>
string(6) "emptys"
}
-- Iteration 8 : string data --
array(3) {
["STRINGD"]=>
string(7) "stringd"
["STRINGS"]=>
string(7) "strings"
["HELLO WORLD"]=>
string(7) "stringh"
}
-- Iteration 9 : undefined data --
array(1) {
[""]=>
string(9) "undefined"
}
-- Iteration 10 : unset data --
array(1) {
[""]=>
string(5) "unset"
}
Done

View File

@@ -10,7 +10,7 @@ echo "*** Testing array_change_key_case() : usage variations ***\n";
$inputs = array (
// group of escape sequences
array(null => 1, NULL => 2, "\a" => 3, "\cx" => 4, "\e" => 5, "\f" => 6, "\n" => 7, "\t" => 8, "\xhh" => 9, "\ddd" => 10, "\v" => 11),
array("\a" => 3, "\cx" => 4, "\e" => 5, "\f" => 6, "\n" => 7, "\t" => 8, "\xhh" => 9, "\ddd" => 10, "\v" => 11),
// array contains combination of capital/small letters
array("lemoN" => 1, "Orange" => 2, "banana" => 3, "apple" => 4, "Test" => 5, "TTTT" => 6, "ttt" => 7, "ww" => 8, "x" => 9, "X" => 10, "oraNGe" => 11, "BANANA" => 12)
@@ -29,9 +29,7 @@ echo "Done";
*** Testing array_change_key_case() : usage variations ***
-- $case = default --
array(10) {
[""]=>
int(2)
array(9) {
["\a"]=>
int(3)
["\cx"]=>
@@ -53,9 +51,7 @@ array(10) {
int(11)
}
-- $case = upper --
array(10) {
[""]=>
int(2)
array(9) {
["\A"]=>
int(3)
["\CX"]=>

View File

@@ -23,13 +23,6 @@ the lazy dog
This is a double quoted string
EOT;
// heredoc with different whitespaces
$diff_whitespaces = <<<EOT
hello\r world\t
1111\t\t != 2222\v\v
heredoc\ndouble quoted string. with\vdifferent\fwhite\vspaces
EOT;
// heredoc with quoted strings and numeric values
$numeric_string = <<<EOT
11 < 12. 123 >22
@@ -45,9 +38,9 @@ $arrays = array (
array(false,true), // with default keys and boolean values
array(), // empty array
/*5*/ array(NULL), // with NULL
array("a\v\f","aaaa\r","b","b\tbbb","c","\[\]\!\@\#\$\%\^\&\*\(\)\{\}"), // with double quoted strings
array('a\v\f','aaaa\r','b','b\tbbb','c','\[\]\!\@\#\$\%\^\&\*\(\)\{\}'), // with single quoted strings
array("h1" => $blank_line, "h2" => $multiline_string, "h3" => $diff_whitespaces, $numeric_string), // with heredocs
array("a\v\f","aaaa\n","b","b\tbbb","c","\[\]\!\@\#\$\%\^\&\*\(\)\{\}"), // with double quoted strings
array('a\v\f','aaaa\n','b','b\tbbb','c','\[\]\!\@\#\$\%\^\&\*\(\)\{\}'), // with single quoted strings
array("h1" => $blank_line, "h2" => $multiline_string, $numeric_string), // with heredocs
// associative arrays
/*9*/ array(1 => "one", 2 => "two", 3 => "three"), // explicit numeric keys, string values
@@ -57,11 +50,11 @@ $arrays = array (
array("one" => 1, 2 => "two", 4 => "four"), //mixed
// associative array, containing null/empty/boolean values as key/value
/*14*/ array(NULL => "NULL", null => "null", "NULL" => NULL, "null" => null),
/*14*/
array(true => "true", false => "false", "false" => false, "true" => true),
array("" => "emptyd", '' => 'emptys', "emptyd" => "", 'emptys' => ''),
array(1 => '', 2 => "", 3 => NULL, 4 => null, 5 => false, 6 => true),
array('' => 1, "" => 2, NULL => 3, null => 4, false => 5, true => 6),
array(1 => '', 2 => "", 5 => false, 6 => true),
array('' => 1, "" => 2, false => 5, true => 6),
// array with repetitive keys
/*19*/ array("One" => 1, "two" => 2, "One" => 10, "two" => 20, "three" => 3)
@@ -113,8 +106,10 @@ array(1) {
array(6) {
["a "]=>
string(3) "a "
["aaaa "]=>
string(5) "aaaa "
["aaaa
"]=>
string(5) "aaaa
"
["b"]=>
string(1) "b"
["b bbb"]=>
@@ -128,8 +123,8 @@ array(6) {
array(6) {
["a\v\f"]=>
string(5) "a\v\f"
["aaaa\r"]=>
string(6) "aaaa\r"
["aaaa\n"]=>
string(6) "aaaa\n"
["b"]=>
string(1) "b"
["b\tbbb"]=>
@@ -140,7 +135,7 @@ array(6) {
string(28) "\[\]\!\@\#\$\%\^\&\*\(\)\{\}"
}
-- Iteration 8 --
array(4) {
array(3) {
["
"]=>
string(1) "
@@ -153,14 +148,6 @@ This is a double quoted string"]=>
The quick brown fox jumped over;
the lazy dog
This is a double quoted string"
["hello world
1111 != 2222
heredoc
double quoted string. with different white spaces"]=>
string(88) "hello world
1111 != 2222
heredoc
double quoted string. with different white spaces"
["11 < 12. 123 >22
'single quoted string'
"double quoted string"
@@ -220,13 +207,6 @@ array(3) {
string(4) "four"
}
-- Iteration 14 --
array(2) {
["null"]=>
string(4) "null"
[""]=>
NULL
}
-- Iteration 15 --
array(4) {
["true"]=>
string(4) "true"
@@ -237,30 +217,30 @@ array(4) {
[1]=>
bool(true)
}
-- Iteration 16 --
-- Iteration 15 --
array(2) {
["emptys"]=>
string(6) "emptys"
[""]=>
string(0) ""
}
-- Iteration 17 --
-- Iteration 16 --
array(2) {
[""]=>
bool(false)
[1]=>
bool(true)
}
-- Iteration 18 --
-- Iteration 17 --
array(3) {
[4]=>
int(4)
[2]=>
int(2)
[5]=>
int(5)
[6]=>
int(6)
}
-- Iteration 19 --
-- Iteration 18 --
array(3) {
[10]=>
int(10)

View File

@@ -9,9 +9,6 @@ Test array_combine() function : usage variations - associative array with differ
*/
echo "*** Testing array_combine() : assoc array with diff keys to both \$keys and \$values argument ***\n";
// get an unset variable
$unset_var = 10;
unset ($unset_var);
// get a resource variable
$fp = fopen(__FILE__, "r");
@@ -24,11 +21,6 @@ class classA
}
}
// get a heredoc string
$heredoc = <<<EOT
Hello world
EOT;
// different variations of associative arrays to be passed to $arr1 argument
$arrays = array (
@@ -45,15 +37,14 @@ $arrays = array (
'\v\fworld' => 2.2, 'pen\n' => 33),
array("\tHello" => 111, "re\td" => "color",
"\v\fworld" => 2.2, "pen\n" => 33),
array("hello", $heredoc => "string"), // heredoc
// array with object, unset variable and resource variable
/*10*/ array(@$unset_var => "hello", $fp => 'resource'),
/*10*/ array($fp => 'resource'),
// array with mixed keys
/*11*/ array('hello' => 1, "fruit" => 2.2,
$fp => 'resource', 133 => "int",
@$unset_var => "unset", $heredoc => "heredoc")
)
);
// array to be passsed to $arr2 argument
@@ -128,21 +119,12 @@ array(4) {
int(33)
}
-- Iteration 7 --
array(2) {
["hello"]=>
string(5) "hello"
["string"]=>
string(6) "string"
}
-- Iteration 8 --
array(2) {
["hello"]=>
string(5) "hello"
array(1) {
["resource"]=>
string(8) "resource"
}
-- Iteration 9 --
array(6) {
-- Iteration 8 --
array(4) {
[1]=>
int(1)
["2.2"]=>
@@ -151,9 +133,5 @@ array(6) {
string(8) "resource"
["int"]=>
string(3) "int"
["unset"]=>
string(5) "unset"
["heredoc"]=>
string(7) "heredoc"
}
Done

View File

@@ -1,52 +0,0 @@
--TEST--
Test array_diff_key() function : usage variation - Passing null,unset and undefined variable indexed array
--FILE--
<?php
echo "*** Testing array_diff_key() : usage variation ***\n";
// Initialise function arguments not being substituted (if any)
$input_array = array(10 => '10', "" => 'empty');
//get an unset variable
$unset_var = 10;
unset ($unset_var);
$input_arrays = array(
'null indexed' => array(NULL => 'null 1', null => 'null 2'),
'undefined indexed' => array(@$undefined_var => 'undefined'),
'unset indexed' => array(@$unset_var => 'unset'),
);
foreach($input_arrays as $key =>$value) {
echo "\n--$key--\n";
// loop through each element of the array for arr1
var_dump( array_diff_key($input_array, $value) );
var_dump( array_diff_key($value, $input_array) );
}
?>
--EXPECT--
*** Testing array_diff_key() : usage variation ***
--null indexed--
array(1) {
[10]=>
string(2) "10"
}
array(0) {
}
--undefined indexed--
array(1) {
[10]=>
string(2) "10"
}
array(0) {
}
--unset indexed--
array(1) {
[10]=>
string(2) "10"
}
array(0) {
}

View File

@@ -1,52 +0,0 @@
--TEST--
Test array_diff_uassoc() function : usage variation - Passing null,unset and undefined variable indexed array
--FILE--
<?php
echo "*** Testing array_diff_uassoc() : usage variation ***\n";
// Initialise function arguments not being substituted (if any)
$input_array = array(10 => '10', "" => '');
//get an unset variable
$unset_var = 10;
unset ($unset_var);
$input_arrays = array(
'null indexed' => array(NULL => NULL, null => null),
'undefined indexed' => array(@$undefined_var => @$undefined_var),
'unset indexed' => array(@$unset_var => @$unset_var),
);
foreach($input_arrays as $key =>$value) {
echo "\n--$key--\n";
var_dump( array_diff_uassoc($input_array, $value, "strcasecmp") );
var_dump( array_diff_uassoc($value, $input_array, "strcasecmp") );
}
?>
--EXPECT--
*** Testing array_diff_uassoc() : usage variation ***
--null indexed--
array(1) {
[10]=>
string(2) "10"
}
array(0) {
}
--undefined indexed--
array(1) {
[10]=>
string(2) "10"
}
array(0) {
}
--unset indexed--
array(1) {
[10]=>
string(2) "10"
}
array(0) {
}

View File

@@ -1,52 +0,0 @@
--TEST--
Test array_diff_ukey() function : usage variation - Passing null,unset and undefined variable indexed array
--FILE--
<?php
echo "*** Testing array_diff_ukey() : usage variation ***\n";
// Initialise function arguments not being substituted (if any)
$input_array = array(10 => '10', "" => 'empty');
//get an unset variable
$unset_var = 10;
unset ($unset_var);
$input_arrays = array(
'null indexed' => array(NULL => 'null 1', null => 'null 2'),
'undefined indexed' => array(@$undefined_var => 'undefined'),
'unset indexed' => array(@$unset_var => 'unset'),
);
foreach($input_arrays as $key =>$value) {
echo "\n--$key--\n";
var_dump( array_diff_ukey($value, $input_array, 'strcasecmp') );
var_dump( array_diff_ukey($input_array, $value, 'strcasecmp') );
}
?>
--EXPECT--
*** Testing array_diff_ukey() : usage variation ***
--null indexed--
array(0) {
}
array(1) {
[10]=>
string(2) "10"
}
--undefined indexed--
array(0) {
}
array(1) {
[10]=>
string(2) "10"
}
--unset indexed--
array(0) {
}
array(1) {
[10]=>
string(2) "10"
}

View File

@@ -23,10 +23,9 @@ $values = array(
/* 5 */ array('color' => 'red' , 'item' => 'pen'),
array( 'color' => 'red' , 2 => 'green ' ),
array("colour" => "red" , "item" => "pen"),
array( TRUE => "red" , FALSE => "green" ),
array( true => "red" , FALSE => "green" ),
array( true => "red" , false => "green" ),
/* 10 */ array( 1 => "Hi" , "color" => "red" , 'item' => 'pen'),
array( NULL => "Hi", '1' => "Hello" , "1" => "Green"),
array( '' => "Hi", '1' => "Hello" , "1" => "Green"),
array( ""=>1, "color" => "green"),
/* 13 */ array('Saffron' , 'White' , 'Green')
);
@@ -193,39 +192,39 @@ array(2) {
-- Iteration 9 --
array(2) {
[0]=>
array(2) {
array(3) {
[1]=>
string(2) "Hi"
["color"]=>
string(3) "red"
[0]=>
string(5) "green"
["item"]=>
string(3) "pen"
}
[1]=>
array(2) {
array(3) {
[1]=>
string(2) "Hi"
["color"]=>
string(3) "red"
[0]=>
string(5) "green"
["item"]=>
string(3) "pen"
}
}
-- Iteration 10 --
array(2) {
[0]=>
array(3) {
[1]=>
array(2) {
[""]=>
string(2) "Hi"
["color"]=>
string(3) "red"
["item"]=>
string(3) "pen"
[1]=>
string(5) "Green"
}
[1]=>
array(3) {
[1]=>
array(2) {
[""]=>
string(2) "Hi"
["color"]=>
string(3) "red"
["item"]=>
string(3) "pen"
[1]=>
string(5) "Green"
}
}
-- Iteration 11 --
@@ -233,36 +232,19 @@ array(2) {
[0]=>
array(2) {
[""]=>
string(2) "Hi"
[1]=>
string(5) "Green"
int(1)
["color"]=>
string(5) "green"
}
[1]=>
array(2) {
[""]=>
string(2) "Hi"
[1]=>
string(5) "Green"
int(1)
["color"]=>
string(5) "green"
}
}
-- Iteration 12 --
array(2) {
[0]=>
array(2) {
[""]=>
int(1)
["color"]=>
string(5) "green"
}
[1]=>
array(2) {
[""]=>
int(1)
["color"]=>
string(5) "green"
}
}
-- Iteration 13 --
array(2) {
[0]=>
array(3) {

View File

@@ -24,11 +24,10 @@ $input_values = array(
array(0, 1, 2, -1, 034, 0X4A), // integer values
array(0.0, 1.2, 1.2e3, 1.2e-3), // float values
array('value1', "value2", '', " ", ""), // string values
array(true, false, TRUE, FALSE), // bool values
array(null, NULL), // null values
array(true, false), // bool values
array(1 => 'one', 'zero' => 0, -2 => "value"), //associative array
array("one" => 1, null => 'null', 5 => "float", true => 1, "" => 'empty'), // associative array with different keys
array(1 => 'one', 2, "key" => 'value') // combinition of associative and non-associative array
array("one" => 1, 5 => "float", true => 1, "" => 'empty'), // associative array with different keys
array(1 => 'one', 2, "key" => 'value') // combination of associative and non-associative array
);
@@ -119,36 +118,19 @@ array(5) {
array(0) {
}
-- Iteration 4 --
array(1) {
[0]=>
bool(true)
}
array(2) {
[0]=>
bool(true)
[2]=>
bool(true)
}
array(4) {
[0]=>
bool(true)
[1]=>
bool(false)
[2]=>
bool(true)
[3]=>
bool(false)
}
array(0) {
}
-- Iteration 5 --
array(0) {
}
array(2) {
[0]=>
NULL
[1]=>
NULL
}
array(0) {
}
-- Iteration 6 --
array(2) {
[1]=>
string(3) "one"
@@ -165,30 +147,30 @@ array(3) {
}
array(0) {
}
-- Iteration 7 --
-- Iteration 6 --
array(4) {
["one"]=>
int(1)
[""]=>
string(5) "empty"
[5]=>
string(5) "float"
[1]=>
int(1)
[""]=>
string(5) "empty"
}
array(4) {
["one"]=>
int(1)
[""]=>
string(5) "empty"
[5]=>
string(5) "float"
[1]=>
int(1)
[""]=>
string(5) "empty"
}
array(0) {
}
-- Iteration 8 --
-- Iteration 7 --
array(3) {
[1]=>
string(3) "one"

View File

@@ -8,25 +8,12 @@ Test array_flip() function : usage variations - 'input' array with different key
echo "*** Testing array_flip() : different keys for 'input' array argument ***\n";
// different heredoc strings
$empty_heredoc = <<<EOT1
EOT1;
$simple_heredoc = <<<EOT4
simple
EOT4;
$multiline_heredoc = <<<EOT7
multiline heredoc with 123 and
speci@! ch@r$...checking\nand\talso
EOT7;
$input = array(
// default key
'one', //expected: default key 0, value will be replaced by 'bool_key4'
'one', //expected: default key 0, value will be replaced by 'bool_key2'
// numeric keys
1 => 'int_key', // expected: value will be replaced by 'bool_key3'
1 => 'int_key', // expected: value will be replaced by 'bool_key1'
-2 => 'negative_key',
012 => 'octal_key',
0x34 => 'hex_key',
@@ -41,21 +28,10 @@ $input = array(
// bool keys
true => 'bool_key1',
false => 'bool_key2',
TRUE => 'bool_key3',
FALSE => 'bool_key4',
// null keys
null => 'null_key1', // expected: value will be replaced by 'null_key2'
NULL => 'null_key2',
// binary key
"a".chr(0)."b" => 'binary_key1',
b"binary" => 'binary_key2',
//heredoc keys
$empty_heredoc => 'empty_heredoc',
$simple_heredoc => 'simple_heredoc',
$multiline_heredoc => 'multiline_heredoc',
);
var_dump( array_flip($input) );
@@ -64,10 +40,10 @@ echo "Done"
?>
--EXPECTF--
*** Testing array_flip() : different keys for 'input' array argument ***
array(13) {
["bool_key4"]=>
array(11) {
["bool_key2"]=>
int(0)
["bool_key3"]=>
["bool_key1"]=>
int(1)
["negative_key"]=>
int(-2)
@@ -79,7 +55,7 @@ array(13) {
string(3) "key"
["string_key2"]=>
string(3) "two"
["empty_heredoc"]=>
["string_key4"]=>
string(0) ""
["string_key5"]=>
string(1) " "
@@ -87,11 +63,5 @@ array(13) {
string(3) "a%0b"
["binary_key2"]=>
string(6) "binary"
["simple_heredoc"]=>
string(6) "simple"
["multiline_heredoc"]=>
string(6%d) "multiline heredoc with 123 and
speci@! ch@r$...checking
and also"
}
Done

View File

@@ -3,39 +3,35 @@ Test array_flip() function : usage variations - 'input' argument with repeatitiv
--FILE--
<?php
/*
* Using different types of repeatitive keys as well as values for 'input' array
* Using different types of repetitive keys as well as values for 'input' array
*/
echo "*** Testing array_flip() : 'input' array with repeatitive keys/values ***\n";
echo "*** Testing array_flip() : 'input' array with repetitive keys/values ***\n";
// array with numeric key repeatition
// array with numeric key repetition
$input = array(1 => 'value', 2 => 'VALUE', 1 => "VaLuE", 3 => 4, 3 => 5);
var_dump( array_flip($input) );
// array with string key repeatition
// array with string key repetition
$input = array("key" => 1, "two" => 'TWO', 'three' => 3, 'key' => "FOUR");
var_dump( array_flip($input) );
// array with bool key repeatition
// array with bool key repetition
$input = array(true => 1, false => 0, TRUE => -1);
var_dump( array_flip($input) );
// array with null key repeatition
$input = array(null => "Hello", NULL => 0);
var_dump( array_flip($input) );
// array with numeric value repeatition
// array with numeric value repetition
$input = array('one' => 1, 'two' => 2, 3 => 1, "index" => 1);
var_dump( array_flip($input) );
//array with string value repeatition
//array with string value repetition
$input = array('key1' => "value1", "key2" => '2', 'key3' => 'value1');
var_dump( array_flip($input) );
echo "Done"
?>
--EXPECT--
*** Testing array_flip() : 'input' array with repeatitive keys/values ***
*** Testing array_flip() : 'input' array with repetitive keys/values ***
array(3) {
["VaLuE"]=>
int(1)
@@ -58,10 +54,6 @@ array(2) {
[0]=>
int(0)
}
array(1) {
[0]=>
string(0) ""
}
array(2) {
[1]=>
string(5) "index"

View File

@@ -25,13 +25,6 @@ the lazy dog
This is a double quoted string
EOT;
// heredoc with different whitespaces
$diff_whitespaces = <<<EOT
hello\r world\t
1111\t\t != 2222\v\v
heredoc\ndouble quoted string. with\vdifferent\fwhite\vspaces
EOT;
// heredoc with quoted strings and numeric values
$numeric_string = <<<EOT
11 < 12. 123 >22
@@ -49,7 +42,7 @@ $arrays = array (
/*5*/ array(NULL), // with NULL
array("a\v\f","aaaa\r","b","b\tbbb","c","\[\]\!\@\#\$\%\^\&\*\(\)\{\}"), // with double quoted strings
array('a\v\f','aaaa\r','b','b\tbbb','c','\[\]\!\@\#\$\%\^\&\*\(\)\{\}'), // with single quoted strings
array("h1" => $blank_line, "h2" => $multiline_string, "h3" => $diff_whitespaces, $numeric_string), // with heredocs
array("h1" => $blank_line, "h2" => $multiline_string, $numeric_string), // with heredocs
// associative arrays
/*9*/ array(1 => "one", 2 => "two", 3 => "three"), // explicit numeric keys, string values
@@ -59,11 +52,10 @@ $arrays = array (
array("one" => 1, 2 => "two", 4 => "four"), //mixed
// associative array, containing null/empty/boolean values as key/value
/*14*/ array(NULL => "NULL", null => "null", "NULL" => NULL, "null" => null),
array(true => "true", false => "false", "false" => false, "true" => true),
/*14*/ array(true => "true", false => "false", "false" => false, "true" => true),
array("" => "emptyd", '' => 'emptys', "emptyd" => "", 'emptys' => ''),
array(1 => '', 2 => "", 3 => NULL, 4 => null, 5 => false, 6 => true),
array('' => 1, "" => 2, NULL => 3, null => 4, false => 5, true => 6),
array('' => 1, "" => 2, false => 5, true => 6),
// array with repetitive keys
/*19*/ array("One" => 1, "two" => 2, "One" => 10, "two" => 20, "three" => 3)
@@ -74,9 +66,9 @@ $arrays = array (
$arr2 = array (
1, 1.1, 2.2, "hello", "one", NULL, 2,
'world', true,5 => false, 1 => 'aaaa\r', "aaaa\r",
'h3' => $diff_whitespaces, $numeric_string,
$numeric_string,
"one" => "ten", 4 => "four", "two" => 2,
'', null => "null", '' => 'emptys', "emptyd" => "",
'', '' => 'emptys', "emptyd" => "",
);
// loop through each sub-array within $arrays to check the behavior of array_intersect_assoc()
@@ -141,19 +133,9 @@ array(1) {
string(6) "aaaa\r"
}
-- Iteration 8 --
array(1) {
["h3"]=>
string(88) "hello world
1111 != 2222
heredoc
double quoted string. with different white spaces"
array(0) {
}
array(1) {
["h3"]=>
string(88) "hello world
1111 != 2222
heredoc
double quoted string. with different white spaces"
array(0) {
}
-- Iteration 9 --
array(0) {
@@ -198,40 +180,35 @@ array(0) {
array(0) {
}
-- Iteration 15 --
array(0) {
array(2) {
[""]=>
string(6) "emptys"
["emptyd"]=>
string(0) ""
}
array(0) {
array(2) {
[""]=>
string(6) "emptys"
["emptyd"]=>
string(0) ""
}
-- Iteration 16 --
array(2) {
[""]=>
string(6) "emptys"
["emptyd"]=>
string(0) ""
array(1) {
[5]=>
bool(false)
}
array(2) {
[""]=>
string(6) "emptys"
["emptyd"]=>
string(0) ""
array(1) {
[5]=>
bool(false)
}
-- Iteration 17 --
array(1) {
[5]=>
bool(false)
array(0) {
}
array(1) {
[5]=>
bool(false)
array(0) {
}
-- Iteration 18 --
array(0) {
}
array(0) {
}
-- Iteration 19 --
array(0) {
}
array(0) {
}
Done

View File

@@ -25,13 +25,6 @@ the lazy dog
This is a double quoted string
EOT;
// heredoc with different whitespaces
$diff_whitespaces = <<<EOT
hello\r world\t
1111\t\t != 2222\v\v
heredoc\ndouble quoted string. with\vdifferent\fwhite\vspaces
EOT;
// heredoc with quoted strings and numeric values
$numeric_string = <<<EOT
11 < 12. 123 >22
@@ -40,13 +33,13 @@ $numeric_string = <<<EOT
2222 != 1111.\t 0000 = 0000\n
EOT;
// array to be passsed to $arr1 argument
// array to be passed to $arr1 argument
$arr1 = array (
1, 1.1, 1.3, 1 => true, "hello", "one", NULL, 2,
'world', true, false, 3 => "b\tbbb", "aaaa\r",
$numeric_string, "h3" => $diff_whitespaces, "true" => true,
$numeric_string, "true" => true,
"one" => "ten", 4 => "four", "two" => 2, 6 => "six",
'', null => "null", '' => 'emptys'
'', '' => 'emptys'
);
// arrays to be passed to $arr2 argument
@@ -58,7 +51,7 @@ $arrays = array (
/*5*/ array(NULL), // array with NULL
array("a\v\f","aaaa\r","b","b\tbbb","c","\[\]\!\@\#\$\%\^\&\*\(\)\{\}"), // array with double quoted strings
array('a\v\f','aaaa\r','b','b\tbbb','c','\[\]\!\@\#\$\%\^\&\*\(\)\{\}'), // array with single quoted strings
array($blank_line, "h2" => $multiline_string, "h3" => $diff_whitespaces, $numeric_string), // array with heredocs
array($blank_line, "h2" => $multiline_string, $numeric_string), // array with heredocs
// associative arrays
/*9*/ array(1 => "one", 2 => "two", 6 => "six"), // explicit numeric keys, string values
@@ -68,11 +61,10 @@ $arrays = array (
array("one" => 1, 2 => "two", 4 => "four"), //mixed
// associative array, containing null/empty/boolean values as key/value
/*14*/ array(NULL => "NULL", null => "null", "NULL" => NULL, "null" => null),
array(true => "true", false => "false", "false" => false, "true" => true),
/*14*/ array(true => "true", false => "false", "false" => false, "true" => true),
array("" => "emptyd", '' => 'emptys', "emptyd" => "", 'emptys' => ''),
array(1 => '', 2 => "", 3 => NULL, 4 => null, 5 => false, 6 => true),
array('' => 1, "" => 2, NULL => 3, null => 4, false => 5, true => 6),
array(1 => '', 2 => "", 5 => false, 6 => true),
array('' => 1, "" => 2, false => 5, true => 6),
// array with repetitive keys
/*19*/ array("One" => 1, "two" => 2, "One" => 10, "two" => 20, "three" => 3)
@@ -148,19 +140,9 @@ array(0) {
array(0) {
}
-- Iteration 8 --
array(1) {
["h3"]=>
string(88) "hello world
1111 != 2222
heredoc
double quoted string. with different white spaces"
array(0) {
}
array(1) {
["h3"]=>
string(88) "hello world
1111 != 2222
heredoc
double quoted string. with different white spaces"
array(0) {
}
-- Iteration 9 --
array(1) {
@@ -204,45 +186,40 @@ array(1) {
string(4) "four"
}
-- Iteration 14 --
array(0) {
array(1) {
["true"]=>
bool(true)
}
array(0) {
array(1) {
["true"]=>
bool(true)
}
-- Iteration 15 --
array(1) {
["true"]=>
bool(true)
[""]=>
string(6) "emptys"
}
array(1) {
["true"]=>
bool(true)
[""]=>
string(6) "emptys"
}
-- Iteration 16 --
array(1) {
[""]=>
string(6) "emptys"
[5]=>
NULL
}
array(1) {
[""]=>
string(6) "emptys"
[5]=>
NULL
}
-- Iteration 17 --
array(1) {
[5]=>
NULL
array(0) {
}
array(1) {
[5]=>
NULL
array(0) {
}
-- Iteration 18 --
array(0) {
}
array(0) {
}
-- Iteration 19 --
array(0) {
}
array(0) {
}
Done

View File

@@ -10,10 +10,6 @@ Test array_intersect_assoc() function : usage variations - assoc array with diff
echo "*** Testing array_intersect_assoc() : assoc array with diff keys to \$arr1 argument ***\n";
// get an unset variable
$unset_var = 10;
unset ($unset_var);
// get a heredoc string
$heredoc = <<<EOT
Hello world
@@ -37,13 +33,10 @@ $arrays = array (
"\v\fworld" => 2.2, "pen\n" => 33),
array("hello", $heredoc => "string"), // heredoc
// array with object, unset variable and resource variable
/*10*/ array(@$unset_var => "hello"),
// array with mixed keys
/*11*/ array('hello' => 1, "fruit" => 2.2,
133 => "int",
@$unset_var => "unset", $heredoc => "heredoc")
$heredoc => "heredoc")
);
// array to be passed to $arr2 argument
@@ -123,11 +116,6 @@ array(1) {
string(6) "string"
}
-- Iteration 8 --
array(0) {
}
array(0) {
}
-- Iteration 9 --
array(1) {
[133]=>
string(3) "int"

View File

@@ -10,10 +10,6 @@ Test array_intersect_assoc() function : usage variations - assoc array with diff
echo "*** Testing array_intersect_assoc() : assoc array with diff keys to \$arr2 argument ***\n";
// get an unset variable
$unset_var = 10;
unset ($unset_var);
// get a heredoc string
$heredoc = <<<EOT
Hello world
@@ -38,12 +34,11 @@ $arrays = array (
array("hello", $heredoc => "string"), // heredoc
// array with unset variable
/*10*/ array( @$unset_var => "hello"),
// array with mixed keys
/*11*/ array('hello' => 1, "fruit" => 2.2,
133 => "int",
@$unset_var => "unset", $heredoc => "heredoc")
$heredoc => "heredoc")
);
// array to be passed to $arr1 argument
@@ -123,11 +118,6 @@ array(1) {
string(6) "string"
}
-- Iteration 8 --
array(0) {
}
array(0) {
}
-- Iteration 9 --
array(1) {
[133]=>
string(3) "int"

View File

@@ -1,56 +0,0 @@
--TEST--
Test array_intersect_key() function : usage variation - Passing null,unset and undefeined variable indexed array
--FILE--
<?php
echo "*** Testing array_intersect_key() : usage variation ***\n";
// Initialise function arguments not being substituted (if any)
$input_array = array(0 => '0', 1 => '1' , -10 => '-10' , null => 'null');
//get an unset variable
$unset_var = 10;
unset ($unset_var);
$input_arrays = array(
'null indexed' => array(NULL => 'null 1', null => 'null 2'),
'undefined indexed' => array(@$undefined_var => 'undefined'),
'unset indexed' => array(@$unset_var => 'unset'),
);
foreach($input_arrays as $key =>$value) {
echo "\n--$key--\n";
var_dump( array_intersect_key($input_array, $value) );
var_dump( array_intersect_key($value,$input_array ) );
}
?>
--EXPECT--
*** Testing array_intersect_key() : usage variation ***
--null indexed--
array(1) {
[""]=>
string(4) "null"
}
array(1) {
[""]=>
string(6) "null 2"
}
--undefined indexed--
array(1) {
[""]=>
string(4) "null"
}
array(1) {
[""]=>
string(9) "undefined"
}
--unset indexed--
array(1) {
[""]=>
string(4) "null"
}
array(1) {
[""]=>
string(5) "unset"
}

View File

@@ -25,13 +25,6 @@ the lazy dog
This is a double quoted string
EOT;
// heredoc with different whitespaces
$diff_whitespaces = <<<EOT
hello\r world\t
1111\t\t != 2222\v\v
heredoc\ndouble quoted string. with\vdifferent\fwhite\vspaces
EOT;
// heredoc with quoted strings and numeric values
$numeric_string = <<<EOT
11 < 12. 123 >22
@@ -47,9 +40,9 @@ $arrays = array (
array(false,true), // array with default keys and boolean values
array(), // empty array
/*5*/ array(NULL), // array with NULL
array("a\v\f","aaaa\r","b","b\tbbb","c","\[\]\!\@\#\$\%\^\&\*\(\)\{\}"), // array with double quoted strings
array('a\v\f','aaaa\r','b','b\tbbb','c','\[\]\!\@\#\$\%\^\&\*\(\)\{\}'), // array with single quoted strings
array($blank_line, $multiline_string, $diff_whitespaces, $numeric_string), // array with heredocs
array("a\v\f","aaaa\n","b","b\tbbb","c","\[\]\!\@\#\$\%\^\&\*\(\)\{\}"), // array with double quoted strings
array('a\v\f','aaaa\n','b','b\tbbb','c','\[\]\!\@\#\$\%\^\&\*\(\)\{\}'), // array with single quoted strings
array($blank_line, $multiline_string, $numeric_string), // array with heredocs
// associative arrays
/*9*/ array(1 => "one", 2 => "two", 3 => "three"), // explicit numeric keys, string values
@@ -58,25 +51,24 @@ $arrays = array (
array( "one" => "ten", "two" => "twenty", "three" => "thirty"), // string key/value
array("one" => 1, 2 => "two", 4 => "four"), //mixed
// associative array, containing null/empty/boolean values as key/value
/*14*/ array(NULL => "NULL", null => "null", "NULL" => NULL, "null" => null),
array(true => "true", false => "false", "false" => false, "true" => true),
// associative array, containing empty/boolean values as key/value
/*14*/ array(true => "true", false => "false", "false" => false, "true" => true),
array("" => "emptyd", '' => 'emptys', "emptyd" => "", 'emptys' => ''),
array(1 => '', 2 => "", 3 => NULL, 4 => null, 5 => false, 6 => true),
array('' => 1, "" => 2, NULL => 3, null => 4, false => 5, true => 6),
array(1 => '', 2 => "", 5 => false, 6 => true),
array('' => 1, "" => 2, false => 5, true => 6),
// array with repetitive keys
/*19*/ array("One" => 1, "two" => 2, "One" => 10, "two" => 20, "three" => 3)
);
// array to be passsed to $arr2 argument
// array to be passed to $arr2 argument
$arr2 = array (
1, 1.1, "hello", "one", NULL, 2,
'world', true, false, false => 5, 'aaaa\r', "aaaa\r",
$numeric_string, $diff_whitespaces,
'world', true, false, false => 5, 'aaaa\n', "aaaa\n",
$numeric_string,
"one" => "ten", 4 => "four", "two" => 2, 2 => "two",
'', null => "null", '' => 'emptys'
'', '' => 'emptys'
);
// loop through each sub-array within $arrays to check the behavior of array_intersect()
@@ -149,42 +141,34 @@ array(1) {
-- Iterator 6 --
array(1) {
[1]=>
string(5) "aaaa "
string(5) "aaaa
"
}
array(1) {
[1]=>
string(5) "aaaa "
string(5) "aaaa
"
}
-- Iterator 7 --
array(1) {
[1]=>
string(6) "aaaa\r"
string(6) "aaaa\n"
}
array(1) {
[1]=>
string(6) "aaaa\r"
string(6) "aaaa\n"
}
-- Iterator 8 --
array(2) {
array(1) {
[2]=>
string(88) "hello world
1111 != 2222
heredoc
double quoted string. with different white spaces"
[3]=>
string(90) "11 < 12. 123 >22
'single quoted string'
"double quoted string"
2222 != 1111. 0000 = 0000
"
}
array(2) {
array(1) {
[2]=>
string(88) "hello world
1111 != 2222
heredoc
double quoted string. with different white spaces"
[3]=>
string(90) "11 < 12. 123 >22
'single quoted string'
"double quoted string"
@@ -250,86 +234,69 @@ array(3) {
}
-- Iterator 14 --
array(2) {
["NULL"]=>
NULL
["null"]=>
NULL
["false"]=>
bool(false)
["true"]=>
bool(true)
}
array(2) {
["NULL"]=>
NULL
["null"]=>
NULL
["false"]=>
bool(false)
["true"]=>
bool(true)
}
-- Iterator 15 --
array(2) {
["false"]=>
bool(false)
["true"]=>
bool(true)
array(3) {
[""]=>
string(6) "emptys"
["emptyd"]=>
string(0) ""
["emptys"]=>
string(0) ""
}
array(2) {
["false"]=>
bool(false)
["true"]=>
bool(true)
array(3) {
[""]=>
string(6) "emptys"
["emptyd"]=>
string(0) ""
["emptys"]=>
string(0) ""
}
-- Iterator 16 --
array(3) {
[""]=>
string(6) "emptys"
["emptyd"]=>
array(4) {
[1]=>
string(0) ""
["emptys"]=>
[2]=>
string(0) ""
[5]=>
bool(false)
[6]=>
bool(true)
}
array(3) {
[""]=>
string(6) "emptys"
["emptyd"]=>
array(4) {
[1]=>
string(0) ""
["emptys"]=>
[2]=>
string(0) ""
[5]=>
bool(false)
[6]=>
bool(true)
}
-- Iterator 17 --
array(6) {
[1]=>
string(0) ""
[2]=>
string(0) ""
[3]=>
NULL
[4]=>
NULL
[5]=>
bool(false)
[6]=>
bool(true)
array(2) {
[""]=>
int(2)
[0]=>
int(5)
}
array(6) {
[1]=>
string(0) ""
[2]=>
string(0) ""
[3]=>
NULL
[4]=>
NULL
[5]=>
bool(false)
[6]=>
bool(true)
array(2) {
[""]=>
int(2)
[0]=>
int(5)
}
-- Iterator 18 --
array(1) {
[0]=>
int(5)
}
array(1) {
[0]=>
int(5)
}
-- Iterator 19 --
array(0) {
}
array(0) {

View File

@@ -25,13 +25,6 @@ the lazy dog
This is a double quoted string
EOT;
// heredoc with different whitespaces
$diff_whitespaces = <<<EOT
hello\r world\t
1111\t\t != 2222\v\v
heredoc\ndouble quoted string. with\vdifferent\fwhite\vspaces
EOT;
// heredoc with quoted strings and numeric values
$numeric_string = <<<EOT
11 < 12. 123 >22
@@ -43,10 +36,10 @@ EOT;
// array to be passsed to $arr1 argument
$arr1 = array (
1, 1.1, "hello", "one", NULL, 2,
'world', true, false, false => 5, 'aaaa\r', "aaaa\r",
$numeric_string, $diff_whitespaces,
'world', true, false, false => 5, 'aaaa\n', "aaaa\n",
$numeric_string,
"one" => "ten", 4 => "four", "two" => 2, 2 => "two",
'', null => "null", '' => 'emptys'
'', '' => 'emptys'
);
// arrays to be passed to $arr2 argument
@@ -56,9 +49,9 @@ $arrays = array (
array(false,true), // array with default keys and boolean values
array(), // empty array
/*5*/ array(NULL), // array with NULL
array("a\v\f","aaaa\r","b","b\tbbb","c","\[\]\!\@\#\$\%\^\&\*\(\)\{\}"), // array with double quoted strings
array('a\v\f','aaaa\r','b','b\tbbb','c','\[\]\!\@\#\$\%\^\&\*\(\)\{\}'), // array with single quoted strings
array($blank_line, $multiline_string, $diff_whitespaces, $numeric_string), // array with heredocs
array("a\v\f","aaaa\n","b","b\tbbb","c","\[\]\!\@\#\$\%\^\&\*\(\)\{\}"), // array with double quoted strings
array('a\v\f','aaaa\n','b','b\tbbb','c','\[\]\!\@\#\$\%\^\&\*\(\)\{\}'), // array with single quoted strings
array($blank_line, $multiline_string, $numeric_string), // array with heredocs
// associative arrays
/*9*/ array(1 => "one", 2 => "two", 3 => "three"), // explicit numeric keys, string values
@@ -68,11 +61,11 @@ $arrays = array (
array("one" => 1, 2 => "two", 4 => "four"), //mixed
// associative array, containing null/empty/boolean values as key/value
/*14*/ array(NULL => "NULL", null => "null", "NULL" => NULL, "null" => null),
/*14*/
array(true => "true", false => "false", "false" => false, "true" => true),
array("" => "emptyd", '' => 'emptys', "emptyd" => "", 'emptys' => ''),
array(1 => '', 2 => "", 3 => NULL, 4 => null, 5 => false, 6 => true),
array('' => 1, "" => 2, NULL => 3, null => 4, false => 5, true => 6),
array(1 => '', 2 => "", 5 => false, 6 => true),
array('' => 1, "" => 2, false => 5, true => 6),
// array with repetitive keys
/*19*/ array("One" => 1, "two" => 2, "One" => 10, "two" => 20, "three" => 3)
@@ -128,7 +121,7 @@ array(3) {
bool(true)
[8]=>
bool(false)
[13]=>
[12]=>
string(0) ""
}
array(3) {
@@ -136,7 +129,7 @@ array(3) {
bool(true)
[8]=>
bool(false)
[13]=>
[12]=>
string(0) ""
}
-- Iteration 4 --
@@ -148,59 +141,51 @@ array(0) {
array(2) {
[8]=>
bool(false)
[13]=>
[12]=>
string(0) ""
}
array(2) {
[8]=>
bool(false)
[13]=>
[12]=>
string(0) ""
}
-- Iteration 6 --
array(1) {
[10]=>
string(5) "aaaa "
string(5) "aaaa
"
}
array(1) {
[10]=>
string(5) "aaaa "
string(5) "aaaa
"
}
-- Iteration 7 --
array(1) {
[9]=>
string(6) "aaaa\r"
string(6) "aaaa\n"
}
array(1) {
[9]=>
string(6) "aaaa\r"
string(6) "aaaa\n"
}
-- Iteration 8 --
array(2) {
array(1) {
[11]=>
string(90) "11 < 12. 123 >22
'single quoted string'
"double quoted string"
2222 != 1111. 0000 = 0000
"
[12]=>
string(88) "hello world
1111 != 2222
heredoc
double quoted string. with different white spaces"
}
array(2) {
array(1) {
[11]=>
string(90) "11 < 12. 123 >22
'single quoted string'
"double quoted string"
2222 != 1111. 0000 = 0000
"
[12]=>
string(88) "hello world
1111 != 2222
heredoc
double quoted string. with different white spaces"
}
-- Iteration 9 --
array(2) {
@@ -264,79 +249,74 @@ array(3) {
bool(true)
}
-- Iteration 14 --
array(2) {
array(3) {
[7]=>
bool(true)
[8]=>
bool(false)
[13]=>
[12]=>
string(0) ""
}
array(2) {
array(3) {
[7]=>
bool(true)
[8]=>
bool(false)
[13]=>
[12]=>
string(0) ""
}
-- Iteration 15 --
array(3) {
[7]=>
bool(true)
[8]=>
bool(false)
[13]=>
[12]=>
string(0) ""
[""]=>
string(6) "emptys"
}
array(3) {
[7]=>
bool(true)
[8]=>
bool(false)
[13]=>
[12]=>
string(0) ""
[""]=>
string(6) "emptys"
}
-- Iteration 16 --
array(3) {
[7]=>
bool(true)
[8]=>
bool(false)
[13]=>
[12]=>
string(0) ""
[""]=>
string(6) "emptys"
}
array(3) {
[7]=>
bool(true)
[8]=>
bool(false)
[13]=>
[12]=>
string(0) ""
[""]=>
string(6) "emptys"
}
-- Iteration 17 --
array(3) {
[7]=>
bool(true)
[8]=>
bool(false)
[13]=>
string(0) ""
[0]=>
int(5)
[5]=>
int(2)
["two"]=>
int(2)
}
array(3) {
[7]=>
bool(true)
[8]=>
bool(false)
[13]=>
string(0) ""
[0]=>
int(5)
[5]=>
int(2)
["two"]=>
int(2)
}
-- Iteration 18 --
array(1) {
[0]=>
int(5)
}
array(1) {
[0]=>
int(5)
}
-- Iteration 19 --
array(0) {
}
array(0) {

View File

@@ -10,10 +10,6 @@ Test array_intersect() function : usage variations - assoc array with diff keys
echo "*** Testing array_intersect() : assoc array with diff keys to \$arr1 argument ***\n";
// get an unset variable
$unset_var = 10;
unset ($unset_var);
// get a heredoc string
$heredoc = <<<EOT
Hello world
@@ -37,13 +33,10 @@ $arrays = array (
"\v\fworld" => 2.2, "pen\n" => 33),
array("hello", $heredoc => "string"), // heredoc
// array with unset variable
/*10*/ array( @$unset_var => "hello"),
// array with mixed keys
/*11*/ array('hello' => 1, "fruit" => 2.2,
133 => "int",
@$unset_var => "unset", $heredoc => "heredoc")
$heredoc => "heredoc")
);
// array to be passed to $arr2 argument
@@ -135,15 +128,6 @@ array(2) {
string(6) "string"
}
-- Iterator 8 --
array(1) {
[""]=>
string(5) "hello"
}
array(1) {
[""]=>
string(5) "hello"
}
-- Iterator 9 --
array(2) {
["hello"]=>
int(1)

View File

@@ -10,10 +10,6 @@ Test array_intersect() function : usage variations - assoc array with diff keys
echo "*** Testing array_intersect() : assoc array with diff keys to \$arr2 argument ***\n";
// get an unset variable
$unset_var = 10;
unset ($unset_var);
// get a heredoc string
$heredoc = <<<EOT
Hello world
@@ -37,13 +33,10 @@ $arrays = array (
"\v\fworld" => 2.2, "pen\n" => 33),
array("hello", $heredoc => "string"), // heredoc
// array with unset variable
/*10*/ array( @$unset_var => "hello"),
// array with mixed keys
/*11*/ array('hello' => 1, "fruit" => 2.2,
133 => "int",
@$unset_var => "unset", $heredoc => "heredoc")
$heredoc => "heredoc")
);
// array to be passed to $arr1 argument
@@ -135,15 +128,6 @@ array(2) {
string(6) "string"
}
-- Iterator 8 --
array(1) {
[3]=>
string(5) "hello"
}
array(1) {
[3]=>
string(5) "hello"
}
-- Iterator 9 --
array(2) {
[0]=>
int(1)

View File

@@ -44,7 +44,7 @@ $search_arrays_v = array (
array(),
array(NULL),
array(array(), 1, 2),
array(1,2,3, "" => "value", NULL => "value", true => "value" ),
array(1,2,3, "" => "value", true => "value" ),
array( array(2,4,5), array ("a","b","d") )
);
// search for $key_variations in each sub array of $search_arrays_v

View File

@@ -10,10 +10,6 @@ Test array_key_exists() function : usage variations - array keys are different d
echo "*** Testing array_key_exists() : usage variations ***\n";
//get an unset variable
$unset_var = 10;
unset ($unset_var);
// heredoc string
$heredoc = <<<EOT
string
@@ -30,29 +26,14 @@ $inputs = array(
-2345 => 'negative',
),
// null data
/*3*/ 'null uppercase' => array(
NULL => 'null 1',
),
'null lowercase' => array(
null => 'null 2',
),
// boolean data
/*4*/ 'bool lowercase' => array(
true => 'lowert',
false => 'lowerf',
),
'bool uppercase' => array(
TRUE => 'uppert',
FALSE => 'upperf',
),
// empty data
/*5*/ 'empty double quotes' => array(
"" => 'emptyd',
),
'empty single quotes' => array(
/*5*/ 'empty single quotes' => array(
'' => 'emptys',
),
@@ -62,22 +43,12 @@ $inputs = array(
'strings' => 'strings',
$heredoc => 'stringh',
),
// undefined data
/*8*/ 'undefined' => array(
@$undefined_var => 'undefined',
),
// unset data
/*9*/ 'unset' => array(
@$unset_var => 'unset',
),
);
// loop through each element of $inputs to check the behavior of array_key_exists()
$iterator = 1;
foreach($inputs as $type => $input) {
echo "\n-- Iteration $iterator: $type data --\n";
echo "\n-- $type data --\n";
//iterate over again to get all different key values
foreach ($inputs as $new_type => $new_input) {
@@ -94,293 +65,67 @@ echo "Done";
--EXPECT--
*** Testing array_key_exists() : usage variations ***
-- Iteration 1: int data --
-- int data --
-- $key arguments are int data:
bool(true)
bool(true)
bool(true)
bool(true)
-- $key arguments are null uppercase data:
bool(false)
-- $key arguments are null lowercase data:
bool(false)
-- $key arguments are bool lowercase data:
bool(true)
bool(true)
-- $key arguments are bool uppercase data:
bool(true)
bool(true)
-- $key arguments are empty double quotes data:
bool(false)
-- $key arguments are empty single quotes data:
bool(false)
-- $key arguments are string data:
bool(false)
bool(false)
bool(false)
-- $key arguments are undefined data:
bool(false)
-- $key arguments are unset data:
bool(false)
-- Iteration 2: null uppercase data --
-- $key arguments are int data:
bool(false)
bool(false)
bool(false)
bool(false)
-- $key arguments are null uppercase data:
bool(true)
-- $key arguments are null lowercase data:
bool(true)
-- $key arguments are bool lowercase data:
bool(false)
bool(false)
-- $key arguments are bool uppercase data:
bool(false)
bool(false)
-- $key arguments are empty double quotes data:
bool(true)
-- $key arguments are empty single quotes data:
bool(true)
-- $key arguments are string data:
bool(false)
bool(false)
bool(false)
-- $key arguments are undefined data:
bool(true)
-- $key arguments are unset data:
bool(true)
-- Iteration 3: null lowercase data --
-- $key arguments are int data:
bool(false)
bool(false)
bool(false)
bool(false)
-- $key arguments are null uppercase data:
bool(true)
-- $key arguments are null lowercase data:
bool(true)
-- $key arguments are bool lowercase data:
bool(false)
bool(false)
-- $key arguments are bool uppercase data:
bool(false)
bool(false)
-- $key arguments are empty double quotes data:
bool(true)
-- $key arguments are empty single quotes data:
bool(true)
-- $key arguments are string data:
bool(false)
bool(false)
bool(false)
-- $key arguments are undefined data:
bool(true)
-- $key arguments are unset data:
bool(true)
-- Iteration 4: bool lowercase data --
-- bool lowercase data --
-- $key arguments are int data:
bool(true)
bool(true)
bool(false)
bool(false)
-- $key arguments are null uppercase data:
bool(false)
-- $key arguments are null lowercase data:
bool(false)
-- $key arguments are bool lowercase data:
bool(true)
bool(true)
-- $key arguments are bool uppercase data:
bool(true)
bool(true)
-- $key arguments are empty double quotes data:
bool(false)
-- $key arguments are empty single quotes data:
bool(false)
-- $key arguments are string data:
bool(false)
bool(false)
bool(false)
-- $key arguments are undefined data:
bool(false)
-- $key arguments are unset data:
bool(false)
-- Iteration 5: bool uppercase data --
-- empty single quotes data --
-- $key arguments are int data:
bool(true)
bool(true)
bool(false)
bool(false)
-- $key arguments are null uppercase data:
bool(false)
-- $key arguments are null lowercase data:
bool(false)
-- $key arguments are bool lowercase data:
bool(true)
bool(true)
-- $key arguments are bool uppercase data:
bool(true)
bool(true)
-- $key arguments are empty double quotes data:
bool(false)
bool(false)
-- $key arguments are empty single quotes data:
bool(false)
bool(true)
-- $key arguments are string data:
bool(false)
bool(false)
bool(false)
-- $key arguments are undefined data:
bool(false)
-- $key arguments are unset data:
bool(false)
-- Iteration 6: empty double quotes data --
-- string data --
-- $key arguments are int data:
bool(false)
bool(false)
bool(false)
bool(false)
-- $key arguments are null uppercase data:
bool(true)
-- $key arguments are null lowercase data:
bool(true)
-- $key arguments are bool lowercase data:
bool(false)
bool(false)
-- $key arguments are bool uppercase data:
bool(false)
bool(false)
-- $key arguments are empty double quotes data:
bool(true)
-- $key arguments are empty single quotes data:
bool(true)
-- $key arguments are string data:
bool(false)
bool(false)
bool(false)
-- $key arguments are undefined data:
bool(true)
-- $key arguments are unset data:
bool(true)
-- Iteration 7: empty single quotes data --
-- $key arguments are int data:
bool(false)
bool(false)
bool(false)
bool(false)
-- $key arguments are null uppercase data:
bool(true)
-- $key arguments are null lowercase data:
bool(true)
-- $key arguments are bool lowercase data:
bool(false)
bool(false)
-- $key arguments are bool uppercase data:
bool(false)
bool(false)
-- $key arguments are empty double quotes data:
bool(true)
-- $key arguments are empty single quotes data:
bool(true)
-- $key arguments are string data:
bool(false)
bool(false)
bool(false)
-- $key arguments are undefined data:
bool(true)
-- $key arguments are unset data:
bool(true)
-- Iteration 8: string data --
-- $key arguments are int data:
bool(false)
bool(false)
bool(false)
bool(false)
-- $key arguments are null uppercase data:
bool(false)
-- $key arguments are null lowercase data:
bool(false)
-- $key arguments are bool lowercase data:
bool(false)
bool(false)
-- $key arguments are bool uppercase data:
bool(false)
bool(false)
-- $key arguments are empty double quotes data:
bool(false)
-- $key arguments are empty single quotes data:
bool(false)
-- $key arguments are string data:
bool(true)
bool(true)
bool(true)
-- $key arguments are undefined data:
bool(false)
-- $key arguments are unset data:
bool(false)
-- Iteration 9: undefined data --
-- $key arguments are int data:
bool(false)
bool(false)
bool(false)
bool(false)
-- $key arguments are null uppercase data:
bool(true)
-- $key arguments are null lowercase data:
bool(true)
-- $key arguments are bool lowercase data:
bool(false)
bool(false)
-- $key arguments are bool uppercase data:
bool(false)
bool(false)
-- $key arguments are empty double quotes data:
bool(true)
-- $key arguments are empty single quotes data:
bool(true)
-- $key arguments are string data:
bool(false)
bool(false)
bool(false)
-- $key arguments are undefined data:
bool(true)
-- $key arguments are unset data:
bool(true)
-- Iteration 10: unset data --
-- $key arguments are int data:
bool(false)
bool(false)
bool(false)
bool(false)
-- $key arguments are null uppercase data:
bool(true)
-- $key arguments are null lowercase data:
bool(true)
-- $key arguments are bool lowercase data:
bool(false)
bool(false)
-- $key arguments are bool uppercase data:
bool(false)
bool(false)
-- $key arguments are empty double quotes data:
bool(true)
-- $key arguments are empty single quotes data:
bool(true)
-- $key arguments are string data:
bool(false)
bool(false)
bool(false)
-- $key arguments are undefined data:
bool(true)
-- $key arguments are unset data:
bool(true)
Done

View File

@@ -15,7 +15,7 @@ $mixed_array = array(
array( "1" => "one", "2" => "two", "3" => "three", "4" => "four", "5" => "five" ),
array( 1 => "one", 2 => "two", 3 => 7, 4 => "four", 5 => "five" ),
array( "f" => "fff", "1" => "one", 4 => 6, "" => "blank", 2 => "float", "F" => "FFF",
"blank" => "", 3 => 3.7, 5 => 7, 6 => 8.6, '5' => "Five", "4name" => "jonny", "a" => NULL, NULL => 3 ),
"blank" => "", 3 => 3.7, 5 => 7, 6 => 8.6, '5' => "Five", "4name" => "jonny", "a" => NULL ),
array( 12, "name", 'age', '45' ),
array( array("oNe", "tWo", 4), array(10, 20, 30, 40, 50), array() ),
array( "one" => 1, "one" => 2, "three" => 3, 3, 4, 3 => 33, 4 => 44, 5, 6,
@@ -174,7 +174,7 @@ array(12) {
[4]=>
int(6)
[""]=>
int(3)
string(5) "blank"
[2]=>
string(5) "float"
["F"]=>

View File

@@ -15,7 +15,7 @@ $mixed_array = array(
array( "1" => "one", "2" => "two", "3" => "three", "4" => "four", "5" => "five" ),
array( 1 => "one", 2 => "two", 3 => 7, 4 => "four", 5 => "five" ),
array( "f" => "fff", "1" => "one", 4 => 6, "" => "blank", 2 => "float", "F" => "FFF",
"blank" => "", 3 => 3.7, 5 => 7, 6 => 8.6, '5' => "Five", "4name" => "jonny", "a" => NULL, NULL => 3 ),
"blank" => "", 3 => 3.7, 5 => 7, 6 => 8.6, '5' => "Five", "4name" => "jonny", "a" => NULL ),
array( 12, "name", 'age', '45' ),
array( array("oNe", "tWo", 4), array(10, 20, 30, 40, 50), array() ),
array( "one" => 1, "one" => 2, "three" => 3, 3, 4, 3 => 33, 4 => 44, 5, 6,
@@ -174,7 +174,7 @@ array(12) {
[4]=>
int(6)
[""]=>
int(3)
string(5) "blank"
[2]=>
string(5) "float"
["F"]=>

View File

@@ -14,7 +14,7 @@ $arrays = array(
array("a" => 1, "b" => 2, "c" =>3, "d" => array()),
array(0 => 0, 1 => 1, 2 => 2, 3 => 3),
array(0 =>3.000, 1 =>2, 1 =>3, "a"=>3, 3=>5, "5"=>3.000),
array(TRUE => TRUE, FALSE => FALSE, NULL => NULL, "\x000", "\000"),
array(TRUE => TRUE, FALSE => FALSE, "\x000", "\000"),
array("a" => "abcd", "a" => "", "ab" => -6, "cd" => -0.5 ),
array(0 => array(), 1=> array(0), 2 => array(1), ""=> array(),""=>"" )
);
@@ -110,16 +110,14 @@ array(5) {
}
-- Iteration 9 --
array(5) {
array(4) {
[0]=>
int(1)
[1]=>
int(0)
[2]=>
string(0) ""
[3]=>
int(2)
[4]=>
[3]=>
int(3)
}

View File

@@ -31,11 +31,11 @@ $arrays = array (
array("one" => 1, 2 => "two", 4 => "four"), //mixed
// associative array, containing null/empty/boolean values as key/value
/*13*/ array(NULL => "NULL", null => "null", "NULL" => NULL, "null" => null),
/*13*/
array(true => "true", false => "false", "false" => false, "true" => true),
array("" => "emptyd", '' => 'emptys', "emptyd" => "", 'emptys' => ''),
array(1 => '', 2 => "", 3 => NULL, 4 => null, 5 => false, 6 => true),
array('' => 1, "" => 2, NULL => 3, null => 4, false => 5, true => 6),
array(1 => '', 2 => "", 5 => false, 6 => true),
array('' => 1, "" => 2, false => 5, true => 6),
// array with repetitive keys
/*18*/ array("One" => 1, "two" => 2, "One" => 10, "two" => 20, "three" => 3)
@@ -158,15 +158,6 @@ array(3) {
string(4) "four"
}
-- Iteration 13 --
array(3) {
[""]=>
string(4) "null"
["NULL"]=>
NULL
["null"]=>
NULL
}
-- Iteration 14 --
array(4) {
[1]=>
string(4) "true"
@@ -177,7 +168,7 @@ array(4) {
["true"]=>
bool(true)
}
-- Iteration 15 --
-- Iteration 14 --
array(3) {
[""]=>
string(6) "emptys"
@@ -186,31 +177,27 @@ array(3) {
["emptys"]=>
string(0) ""
}
-- Iteration 16 --
array(6) {
-- Iteration 15 --
array(4) {
[1]=>
string(0) ""
[2]=>
string(0) ""
[3]=>
NULL
[4]=>
NULL
[5]=>
bool(false)
[6]=>
bool(true)
}
-- Iteration 17 --
-- Iteration 16 --
array(3) {
[""]=>
int(4)
int(2)
[0]=>
int(5)
[1]=>
int(6)
}
-- Iteration 18 --
-- Iteration 17 --
array(3) {
["One"]=>
int(10)

View File

@@ -46,12 +46,12 @@ $arrays = array (
array("hello", $heredoc => "string"), // heredoc
// array with object, unset variable and resource variable
array(@$unset_var => "hello", STDERR => 'resource'),
array(STDERR => 'resource'),
// array with mixed values
/*11*/ array('hello' => 1, "fruit" => 2.2,
STDERR => 'resource', 133 => "int",
@$unset_var => "unset", $heredoc => "heredoc")
$heredoc => "heredoc")
);
// loop through the various elements of $arrays to test array_map()
@@ -125,14 +125,12 @@ array(2) {
string(6) "string"
}
-- Iteration 8 --
array(2) {
[""]=>
string(5) "hello"
array(1) {
[3]=>
string(8) "resource"
}
-- Iteration 9 --
array(6) {
array(5) {
["hello"]=>
int(1)
["fruit"]=>
@@ -141,8 +139,6 @@ array(6) {
string(8) "resource"
[133]=>
string(3) "int"
[""]=>
string(5) "unset"
["Hello world"]=>
string(7) "heredoc"
}

View File

@@ -27,7 +27,7 @@ var_dump( array_map('callback', array(), array(1, 2, 3), array('a', 'b')) ); //
echo "Done";
?>
--EXPECT--
--EXPECTF--
*** Testing array_map() : arrays with diff. size ***
array(3) {
[0]=>
@@ -46,6 +46,12 @@ array(3) {
NULL
}
}
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
array(3) {
[0]=>
array(1) {
@@ -97,6 +103,12 @@ array(3) {
NULL
}
}
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
array(3) {
[0]=>
array(1) {

View File

@@ -27,7 +27,7 @@ EOT;
// heredoc with different whitespaces
$diff_whitespaces = <<<EOT
hello\r world\t
hello\n world\t
1111\t\t != 2222\v\v
heredoc\ndouble quoted string. with\vdifferent\fwhite\vspaces
EOT;
@@ -47,8 +47,8 @@ $arrays = array (
array(false, true), // with default keys and boolean values
array(), // empty array
/*5*/ array(NULL), // with NULL
array("a\v\f", "aaaa\r", "b", "\[\]\!\@\#\$\%\^\&\*\(\)\{\}"), // with double quoted strings
array('a\v\f', 'aaaa\r', 'b', '\[\]\!\@\#\$\%\^\&\*\(\)\{\}'), // with single quoted strings
array("a\v\f", "aaaa\n", "b", "\[\]\!\@\#\$\%\^\&\*\(\)\{\}"), // with double quoted strings
array('a\v\f', 'aaaa\n', 'b', '\[\]\!\@\#\$\%\^\&\*\(\)\{\}'), // with single quoted strings
array("h1" => $blank_line, "h2" => $multiline_string, "h3" => $diff_whitespaces), // with heredocs
// associative arrays
@@ -59,11 +59,11 @@ $arrays = array (
array("one" => 1, 2 => "two", 4 => "four"), //mixed
// associative array, containing null/empty/boolean values as key/value
/*14*/ array(NULL => "NULL", null => "null", "NULL" => NULL, "null" => null),
/*14*/
array(true => "true", false => "false", "false" => false, "true" => true),
array("" => "emptyd", '' => 'emptys', "emptyd" => "", 'emptys' => ''),
array(1 => '', 2 => "", 3 => NULL, 4 => null, 5 => false, 6 => true),
array('' => 1, "" => 2, NULL => 3, null => 4, false => 5, true => 6),
array(1 => '', 2 => "", 5 => false, 6 => true),
array('' => 1, "" => 2, false => 5, true => 6),
// array containing embedded arrays
/*15*/ array("str1", "array" => array("hello", 'world'), array(1, 2))
@@ -236,7 +236,8 @@ array(4) {
[0]=>
string(3) "a "
[1]=>
string(5) "aaaa "
string(5) "aaaa
"
[2]=>
string(1) "b"
[3]=>
@@ -247,7 +248,8 @@ array(8) {
[0]=>
string(3) "a "
[1]=>
string(5) "aaaa "
string(5) "aaaa
"
[2]=>
string(1) "b"
[3]=>
@@ -274,7 +276,7 @@ array(4) {
[0]=>
string(5) "a\v\f"
[1]=>
string(6) "aaaa\r"
string(6) "aaaa\n"
[2]=>
string(1) "b"
[3]=>
@@ -285,7 +287,7 @@ array(8) {
[0]=>
string(5) "a\v\f"
[1]=>
string(6) "aaaa\r"
string(6) "aaaa\n"
[2]=>
string(1) "b"
[3]=>
@@ -318,7 +320,8 @@ The quick brown fox jumped over;
the lazy dog
This is a double quoted string"
["h3"]=>
string(88) "hello world
string(88) "hello
world
1111 != 2222
heredoc
double quoted string. with different white spaces"
@@ -334,7 +337,8 @@ The quick brown fox jumped over;
the lazy dog
This is a double quoted string"
["h3"]=>
string(88) "hello world
string(88) "hello
world
1111 != 2222
heredoc
double quoted string. with different white spaces"
@@ -518,40 +522,6 @@ array(7) {
}
-- Iteration 14 --
-- With default argument --
array(3) {
[""]=>
string(4) "null"
["NULL"]=>
NULL
["null"]=>
NULL
}
-- With more arguments --
array(7) {
[""]=>
string(4) "null"
["NULL"]=>
NULL
["null"]=>
NULL
[0]=>
string(3) "one"
[1]=>
int(2)
["string"]=>
string(5) "hello"
["array"]=>
array(3) {
[0]=>
string(1) "a"
[1]=>
string(1) "b"
[2]=>
string(1) "c"
}
}
-- Iteration 15 --
-- With default argument --
array(4) {
[0]=>
string(4) "true"
@@ -588,7 +558,7 @@ array(8) {
string(1) "c"
}
}
-- Iteration 16 --
-- Iteration 15 --
-- With default argument --
array(3) {
[""]=>
@@ -622,39 +592,65 @@ array(7) {
string(1) "c"
}
}
-- Iteration 16 --
-- With default argument --
array(4) {
[0]=>
string(0) ""
[1]=>
string(0) ""
[2]=>
bool(false)
[3]=>
bool(true)
}
-- With more arguments --
array(8) {
[0]=>
string(0) ""
[1]=>
string(0) ""
[2]=>
bool(false)
[3]=>
bool(true)
[4]=>
string(3) "one"
[5]=>
int(2)
["string"]=>
string(5) "hello"
["array"]=>
array(3) {
[0]=>
string(1) "a"
[1]=>
string(1) "b"
[2]=>
string(1) "c"
}
}
-- Iteration 17 --
-- With default argument --
array(6) {
array(3) {
[""]=>
int(2)
[0]=>
string(0) ""
int(5)
[1]=>
string(0) ""
[2]=>
NULL
[3]=>
NULL
[4]=>
bool(false)
[5]=>
bool(true)
int(6)
}
-- With more arguments --
array(10) {
array(7) {
[""]=>
int(2)
[0]=>
string(0) ""
int(5)
[1]=>
string(0) ""
int(6)
[2]=>
NULL
[3]=>
NULL
[4]=>
bool(false)
[5]=>
bool(true)
[6]=>
string(3) "one"
[7]=>
[3]=>
int(2)
["string"]=>
string(5) "hello"
@@ -670,40 +666,6 @@ array(10) {
}
-- Iteration 18 --
-- With default argument --
array(3) {
[""]=>
int(4)
[0]=>
int(5)
[1]=>
int(6)
}
-- With more arguments --
array(7) {
[""]=>
int(4)
[0]=>
int(5)
[1]=>
int(6)
[2]=>
string(3) "one"
[3]=>
int(2)
["string"]=>
string(5) "hello"
["array"]=>
array(3) {
[0]=>
string(1) "a"
[1]=>
string(1) "b"
[2]=>
string(1) "c"
}
}
-- Iteration 19 --
-- With default argument --
array(3) {
[0]=>
string(4) "str1"

View File

@@ -9,10 +9,6 @@ Test array_merge_recursive() function : usage variations - associative array wit
echo "*** Testing array_merge_recursive() : assoc. array with diff. keys to \$arr1 argument ***\n";
// get an unset variable
$unset_var = 10;
unset ($unset_var);
// get a resource variable
$fp = fopen(__FILE__, "r");
@@ -41,7 +37,7 @@ $arrays = array (
array("hello", $heredoc => array("heredoc", 'string'), "string"),
// array with object, unset variable and resource variable
/*8*/ array(@$unset_var => array("unset"), $fp => 'resource', 11, "hello")
/*8*/ array($fp => 'resource', 11, "hello")
);
// initialise the second array
@@ -292,12 +288,7 @@ array(7) {
}
-- Iteration 6 --
-- With default argument --
array(4) {
[""]=>
array(1) {
[0]=>
string(5) "unset"
}
array(3) {
[0]=>
string(8) "resource"
[1]=>
@@ -306,12 +297,7 @@ array(4) {
string(5) "hello"
}
-- With more arguments --
array(8) {
[""]=>
array(1) {
[0]=>
string(5) "unset"
}
array(7) {
[0]=>
string(8) "resource"
[1]=>

View File

@@ -12,10 +12,6 @@ echo "*** Testing array_merge() : usage variations ***\n";
// Initialise function arguments not being substituted
$arr = array ('one' => 1, 'two' => 2);
//get an unset variable
$unset_var = 10;
unset ($unset_var);
// heredoc string
$heredoc = <<<EOT
hello world
@@ -32,31 +28,13 @@ $inputs = array(
-2345 => 'negative',
),
// null data
/*4*/ 'null uppercase' => array(
NULL => 'null 1',
),
/*5*/ 'null lowercase' => array(
null => 'null 2',
),
// boolean data
/*6*/ 'bool lowercase' => array(
true => 'lowert',
false => 'lowerf',
),
/*7*/ 'bool uppercase' => array(
TRUE => 'uppert',
FALSE => 'upperf',
),
// empty data
/*8*/ 'empty double quotes' => array(
"" => 'emptyd',
),
/*9*/ 'empty single quotes' => array(
'' => 'emptys',
),
@@ -67,16 +45,6 @@ $inputs = array(
'strings' => 'strings',
$heredoc => 'stringh',
),
// undefined data
/*11*/ 'undefined' => array(
@$undefined_var => 'undefined',
),
// unset data
/*12*/ 'unset' => array(
@$unset_var => 'unset',
),
);
// loop through each element of $inputs to check the behavior of array_merge
@@ -123,43 +91,7 @@ array(6) {
string(8) "negative"
}
-- Iteration 2: null uppercase data --
array(3) {
[""]=>
string(6) "null 1"
["one"]=>
int(1)
["two"]=>
int(2)
}
array(3) {
["one"]=>
int(1)
["two"]=>
int(2)
[""]=>
string(6) "null 1"
}
-- Iteration 3: null lowercase data --
array(3) {
[""]=>
string(6) "null 2"
["one"]=>
int(1)
["two"]=>
int(2)
}
array(3) {
["one"]=>
int(1)
["two"]=>
int(2)
[""]=>
string(6) "null 2"
}
-- Iteration 4: bool lowercase data --
-- Iteration 2: bool lowercase data --
array(4) {
[0]=>
string(6) "lowert"
@@ -181,47 +113,7 @@ array(4) {
string(6) "lowerf"
}
-- Iteration 5: bool uppercase data --
array(4) {
[0]=>
string(6) "uppert"
[1]=>
string(6) "upperf"
["one"]=>
int(1)
["two"]=>
int(2)
}
array(4) {
["one"]=>
int(1)
["two"]=>
int(2)
[0]=>
string(6) "uppert"
[1]=>
string(6) "upperf"
}
-- Iteration 6: empty double quotes data --
array(3) {
[""]=>
string(6) "emptyd"
["one"]=>
int(1)
["two"]=>
int(2)
}
array(3) {
["one"]=>
int(1)
["two"]=>
int(2)
[""]=>
string(6) "emptyd"
}
-- Iteration 7: empty single quotes data --
-- Iteration 3: empty single quotes data --
array(3) {
[""]=>
string(6) "emptys"
@@ -239,7 +131,7 @@ array(3) {
string(6) "emptys"
}
-- Iteration 8: string data --
-- Iteration 4: string data --
array(5) {
["stringd"]=>
string(7) "stringd"
@@ -264,40 +156,4 @@ array(5) {
["hello world"]=>
string(7) "stringh"
}
-- Iteration 9: undefined data --
array(3) {
[""]=>
string(9) "undefined"
["one"]=>
int(1)
["two"]=>
int(2)
}
array(3) {
["one"]=>
int(1)
["two"]=>
int(2)
[""]=>
string(9) "undefined"
}
-- Iteration 10: unset data --
array(3) {
[""]=>
string(5) "unset"
["one"]=>
int(1)
["two"]=>
int(2)
}
array(3) {
["one"]=>
int(1)
["two"]=>
int(2)
[""]=>
string(5) "unset"
}
Done

View File

@@ -11,7 +11,7 @@ echo "*** Testing array_merge() : usage variations ***\n";
//mixed keys
$arr1 = array('zero', 20 => 'twenty', 'thirty' => 30, true => 'bool');
$arr2 = array(0, 1, 2, null => 'null', 0 => 'float');
$arr2 = array(0, 1, 2, 0 => 'float');
var_dump(array_merge($arr1, $arr2));
var_dump(array_merge($arr2, $arr1));
@@ -20,7 +20,7 @@ echo "Done";
?>
--EXPECT--
*** Testing array_merge() : usage variations ***
array(8) {
array(7) {
[0]=>
string(4) "zero"
[1]=>
@@ -35,18 +35,14 @@ array(8) {
int(1)
[5]=>
int(2)
[""]=>
string(4) "null"
}
array(8) {
array(7) {
[0]=>
string(5) "float"
[1]=>
int(1)
[2]=>
int(2)
[""]=>
string(4) "null"
[3]=>
string(4) "zero"
[4]=>

View File

@@ -28,7 +28,7 @@ EOT;
// heredoc with different whitespaces
$diff_whitespaces = <<<EOT
hello\r world\t
hello\n world\t
1111\t\t != 2222\v\v
heredoc\ndouble quoted string. with\vdifferent\fwhite\vspaces
EOT;
@@ -48,8 +48,8 @@ $inputs = array (
array(false,true), // with default keys and boolean values
array(), // empty array
/*5*/ array(NULL), // with NULL
array("a\v\f", "aaaa\r", "b\tbbb", "\[\]\!\@\#\$\%\^\&\*\(\)\{\}"), // with double quoted strings
array('a\v\f', 'aaaa\r', 'b\tbbb', '\[\]\!\@\#\$\%\^\&\*\(\)\{\}'), // with single quoted strings
array("a\v\f", "aaaa\n", "b\tbbb", "\[\]\!\@\#\$\%\^\&\*\(\)\{\}"), // with double quoted strings
array('a\v\f', 'aaaa\n', 'b\tbbb', '\[\]\!\@\#\$\%\^\&\*\(\)\{\}'), // with single quoted strings
array("h1" => $blank_line, "h2" => $multiline_string, "h3" => $diff_whitespaces, $numeric_string), // with heredocs
// associative arrays
@@ -60,11 +60,11 @@ $inputs = array (
array("one" => 1, 2 => "two", 4 => "four"), //mixed
// associative array, containing null/empty/boolean values as key/value
/*14*/ array(NULL => "NULL", null => "null", "NULL" => NULL, "null" => null),
/*14*/
array(true => "true", false => "false", "false" => false, "true" => true),
array("" => "emptyd", '' => 'emptys', "emptyd" => "", 'emptys' => ''),
array(1 => '', 2 => "", 3 => NULL, 4 => null, 5 => false, 6 => true),
array('' => 1, "" => 2, NULL => 3, null => 4, false => 5, true => 6),
array(1 => '', 2 => "", 5 => false, 6 => true),
array('' => 1, "" => 2, false => 5, true => 6),
// array with repetitive keys
/*19*/ array("One" => 1, "two" => 2, "One" => 10, "two" => 20, "three" => 3)
@@ -237,7 +237,8 @@ array(6) {
[0]=>
string(3) "a "
[1]=>
string(5) "aaaa "
string(5) "aaaa
"
[2]=>
string(5) "b bbb"
[3]=>
@@ -255,7 +256,8 @@ array(6) {
[2]=>
string(3) "a "
[3]=>
string(5) "aaaa "
string(5) "aaaa
"
[4]=>
string(5) "b bbb"
[5]=>
@@ -266,7 +268,7 @@ array(6) {
[0]=>
string(5) "a\v\f"
[1]=>
string(6) "aaaa\r"
string(6) "aaaa\n"
[2]=>
string(6) "b\tbbb"
[3]=>
@@ -284,7 +286,7 @@ array(6) {
[2]=>
string(5) "a\v\f"
[3]=>
string(6) "aaaa\r"
string(6) "aaaa\n"
[4]=>
string(6) "b\tbbb"
[5]=>
@@ -301,7 +303,8 @@ The big brown fox jumped over;
the lazy dog
This is a double quoted string"
["h3"]=>
string(88) "hello world
string(88) "hello
world
1111 != 2222
heredoc
double quoted string. with different white spaces"
@@ -330,7 +333,8 @@ The big brown fox jumped over;
the lazy dog
This is a double quoted string"
["h3"]=>
string(88) "hello world
string(88) "hello
world
1111 != 2222
heredoc
double quoted string. with different white spaces"
@@ -488,18 +492,18 @@ array(6) {
}
-- Iteration 14 --
array(6) {
[""]=>
string(4) "null"
["NULL"]=>
NULL
["null"]=>
NULL
[0]=>
string(5) "HELLO"
string(4) "true"
[1]=>
string(5) "HELLO"
string(5) "false"
["false"]=>
bool(false)
["true"]=>
bool(true)
[2]=>
string(5) "HELLO"
[3]=>
string(5) "HELLO"
}
array(6) {
[0]=>
@@ -507,27 +511,27 @@ array(6) {
[1]=>
string(5) "HELLO"
[2]=>
string(5) "HELLO"
[""]=>
string(4) "null"
["NULL"]=>
NULL
["null"]=>
NULL
string(4) "true"
[3]=>
string(5) "false"
["false"]=>
bool(false)
["true"]=>
bool(true)
}
-- Iteration 15 --
array(6) {
[""]=>
string(6) "emptys"
["emptyd"]=>
string(0) ""
["emptys"]=>
string(0) ""
[0]=>
string(4) "true"
[1]=>
string(5) "false"
["false"]=>
bool(false)
["true"]=>
bool(true)
[2]=>
string(5) "HELLO"
[3]=>
[1]=>
string(5) "HELLO"
[2]=>
string(5) "HELLO"
}
array(6) {
@@ -536,27 +540,27 @@ array(6) {
[1]=>
string(5) "HELLO"
[2]=>
string(4) "true"
[3]=>
string(5) "false"
["false"]=>
bool(false)
["true"]=>
bool(true)
string(5) "HELLO"
[""]=>
string(6) "emptys"
["emptyd"]=>
string(0) ""
["emptys"]=>
string(0) ""
}
-- Iteration 16 --
array(6) {
[""]=>
string(6) "emptys"
["emptyd"]=>
string(0) ""
["emptys"]=>
string(0) ""
[0]=>
string(5) "HELLO"
string(0) ""
[1]=>
string(5) "HELLO"
string(0) ""
[2]=>
bool(false)
[3]=>
bool(true)
[4]=>
string(5) "HELLO"
[5]=>
string(5) "HELLO"
}
array(6) {
@@ -565,73 +569,44 @@ array(6) {
[1]=>
string(5) "HELLO"
[2]=>
string(5) "HELLO"
[""]=>
string(6) "emptys"
["emptyd"]=>
string(0) ""
["emptys"]=>
[3]=>
string(0) ""
[4]=>
bool(false)
[5]=>
bool(true)
}
-- Iteration 17 --
array(6) {
[""]=>
int(2)
[0]=>
int(5)
[1]=>
string(0) ""
int(6)
[2]=>
string(0) ""
string(5) "HELLO"
[3]=>
NULL
string(5) "HELLO"
[4]=>
NULL
[5]=>
bool(false)
[6]=>
bool(true)
string(5) "HELLO"
}
array(6) {
[0]=>
string(5) "HELLO"
[1]=>
string(0) ""
string(5) "HELLO"
[2]=>
string(0) ""
string(5) "HELLO"
[""]=>
int(2)
[3]=>
NULL
int(5)
[4]=>
NULL
[5]=>
bool(false)
[6]=>
bool(true)
int(6)
}
-- Iteration 18 --
array(6) {
[""]=>
int(4)
[0]=>
int(5)
[1]=>
int(6)
[2]=>
string(5) "HELLO"
[3]=>
string(5) "HELLO"
[4]=>
string(5) "HELLO"
}
array(6) {
[0]=>
string(5) "HELLO"
[1]=>
string(5) "HELLO"
[2]=>
string(5) "HELLO"
[""]=>
int(4)
[3]=>
int(5)
[4]=>
int(6)
}
-- Iteration 19 --
array(6) {
["One"]=>
int(10)

View File

@@ -18,7 +18,7 @@ $mixed_array = array(
array( "1" => "one", "2" => "two", "3" => "three", "4" => "four", "5" => "five" ),
array( 1 => "one", 2 => "two", 3 => 7, 4 => "four", 5 => "five" ),
array( "f" => "fff", "1" => "one", 4 => 6, "" => "blank", 2 => "float", "F" => "FFF",
"blank" => "", 3 => 3.7, 5 => 7, 6 => 8.6, '5' => "Five", "4name" => "jonny", "a" => NULL, NULL => 3 ),
"blank" => "", 3 => 3.7, 5 => 7, 6 => 8.6, '5' => "Five", "4name" => "jonny", "a" => NULL ),
array( 12, "name", 'age', '45' ),
array( array("oNe", "tWo", 4), array(10, 20, 30, 40, 50), array() ),
array( "one" => 1, "one" => 2, "three" => 3, 3, 4, 3 => 33, 4 => 44, 5, 6,
@@ -175,7 +175,7 @@ array(12) {
[4]=>
int(6)
[""]=>
int(3)
string(5) "blank"
[2]=>
string(5) "float"
["F"]=>

View File

@@ -13,7 +13,7 @@ $mixed_array = array(
array( "1" => "one", "2" => "two", "3" => "three", "4" => "four", "5" => "five" ),
array( 1 => "one", 2 => "two", 3 => 7, 4 => "four", 5 => "five" ),
array( "f" => "fff", "1" => "one", 4 => 6, "" => "blank", 2 => "float", "F" => "FFF",
"blank" => "", 3 => 3.7, 5 => 7, 6 => 8.6, '5' => "Five", "4name" => "jonny", "a" => NULL, NULL => 3 ),
"blank" => "", 3 => 3.7, 5 => 7, 6 => 8.6, '5' => "Five", "4name" => "jonny", "a" => NULL ),
array( 12, "name", 'age', '45' ),
array( array("oNe", "tWo", 4), array(10, 20, 30, 40, 50), array() ),
array( "one" => 1, "one" => 2, "three" => 3, 3, 4, 3 => 33, 4 => 44, 5, 6,

View File

@@ -18,7 +18,7 @@ $mixed_array = array(
array( "1" => "one", "2" => "two", "3" => "three", "4" => "four", "5" => "five" ),
array( 1 => "one", 2 => "two", 3 => 7, 4 => "four", 5 => "five" ),
array( "f" => "fff", "1" => "one", 4 => 6, "" => "blank", 2 => "float", "F" => "FFF",
"blank" => "", 3 => 3.7, 5 => 7, 6 => 8.6, '5' => "Five", "4name" => "jonny", "a" => NULL, NULL => 3 ),
"blank" => "", 3 => 3.7, 5 => 7, 6 => 8.6, '5' => "Five", "4name" => "jonny", "a" => NULL),
array( 12, "name", 'age', '45' ),
array( array("oNe", "tWo", 4), array(10, 20, 30, 40, 50), array() ),
array( "one" => 1, "one" => 2, "three" => 3, 3, 4, 3 => 33, 4 => 44, 5, 6,
@@ -198,7 +198,7 @@ array(12) {
[4]=>
int(6)
[""]=>
int(3)
string(5) "blank"
[2]=>
string(5) "float"
["F"]=>

View File

@@ -11,10 +11,6 @@ echo "*** Testing array_push() : usage variations ***\n";
// Initialise function arguments not being substituted
$var = 'value';
//get an unset variable
$unset_var = 10;
unset ($unset_var);
// heredoc string
$heredoc = <<<EOT
hello world
@@ -31,28 +27,13 @@ $inputs = array(
-2345 => 'negative',
),
// null data
/*3*/ 'null uppercase' => array(
NULL => 'null 1',
),
'null lowercase' => array(
null => 'null 2',
),
// boolean data
/*4*/ 'bool lowercase' => array(
true => 'lowert',
false => 'lowerf',
),
'bool uppercase' => array(
TRUE => 'uppert',
FALSE => 'upperf',
),
// empty data
/*5*/ 'empty double quotes' => array(
"" => 'emptyd',
),
'empty single quotes' => array(
'' => 'emptys',
),
@@ -63,27 +44,15 @@ $inputs = array(
'strings' => 'strings',
$heredoc => 'stringh',
),
// undefined data
/*8*/ 'undefined' => array(
@$undefined_var => 'undefined',
),
// unset data
/*9*/ 'unset' => array(
@$unset_var => 'unset',
),
);
// loop through each sub-array of $inputs to check the behavior of array_push()
$iterator = 1;
foreach($inputs as $key => $input) {
echo "\n-- Iteration $iterator : $key data --\n";
echo "\n-- $key data --\n";
echo "Before : ";
var_dump(count($input));
echo "After : ";
var_dump( array_push($input, $var) );
$iterator++;
};
echo "Done";
@@ -91,43 +60,19 @@ echo "Done";
--EXPECT--
*** Testing array_push() : usage variations ***
-- Iteration 1 : int data --
-- int data --
Before : int(4)
After : int(5)
-- Iteration 2 : null uppercase data --
Before : int(1)
After : int(2)
-- Iteration 3 : null lowercase data --
Before : int(1)
After : int(2)
-- Iteration 4 : bool lowercase data --
-- bool lowercase data --
Before : int(2)
After : int(3)
-- Iteration 5 : bool uppercase data --
Before : int(2)
After : int(3)
-- Iteration 6 : empty double quotes data --
-- empty single quotes data --
Before : int(1)
After : int(2)
-- Iteration 7 : empty single quotes data --
Before : int(1)
After : int(2)
-- Iteration 8 : string data --
-- string data --
Before : int(3)
After : int(4)
-- Iteration 9 : undefined data --
Before : int(1)
After : int(2)
-- Iteration 10 : unset data --
Before : int(1)
After : int(2)
Done

View File

@@ -9,10 +9,6 @@ Test array_reverse() function : usage variations - different array values for 'a
echo "*** Testing array_reverse() : usage variations ***\n";
//get an unset variable
$unset_var = 10;
unset ($unset_var);
//get a resource variable
$fp = fopen(__FILE__, "r");
@@ -46,11 +42,11 @@ $arrays = array (
array("one" => 1, 2 => "two", 4 => "four"), //mixed
// associative array, containing null/empty/boolean values as key/value
/*13*/ array(NULL => "NULL", null => "null", "NULL" => NULL, "null" => null),
/*13*/
array(true => "true", false => "false", "false" => false, "true" => true),
array("" => "emptyd", '' => 'emptys', "emptyd" => "", 'emptys' => ''),
array(1 => '', 2 => "", 3 => NULL, 4 => null, 5 => false, 6 => true),
array('' => 1, "" => 2, NULL => 3, null => 4, false => 5, true => 6),
array(1 => '', 2 => "", 5 => false, 6 => true),
array('' => 1, "" => 2, false => 5, true => 6),
// array with repetitive keys
/*18*/ array("One" => 1, "two" => 2, "One" => 10, "two" => 20, "three" => 3)
@@ -404,141 +400,101 @@ array(3) {
}
-- Iteration 13 --
- with default argument -
array(3) {
["null"]=>
NULL
["NULL"]=>
NULL
[""]=>
string(4) "null"
array(4) {
["true"]=>
bool(true)
["false"]=>
bool(false)
[0]=>
string(5) "false"
[1]=>
string(4) "true"
}
- with $preserve keys = true -
array(3) {
["null"]=>
NULL
["NULL"]=>
NULL
[""]=>
string(4) "null"
array(4) {
["true"]=>
bool(true)
["false"]=>
bool(false)
[0]=>
string(5) "false"
[1]=>
string(4) "true"
}
- with $preserve_keys = false -
array(3) {
["null"]=>
NULL
["NULL"]=>
NULL
[""]=>
string(4) "null"
array(4) {
["true"]=>
bool(true)
["false"]=>
bool(false)
[0]=>
string(5) "false"
[1]=>
string(4) "true"
}
-- Iteration 14 --
- with default argument -
array(4) {
["true"]=>
bool(true)
["false"]=>
bool(false)
[0]=>
string(5) "false"
[1]=>
string(4) "true"
array(3) {
["emptys"]=>
string(0) ""
["emptyd"]=>
string(0) ""
[""]=>
string(6) "emptys"
}
- with $preserve keys = true -
array(4) {
["true"]=>
bool(true)
["false"]=>
bool(false)
[0]=>
string(5) "false"
[1]=>
string(4) "true"
array(3) {
["emptys"]=>
string(0) ""
["emptyd"]=>
string(0) ""
[""]=>
string(6) "emptys"
}
- with $preserve_keys = false -
array(4) {
["true"]=>
bool(true)
["false"]=>
bool(false)
[0]=>
string(5) "false"
[1]=>
string(4) "true"
array(3) {
["emptys"]=>
string(0) ""
["emptyd"]=>
string(0) ""
[""]=>
string(6) "emptys"
}
-- Iteration 15 --
- with default argument -
array(3) {
["emptys"]=>
string(0) ""
["emptyd"]=>
string(0) ""
[""]=>
string(6) "emptys"
}
- with $preserve keys = true -
array(3) {
["emptys"]=>
string(0) ""
["emptyd"]=>
string(0) ""
[""]=>
string(6) "emptys"
}
- with $preserve_keys = false -
array(3) {
["emptys"]=>
string(0) ""
["emptyd"]=>
string(0) ""
[""]=>
string(6) "emptys"
}
-- Iteration 16 --
- with default argument -
array(6) {
array(4) {
[0]=>
bool(true)
[1]=>
bool(false)
[2]=>
NULL
[3]=>
NULL
[4]=>
string(0) ""
[5]=>
[3]=>
string(0) ""
}
- with $preserve keys = true -
array(6) {
array(4) {
[6]=>
bool(true)
[5]=>
bool(false)
[4]=>
NULL
[3]=>
NULL
[2]=>
string(0) ""
[1]=>
string(0) ""
}
- with $preserve_keys = false -
array(6) {
array(4) {
[0]=>
bool(true)
[1]=>
bool(false)
[2]=>
NULL
[3]=>
NULL
[4]=>
string(0) ""
[5]=>
[3]=>
string(0) ""
}
-- Iteration 17 --
-- Iteration 16 --
- with default argument -
array(3) {
[0]=>
@@ -546,7 +502,7 @@ array(3) {
[1]=>
int(5)
[""]=>
int(4)
int(2)
}
- with $preserve keys = true -
array(3) {
@@ -555,7 +511,7 @@ array(3) {
[0]=>
int(5)
[""]=>
int(4)
int(2)
}
- with $preserve_keys = false -
array(3) {
@@ -564,9 +520,9 @@ array(3) {
[1]=>
int(5)
[""]=>
int(4)
int(2)
}
-- Iteration 18 --
-- Iteration 17 --
- with default argument -
array(3) {
["three"]=>

View File

@@ -9,10 +9,6 @@ Test array_reverse() function : usage variations - assoc. array with diff. keys
echo "*** Testing array_reverse() : usage variations ***\n";
//get an unset variable
$unset_var = 10;
unset ($unset_var);
//get a class
class classA{
public function __toString(){
@@ -42,10 +38,10 @@ $arrays = array (
array("hello", $heredoc => "string"), // heredoc
// array with object, unset variable and resource variable
array(@$unset_var => "hello", STDERR => 'resource'),
array(STDERR => 'resource'),
// array with mixed values
/*11*/ array('hello' => 1, "fruit" => 2.2, STDERR => 'resource', 133 => "int", @$unset_var => "unset", $heredoc => "heredoc")
/*11*/ array('hello' => 1, "fruit" => 2.2, STDERR => 'resource', 133 => "int", $heredoc => "heredoc")
);
// loop through the various elements of $arrays to test array_reverse()
@@ -245,33 +241,25 @@ array(2) {
}
-- Iteration 8 --
- default argument -
array(2) {
array(1) {
[0]=>
string(8) "resource"
[""]=>
string(5) "hello"
}
- $preserve keys = true -
array(2) {
array(1) {
[3]=>
string(8) "resource"
[""]=>
string(5) "hello"
}
- $preserve_keys = false -
array(2) {
array(1) {
[0]=>
string(8) "resource"
[""]=>
string(5) "hello"
}
-- Iteration 9 --
- default argument -
array(6) {
array(5) {
["Hello world"]=>
string(7) "heredoc"
[""]=>
string(5) "unset"
[0]=>
string(3) "int"
[1]=>
@@ -282,11 +270,9 @@ array(6) {
int(1)
}
- $preserve keys = true -
array(6) {
array(5) {
["Hello world"]=>
string(7) "heredoc"
[""]=>
string(5) "unset"
[133]=>
string(3) "int"
[3]=>
@@ -297,11 +283,9 @@ array(6) {
int(1)
}
- $preserve_keys = false -
array(6) {
array(5) {
["Hello world"]=>
string(7) "heredoc"
[""]=>
string(5) "unset"
[0]=>
string(3) "int"
[1]=>

View File

@@ -15,7 +15,7 @@ $misc_array = array (
0 =>"-.08",
"e" =>"5",
"y" =>NULL,
NULL =>"",
'' =>"",
0,
TRUE,
FALSE,

View File

@@ -8,10 +8,6 @@ Test array_shift() function : usage variations - Pass array with different data
echo "*** Testing array_shift() : usage variations ***\n";
//get an unset variable
$unset_var = 10;
unset ($unset_var);
// heredoc string
$heredoc = <<<EOT
hello world
@@ -28,30 +24,13 @@ $inputs = array(
-2345 => 'negative',
),
// null data
/*4*/ 'null uppercase' => array(
NULL => 'null 1',
),
/*5*/ 'null lowercase' => array(
null => 'null 2',
),
// boolean data
/*6*/ 'bool lowercase' => array(
true => 'lowert',
false => 'lowerf',
),
/*7*/ 'bool uppercase' => array(
TRUE => 'uppert',
FALSE => 'upperf',
),
// empty data
/*8*/ 'empty double quotes' => array(
"" => 'emptyd',
),
/*9*/ 'empty single quotes' => array(
'' => 'emptys',
@@ -63,16 +42,6 @@ $inputs = array(
'strings' => 'strings',
$heredoc => 'stringh',
),
// undefined data
/*11*/ 'undefined' => array(
@$undefined_var => 'undefined',
),
// unset data
/*12*/ 'unset' => array(
@$unset_var => 'unset',
),
);
// loop through each element of $inputs to check the behavior of array_shift()
@@ -100,41 +69,19 @@ array(3) {
string(8) "negative"
}
-- Iteration 2 : null uppercase data --
string(6) "null 1"
array(0) {
}
-- Iteration 3 : null lowercase data --
string(6) "null 2"
array(0) {
}
-- Iteration 4 : bool lowercase data --
-- Iteration 2 : bool lowercase data --
string(6) "lowert"
array(1) {
[0]=>
string(6) "lowerf"
}
-- Iteration 5 : bool uppercase data --
string(6) "uppert"
array(1) {
[0]=>
string(6) "upperf"
}
-- Iteration 6 : empty double quotes data --
string(6) "emptyd"
array(0) {
}
-- Iteration 7 : empty single quotes data --
-- Iteration 3 : empty single quotes data --
string(6) "emptys"
array(0) {
}
-- Iteration 8 : string data --
-- Iteration 4 : string data --
string(7) "stringd"
array(2) {
["strings"]=>
@@ -142,14 +89,4 @@ array(2) {
["hello world"]=>
string(7) "stringh"
}
-- Iteration 9 : undefined data --
string(9) "undefined"
array(0) {
}
-- Iteration 10 : unset data --
string(5) "unset"
array(0) {
}
Done

View File

@@ -13,10 +13,6 @@ echo "*** Testing array_slice() : usage variations ***\n";
$offset = 0;
$length = 10; // to ensure all elements are displayed
//get an unset variable
$unset_var = 10;
unset ($unset_var);
// heredoc string
$heredoc = <<<EOT
hello world
@@ -33,30 +29,13 @@ $inputs = array(
-2345 => 'negative',
),
// null data
/*4*/ 'null uppercase' => array(
NULL => 'null 1',
),
/*5*/ 'null lowercase' => array(
null => 'null 2',
),
// boolean data
/*6*/ 'bool lowercase' => array(
true => 'lowert',
false => 'lowerf',
),
/*7*/ 'bool uppercase' => array(
TRUE => 'uppert',
FALSE => 'upperf',
),
// empty data
/*8*/ 'empty double quotes' => array(
"" => 'emptyd',
),
/*9*/ 'empty single quotes' => array(
'' => 'emptys',
@@ -68,16 +47,6 @@ $inputs = array(
'strings' => 'strings',
$heredoc => 'stringh',
),
// undefined data
/*11*/ 'undefined' => array(
@$undefined_var => 'undefined',
),
// unset data
/*12*/ 'unset' => array(
@$unset_var => 'unset',
),
);
// loop through each element of $inputs to check the behavior of array_slice()
@@ -120,31 +89,7 @@ array(4) {
string(8) "negative"
}
-- Iteration 2 : key type is null uppercase --
$preserve_keys = TRUE
array(1) {
[""]=>
string(6) "null 1"
}
$preserve_keys = FALSE
array(1) {
[""]=>
string(6) "null 1"
}
-- Iteration 3 : key type is null lowercase --
$preserve_keys = TRUE
array(1) {
[""]=>
string(6) "null 2"
}
$preserve_keys = FALSE
array(1) {
[""]=>
string(6) "null 2"
}
-- Iteration 4 : key type is bool lowercase --
-- Iteration 2 : key type is bool lowercase --
$preserve_keys = TRUE
array(2) {
[1]=>
@@ -160,35 +105,7 @@ array(2) {
string(6) "lowerf"
}
-- Iteration 5 : key type is bool uppercase --
$preserve_keys = TRUE
array(2) {
[1]=>
string(6) "uppert"
[0]=>
string(6) "upperf"
}
$preserve_keys = FALSE
array(2) {
[0]=>
string(6) "uppert"
[1]=>
string(6) "upperf"
}
-- Iteration 6 : key type is empty double quotes --
$preserve_keys = TRUE
array(1) {
[""]=>
string(6) "emptyd"
}
$preserve_keys = FALSE
array(1) {
[""]=>
string(6) "emptyd"
}
-- Iteration 7 : key type is empty single quotes --
-- Iteration 3 : key type is empty single quotes --
$preserve_keys = TRUE
array(1) {
[""]=>
@@ -200,7 +117,7 @@ array(1) {
string(6) "emptys"
}
-- Iteration 8 : key type is string --
-- Iteration 4 : key type is string --
$preserve_keys = TRUE
array(3) {
["stringd"]=>
@@ -219,28 +136,4 @@ array(3) {
["hello world"]=>
string(7) "stringh"
}
-- Iteration 9 : key type is undefined --
$preserve_keys = TRUE
array(1) {
[""]=>
string(9) "undefined"
}
$preserve_keys = FALSE
array(1) {
[""]=>
string(9) "undefined"
}
-- Iteration 10 : key type is unset --
$preserve_keys = TRUE
array(1) {
[""]=>
string(5) "unset"
}
$preserve_keys = FALSE
array(1) {
[""]=>
string(5) "unset"
}
Done

View File

@@ -26,7 +26,7 @@ EOT;
// heredoc with different whitespaces
$diff_whitespaces = <<<EOT
hello\r world\t
hello\n world\t
1111\t\t != 2222\v\v
heredoc\ndouble quoted string. with\vdifferent\fwhite\vspaces
EOT;
@@ -46,8 +46,8 @@ $inputs = array (
array(false, true, false), // with default keys and boolean values
array(), // empty array
/*5*/ array(NULL, null), // with NULL
array("a\v\f", "aaaa\r", "b", "aaaa\r", "\[\]\!\@\#\$\%\^\&\*\(\)\{\}"), // with double quoted strings
array('a\v\f', 'aaaa\r', 'b', 'aaaa\r', '\[\]\!\@\#\$\%\^\&\*\(\)\{\}'), // with single quoted strings
array("a\v\f", "aaaa\n", "b", "aaaa\n", "\[\]\!\@\#\$\%\^\&\*\(\)\{\}"), // with double quoted strings
array('a\v\f', 'aaaa\n', 'b', 'aaaa\n', '\[\]\!\@\#\$\%\^\&\*\(\)\{\}'), // with single quoted strings
array("h1" => $blank_line, "h2" => $multiline_string, "h3" => $diff_whitespaces, $blank_line), // with heredocs
// associative arrays
@@ -58,11 +58,11 @@ $inputs = array (
array("one" => 1, 2 => "two", 4 => "four"), //mixed
// associative array, containing null/empty/boolean values as key/value
/*14*/ array(NULL => "NULL", null => "null", "NULL" => NULL, "null" => null),
/*14*/
array(true => "true", false => "false", "false" => false, "true" => true),
array("" => "emptyd", '' => 'emptys', "emptyd" => "", 'emptys' => ''),
array(1 => '', 2 => "", 3 => NULL, 4 => null, 5 => false, 6 => true),
/*18*/ array('' => 1, "" => 2, NULL => 3, null => 4, false => 5, true => 6),
array(1 => '', 2 => "", 5 => false, 6 => true),
/*18*/ array('' => 1, "" => 2, false => 5, true => 6),
);
// loop through each sub-array of $inputs to check the behavior of array_unique()
@@ -111,7 +111,8 @@ array(4) {
[0]=>
string(3) "a "
[1]=>
string(5) "aaaa "
string(5) "aaaa
"
[2]=>
string(1) "b"
[4]=>
@@ -122,7 +123,7 @@ array(4) {
[0]=>
string(5) "a\v\f"
[1]=>
string(6) "aaaa\r"
string(6) "aaaa\n"
[2]=>
string(1) "b"
[4]=>
@@ -139,7 +140,8 @@ The quick brown fox jumped over;
the lazy dog
This is a double quoted string"
["h3"]=>
string(88) "hello world
string(88) "hello
world
1111 != 2222
heredoc
double quoted string. with different white spaces"
@@ -184,13 +186,6 @@ array(3) {
string(4) "four"
}
-- Iteration 14 --
array(2) {
[""]=>
string(4) "null"
["NULL"]=>
NULL
}
-- Iteration 15 --
array(4) {
[1]=>
string(4) "true"
@@ -201,24 +196,24 @@ array(4) {
["true"]=>
bool(true)
}
-- Iteration 16 --
-- Iteration 15 --
array(2) {
[""]=>
string(6) "emptys"
["emptyd"]=>
string(0) ""
}
-- Iteration 17 --
-- Iteration 16 --
array(2) {
[1]=>
string(0) ""
[6]=>
bool(true)
}
-- Iteration 18 --
-- Iteration 17 --
array(3) {
[""]=>
int(4)
int(2)
[0]=>
int(5)
[1]=>

View File

@@ -9,10 +9,6 @@ Test array_unique() function : usage variations - associative array with differe
echo "*** Testing array_unique() : assoc. array with diff. keys passed to \$input argument ***\n";
// get an unset variable
$unset_var = 10;
unset ($unset_var);
// get a class
class classA
{
@@ -38,7 +34,7 @@ $inputs = array (
array("hello", $heredoc => "string", "string"),
// array with object, unset variable and resource variable
/*8*/ array(@$unset_var => "hello", STDERR => 'resource', 11, "hello"),
/*8*/ array(STDERR => 'resource', 11, "hello"),
);
// loop through each sub-array of $inputs to check the behavior of array_unique()
@@ -96,11 +92,11 @@ array(2) {
}
-- Iteration 6 --
array(3) {
[""]=>
string(5) "hello"
[3]=>
string(8) "resource"
[4]=>
int(11)
[5]=>
string(5) "hello"
}
Done

View File

@@ -29,12 +29,11 @@ $arrays = array (
array( "one" => "ten", "two" => "twenty", "three" => "thirty"), // string key/value
array("one" => 1, 2 => "two", 4 => "four"), //mixed
// associative array, containing null/empty/boolean values as key/value
/*13*/ array(NULL => "NULL", null => "null", "NULL" => NULL, "null" => null),
array(true => "true", false => "false", "false" => false, "true" => true),
// associative array, containing empty/boolean values as key/value
/*13*/ array(true => "true", false => "false", "false" => false, "true" => true),
array("" => "emptyd", '' => 'emptys', "emptyd" => "", 'emptys' => ''),
array(1 => '', 2 => "", 3 => NULL, 4 => null, 5 => false, 6 => true),
array('' => 1, "" => 2, NULL => 3, null => 4, false => 5, true => 6),
array(1 => '', 2 => "", 5 => false, 6 => true),
array('' => 1, "" => 2, false => 5, true => 6),
// array with repetitive keys
/*18*/ array("One" => 1, "two" => 2, "One" => 10, "two" => 20, "three" => 3)
@@ -386,33 +385,6 @@ array(6) {
string(4) "four"
}
-- Iteration 13 --
int(4)
array(4) {
[0]=>
int(10)
[""]=>
string(4) "null"
["NULL"]=>
NULL
["null"]=>
NULL
}
int(6)
array(6) {
[0]=>
int(10)
[1]=>
string(5) "hello"
[2]=>
string(5) "world"
[""]=>
string(4) "null"
["NULL"]=>
NULL
["null"]=>
NULL
}
-- Iteration 14 --
int(5)
array(5) {
[0]=>
@@ -443,7 +415,7 @@ array(7) {
["true"]=>
bool(true)
}
-- Iteration 15 --
-- Iteration 14 --
int(4)
array(4) {
[0]=>
@@ -470,26 +442,22 @@ array(6) {
["emptys"]=>
string(0) ""
}
-- Iteration 16 --
-- Iteration 15 --
int(5)
array(5) {
[0]=>
int(10)
[1]=>
string(0) ""
[2]=>
string(0) ""
[3]=>
bool(false)
[4]=>
bool(true)
}
int(7)
array(7) {
[0]=>
int(10)
[1]=>
string(0) ""
[2]=>
string(0) ""
[3]=>
NULL
[4]=>
NULL
[5]=>
bool(false)
[6]=>
bool(true)
}
int(9)
array(9) {
[0]=>
int(10)
[1]=>
@@ -501,21 +469,17 @@ array(9) {
[4]=>
string(0) ""
[5]=>
NULL
[6]=>
NULL
[7]=>
bool(false)
[8]=>
[6]=>
bool(true)
}
-- Iteration 17 --
-- Iteration 16 --
int(4)
array(4) {
[0]=>
int(10)
[""]=>
int(4)
int(2)
[1]=>
int(5)
[2]=>
@@ -530,13 +494,13 @@ array(6) {
[2]=>
string(5) "world"
[""]=>
int(4)
int(2)
[3]=>
int(5)
[4]=>
int(6)
}
-- Iteration 18 --
-- Iteration 17 --
int(4)
array(4) {
[0]=>

View File

@@ -10,10 +10,6 @@ Test array_unshift() function : usage variations - assoc. array with diff. keys
echo "*** Testing array_unshift() : associative array with different keys ***\n";
//get an unset variable
$unset_var = 10;
unset ($unset_var);
//get a resource variable
$fp = fopen(__FILE__, "r");
@@ -52,12 +48,12 @@ $arrays = array (
array("hello", $heredoc => "string"), // heredoc
// array with object, unset variable and resource variable
array(@$unset_var => "hello", $fp => 'resource'),
array($fp => 'resource'),
// array with mixed keys
/*11*/ array('hello' => 1, "fruit" => 2.2,
$fp => 'resource', 133 => "int",
@$unset_var => "unset", $heredoc => "heredoc")
$heredoc => "heredoc")
);
// loop through the various elements of $arrays to test array_unshift()
@@ -265,31 +261,27 @@ array(5) {
string(6) "string"
}
-- Iteration 8 --
int(3)
array(3) {
int(2)
array(2) {
[0]=>
int(10)
[""]=>
string(5) "hello"
[1]=>
string(8) "resource"
}
int(5)
array(5) {
int(4)
array(4) {
[0]=>
int(10)
[1]=>
string(5) "hello"
[2]=>
string(5) "world"
[""]=>
string(5) "hello"
[3]=>
string(8) "resource"
}
-- Iteration 9 --
int(7)
array(7) {
int(6)
array(6) {
[0]=>
int(10)
["hello"]=>
@@ -300,13 +292,11 @@ array(7) {
string(8) "resource"
[2]=>
string(3) "int"
[""]=>
string(5) "unset"
["Hello world"]=>
string(7) "heredoc"
}
int(9)
array(9) {
int(8)
array(8) {
[0]=>
int(10)
[1]=>
@@ -321,8 +311,6 @@ array(9) {
string(8) "resource"
[4]=>
string(3) "int"
[""]=>
string(5) "unset"
["Hello world"]=>
string(7) "heredoc"
}

View File

@@ -9,10 +9,6 @@ Test array_values() function : usage variations - array keys different data type
echo "*** Testing array_values() : usage variations ***\n";
//get an unset variable
$unset_var = 10;
unset ($unset_var);
// heredoc string
$heredoc = <<<EOT
hello world
@@ -29,31 +25,12 @@ $inputs = array(
-2345 => 'negative',
),
// null data
/*4*/ 'null uppercase' => array(
NULL => 'null 1',
),
/*5*/ 'null lowercase' => array(
null => 'null 2',
),
// boolean data
/*6*/ 'bool lowercase' => array(
true => 'lowert',
false => 'lowerf',
),
/*7*/ 'bool uppercase' => array(
TRUE => 'uppert',
FALSE => 'upperf',
),
// empty data
/*8*/ 'empty double quotes' => array(
"" => 'emptyd',
),
/*9*/ 'empty single quotes' => array(
'' => 'emptys',
),
@@ -64,31 +41,19 @@ $inputs = array(
'strings' => 'strings',
$heredoc => 'stringh',
),
// undefined data
/*11*/ 'undefined' => array(
@$undefined_var => 'undefined',
),
// unset data
/*12*/ 'unset' => array(
@$unset_var => 'unset',
),
);
// loop through each element of $inputs to check the behavior of array_values()
$iterator = 1;
foreach($inputs as $key => $input) {
echo "\n-- Iteration $iterator: $key data --\n";
echo "\n-- $key data --\n";
var_dump( array_values($input) );
$iterator++;
};
echo "Done";
?>
--EXPECT--
*** Testing array_values() : usage variations ***
-- Iteration 1: int data --
-- int data --
array(4) {
[0]=>
string(4) "zero"
@@ -100,19 +65,7 @@ array(4) {
string(8) "negative"
}
-- Iteration 2: null uppercase data --
array(1) {
[0]=>
string(6) "null 1"
}
-- Iteration 3: null lowercase data --
array(1) {
[0]=>
string(6) "null 2"
}
-- Iteration 4: bool lowercase data --
-- bool lowercase data --
array(2) {
[0]=>
string(6) "lowert"
@@ -120,27 +73,13 @@ array(2) {
string(6) "lowerf"
}
-- Iteration 5: bool uppercase data --
array(2) {
[0]=>
string(6) "uppert"
[1]=>
string(6) "upperf"
}
-- Iteration 6: empty double quotes data --
array(1) {
[0]=>
string(6) "emptyd"
}
-- Iteration 7: empty single quotes data --
-- empty single quotes data --
array(1) {
[0]=>
string(6) "emptys"
}
-- Iteration 8: string data --
-- string data --
array(3) {
[0]=>
string(7) "stringd"
@@ -149,16 +88,4 @@ array(3) {
[2]=>
string(7) "stringh"
}
-- Iteration 9: undefined data --
array(1) {
[0]=>
string(9) "undefined"
}
-- Iteration 10: unset data --
array(1) {
[0]=>
string(5) "unset"
}
Done

View File

@@ -37,6 +37,10 @@ try {
Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d
Deprecated: Implicit conversion from float 7.38 to int loses precision in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
Deprecated: Using null as an array offset is deprecated, use an empty string instead in %s on line %d
array(8) {
[10]=>
array(1) {

View File

@@ -17,7 +17,7 @@ print "COUNT_RECURSIVE: should be 6, is ".count($arr, COUNT_RECURSIVE)."\n";
print "-- Testing various types with no second argument --\n";
print "COUNT_NORMAL: should be 2, is ".count(array("a", array("b")))."\n";
$arr = array('a'=>array(NULL, NULL, NULL), 1=>array(NULL=>1, 1=>NULL),
$arr = array('a'=>array(NULL, NULL, NULL), 1=>array(''=>1, 1=>NULL),
array(array(array(array(array(NULL))))));
print "-- Testing really cool arrays --\n";
print "COUNT_NORMAL: should be 3, is ".count($arr, COUNT_NORMAL)."\n";
@@ -27,14 +27,14 @@ echo "\n*** Testing possible variations of count() function on arrays ***";
$count_array = array(
array(),
array( 1 => "string"),
array( "" => "string", 0 => "a", NULL => "b", -1 => "c",
array( "" => "string", 0 => "a", -1 => "c",
array(array(array(NULL)))),
array( -2 => 12, array(array(1, 2, array(array("0"))))),
array( "a" => 1, "b" => -2.344, "b" => "string", "c" => NULL, "d" => -2.344),
array( 4 => 1, 3 => -2.344, "3" => "string", "2" => NULL,
1 => -2.344, array()),
array( TRUE => TRUE, FALSE => FALSE, "" => "", " " => " ",
NULL => NULL, "\x000" => "\x000", "\000" => "\000"),
"\x000" => "\x000", "\000" => "\000"),
array( NULL, 1 => "Hi", "string" => "hello",
array("" => "World", "-2.34" => "a", "0" => "b"))
);

View File

@@ -6,7 +6,7 @@ Test extract() function (variation 4)
$mixed_array = array(
array( 1 => "one", 2 => "two", 3 => 7, 4 => "four", 5 => "five" ),
array( "f" => "fff", "1" => "one", 4 => 6, "" => "blank", 2 => "float", "F" => "FFF",
"blank" => "", 3 => 3.7, 5 => 7, 6 => 8.6, '5' => "Five", "4name" => "jonny", "a" => NULL, NULL => 3 ),
"blank" => "", 3 => 3.7, 5 => 7, 6 => 8.6, '5' => "Five", "4name" => "jonny", "a" => NULL),
array( 12, "name", 'age', '45' ),
);

View File

@@ -9,7 +9,7 @@ $a = array( "1" => "one", "2" => "two", "3" => "three", "4" => "four", "5" => "f
var_dump ( extract($a, EXTR_PREFIX_ALL, "same"));
$b = array( "f" => "fff", "1" => "one", 4 => 6, "" => "blank", 2 => "float", "F" => "FFF",
"blank" => "", 3 => 3.7, 5 => 7, 6 => 8.6, '5' => "Five", "4name" => "jonny", "a" => NULL, NULL => 3 );
"blank" => "", 3 => 3.7, 5 => 7, 6 => 8.6, '5' => "Five", "4name" => "jonny", "a" => NULL);
var_dump ( extract($b, EXTR_PREFIX_ALL, "same"));
var_dump ( extract($b, EXTR_PREFIX_ALL, "diff"));

View File

@@ -14,7 +14,7 @@ $misc_array = array (
0 =>"-.08",
"e" =>"5",
"y" =>NULL,
NULL =>"",
'' =>"",
0,
TRUE,
FALSE,

View File

@@ -28,31 +28,12 @@ $inputs = array(
-2345 => 'negative',
),
// null data
/*4*/ 'null uppercase' => array(
NULL => 'null 1',
),
/*5*/ 'null lowercase' => array(
null => 'null 2',
),
// boolean data
/*6*/ 'bool lowercase' => array(
true => 'lowert',
false => 'lowerf',
),
/*7*/ 'bool uppercase' => array(
TRUE => 'uppert',
FALSE => 'upperf',
),
// empty data
/*8*/ 'empty double quotes' => array(
"" => 'emptyd',
),
/*9*/ 'empty single quotes' => array(
'' => 'emptys',
),
@@ -63,16 +44,6 @@ $inputs = array(
'strings' => 'strings',
$heredoc => 'stringh',
),
// undefined data
/*11*/ 'undefined' => array(
@$undefined_var => 'undefined',
),
// unset data
/*12*/ 'unset' => array(
@$unset_var => 'unset',
),
);
// loop through each element of $inputs to check the behavior of key()
@@ -95,33 +66,14 @@ int(1)
int(12345)
int(-2345)
-- Iteration 2 : null uppercase data --
string(0) ""
-- Iteration 3 : null lowercase data --
string(0) ""
-- Iteration 4 : bool lowercase data --
-- Iteration 2 : bool lowercase data --
int(1)
int(0)
-- Iteration 5 : bool uppercase data --
int(1)
int(0)
-- Iteration 6 : empty double quotes data --
-- Iteration 3 : empty single quotes data --
string(0) ""
-- Iteration 7 : empty single quotes data --
string(0) ""
-- Iteration 8 : string data --
-- Iteration 4 : string data --
string(7) "stringd"
string(7) "strings"
string(11) "hello world"
-- Iteration 9 : undefined data --
string(0) ""
-- Iteration 10 : unset data --
string(0) ""

View File

@@ -17,7 +17,7 @@ $mixed_values = array (
"sub_array[2,3]" => array(22,-55), "sub_array[2,4]" => array()
),
4 => 4, "4" => "4", 4 => 4.01, "b" => "b", "5" => "5", -2 => -2, -2 => -2.01,
-2 => -2.98989, "-.9" => "-.9", "True" => "True", "" => "", NULL => NULL,
-2 => -2.98989, "-.9" => "-.9", "True" => "True", "" => "",
"ab" => "ab", "abcd" => "abcd", 0 => 0.01, -0 => -0, '' => '' ,
"abcd\x00abcd\x00abcd" => "abcd\x00abcd\x00abcd", 0 => 0.001
);

View File

@@ -14,11 +14,9 @@ const EXPECTED_RESULT = [
"\v" => "\v",
"\n" => "\n",
"\t" => "\t",
null => null,
];
$array = [
null => null,
"\a" => "\a",
"\cx" => "\cx",
"\e" => "\e",

View File

@@ -17,7 +17,7 @@ $mixed_values = array (
"sub_array[2,3]" => array(22,-55), "sub_array[2,4]" => array()
),
4 => 4, "4" => "4", 4 => 4.01, "b" => "b", "5" => "5", -2 => -2, -2 => -2.01,
-2 => -2.98989, "-.9" => "-.9", "True" => "True", "" => "", NULL => NULL,
-2 => -2.98989, "-.9" => "-.9", "True" => "True", "" => "",
"ab" => "ab", "abcd" => "abcd", 0 => 0.01, -0 => -0, '' => '' ,
"abcd\x00abcd\x00abcd" => "abcd\x00abcd\x00abcd", 0 => 0.001
);

View File

@@ -4,7 +4,6 @@ Test asort() function: sorting escape sequences
<?php
const EXPECTED_RESULT = [
null => null,
"\t" => "\t",
"\n" => "\n",
"\v" => "\v",
@@ -18,7 +17,6 @@ const EXPECTED_RESULT = [
];
$array = [
null => null,
"\a" => "\a",
"\cx" => "\cx",
"\e" => "\e",

View File

@@ -18,7 +18,7 @@ $mixed_values = array (
"sub_array[2,3]" => array(22,-55), "sub_array[2,4]" => array()
),
4 => 4, "4" => "4", 4 => 4.01, "b" => "b", "5" => "5", -2 => -2, -2 => -2.01,
-2 => -2.98989, "-.9" => "-.9", "True" => "True", "" => "", NULL => NULL,
-2 => -2.98989, "-.9" => "-.9", "True" => "True", "" => "",
"ab" => "ab", "abcd" => "abcd", 0 => 0.01, -0 => -0, '' => '' ,
"abcd\x00abcd\x00abcd" => "abcd\x00abcd\x00abcd", 0 => 0.001
);

View File

@@ -14,11 +14,9 @@ const EXPECTED_RESULT = [
"\v" => "\v",
"\n" => "\n",
"\t" => "\t",
null => null,
];
$array = [
null => null,
"\a" => "\a",
"\cx" => "\cx",
"\e" => "\e",

View File

@@ -17,7 +17,7 @@ $mixed_values = array (
"sub_array[2,3]" => array(22,-55), "sub_array[2,4]" => array()
),
4 => 4, "4" => "4", 4 => 4.01, "b" => "b", "5" => "5", -2 => -2, -2 => -2.01,
-2 => -2.98989, "-.9" => "-.9", "True" => "True", "" => "", NULL => NULL,
-2 => -2.98989, "-.9" => "-.9", "True" => "True", "" => "",
"ab" => "ab", "abcd" => "abcd", 0 => 0.01, -0 => -0, '' => '' ,
"abcd\x00abcd\x00abcd" => "abcd\x00abcd\x00abcd", 0 => 0.001
);

View File

@@ -4,7 +4,6 @@ Test ksort() function: sorting escape sequences
<?php
const EXPECTED_RESULT = [
null => null,
"\t" => "\t",
"\n" => "\n",
"\v" => "\v",
@@ -18,7 +17,6 @@ const EXPECTED_RESULT = [
];
$array = [
null => null,
"\a" => "\a",
"\cx" => "\cx",
"\e" => "\e",

View File

@@ -8,10 +8,6 @@ Test natcasesort() function : usage variations - Different array keys
echo "*** Testing natcasesort() : usage variations ***\n";
//get an unset variable
$unset_var = 10;
unset ($unset_var);
// heredoc string
$heredoc = <<<EOT
hello world
@@ -28,31 +24,12 @@ $inputs = array(
-2345 => 'negative',
),
// null data
/*4*/ 'null uppercase' => array(
NULL => 'null 1',
),
/*5*/ 'null lowercase' => array(
null => 'null 2',
),
// boolean data
/*6*/ 'bool lowercase' => array(
true => 'lowert',
false => 'lowerf',
),
/*7*/ 'bool uppercase' => array(
TRUE => 'uppert',
FALSE => 'upperf',
),
// empty data
/*8*/ 'empty double quotes' => array(
"" => 'emptyd',
),
/*9*/ 'empty single quotes' => array(
'' => 'emptys',
),
@@ -64,16 +41,6 @@ $inputs = array(
$heredoc => 'stringh',
),
// undefined data
/*11*/ 'undefined' => array(
@$undefined_var => 'undefined',
),
// unset data
/*12*/ 'unset' => array(
@$unset_var => 'unset',
),
// duplicate values
/*13*/ 'duplicate' => array(
'foo' => 'bar',
@@ -112,20 +79,6 @@ array(4) {
-- Iteration 2 --
bool(true)
array(1) {
[""]=>
string(6) "null 1"
}
-- Iteration 3 --
bool(true)
array(1) {
[""]=>
string(6) "null 2"
}
-- Iteration 4 --
bool(true)
array(2) {
[0]=>
string(6) "lowerf"
@@ -133,30 +86,14 @@ array(2) {
string(6) "lowert"
}
-- Iteration 5 --
bool(true)
array(2) {
[0]=>
string(6) "upperf"
[1]=>
string(6) "uppert"
}
-- Iteration 6 --
bool(true)
array(1) {
[""]=>
string(6) "emptyd"
}
-- Iteration 7 --
-- Iteration 3 --
bool(true)
array(1) {
[""]=>
string(6) "emptys"
}
-- Iteration 8 --
-- Iteration 4 --
bool(true)
array(3) {
["stringd"]=>
@@ -167,21 +104,7 @@ array(3) {
string(7) "strings"
}
-- Iteration 9 --
bool(true)
array(1) {
[""]=>
string(9) "undefined"
}
-- Iteration 10 --
bool(true)
array(1) {
[""]=>
string(5) "unset"
}
-- Iteration 11 --
-- Iteration 5 --
bool(true)
array(3) {
["foo"]=>

View File

@@ -33,7 +33,7 @@ $array_arg = array(
/*7*/ array("hex1" => 0x123, 'hex2' => 0xabc, "hex\t3" => 0xABC, "hex\04" => 0xAb1),
// array with negative hexa values
array(NULL => -0x123, "NULL" => -0xabc, "-ABC" => -0xABC, -0xAB1 => -0xAb1),
array('' => -0x123, "NULL" => -0xabc, "-ABC" => -0xABC, -0xAB1 => -0xAb1),
// array with positive octal values
/*9*/ array(0123 => 0123, "0234" => 0234, '034' => 034, 00 => 00),
@@ -41,9 +41,6 @@ $array_arg = array(
// array with negative octal values
array(-0123 => -0123, "-0234" => -0234, '-034' => -034),
// array with null values
/*11*/ array(NULL => NULL, "null" => NULL, "NULL" => NULL)
);
// looping to test shuffle() with each sub-array in the $array_arg array
@@ -209,17 +206,4 @@ array(3) {
[2]=>
int(-%d)
}
-- Iteration 11 --
bool(true)
The output array is:
array(3) {
[0]=>
NULL
[1]=>
NULL
[2]=>
NULL
}
Done

View File

@@ -51,19 +51,12 @@ $array_arg = array(
// string keys
'key' => 5, //single quoted key
"two" => 4, //double quoted key
'' => 3,
"" => 2,
'' => 35,
" " => 0, // space as key
// bool keys
true => 15,
false => 5,
TRUE => 100,
FALSE => 25,
// null keys
null => 20, // expecting: value will be replaced by 'NULL'
NULL => 35,
true => 100,
false => 25,
// binary key
"a".chr(0)."b" => 45,

View File

@@ -45,14 +45,12 @@ $array_arg = array(
'key' => 5, //single quoted key
"two" => 4, //double quoted key
" " => 0, // space as key
'' => 35,
// bool keys
TRUE => 100,
FALSE => 25,
// null keys
NULL => 35,
// binary key
"a".chr(0)."b" => 45,
b"binary" => 30,

View File

@@ -24,12 +24,11 @@ $pieces_arrays = array (
array( "one" => "ten", "two" => "twenty", "three" => "thirty"), // string key/value
array("one" => 1, 2 => "two", 4 => "four"), //mixed
// associative array, containing null/empty/boolean values as key/value
array(NULL => "NULL", null => "null", "NULL" => NULL, "null" => null),
// associative array, containing empty/boolean values as key/value
array(true => "true", false => "false", "false" => false, "true" => true),
array("" => "emptyd", '' => 'emptys', "emptyd" => "", 'emptys' => ''),
array(1 => '', 2 => "", 3 => NULL, 4 => null, 5 => false, 6 => true),
array('' => 1, "" => 2, NULL => 3, null => 4, false => 5, true => 6),
array(1 => '', 2 => "", 5 => false, 6 => true),
array('' => 1, "" => 2, false => 5, true => 6),
// array with repetitive keys
array("One" => 1, "two" => 2, "One" => 10, "two" => 20, "three" => 3)
@@ -79,15 +78,13 @@ string(23) "ten], [twenty], [thirty"
-- Iteration 12 --
string(16) "1], [two], [four"
-- Iteration 13 --
string(12) "null], [], ["
-- Iteration 14 --
string(22) "true], [false], [], [1"
-- Iteration 15 --
-- Iteration 14 --
string(14) "emptys], [], ["
-- Iteration 15 --
string(13) "], [], [], [1"
-- Iteration 16 --
string(21) "], [], [], [], [], [1"
string(11) "2], [5], [6"
-- Iteration 17 --
string(11) "4], [5], [6"
-- Iteration 18 --
string(13) "10], [20], [3"
Done