if ((result = zend_hash_minmax(Z_ARRVAL(args[0]), php_array_data_compare, 0)) != NULL) {
ZVAL_COPY_DEREF(return_value, result);
} else {
- zend_throw_error(NULL, "Array must contain at least one element");
+ zend_value_error("Array must contain at least one element");
return;
}
}
if ((result = zend_hash_minmax(Z_ARRVAL(args[0]), php_array_data_compare, 1)) != NULL) {
ZVAL_COPY_DEREF(return_value, result);
} else {
- zend_throw_error(NULL, "Array must contain at least one element");
+ zend_value_error("Array must contain at least one element");
return;
}
}
extract_type &= 0xff;
if (extract_type < EXTR_OVERWRITE || extract_type > EXTR_IF_EXISTS) {
- zend_throw_error(NULL, "Invalid extract type");
+ zend_value_error("Invalid extract type");
return;
}
if (extract_type > EXTR_SKIP && extract_type <= EXTR_PREFIX_IF_EXISTS && ZEND_NUM_ARGS() < 3) {
- zend_throw_error(NULL, "Specified extract type requires the prefix parameter");
+ zend_value_error("Specified extract type requires the prefix parameter");
return;
}
if (prefix) {
if (ZSTR_LEN(prefix) && !php_valid_var_name(ZSTR_VAL(prefix), ZSTR_LEN(prefix))) {
- zend_throw_error(NULL, "Prefix is not a valid identifier");
+ zend_value_error("Prefix is not a valid identifier");
return;
}
}
if (EXPECTED(num > 0)) {
if (sizeof(num) > 4 && UNEXPECTED(EXPECTED(num > 0x7fffffff))) {
- zend_throw_error(NULL, "Too many elements");
+ zend_value_error("Too many elements");
return;
} else if (UNEXPECTED(start_key > ZEND_LONG_MAX - num + 1)) {
zend_throw_error(NULL, "Cannot add element to the array as the next element is already occupied");
} else if (EXPECTED(num == 0)) {
RETURN_EMPTY_ARRAY();
} else {
- zend_throw_error(NULL, "Number of elements can't be negative");
+ zend_value_error("Number of elements can't be negative");
return;
}
}
#define RANGE_CHECK_DOUBLE_INIT_ARRAY(start, end) do { \
double __calc_size = ((start - end) / step) + 1; \
if (__calc_size >= (double)HT_MAX_SIZE) { \
- zend_throw_error(NULL, \
+ zend_value_error(\
"The supplied range exceeds the maximum array size: start=%0.0f end=%0.0f", end, start); \
return; \
} \
#define RANGE_CHECK_LONG_INIT_ARRAY(start, end) do { \
zend_ulong __calc_size = ((zend_ulong) start - end) / lstep; \
if (__calc_size >= HT_MAX_SIZE - 1) { \
- zend_throw_error(NULL, \
+ zend_value_error(\
"The supplied range exceeds the maximum array size: start=" ZEND_LONG_FMT " end=" ZEND_LONG_FMT, end, start); \
return; \
} \
high = zval_get_double(zhigh);
if (zend_isinf(high) || zend_isinf(low)) {
- zend_throw_error(NULL, "Invalid range supplied: start=%0.0f end=%0.0f", low, high);
+ zend_value_error("Invalid range supplied: start=%0.0f end=%0.0f", low, high);
return;
}
}
err:
if (err) {
- zend_throw_error(NULL, "step exceeds the specified range");
+ zend_value_error("step exceeds the specified range");
return;
}
}
input_size = zend_hash_num_elements(Z_ARRVAL_P(input));
pad_size_abs = ZEND_ABS(pad_size);
if (pad_size_abs < 0 || pad_size_abs - input_size > Z_L(1048576)) {
- zend_throw_error(NULL, "You may only pad up to 1048576 elements at a time");
+ zend_value_error("You may only pad up to 1048576 elements at a time");
return;
}
array_size = zend_hash_num_elements(Z_ARRVAL_P(arrays[0]));
for (i = 0; i < num_arrays; i++) {
if (zend_hash_num_elements(Z_ARRVAL_P(arrays[i])) != (uint32_t)array_size) {
- zend_throw_error(NULL, "Array sizes are inconsistent");
+ zend_value_error("Array sizes are inconsistent");
MULTISORT_ABORT;
}
}
num_avail = zend_hash_num_elements(Z_ARRVAL_P(input));
if (num_avail == 0) {
- zend_throw_error(NULL, "Array is empty");
+ zend_value_error("Array is empty");
return;
}
}
if (num_req <= 0 || num_req > num_avail) {
- zend_throw_error(NULL, "Second argument has to be between 1 and the number of elements in the array");
+ zend_value_error("Second argument has to be between 1 and the number of elements in the array");
return;
}
/* Do bounds checking for size parameter. */
if (size < 1) {
- zend_throw_error(NULL, "Size parameter expected to be greater than 0");
+ zend_value_error("Size parameter expected to be greater than 0");
return;
}
num_values = zend_hash_num_elements(values);
if (num_keys != num_values) {
- zend_throw_error(NULL, "Both parameters should have an equal number of elements");
+ zend_value_error("Both parameters should have an equal number of elements");
return;
}
break;
default:
- zend_throw_error(NULL, "Unknown value " ZEND_LONG_FMT, what);
+ zend_value_error("Unknown value " ZEND_LONG_FMT, what);
break;
}
ZEND_PARSE_PARAMETERS_END();
if (dirn_len < 1) {
- zend_throw_error(NULL, "Directory name cannot be empty");
+ zend_value_error("Directory name cannot be empty");
return;
}
}
if (breakchar_len == 0) {
- zend_throw_error(NULL, "Break string cannot be empty");
+ zend_value_error("Break string cannot be empty");
return;
}
if (linelength == 0 && docut) {
- zend_throw_error(NULL, "Can't force cut when width is zero");
+ zend_value_error("Can't force cut when width is zero");
return;
}
ZEND_PARSE_PARAMETERS_END();
if (ZSTR_LEN(delim) == 0) {
- zend_throw_error(NULL, "Empty delimiter");
+ zend_value_error("Empty delimiter");
return;
}
ZSTR_LEN(ret) = zend_dirname(ZSTR_VAL(ret), str_len);
#endif
} else if (levels < 1) {
- zend_throw_error(NULL, "Invalid argument, levels must be >= 1");
+ zend_value_error("Invalid argument, levels must be >= 1");
zend_string_efree(ret);
return;
} else {
ZEND_PARSE_PARAMETERS_END();
if (chunklen <= 0) {
- zend_throw_error(NULL, "Chunk length should be greater than zero");
+ zend_value_error("Chunk length should be greater than zero");
return;
}
ZEND_PARSE_PARAMETERS_END();
if (mult < 0) {
- zend_throw_error(NULL, "Second argument has to be greater than or equal to 0");
+ zend_value_error("Second argument has to be greater than or equal to 0");
return;
}
ZEND_PARSE_PARAMETERS_END();
if (needle_len == 0) {
- zend_throw_error(NULL, "Empty substring");
+ zend_value_error("Empty substring");
return;
}
}
if (pad_str_len == 0) {
- zend_throw_error(NULL, "Padding string cannot be empty");
+ zend_value_error("Padding string cannot be empty");
return;
}
if (pad_type_val < STR_PAD_LEFT || pad_type_val > STR_PAD_BOTH) {
- zend_throw_error(NULL, "Padding type has to be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH");
+ zend_value_error("Padding type has to be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH");
return;
}
/* nothing to be done */
break;
default:
- zend_throw_error(NULL, "Invalid format value " ZEND_LONG_FMT, type);
+ zend_value_error("Invalid format value " ZEND_LONG_FMT, type);
return;
}
ZEND_PARSE_PARAMETERS_END();
if (split_length <= 0) {
- zend_throw_error(NULL, "The length of each segment must be greater than zero");
+ zend_value_error("The length of each segment must be greater than zero");
return;
}
if (len == 0) {
RETURN_LONG(0L);
} else {
- zend_throw_error(NULL, "The length must be greater than or equal to zero");
+ zend_value_error("The length must be greater than or equal to zero");
return;
}
}
try {
var_dump(array_chunk($input_array, 0));
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
try {
var_dump(array_chunk($input_array, 0, true));
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
echo "\n-- Testing array_chunk() when size = $size --\n";
try {
var_dump( array_chunk($input_array, $size) );
- } catch (\Error $e) {
+ } catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
try {
var_dump( array_chunk($input_array, $size, true) );
- } catch (\Error $e) {
+ } catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
try {
var_dump( array_chunk($input_array, $size, false) );
- } catch (\Error $e) {
+ } catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
}
?>
-DONE
--EXPECT--
*** Testing array_chunk() : usage variations ***
int(3)
}
}
-
-DONE
echo "\n-- Testing array_combine() function with empty array for \$keys argument --\n";
try {
var_dump( array_combine(array(), array(1, 2)) );
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage();
}
echo "\n-- Testing array_combine() function with empty array for \$values argument --\n";
try {
var_dump( array_combine(array(1, 2), array()) );
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage();
}
echo "\n-- Testing array_combine() function by passing array with unequal number of elements --\n";
try {
var_dump( array_combine(array(1, 2), array(1, 2, 3)) );
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage();
}
?>
-
-DONE
--EXPECT--
*** Testing array_combine() : error conditions specific to array_combine() ***
Both parameters should have an equal number of elements
-- Testing array_combine() function by passing array with unequal number of elements --
Both parameters should have an equal number of elements
-DONE
try {
var_dump( array_fill($start_key,$num,$val) );
-} catch (Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
?>
-
-DONE
---EXPECTF--
+--EXPECT--
*** Testing array_fill() : error conditions ***
Number of elements can't be negative
-
-DONE
$ar1 = array(1);
try {
var_dump( array_multisort($ar1, SORT_ASC, SORT_ASC) );
-} catch (Error $e) {
+} catch (\TypeError $e) {
echo $e->getMessage() . "\n";
}
$ar1 = array(1);
try {
var_dump( array_multisort($ar1, SORT_STRING, SORT_NUMERIC) );
-} catch (Error $e) {
+} catch (\TypeError $e) {
echo $e->getMessage() . "\n";
}
echo "\n--$key--\n";
try {
var_dump( array_multisort($value));
- } catch (Error $e) {
+ } catch (\ValueError | \TypeError $e) {
echo $e->getMessage() . "\n";
}
};
echo "\n--$key--\n";
try {
var_dump( array_multisort($ar1, $value) );
- } catch (Error $e) {
+ } catch (\ValueError | \TypeError $e) {
echo $e->getMessage() . "\n";
}
};
echo "\n--$key--\n";
try {
var_dump( array_multisort($ar1, SORT_REGULAR, $value) );
- } catch (Error $e) {
+ } catch (\ValueError | \TypeError $e) {
echo $e->getMessage() . "\n";
}
};
try {
var_dump(array_pad(array("", -1, 2.0), 2000000, 0));
-} catch (Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
?>
-
-DONE
--EXPECT--
array(1) {
[0]=>
float(2)
}
You may only pad up to 1048576 elements at a time
-
-DONE
}
var_dump($array);
-echo "Done";
?>
--EXPECTF--
*** Testing array_push() : error conditions ***
[%d]=>
string(3) "max"
}
-Done
try {
var_dump(array_rand(array()));
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
try {
var_dump(array_rand(array(), 0));
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
try {
var_dump(array_rand(array(1,2,3), 0));
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
try {
var_dump(array_rand(array(1,2,3), -1));
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
try {
var_dump(array_rand(array(1,2,3), 10));
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
var_dump(array_rand(array(1,2,3), 3));
var_dump(array_rand(array(1,2,3), 2));
-echo "Done\n";
?>
--EXPECTF--
Array is empty
[1]=>
int(%d)
}
-Done
echo"\n-- With num_req = 0 --\n";
try {
var_dump( array_rand($input, 0) ); // with $num_req=0
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
echo"\n-- With num_req = -1 --\n";
try {
var_dump( array_rand($input, -1) ); // with $num_req=-1
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
echo"\n-- With num_req = -2 --\n";
try {
var_dump( array_rand($input, -2) ); // with $num_req=-2
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
echo"\n-- With num_req more than number of members in 'input' array --\n";
try {
var_dump( array_rand($input, 13) ); // with $num_req=13
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
?>
-
-DONE
--EXPECTF--
*** Testing array_rand() : with invalid values for 'req_num' ***
-- With num_req more than number of members in 'input' array --
Second argument has to be between 1 and the number of elements in the array
-
-DONE
$b["key1"]["key2"]["key3"] = null;
?>
-
-DONE
--EXPECT--
Recursion detected
-
-DONE
}
?>
-OKAY
--EXPECT--
Cannot call compact() dynamically
-OKAY
try {
array_multisort(array_column($data, 'bb'),SORT_DESC, $data); // PHP Warning error
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
?>
try {
var_dump(compact($arr1));
-} catch (\Error $e) {
+} catch (Error $e) {
echo $e->getMessage() . "\n";
}
try {
var_dump(compact($arr2));
-} catch (\Error $e) {
+} catch (Error $e) {
echo $e->getMessage() . "\n";
}
-try {
- var_dump(compact($arr3));
-} catch (\Error $e) {
- echo $e->getMessage() . "\n";
-}
-?>
+var_dump(compact($arr3));
-DONE
+?>
--EXPECT--
*** Testing compact() : usage variations - arrays containing references ***
Recursion detected
["c"]=>
int(3)
}
-
-DONE
try {
var_dump( extract($arr, -1 . "wddr") );
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
try {
var_dump( extract($arr, 7 , "wddr") );
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
/* Two Arguments, second as prefix but without prefix string as third argument */
try {
var_dump( extract($arr,EXTR_PREFIX_IF_EXISTS) );
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
-echo "Done\n";
?>
--EXPECTF--
*** Testing Error Conditions ***
Invalid extract type
Invalid extract type
Specified extract type requires the prefix parameter
-Done
try {
extract($a, EXTR_PREFIX_ALL, '85bogus');
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage();
}
?>
try {
var_dump(max(array()));
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
var_dump(max(1, true, false, true));
var_dump(max(0, true, false, true));
-echo "Done\n";
?>
--EXPECT--
When only one parameter is given, it must be an array
bool(true)
int(1)
bool(true)
-Done
try {
var_dump(min(array()));
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
var_dump(min(1, true, false, true));
var_dump(min(0, true, false, true));
-echo "Done\n";
?>
--EXPECT--
When only one parameter is given, it must be an array
bool(false)
bool(false)
int(0)
-Done
<?php
try {
range(0, pow(2.0, 100000000));
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
?>
<?php
try {
range(pow(2.0, 100000000), pow(2.0, 100000000) + 1);
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
?>
<?php
try {
var_dump(range(0, PHP_INT_MAX));
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
?>
<?php
try {
var_dump(range(PHP_INT_MIN, 0));
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
?>
echo "\n-- Testing ( (low < high) && (step = 0) ) --\n";
try {
var_dump( range(1, 2, 0) );
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage(), "\n";
}
try {
var_dump( range("a", "b", 0) );
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage(), "\n";
}
echo "\n\n-- Testing ( (low > high) && (step = 0) ) --\n";
try {
var_dump( range(2, 1, 0) );
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage(), "\n";
}
try {
var_dump( range("b", "a", 0) );
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage(), "\n";
}
echo "\n\n-- Testing ( (low < high) && (high-low < step) ) --\n";
try {
var_dump( range(1.0, 7.0, 6.5) );
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage(), "\n";
}
echo "\n\n-- Testing ( (low > high) && (low-high < step) ) --\n";
try {
var_dump( range(7.0, 1.0, 6.5) );
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage(), "\n";
}
echo "\n-- Testing other conditions --\n";
try {
var_dump( range(-1, -2, 2) );
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage(), "\n";
}
try {
var_dump( range("a", "j", "z") );
-} catch (TypeError $e) {
- echo $e->getMessage(), "\n";
-} catch (\Error $e) {
+} catch (\TypeError $e) {
echo $e->getMessage(), "\n";
}
try {
var_dump( range(0, 1, "140962482048819216326.24") );
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage(), "\n";
}
try {
var_dump( range(0, 1, "140962482048819216326.24.") );
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage(), "\n";
}
foreach( $step_arr as $step ) {
try {
var_dump( range( 1, 5, $step ) );
- } catch (\TypeError $e) {
- echo $e->getMessage(), "\n";
- } catch (\Error $e) {
+ } catch (\TypeError | \ValueError $e) {
echo $e->getMessage(), "\n";
}
}
-
-echo "Done\n";
?>
--EXPECTF--
*** Testing error conditions ***
step exceeds the specified range
range() expects parameter 3 to be int or float, string given
range() expects parameter 3 to be int or float, string given
-Done
<?php
try {
assert_options(1000);
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage();
}
?>
--EXPECT--
-Unknown value 1000
\ No newline at end of file
+Unknown value 1000
try {
var_dump(scandir(''));
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
Unable to find my handle property
Unable to find my handle property
Unable to find my handle property
-
<?php
try {
substr_compare("aa", "a", -99999999, -1, 0);
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage();
}
?>
---EXPECTF--
+--EXPECT--
The length must be greater than or equal to zero
var_dump( chunk_split($heredoc_str, $values[$count], $ending) );
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
- } catch (\Error $e) {
+ } catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
}
-echo "Done"
?>
---EXPECTF--
+--EXPECT--
*** Testing chunk_split() : different 'chunklen' with heredoc 'str' ***
-- Iteration 1 --
Chunk length should be greater than zero
chunk_split() expects parameter 2 to be int, float given
-- Iteration 8 --
Chunk length should be greater than zero
-Done
// Bad arg
try {
dirname("/var/tmp/bar.gz", 0);
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
-echo "Done\n";
?>
---EXPECTF--
+--EXPECT--
*** Testing error conditions ***
Invalid argument, levels must be >= 1
-Done
for ($i=0 ; $i<5 ; $i++) {
try {
var_dump(dirname("/foo/bar/baz", $i));
- } catch (\Error $e) {
+ } catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
}
var_dump(dirname("/foo/bar/baz", PHP_INT_MAX));
?>
-Done
---EXPECTF--
+--EXPECT--
Invalid argument, levels must be >= 1
string(8) "/foo/bar"
string(4) "/foo"
string(1) "/"
string(1) "/"
string(1) "/"
-Done
for ($i=0 ; $i<5 ; $i++) {
try {
var_dump(dirname("/foo/bar/baz", $i));
- } catch (\Error $e) {
+ } catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
}
var_dump(dirname("g:/foo/bar/baz", PHP_INT_MAX));
var_dump(dirname("g:foo/bar/baz", PHP_INT_MAX));
?>
-Done
--EXPECT--
Invalid argument, levels must be >= 1
string(8) "/foo/bar"
string(1) "\"
string(3) "g:\"
string(3) "g:."
-Done
try {
var_dump(explode("", ""));
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
try {
var_dump(explode("", NULL));
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
try {
var_dump(explode(NULL, ""));
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
var_dump(explode("a", NULL));
try {
var_dump(explode(NULL, "a"));
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
var_dump(explode("abc", "acb"));
try {
var_dump( explode($delimiter, $string, -1) );
- } catch (\Error $e) {
+ } catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
try {
var_dump( explode($delimiter, $string, 0) );
- } catch (\Error $e) {
+ } catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
try {
var_dump( explode($delimiter, $string, 1) );
- } catch (\Error $e) {
+ } catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
try {
var_dump( explode($delimiter, $string, 2) );
- } catch (\Error $e) {
+ } catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
$counter++;
$obj = new string1;
var_dump( explode("b", $obj) );
-echo "Done\n";
?>
---EXPECTF--
+--EXPECT--
*** Testing explode() for basic operations ***
-- Iteration 1 --
Empty delimiter
[1]=>
string(4) "ject"
}
-Done
try {
str_pad($input_string, 12, NULL);
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
try {
str_pad($input_string, 12, "");
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
try {
str_pad($input_string, $pad_length, "+", 15);
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
-echo "Done\n";
?>
--EXPECT--
#### Basic operations ####
Padding string cannot be empty
Padding string cannot be empty
Padding type has to be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH
-Done
try {
var_dump( str_split($str, $values[$count]) );
- } catch (\Error $e) {
+ } catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
}
-echo "Done"
?>
--EXPECT--
*** Testing str_split() : different integer values for 'split_length' ***
}
-- Iteration 7 --
The length of each segment must be greater than zero
-Done
* passing different integer values for 'split_length' argument to str_split()
*/
-echo "*** Testing str_split() : different intger values for 'split_length' ***\n";
+echo "*** Testing str_split() : different integer values for 'split_length' ***\n";
//Initialise variables
$str = 'This is a string with 123 & escape char \t';
echo "-- Iteration ".($count + 1)." --\n";
try {
var_dump( str_split($str, $values[$count]) );
- } catch (\Error $e) {
+ } catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
}
-echo "Done"
?>
--EXPECT--
-*** Testing str_split() : different intger values for 'split_length' ***
+*** Testing str_split() : different integer values for 'split_length' ***
-- Iteration 1 --
The length of each segment must be greater than zero
-- Iteration 2 --
}
-- Iteration 8 --
The length of each segment must be greater than zero
-Done
try {
var_dump( str_split($str, $values[$count]) );
- } catch (\Error $e) {
+ } catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
}
-echo "Done"
?>
--EXPECT--
*** Testing str_split() : different integer values for 'split_length' with heredoc 'str' ***
}
-- Iteration 7 --
The length of each segment must be greater than zero
-Done
echo "-- Iteration ".($count + 1)." --\n";
try {
var_dump( str_split($str, $values[$count]) );
- } catch (\Error $e) {
+ } catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
}
-echo "Done"
?>
--EXPECT--
*** Testing str_split() : different integer values for 'split_length' with heredoc 'str' ***
}
-- Iteration 8 --
The length of each segment must be greater than zero
-Done
try {
var_dump(str_word_count($str, 3));
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
try {
var_dump(str_word_count($str, 123));
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
try {
var_dump(str_word_count($str, -1));
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
try {
var_dump(str_word_count($str, 999999999));
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
try {
var_dump(str_word_count("", -1));
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
try {
var_dump(str_word_count("", -1, $a));
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
var_dump($a);
?>
-
-DONE
--EXPECTF--
int(0)
Invalid format value -1
Warning: Undefined variable: a in %s on line %d
NULL
-
-DONE
try {
substr_compare("abcde", "abc", 0, -1);
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
var_dump(substr_compare("abcde", "abc", -1, NULL, -5) > 0);
-
-echo "Done\n";
?>
---EXPECTF--
+--EXPECT--
bool(true)
bool(true)
int(0)
Test
The length must be greater than or equal to zero
bool(true)
-Done
echo "***Testing basic operations ***\n";
try {
substr_count("", "");
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
try {
substr_count("a", "");
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
var_dump(substr_count("", "a"));
var_dump(substr_count($a, "bca", -200, 50));
var_dump(substr_count($a, "bca", -200, -50));
-echo "Done\n";
-
?>
--EXPECT--
***Testing basic operations ***
int(40)
int(10)
int(30)
-Done
try {
wordwrap(chr(0), 0, "");
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
--EXPECT--
try {
wordwrap($str, $width, $break, $cut);
-} catch (\Error $e) {
+} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
$width = -10;
$cut = true;
var_dump( wordwrap($str, $width, $break, $cut) );
-
-echo "Done\n";
?>
---EXPECTF--
+--EXPECT--
*** Testing wordwrap() : error conditions ***
-- Testing wordwrap() function with negative/zero value for width argument --
string(39) "testing<br />\nwordwrap<br />\nfunction"
-- width = -10 & cut = true --
string(223) "<br />\nt<br />\ne<br />\ns<br />\nt<br />\ni<br />\nn<br />\ng<br />\n<br />\nw<br />\no<br />\nr<br />\nd<br />\nw<br />\nr<br />\na<br />\np<br />\n<br />\nf<br />\nu<br />\nn<br />\nc<br />\nt<br />\ni<br />\no<br />\nn"
-Done