mirror of
https://github.com/php/php-src.git
synced 2026-04-14 03:22:58 +02:00
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
110 lines
1.7 KiB
PHP
110 lines
1.7 KiB
PHP
--TEST--
|
||
Test natcasesort() function : usage variations - mixed array
|
||
--FILE--
|
||
<?php
|
||
/* Prototype : bool natcasesort(array &$array_arg)
|
||
* Description: Sort an array using case-insensitive natural sort
|
||
* Source code: ext/standard/array.c
|
||
*/
|
||
|
||
/*
|
||
* Pass an array containing sub-arrays, ints, floats, strings, boolean, null
|
||
* and escape characters to test how natcasesort() re-orders it
|
||
*/
|
||
|
||
echo "*** Testing natcasesort() : usage variation ***\n";
|
||
|
||
$mixed_values = array (
|
||
array(),
|
||
array( array(33, -5, 6),
|
||
array(11),
|
||
array(22, -55),
|
||
array()
|
||
),
|
||
-4, "4", 4.00, "b", "5", -2, -2.0, -2.98989, "-.9", "True", "",
|
||
NULL, "ab", "abcd", 0.0, -0, "abcd\x00abcd\x00abcd", '', true, false
|
||
);
|
||
// suppress errors as is generating a lot of "array to string" notices
|
||
var_dump( @natcasesort($mixed_values) );
|
||
|
||
var_dump($mixed_values);
|
||
|
||
echo "Done";
|
||
?>
|
||
--EXPECT--
|
||
*** Testing natcasesort() : usage variation ***
|
||
bool(true)
|
||
array(22) {
|
||
[21]=>
|
||
bool(false)
|
||
[13]=>
|
||
NULL
|
||
[12]=>
|
||
string(0) ""
|
||
[19]=>
|
||
string(0) ""
|
||
[10]=>
|
||
string(3) "-.9"
|
||
[7]=>
|
||
int(-2)
|
||
[8]=>
|
||
float(-2)
|
||
[9]=>
|
||
float(-2.98989)
|
||
[2]=>
|
||
int(-4)
|
||
[16]=>
|
||
float(0)
|
||
[17]=>
|
||
int(0)
|
||
[20]=>
|
||
bool(true)
|
||
[4]=>
|
||
float(4)
|
||
[3]=>
|
||
string(1) "4"
|
||
[6]=>
|
||
string(1) "5"
|
||
[14]=>
|
||
string(2) "ab"
|
||
[15]=>
|
||
string(4) "abcd"
|
||
[18]=>
|
||
string(14) "abcd |