mirror of
https://github.com/php/php-src.git
synced 2024-09-24 03:17:26 +00:00
d679f02295
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
151 lines
2.4 KiB
PHP
151 lines
2.4 KiB
PHP
--TEST--
|
|
Evaluation order during assignments.
|
|
--FILE--
|
|
<?php
|
|
|
|
function f() {
|
|
echo "in f()\n";
|
|
return "name";
|
|
}
|
|
|
|
function g() {
|
|
echo "in g()\n";
|
|
return "assigned value";
|
|
}
|
|
|
|
|
|
echo "\n\nOrder with local assignment:\n";
|
|
${f()} = g();
|
|
var_dump($name);
|
|
|
|
echo "\n\nOrder with array assignment:\n";
|
|
$a[f()] = g();
|
|
var_dump($a);
|
|
|
|
echo "\n\nOrder with object property assignment:\n";
|
|
$oa = new stdClass;
|
|
$oa->${f()} = g();
|
|
var_dump($oa);
|
|
|
|
echo "\n\nOrder with nested object property assignment:\n";
|
|
$ob = new stdClass;
|
|
$ob->o1 = new stdClass;
|
|
$ob->o1->o2 = new stdClass;
|
|
$ob->o1->o2->${f()} = g();
|
|
var_dump($ob);
|
|
|
|
echo "\n\nOrder with dim_list property assignment:\n";
|
|
$oc = new stdClass;
|
|
$oc->a[${f()}] = g();
|
|
var_dump($oc);
|
|
|
|
|
|
class C {
|
|
public static $name = "original";
|
|
public static $a = array();
|
|
public static $string = "hello";
|
|
}
|
|
echo "\n\nOrder with static property assignment:\n";
|
|
C::${f()} = g();
|
|
var_dump(C::$name);
|
|
|
|
echo "\n\nOrder with static array property assignment:\n";
|
|
C::$a[f()] = g();
|
|
var_dump(C::$a);
|
|
|
|
echo "\n\nOrder with indexed string assignment:\n";
|
|
$string = "hello";
|
|
function getOffset() {
|
|
echo "in getOffset()\n";
|
|
return 0;
|
|
}
|
|
function newChar() {
|
|
echo "in newChar()\n";
|
|
return 'j';
|
|
}
|
|
$string[getOffset()] = newChar();
|
|
var_dump($string);
|
|
|
|
echo "\n\nOrder with static string property assignment:\n";
|
|
C::$string[getOffset()] = newChar();
|
|
var_dump(C::$string);
|
|
|
|
?>
|
|
--EXPECTF--
|
|
Order with local assignment:
|
|
in f()
|
|
in g()
|
|
string(14) "assigned value"
|
|
|
|
|
|
Order with array assignment:
|
|
in f()
|
|
in g()
|
|
array(1) {
|
|
["name"]=>
|
|
string(14) "assigned value"
|
|
}
|
|
|
|
|
|
Order with object property assignment:
|
|
in f()
|
|
in g()
|
|
object(stdClass)#%d (1) {
|
|
["assigned value"]=>
|
|
string(14) "assigned value"
|
|
}
|
|
|
|
|
|
Order with nested object property assignment:
|
|
in f()
|
|
in g()
|
|
object(stdClass)#%d (1) {
|
|
["o1"]=>
|
|
object(stdClass)#%d (1) {
|
|
["o2"]=>
|
|
object(stdClass)#%d (1) {
|
|
["assigned value"]=>
|
|
string(14) "assigned value"
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
Order with dim_list property assignment:
|
|
in f()
|
|
in g()
|
|
object(stdClass)#%d (1) {
|
|
["a"]=>
|
|
array(1) {
|
|
["assigned value"]=>
|
|
string(14) "assigned value"
|
|
}
|
|
}
|
|
|
|
|
|
Order with static property assignment:
|
|
in f()
|
|
in g()
|
|
string(14) "assigned value"
|
|
|
|
|
|
Order with static array property assignment:
|
|
in f()
|
|
in g()
|
|
array(1) {
|
|
["name"]=>
|
|
string(14) "assigned value"
|
|
}
|
|
|
|
|
|
Order with indexed string assignment:
|
|
in getOffset()
|
|
in newChar()
|
|
string(5) "jello"
|
|
|
|
|
|
Order with static string property assignment:
|
|
in getOffset()
|
|
in newChar()
|
|
string(5) "jello"
|