1
0
mirror of https://github.com/php/php-src.git synced 2026-04-14 11:32:11 +02:00
Files
archived-php-src/ext/standard/tests/array/arsort_variation1.phpt
Peter Kokot d679f02295 Sync leading and final newlines in *.phpt sections
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines in all
*.phpt sections.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-15 04:33:09 +02:00

400 lines
13 KiB
PHP

--TEST--
Test arsort() function : usage variations - unexpected values for 'array_arg' argument
--FILE--
<?php
/* Prototype : bool arsort(array &array_arg [, int sort_flags])
* Description: Sort an array and maintain index association
Elements will be arranged from highest to lowest when this function has completed.
* Source code: ext/standard/array.c
*/
/*
* testing arsort() by providing different unexpected values for array argument with following flag values.
* 1. flag value as defualt
* 2. SORT_REGULAR - compare items normally
* 3. SORT_NUMERIC - compare items numerically
* 4. SORT_STRING - compare items as strings
*/
echo "*** Testing arsort() : usage variations ***\n";
// get an unset variable
$unset_var = 10;
unset ($unset_var);
// resource variable
$fp = fopen(__FILE__, "r");
//array of values with indices to iterate over
$unexpected_values = array (
// int data
0 => 0,
1 => 1,
2 => 12345,
3 => -2345,
// float data
4 => 10.5,
5 => -10.5,
6 => 10.5e3,
7 => 10.6E-2,
8 => .5,
// null data
9 => NULL,
10 => null,
// boolean data
11 => true,
12 => false,
13 => TRUE,
14 => FALSE,
// empty data
15 => "",
16 => '',
// string data
17 => "string",
18 => 'string',
// object data
19 => new stdclass(),
// undefined data
20 => @undefined_var,
// unset data
21 => @unset_var,
// resource variable
22 => $fp
);
// loop though each element of the array and check the working of arsort()
// when $array argument is supplied with different values from $unexpected_values
echo "\n-- Testing arsort() by supplying different unexpected values for 'array' argument --\n";
echo "\n-- Flag values are defualt, SORT_REGULAR, SORT_NUMERIC, SORT_STRING --\n";
$counter = 1;
for($index = 0; $index < count($unexpected_values); $index ++) {
echo "-- Iteration $counter --\n";
$value = $unexpected_values [$index];
var_dump( arsort($value) ); // expecting : bool(false)
var_dump( arsort($value, SORT_REGULAR) ); // expecting : bool(false)
var_dump( arsort($value, SORT_NUMERIC) ); // expecting : bool(false)
var_dump( arsort($value, SORT_STRING) ); // expecting : bool(false)
$counter++;
}
echo "Done";
?>
--EXPECTF--
*** Testing arsort() : usage variations ***
-- Testing arsort() by supplying different unexpected values for 'array' argument --
-- Flag values are defualt, SORT_REGULAR, SORT_NUMERIC, SORT_STRING --
-- Iteration 1 --
Warning: arsort() expects parameter 1 to be array, int given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, int given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, int given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, int given in %sarsort_variation1.php on line %d
bool(false)
-- Iteration 2 --
Warning: arsort() expects parameter 1 to be array, int given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, int given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, int given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, int given in %sarsort_variation1.php on line %d
bool(false)
-- Iteration 3 --
Warning: arsort() expects parameter 1 to be array, int given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, int given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, int given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, int given in %sarsort_variation1.php on line %d
bool(false)
-- Iteration 4 --
Warning: arsort() expects parameter 1 to be array, int given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, int given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, int given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, int given in %sarsort_variation1.php on line %d
bool(false)
-- Iteration 5 --
Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
bool(false)
-- Iteration 6 --
Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
bool(false)
-- Iteration 7 --
Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
bool(false)
-- Iteration 8 --
Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
bool(false)
-- Iteration 9 --
Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
bool(false)
-- Iteration 10 --
Warning: arsort() expects parameter 1 to be array, null given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, null given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, null given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, null given in %sarsort_variation1.php on line %d
bool(false)
-- Iteration 11 --
Warning: arsort() expects parameter 1 to be array, null given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, null given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, null given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, null given in %sarsort_variation1.php on line %d
bool(false)
-- Iteration 12 --
Warning: arsort() expects parameter 1 to be array, bool given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, bool given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, bool given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, bool given in %sarsort_variation1.php on line %d
bool(false)
-- Iteration 13 --
Warning: arsort() expects parameter 1 to be array, bool given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, bool given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, bool given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, bool given in %sarsort_variation1.php on line %d
bool(false)
-- Iteration 14 --
Warning: arsort() expects parameter 1 to be array, bool given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, bool given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, bool given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, bool given in %sarsort_variation1.php on line %d
bool(false)
-- Iteration 15 --
Warning: arsort() expects parameter 1 to be array, bool given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, bool given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, bool given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, bool given in %sarsort_variation1.php on line %d
bool(false)
-- Iteration 16 --
Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
bool(false)
-- Iteration 17 --
Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
bool(false)
-- Iteration 18 --
Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
bool(false)
-- Iteration 19 --
Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
bool(false)
-- Iteration 20 --
Warning: arsort() expects parameter 1 to be array, object given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, object given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, object given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, object given in %sarsort_variation1.php on line %d
bool(false)
-- Iteration 21 --
Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
bool(false)
-- Iteration 22 --
Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
bool(false)
-- Iteration 23 --
Warning: arsort() expects parameter 1 to be array, resource given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, resource given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, resource given in %sarsort_variation1.php on line %d
bool(false)
Warning: arsort() expects parameter 1 to be array, resource given in %sarsort_variation1.php on line %d
bool(false)
Done