diff options
| -rw-r--r-- | Zend/tests/generators/errors/count_error.phpt | 8 | ||||
| -rw-r--r-- | Zend/zend_vm_def.h | 16 | ||||
| -rw-r--r-- | Zend/zend_vm_execute.h | 48 | ||||
| -rw-r--r-- | ext/standard/array.c | 18 | ||||
| -rw-r--r-- | ext/standard/tests/array/count_invalid.phpt | 82 | ||||
| -rw-r--r-- | ext/standard/tests/array/count_recursive.phpt | 55 | ||||
| -rw-r--r-- | ext/standard/tests/array/sizeof_basic1.phpt | 65 | ||||
| -rw-r--r-- | ext/standard/tests/array/sizeof_object2.phpt | 98 | ||||
| -rw-r--r-- | ext/standard/tests/array/sizeof_variation1.phpt | 322 | ||||
| -rw-r--r-- | ext/standard/tests/array/sizeof_variation4.phpt | 463 | ||||
| -rw-r--r-- | ext/standard/tests/general_functions/is_countable_with_variables.phpt | 11 |
11 files changed, 117 insertions, 1069 deletions
diff --git a/Zend/tests/generators/errors/count_error.phpt b/Zend/tests/generators/errors/count_error.phpt index 2eacfd0d35..b88902d841 100644 --- a/Zend/tests/generators/errors/count_error.phpt +++ b/Zend/tests/generators/errors/count_error.phpt @@ -9,10 +9,10 @@ $gen = gen(); try { count($gen); -} catch (Exception $e) { - echo $e; +} catch (\TypeError $e) { + echo $e->getMessage(), PHP_EOL; } ?> ---EXPECTF-- -Warning: count(): Argument #1 ($var) must be of type Countable|array, Generator given in %s on line %d +--EXPECT-- +count(): Argument #1 ($var) must be of type Countable|array, Generator given diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 9e10721265..1c06bb42e9 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -8883,6 +8883,7 @@ ZEND_VM_COLD_CONST_HANDLER(190, ZEND_COUNT, CONST|TMPVAR|CV, UNUSED) SAVE_OPLINE(); op1 = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R); + while (1) { if (Z_TYPE_P(op1) == IS_ARRAY) { count = zend_array_count(Z_ARRVAL_P(op1)); @@ -8911,20 +8912,15 @@ ZEND_VM_COLD_CONST_HANDLER(190, ZEND_COUNT, CONST|TMPVAR|CV, UNUSED) break; } - /* If There's no handler and it doesn't implement Countable then add a warning */ - count = 1; + /* If There's no handler and it doesn't implement Countable then emit a TypeError */ } else if ((OP1_TYPE & (IS_VAR|IS_CV)) != 0 && Z_TYPE_P(op1) == IS_REFERENCE) { op1 = Z_REFVAL_P(op1); continue; - } else if (Z_TYPE_P(op1) <= IS_NULL) { - if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(op1) == IS_UNDEF)) { - ZVAL_UNDEFINED_OP1(); - } - count = 0; - } else { - count = 1; + } else if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(op1) == IS_UNDEF)) { + ZVAL_UNDEFINED_OP1(); } - zend_error(E_WARNING, "%s(): Argument #1 ($var) must be of type Countable|array, %s given", opline->extended_value ? "sizeof" : "count", zend_zval_type_name(op1)); + count = 0; + zend_type_error("%s(): Argument #1 ($var) must be of type Countable|array, %s given", opline->extended_value ? "sizeof" : "count", zend_zval_type_name(op1)); break; } diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index ac0dd911c0..f43fc024b9 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -10324,6 +10324,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_CONST_ SAVE_OPLINE(); op1 = RT_CONSTANT(opline, opline->op1); + while (1) { if (Z_TYPE_P(op1) == IS_ARRAY) { count = zend_array_count(Z_ARRVAL_P(op1)); @@ -10352,20 +10353,15 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_CONST_ break; } - /* If There's no handler and it doesn't implement Countable then add a warning */ - count = 1; + /* If There's no handler and it doesn't implement Countable then emit a TypeError */ } else if ((IS_CONST & (IS_VAR|IS_CV)) != 0 && Z_TYPE_P(op1) == IS_REFERENCE) { op1 = Z_REFVAL_P(op1); continue; - } else if (Z_TYPE_P(op1) <= IS_NULL) { - if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(op1) == IS_UNDEF)) { - ZVAL_UNDEFINED_OP1(); - } - count = 0; - } else { - count = 1; + } else if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(op1) == IS_UNDEF)) { + ZVAL_UNDEFINED_OP1(); } - zend_error(E_WARNING, "%s(): Argument #1 ($var) must be of type Countable|array, %s given", opline->extended_value ? "sizeof" : "count", zend_zval_type_name(op1)); + count = 0; + zend_type_error("%s(): Argument #1 ($var) must be of type Countable|array, %s given", opline->extended_value ? "sizeof" : "count", zend_zval_type_name(op1)); break; } @@ -17567,6 +17563,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_TMPVAR_UNUSED_HANDL SAVE_OPLINE(); op1 = _get_zval_ptr_var(opline->op1.var EXECUTE_DATA_CC); + while (1) { if (Z_TYPE_P(op1) == IS_ARRAY) { count = zend_array_count(Z_ARRVAL_P(op1)); @@ -17595,20 +17592,15 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_TMPVAR_UNUSED_HANDL break; } - /* If There's no handler and it doesn't implement Countable then add a warning */ - count = 1; + /* If There's no handler and it doesn't implement Countable then emit a TypeError */ } else if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_CV)) != 0 && Z_TYPE_P(op1) == IS_REFERENCE) { op1 = Z_REFVAL_P(op1); continue; - } else if (Z_TYPE_P(op1) <= IS_NULL) { - if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_P(op1) == IS_UNDEF)) { - ZVAL_UNDEFINED_OP1(); - } - count = 0; - } else { - count = 1; + } else if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_P(op1) == IS_UNDEF)) { + ZVAL_UNDEFINED_OP1(); } - zend_error(E_WARNING, "%s(): Argument #1 ($var) must be of type Countable|array, %s given", opline->extended_value ? "sizeof" : "count", zend_zval_type_name(op1)); + count = 0; + zend_type_error("%s(): Argument #1 ($var) must be of type Countable|array, %s given", opline->extended_value ? "sizeof" : "count", zend_zval_type_name(op1)); break; } @@ -47327,6 +47319,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_CV_UNUSED_HANDLER(Z SAVE_OPLINE(); op1 = EX_VAR(opline->op1.var); + while (1) { if (Z_TYPE_P(op1) == IS_ARRAY) { count = zend_array_count(Z_ARRVAL_P(op1)); @@ -47355,20 +47348,15 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_CV_UNUSED_HANDLER(Z break; } - /* If There's no handler and it doesn't implement Countable then add a warning */ - count = 1; + /* If There's no handler and it doesn't implement Countable then emit a TypeError */ } else if ((IS_CV & (IS_VAR|IS_CV)) != 0 && Z_TYPE_P(op1) == IS_REFERENCE) { op1 = Z_REFVAL_P(op1); continue; - } else if (Z_TYPE_P(op1) <= IS_NULL) { - if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_P(op1) == IS_UNDEF)) { - ZVAL_UNDEFINED_OP1(); - } - count = 0; - } else { - count = 1; + } else if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_P(op1) == IS_UNDEF)) { + ZVAL_UNDEFINED_OP1(); } - zend_error(E_WARNING, "%s(): Argument #1 ($var) must be of type Countable|array, %s given", opline->extended_value ? "sizeof" : "count", zend_zval_type_name(op1)); + count = 0; + zend_type_error("%s(): Argument #1 ($var) must be of type Countable|array, %s given", opline->extended_value ? "sizeof" : "count", zend_zval_type_name(op1)); break; } diff --git a/ext/standard/array.c b/ext/standard/array.c index bd2823a407..f99af84611 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -740,11 +740,6 @@ PHP_FUNCTION(count) } switch (Z_TYPE_P(array)) { - case IS_NULL: - /* Intentionally not converted to an exception */ - php_error_docref(NULL, E_WARNING, "%s(): Argument #1 ($var) must be of type Countable|array, %s given", get_active_function_name(), zend_zval_type_name(array)); - RETURN_LONG(0); - break; case IS_ARRAY: if (mode != COUNT_RECURSIVE) { cnt = zend_array_count(Z_ARRVAL_P(array)); @@ -774,18 +769,11 @@ PHP_FUNCTION(count) } return; } - - /* If There's no handler and it doesn't implement Countable then add a warning */ - /* Intentionally not converted to an exception */ - php_error_docref(NULL, E_WARNING, "%s(): Argument #1 ($var) must be of type Countable|array, %s given", get_active_function_name(), zend_zval_type_name(array)); - RETURN_LONG(1); - break; } + /* fallthrough */ default: - /* Intentionally not converted to an exception */ - php_error_docref(NULL, E_WARNING, "%s(): Argument #1 ($var) must be of type Countable|array, %s given", get_active_function_name(), zend_zval_type_name(array)); - RETURN_LONG(1); - break; + zend_argument_type_error(1, "must be of type Countable|array, %s given", zend_zval_type_name(array)); + RETURN_THROWS(); } } /* }}} */ diff --git a/ext/standard/tests/array/count_invalid.phpt b/ext/standard/tests/array/count_invalid.phpt index 4b146de85b..b4fb27c8a9 100644 --- a/ext/standard/tests/array/count_invalid.phpt +++ b/ext/standard/tests/array/count_invalid.phpt @@ -3,40 +3,54 @@ Only arrays and countable objects can be counted --FILE-- <?php -$result = count(null); -var_dump($result); - -$result = count("string"); -var_dump($result); - -$result = count(123); -var_dump($result); - -$result = count(true); -var_dump($result); - -$result = count(false); -var_dump($result); - -$result = count((object) []); -var_dump($result); +try { + $result = count(null); + var_dump($result); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} + +try { + $result = count("string"); + var_dump($result); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} + +try { + $result = count(123); + var_dump($result); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} + +try { + $result = count(true); + var_dump($result); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} + +try { + $result = count(false); + var_dump($result); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} + +try { + $result = count((object) []); + var_dump($result); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} ?> ---EXPECTF-- -Warning: count(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -Warning: count(): Argument #1 ($var) must be of type Countable|array, string given in %s on line %d -int(1) - -Warning: count(): Argument #1 ($var) must be of type Countable|array, int given in %s on line %d -int(1) - -Warning: count(): Argument #1 ($var) must be of type Countable|array, bool given in %s on line %d -int(1) - -Warning: count(): Argument #1 ($var) must be of type Countable|array, bool given in %s on line %d -int(1) +--EXPECT-- +count(): Argument #1 ($var) must be of type Countable|array, null given +count(): Argument #1 ($var) must be of type Countable|array, string given +count(): Argument #1 ($var) must be of type Countable|array, int given +count(): Argument #1 ($var) must be of type Countable|array, bool given +count(): Argument #1 ($var) must be of type Countable|array, bool given +count(): Argument #1 ($var) must be of type Countable|array, stdClass given -Warning: count(): Argument #1 ($var) must be of type Countable|array, stdClass given in %s on line %d -int(1) diff --git a/ext/standard/tests/array/count_recursive.phpt b/ext/standard/tests/array/count_recursive.phpt index 8532a74cb6..321706bc24 100644 --- a/ext/standard/tests/array/count_recursive.phpt +++ b/ext/standard/tests/array/count_recursive.phpt @@ -3,10 +3,6 @@ Test count() function --FILE-- <?php echo "*** Testing basic functionality of count() function ***\n"; -print "-- Testing NULL --\n"; -$arr = NULL; -print "COUNT_NORMAL: should be 0, is ".count($arr, COUNT_NORMAL)."\n"; -print "COUNT_RECURSIVE: should be 0, is ".count($arr, COUNT_RECURSIVE)."\n"; print "-- Testing arrays --\n"; $arr = array(1, array(3, 4, array(6, array(8)))); @@ -18,12 +14,7 @@ $arr = array("a" => 1, "b" => 2, array("c" => 3, array("d" => 5))); print "COUNT_NORMAL: should be 3, is ".count($arr, COUNT_NORMAL)."\n"; print "COUNT_RECURSIVE: should be 6, is ".count($arr, COUNT_RECURSIVE)."\n"; -print "-- Testing strings --\n"; -print "COUNT_NORMAL: should be 1, is ".count("string", COUNT_NORMAL)."\n"; -print "COUNT_RECURSIVE: should be 1, is ".count("string", COUNT_RECURSIVE)."\n"; - print "-- Testing various types with no second argument --\n"; -print "COUNT_NORMAL: should be 1, is ".count("string")."\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), @@ -56,18 +47,6 @@ foreach ($count_array as $count_value) { $i++; } - -/* Testing count() by passing constant with no second argument */ -print "\n-- Testing count() on constants with no second argument --\n"; -print "COUNT_NORMAL: should be 1, is ".count(100)."\n"; -print "COUNT_NORMAL: should be 1, is ".count(-23.45)."\n"; - -print "\n-- Testing count() on NULL and Unset variables --\n"; -print "COUNT_NORMAL: should be 0, is ".count(NULL)."\n"; -print "COUNT_NORMAL: should be 1, is ".count("")."\n"; -print "COUNT_NORMAL: should be 0, is ".@count($a)."\n"; - - print "\n-- Testing count() on an empty sub-array --\n"; $arr = array(1, array(3, 4, array())); print "COUNT_NORMAL: should be 2, is ".count($arr, COUNT_NORMAL)."\n"; @@ -111,30 +90,13 @@ closedir( $resource2 ); ?> --EXPECTF-- *** Testing basic functionality of count() function *** --- Testing NULL -- - -Warning: count(): count(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -COUNT_NORMAL: should be 0, is 0 - -Warning: count(): count(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -COUNT_RECURSIVE: should be 0, is 0 -- Testing arrays -- COUNT_NORMAL: should be 2, is 2 COUNT_RECURSIVE: should be 8, is 8 -- Testing hashes -- COUNT_NORMAL: should be 3, is 3 COUNT_RECURSIVE: should be 6, is 6 --- Testing strings -- - -Warning: count(): count(): Argument #1 ($var) must be of type Countable|array, string given in %s on line %d -COUNT_NORMAL: should be 1, is 1 - -Warning: count(): count(): Argument #1 ($var) must be of type Countable|array, string given in %s on line %d -COUNT_RECURSIVE: should be 1, is 1 -- Testing various types with no second argument -- - -Warning: count(): Argument #1 ($var) must be of type Countable|array, string given in %s on line %d -COUNT_NORMAL: should be 1, is 1 COUNT_NORMAL: should be 2, is 2 -- Testing really cool arrays -- COUNT_NORMAL: should be 3, is 3 @@ -173,23 +135,6 @@ COUNT_RECURSIVE is 6 COUNT_NORMAL is 4 COUNT_RECURSIVE is 7 --- Testing count() on constants with no second argument -- - -Warning: count(): Argument #1 ($var) must be of type Countable|array, int given in %s on line %d -COUNT_NORMAL: should be 1, is 1 - -Warning: count(): Argument #1 ($var) must be of type Countable|array, float given in %s on line %d -COUNT_NORMAL: should be 1, is 1 - --- Testing count() on NULL and Unset variables -- - -Warning: count(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -COUNT_NORMAL: should be 0, is 0 - -Warning: count(): Argument #1 ($var) must be of type Countable|array, string given in %s on line %d -COUNT_NORMAL: should be 1, is 1 -COUNT_NORMAL: should be 0, is 0 - -- Testing count() on an empty sub-array -- COUNT_NORMAL: should be 2, is 2 COUNT_RECURSIVE: should be 5, is 5 diff --git a/ext/standard/tests/array/sizeof_basic1.phpt b/ext/standard/tests/array/sizeof_basic1.phpt deleted file mode 100644 index 4c5910e357..0000000000 --- a/ext/standard/tests/array/sizeof_basic1.phpt +++ /dev/null @@ -1,65 +0,0 @@ ---TEST-- -Test sizeof() function : basic functionality - for scalar types ---FILE-- -<?php -/* Testing the sizeof() for some of the scalar types(integer, float) values - * in default, COUNT_NORMAL and COUNT_RECURSIVE modes. - */ - -echo "*** Testing sizeof() : basic functionality ***\n"; - -$intval = 10; -$floatval = 10.5; -$stringval = "String"; - -echo "-- Testing sizeof() for integer type in default, COUNT_NORMAL and COUNT_RECURSIVE modes --\n"; -echo "default mode: "; -var_dump( sizeof($intval) ); -echo "\n"; -echo "COUNT_NORMAL mode: "; -var_dump( sizeof($intval, COUNT_NORMAL) ); -echo "\n"; -echo "COUNT_RECURSIVE mode: "; -var_dump( sizeof($intval, COUNT_RECURSIVE) ); -echo "\n"; - -echo "-- Testing sizeof() for float type in default, COUNT_NORMAL and COUNT_RECURSIVE modes --\n"; -echo "default mode: "; -var_dump( sizeof($floatval) ); -echo "\n"; -echo "COUNT_NORMAL mode: "; -var_dump( sizeof($floatval, COUNT_NORMAL) ); -echo "\n"; -echo "COUNT_RECURSIVE mode: "; -var_dump( sizeof($floatval, COUNT_RECURSIVE) ); - -echo "Done"; -?> ---EXPECTF-- -*** Testing sizeof() : basic functionality *** --- Testing sizeof() for integer type in default, COUNT_NORMAL and COUNT_RECURSIVE modes -- -default mode: -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, int given in %s on line %d -int(1) - -COUNT_NORMAL mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, int given in %s on line %d -int(1) - -COUNT_RECURSIVE mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, int given in %s on line %d -int(1) - --- Testing sizeof() for float type in default, COUNT_NORMAL and COUNT_RECURSIVE modes -- -default mode: -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, float given in %s on line %d -int(1) - -COUNT_NORMAL mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, float given in %s on line %d -int(1) - -COUNT_RECURSIVE mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, float given in %s on line %d -int(1) -Done diff --git a/ext/standard/tests/array/sizeof_object2.phpt b/ext/standard/tests/array/sizeof_object2.phpt index 9a96719eb6..7541987656 100644 --- a/ext/standard/tests/array/sizeof_object2.phpt +++ b/ext/standard/tests/array/sizeof_object2.phpt @@ -74,88 +74,52 @@ for($i = 0; $i < count($objects); $i++) $var = $objects[$i]; echo "Default Mode: "; - var_dump( sizeof($var) ); - echo "\n"; + try { + var_dump( sizeof($var) ); + } catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; + } echo "COUNT_NORMAL Mode: "; - var_dump( sizeof($var, COUNT_NORMAL) ); - echo "\n"; + try { + var_dump( sizeof($var, COUNT_NORMAL) ); + } catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; + } echo "COUNT_RECURSIVE Mode: "; - var_dump( sizeof($var, COUNT_RECURSIVE) ); - echo "\n"; + try { + var_dump( sizeof($var, COUNT_RECURSIVE) ); + } catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; + } $counter++; } echo "Done"; ?> ---EXPECTF-- +--EXPECT-- *** Testing sizeof() : object functionality *** --- Testing sizeof() with objects which doesn't implement Countable interface --- -- Iteration 1 -- -Default Mode: -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, test given in %s on line %d -int(1) - -COUNT_NORMAL Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, test given in %s on line %d -int(1) - -COUNT_RECURSIVE Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, test given in %s on line %d -int(1) - +Default Mode: sizeof(): Argument #1 ($var) must be of type Countable|array, test given +COUNT_NORMAL Mode: sizeof(): Argument #1 ($var) must be of type Countable|array, test given +COUNT_RECURSIVE Mode: sizeof(): Argument #1 ($var) must be of type Countable|array, test given -- Iteration 2 -- -Default Mode: -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, test1 given in %s on line %d -int(1) - -COUNT_NORMAL Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, test1 given in %s on line %d -int(1) - -COUNT_RECURSIVE Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, test1 given in %s on line %d -int(1) - +Default Mode: sizeof(): Argument #1 ($var) must be of type Countable|array, test1 given +COUNT_NORMAL Mode: sizeof(): Argument #1 ($var) must be of type Countable|array, test1 given +COUNT_RECURSIVE Mode: sizeof(): Argument #1 ($var) must be of type Countable|array, test1 given -- Iteration 3 -- -Default Mode: -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, test2 given in %s on line %d -int(1) - -COUNT_NORMAL Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, test2 given in %s on line %d -int(1) - -COUNT_RECURSIVE Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, test2 given in %s on line %d -int(1) - +Default Mode: sizeof(): Argument #1 ($var) must be of type Countable|array, test2 given +COUNT_NORMAL Mode: sizeof(): Argument #1 ($var) must be of type Countable|array, test2 given +COUNT_RECURSIVE Mode: sizeof(): Argument #1 ($var) must be of type Countable|array, test2 given -- Iteration 4 -- -Default Mode: -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, child_test2 given in %s on line %d -int(1) - -COUNT_NORMAL Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, child_test2 given in %s on line %d -int(1) - -COUNT_RECURSIVE Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, child_test2 given in %s on line %d -int(1) - +Default Mode: sizeof(): Argument #1 ($var) must be of type Countable|array, child_test2 given +COUNT_NORMAL Mode: sizeof(): Argument #1 ($var) must be of type Countable|array, child_test2 given +COUNT_RECURSIVE Mode: sizeof(): Argument #1 ($var) must be of type Countable|array, child_test2 given -- Iteration 5 -- -Default Mode: -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, concrete_class given in %s on line %d -int(1) - -COUNT_NORMAL Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, concrete_class given in %s on line %d -int(1) - -COUNT_RECURSIVE Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, concrete_class given in %s on line %d -int(1) - +Default Mode: sizeof(): Argument #1 ($var) must be of type Countable|array, concrete_class given +COUNT_NORMAL Mode: sizeof(): Argument #1 ($var) must be of type Countable|array, concrete_class given +COUNT_RECURSIVE Mode: sizeof(): Argument #1 ($var) must be of type Countable|array, concrete_class given Done diff --git a/ext/standard/tests/array/sizeof_variation1.phpt b/ext/standard/tests/array/sizeof_variation1.phpt deleted file mode 100644 index 13196d3170..0000000000 --- a/ext/standard/tests/array/sizeof_variation1.phpt +++ /dev/null @@ -1,322 +0,0 @@ ---TEST-- -Test sizeof() function : usage variations - for all scalar types and resource variable ---FILE-- -<?php -echo "*** Testing sizeof() : usage variations ***\n"; - -echo "--- Testing sizeof() for all scalar types in default,COUNT_NORMAL and COUNT_RECURSIVE mode ---\n"; -// get a resource variable -$fp = fopen(__FILE__, "r"); - -// array containing all scalar types -$values = array ( - // int values - /* 1 */ 0, - 1, - - // float values - /* 3 */ 10.5, - -10.5, - 12.3456789000e10, - 12.3456789000E-10, - /* 7 */ .5, - - // NULL values - /* 8 */ NULL, - null, - - // boolean values - /* 10 */ TRUE, - FALSE, - true, - /* 13 */ false, - - // string data - /* 14 */ "", - '', - "string", - /* 17 */ 'string', - - // undefined variable - @$undefined_var, - - // resource variable - /* 19 */ $fp -); - -// loop through the each value of the array for 'var' argument and check the behaviour of sizeof() -$counter = 1; -for($i = 0; $i < count($values); $i++) -{ - echo "-- Iteration $counter --\n"; - - $var = $values[$i]; - - echo "Default Mode: "; - var_dump( sizeof($var) ); - echo "\n"; - - echo "COUNT_NORMAL Mode: "; - var_dump( sizeof($var, COUNT_NORMAL) ); - echo "\n"; - - echo "COUNT_RECURSIVE Mode: "; - var_dump( sizeof($var, COUNT_RECURSIVE) ); - echo "\n"; - - $counter++; -} - -echo "Done"; -?> ---EXPECTF-- -*** Testing sizeof() : usage variations *** ---- Testing sizeof() for all scalar types in default,COUNT_NORMAL and COUNT_RECURSIVE mode --- --- Iteration 1 -- -Default Mode: -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, int given in %s on line %d -int(1) - -COUNT_NORMAL Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, int given in %s on line %d -int(1) - -COUNT_RECURSIVE Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, int given in %s on line %d -int(1) - --- Iteration 2 -- -Default Mode: -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, int given in %s on line %d -int(1) - -COUNT_NORMAL Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, int given in %s on line %d -int(1) - -COUNT_RECURSIVE Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, int given in %s on line %d -int(1) - --- Iteration 3 -- -Default Mode: -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, float given in %s on line %d -int(1) - -COUNT_NORMAL Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, float given in %s on line %d -int(1) - -COUNT_RECURSIVE Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, float given in %s on line %d -int(1) - --- Iteration 4 -- -Default Mode: -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, float given in %s on line %d -int(1) - -COUNT_NORMAL Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, float given in %s on line %d -int(1) - -COUNT_RECURSIVE Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, float given in %s on line %d -int(1) - --- Iteration 5 -- -Default Mode: -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, float given in %s on line %d -int(1) - -COUNT_NORMAL Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, float given in %s on line %d -int(1) - -COUNT_RECURSIVE Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, float given in %s on line %d -int(1) - --- Iteration 6 -- -Default Mode: -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, float given in %s on line %d -int(1) - -COUNT_NORMAL Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, float given in %s on line %d -int(1) - -COUNT_RECURSIVE Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, float given in %s on line %d -int(1) - --- Iteration 7 -- -Default Mode: -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, float given in %s on line %d -int(1) - -COUNT_NORMAL Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, float given in %s on line %d -int(1) - -COUNT_RECURSIVE Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, float given in %s on line %d -int(1) - --- Iteration 8 -- -Default Mode: -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_NORMAL Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_RECURSIVE Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - --- Iteration 9 -- -Default Mode: -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_NORMAL Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_RECURSIVE Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - --- Iteration 10 -- -Default Mode: -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, bool given in %s on line %d -int(1) - -COUNT_NORMAL Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, bool given in %s on line %d -int(1) - -COUNT_RECURSIVE Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, bool given in %s on line %d -int(1) - --- Iteration 11 -- -Default Mode: -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, bool given in %s on line %d -int(1) - -COUNT_NORMAL Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, bool given in %s on line %d -int(1) - -COUNT_RECURSIVE Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, bool given in %s on line %d -int(1) - --- Iteration 12 -- -Default Mode: -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, bool given in %s on line %d -int(1) - -COUNT_NORMAL Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, bool given in %s on line %d -int(1) - -COUNT_RECURSIVE Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, bool given in %s on line %d -int(1) - --- Iteration 13 -- -Default Mode: -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, bool given in %s on line %d -int(1) - -COUNT_NORMAL Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, bool given in %s on line %d -int(1) - -COUNT_RECURSIVE Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, bool given in %s on line %d -int(1) - --- Iteration 14 -- -Default Mode: -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, string given in %s on line %d -int(1) - -COUNT_NORMAL Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, string given in %s on line %d -int(1) - -COUNT_RECURSIVE Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, string given in %s on line %d -int(1) - --- Iteration 15 -- -Default Mode: -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, string given in %s on line %d -int(1) - -COUNT_NORMAL Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, string given in %s on line %d -int(1) - -COUNT_RECURSIVE Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, string given in %s on line %d -int(1) - --- Iteration 16 -- -Default Mode: -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, string given in %s on line %d -int(1) - -COUNT_NORMAL Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, string given in %s on line %d -int(1) - -COUNT_RECURSIVE Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, string given in %s on line %d -int(1) - --- Iteration 17 -- -Default Mode: -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, string given in %s on line %d -int(1) - -COUNT_NORMAL Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, string given in %s on line %d -int(1) - -COUNT_RECURSIVE Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, string given in %s on line %d -int(1) - --- Iteration 18 -- -Default Mode: -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_NORMAL Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_RECURSIVE Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - --- Iteration 19 -- -Default Mode: -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, resource given in %s on line %d -int(1) - -COUNT_NORMAL Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, resource given in %s on line %d -int(1) - -COUNT_RECURSIVE Mode: -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, resource given in %s on line %d -int(1) - -Done diff --git a/ext/standard/tests/array/sizeof_variation4.phpt b/ext/standard/tests/array/sizeof_variation4.phpt deleted file mode 100644 index c8484d8451..0000000000 --- a/ext/standard/tests/array/sizeof_variation4.phpt +++ /dev/null @@ -1,463 +0,0 @@ ---TEST-- -Test sizeof() function : usage variations - all kinds of unset variables for 'var' argument ---FILE-- -<?php -echo "*** Testing sizeof() : usage variations ***\n"; - -echo "--- Testing sizeof() for all kinds of unset variables in default, Normal and Recursive Modes ---\n"; - -// class declaration -class test -{ - public $member1; -} - -// get an resource variable -$fp = fopen(__FILE__, "r"); - -// array containing different types of variables -$values = array ( - // int values - /* 1 */ 0, - 1, - // float values - /* 3 */ 10.5, - -10.5, - 12.34e3, - /* 6 */ 12.34E-3, - // string values - /* 7 */ "string", - 'string', - "", - /* 10 */ '', - // NULL values - /* 11 */ NULL, - null, - // Boolean Values - /* 12 */ TRUE, - true, - false, - /* 16 */ FALSE, - // array values - /* 17 */ array(), - array(1, 2, 3,4 , array(5, 6)), - // object variable - /* 19 */ new test(), - // resource variable - /* 20 */ $fp -); - -// loop through the each element of the $values array for 'var' argument -// and check the functionality of sizeof() -$counter = 1; -foreach($values as $value) -{ - echo "-- Iteration $counter --\n"; - - // unset the variable - unset($value); - - // now check the size of unset variable when different modes are given - echo "Default Mode: "; - var_dump( sizeof($value) ); - echo "\n"; - - echo "COUNT_NORMAL Mode: "; - var_dump( sizeof($value, COUNT_NORMAL) ); - echo "\n"; - - echo "COUNT_RECURSIVE Mode: "; - var_dump( sizeof($value, COUNT_RECURSIVE) ); - echo "\n"; - - $counter++; -} - -fclose($fp); - -echo "Done"; -?> ---EXPECTF-- -*** Testing sizeof() : usage variations *** ---- Testing sizeof() for all kinds of unset variables in default, Normal and Recursive Modes --- --- Iteration 1 -- -Default Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_NORMAL Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_RECURSIVE Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - --- Iteration 2 -- -Default Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_NORMAL Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_RECURSIVE Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - --- Iteration 3 -- -Default Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_NORMAL Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_RECURSIVE Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - --- Iteration 4 -- -Default Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_NORMAL Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_RECURSIVE Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - --- Iteration 5 -- -Default Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_NORMAL Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_RECURSIVE Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - --- Iteration 6 -- -Default Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_NORMAL Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_RECURSIVE Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - --- Iteration 7 -- -Default Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_NORMAL Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_RECURSIVE Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - --- Iteration 8 -- -Default Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_NORMAL Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_RECURSIVE Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - --- Iteration 9 -- -Default Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_NORMAL Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_RECURSIVE Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - --- Iteration 10 -- -Default Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_NORMAL Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_RECURSIVE Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - --- Iteration 11 -- -Default Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_NORMAL Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_RECURSIVE Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - --- Iteration 12 -- -Default Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_NORMAL Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_RECURSIVE Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - --- Iteration 13 -- -Default Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_NORMAL Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_RECURSIVE Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - --- Iteration 14 -- -Default Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_NORMAL Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_RECURSIVE Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - --- Iteration 15 -- -Default Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_NORMAL Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_RECURSIVE Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - --- Iteration 16 -- -Default Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_NORMAL Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_RECURSIVE Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - --- Iteration 17 -- -Default Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_NORMAL Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_RECURSIVE Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - --- Iteration 18 -- -Default Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_NORMAL Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_RECURSIVE Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - --- Iteration 19 -- -Default Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_NORMAL Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_RECURSIVE Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - --- Iteration 20 -- -Default Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_NORMAL Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -COUNT_RECURSIVE Mode: -Warning: Undefined variable $value in %s on line %d - -Warning: sizeof(): sizeof(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d -int(0) - -Done diff --git a/ext/standard/tests/general_functions/is_countable_with_variables.phpt b/ext/standard/tests/general_functions/is_countable_with_variables.phpt index 7a4efc914b..01fa0fae6f 100644 --- a/ext/standard/tests/general_functions/is_countable_with_variables.phpt +++ b/ext/standard/tests/general_functions/is_countable_with_variables.phpt @@ -16,13 +16,16 @@ if (is_countable($foo)) { $bar = null; if (!is_countable($bar)) { - count($bar); + try { + count($bar); + } catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; + } } ?> ---EXPECTF-- +--EXPECT-- bool(true) bool(true) bool(false) int(2) - -Warning: count(): Argument #1 ($var) must be of type Countable|array, null given in %s on line %d +count(): Argument #1 ($var) must be of type Countable|array, null given |
