com php-langspec: Update tests to be compatible with master: tests/expressions/list/list_keyed_conversions.phpt test
s/expressions/list/list_mixed_keyed_unkeyed.phpt test s/expressions/postfix_operators/subscripting.phpt tests/e
xpressions/primary_expressions/intrinsics_empty.phpt te sts/expressions/primary_expressions/intrinsics_isset.phpt
tests/expressions/primary_expressions/intrinsics_unset .phpt tests/expressions/unary_operators/cast.phpt tes ts/f

From: Date: Mon, 12 Dec 2016 23:24:59 +0000
Subject: com php-langspec: Update tests to be compatible with master: tests/expressions/list/list_keyed_conversions.phpt test
s/expressions/list/list_mixed_keyed_unkeyed.phpt test s/expressions/postfix_operators/subscripting.phpt tests/e
xpressions/primary_expressions/intrinsics_empty.phpt te sts/expressions/primary_expressions/intrinsics_isset.phpt
tests/expressions/primary_expressions/intrinsics_unset .phpt tests/expressions/unary_operators/cast.phpt tes ts/f
Groups: php.standards.cvs 
Request: Send a blank email to standards--cvs+get-374@lists.php.net to get a copy of this message
Commit: ebf06e157a26b6b215334c43911067ae1863465f Author: Pedro Magalhães <pkemo85@gmail.com> Mon, 12 Dec 2016 21:01:33 +0100 Committer: Nikita Popov <nikic@php.net> Tue, 13 Dec 2016 00:24:59 +0100 Parents: 0ac3b233e6fe5beba1d49dbfeb881b1ce9d4bd4c Branches: master Link: http://git.php.net/?p=php-langspec.git;a=commitdiff;h=ebf06e157a26b6b215334c43911067ae1863465f Log: Update tests to be compatible with master Changed paths: M tests/expressions/list/list_keyed_conversions.phpt M tests/expressions/list/list_mixed_keyed_unkeyed.phpt M tests/expressions/postfix_operators/subscripting.phpt M tests/expressions/primary_expressions/intrinsics_empty.phpt M tests/expressions/primary_expressions/intrinsics_isset.phpt M tests/expressions/primary_expressions/intrinsics_unset.phpt M tests/expressions/unary_operators/cast.phpt M tests/functions/basics.phpt M tests/functions/default_arguments.phpt M tests/functions/passing_by_reference.phpt M tests/functions/using_byrefs_to_undefined_variables.phpt M tests/functions/void_disallowed1.phpt M tests/traits/traits.phpt

diff --git a/tests/expressions/list/list_keyed_conversions.phpt b/tests/expressions/list/list_keyed_conversions.phpt index e2cf91a..c1837a9 100644 --- a/tests/expressions/list/list_keyed_conversions.phpt +++ b/tests/expressions/list/list_keyed_conversions.phpt @@ -30,3 +30,5 @@ int(0) int(1) Notice: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d + +Notice: Undefined offset: %d in %s on line %d diff --git a/tests/expressions/list/list_mixed_keyed_unkeyed.phpt b/tests/expressions/list/list_mixed_keyed_unkeyed.phpt index 5562479..11073a4 100644 --- a/tests/expressions/list/list_mixed_keyed_unkeyed.phpt +++ b/tests/expressions/list/list_mixed_keyed_unkeyed.phpt @@ -13,4 +13,4 @@ list($zero, 1 => $one, "foo" => $foo) = $contrivedKeyedAndUnkeyedArrayExample; ?> --EXPECTF-- -Parse error: syntax error, unexpected %s in %s on line %d +Fatal error: Cannot mix keyed and unkeyed array entries in assignments in %s diff --git a/tests/expressions/postfix_operators/subscripting.phpt b/tests/expressions/postfix_operators/subscripting.phpt index dfd46e2..a6373ff 100644 --- a/tests/expressions/postfix_operators/subscripting.phpt +++ b/tests/expressions/postfix_operators/subscripting.phpt @@ -144,7 +144,7 @@ var_dump($v[1]); // OK, results in NULL "red"[1]; var_dump("red"[1]); // OK, results in "e" var_dump("red"[1.9]); // OK, results in "e" -var_dump("red"[-1]); // OK, results in "" +var_dump("red"[-1]); // OK, results in "d" var_dump("red"[10]); // OK, results in "" var_dump("red"["abc"]); // Warning, results in "r" from [0] @@ -179,7 +179,7 @@ $s[0] = "DEF"; // "r" -> "D"; only 1 char changed var_dump($s); $s[0] = "MN"; // "D" -> "M"; only 1 char changed var_dump($s); -$s[0] = ""; // "M" -> "\0" +$s[0] = ""; // warning; nothing changed var_dump($s); $s["zz"] = "Q"; // warning; "Q" goes into [0] var_dump($s); @@ -364,9 +364,7 @@ string(1) "e" Notice: String offset cast occurred in %s/expressions/postfix_operators/subscripting.php on line 143 string(1) "e" - -Notice: Uninitialized string offset: -1 in %s/expressions/postfix_operators/subscripting.php on line 144 -string(0) "" +string(1) "d" Notice: Uninitialized string offset: 10 in %s/expressions/postfix_operators/subscripting.php on line 145 string(0) "" @@ -393,7 +391,9 @@ string(6) "rXd Z" [5] is not a space string(6) "DXd Z" string(6) "MXd Z" -string(6) "Xd Z" + +Warning: Cannot assign an empty string to a string offset in %s +string(6) "MXd Z" Warning: Illegal string offset 'zz' in %s/expressions/postfix_operators/subscripting.php on line 181 string(6) "QXd Z" diff --git a/tests/expressions/primary_expressions/intrinsics_empty.phpt b/tests/expressions/primary_expressions/intrinsics_empty.phpt index 9500a63..2eca904 100644 --- a/tests/expressions/primary_expressions/intrinsics_empty.phpt +++ b/tests/expressions/primary_expressions/intrinsics_empty.phpt @@ -114,18 +114,6 @@ class XX {} $v = new XX; var_dump(empty($v)); -echo "--------- undefined parameter -------------\n"; - -function f($p) -{ - var_dump($p); - var_dump(empty($p)); -} - -f(); -f(NULL); -f(10); - echo "---------- resource STDIN ------------\n"; var_dump(empty(STDIN)); @@ -205,17 +193,6 @@ bool(false) bool(false) --------- instance of class having no properties ------------- bool(false) ---------- undefined parameter ------------- - -Warning: %s - -Notice: Undefined variable: p in %s/expressions/primary_expressions/intrinsics_empty.php on line 118 -NULL -bool(true) -NULL -bool(true) -int(10) -bool(false) ---------- resource STDIN ------------ bool(false) bool(false) diff --git a/tests/expressions/primary_expressions/intrinsics_isset.phpt b/tests/expressions/primary_expressions/intrinsics_isset.phpt index 8df019e..86293ee 100644 --- a/tests/expressions/primary_expressions/intrinsics_isset.phpt +++ b/tests/expressions/primary_expressions/intrinsics_isset.phpt @@ -26,18 +26,6 @@ echo "--------- TRUE, 12.3, NULL -------------\n"; $v1 = TRUE; $v2 = 12.3; $v3 = NULL; var_dump(isset($v1, $v2, $v3)); -echo "--------- undefined parameter -------------\n"; - -function f($p) -{ - var_dump($p); - var_dump(isset($p)); -} - -f(); -f(NULL); -f(10); - echo "---------- dynamic property ------------\n"; class X1 @@ -68,17 +56,6 @@ bool(true) bool(false) --------- TRUE, 12.3, NULL ------------- bool(false) ---------- undefined parameter ------------- - -Warning: %s - -Notice: Undefined variable: p in %s/expressions/primary_expressions/intrinsics_isset.php on line 30 -NULL -bool(false) -NULL -bool(false) -int(10) -bool(true) ---------- dynamic property ------------ bool(false) bool(true) diff --git a/tests/expressions/primary_expressions/intrinsics_unset.phpt b/tests/expressions/primary_expressions/intrinsics_unset.phpt index 8438d2d..3e77580 100644 --- a/tests/expressions/primary_expressions/intrinsics_unset.phpt +++ b/tests/expressions/primary_expressions/intrinsics_unset.phpt @@ -32,20 +32,6 @@ var_dump(isset($v1, $v2, $v3)); unset($v1, $v2, $v3); var_dump(isset($v1, $v2, $v3)); -echo "--------- undefined parameter -------------\n"; - -function f($p) -{ - var_dump($p); - var_dump(isset($p)); - unset($p); - var_dump(isset($p)); -} - -f(); -f(NULL); -f(10); - echo "---------- dynamic property ------------\n"; class X1 @@ -162,32 +148,6 @@ $c2 = new C; var_dump($c2); var_dump(isset($c2->prop)); -echo "---------- unsetting \$this ------------\n"; - -class D -{ - public function f() - { - echo "Inside ". __METHOD__ . "\n"; - - var_dump(isset($this)); - unset($this); - var_dump(isset($this)); - - $this->g(); // use $this to call sibling instance method - } - - private function g() - { - echo "Inside ". __METHOD__ . "\n"; - - var_dump(isset($this)); - } -} - -$d = new D; -$d->f(); - echo "---------- unsetting array elements ------------\n"; $a = array(10, 20, "xx" => 30); @@ -210,20 +170,6 @@ bool(false) --------- TRUE, 12.3, NULL ------------- bool(true) bool(false) ---------- undefined parameter ------------- - -Warning: %s - -Notice: Undefined variable: p in %s/expressions/primary_expressions/intrinsics_unset.php on line 36 -NULL -bool(false) -bool(false) -NULL -bool(false) -bool(false) -int(10) -bool(true) -bool(false) ---------- dynamic property ------------ bool(false) bool(true) @@ -270,12 +216,6 @@ object(C)#4 (1) { int(10) } bool(true) ----------- unsetting $this ------------ -Inside D::f -bool(true) -bool(false) -Inside D::g -bool(true) ---------- unsetting array elements ------------ Array ( diff --git a/tests/expressions/unary_operators/cast.phpt b/tests/expressions/unary_operators/cast.phpt index 7805253..d87341e 100644 --- a/tests/expressions/unary_operators/cast.phpt +++ b/tests/expressions/unary_operators/cast.phpt @@ -464,9 +464,9 @@ string(5) "Array" int(20) } >>---object(stdClass)#1 (2) { - [5]=> + ["5"]=> int(10) - [2]=> + ["2"]=> int(20) } array(4) { @@ -497,13 +497,13 @@ string(5) "Array" NULL } >>---object(stdClass)#1 (4) { - [0]=> + ["0"]=> float(1.23) - [1]=> + ["1"]=> bool(true) - [2]=> + ["2"]=> string(5) "Hello" - [3]=> + ["3"]=> NULL } float(3.3333333333333) diff --git a/tests/functions/basics.phpt b/tests/functions/basics.phpt index 299a9c5..58bbc4b 100644 --- a/tests/functions/basics.phpt +++ b/tests/functions/basics.phpt @@ -53,11 +53,20 @@ function f2($p1, $p2) ", \$p2 = ".($p2 == NULL ? "NULL" : $p2)."\n"; } -// if fewer arguments are passed than there are paramaters declared, a warning is issued -// and the parameters corresponding to each each omitted argument are undefined +// if fewer arguments are passed than there are paramaters declared, an ArgumentCountError is thrown -f2(); // pass 0 (< 2) -f2(10); // pass 1 (< 2) +try { + f2(); +} +catch (ArgumentCountError $e) { + echo $e->getMessage() . PHP_EOL; +} +try { + f2(10); +} +catch (ArgumentCountError $e) { + echo $e->getMessage() . PHP_EOL; +} f2(10, 20); // pass 2 (== 2) f2(10, 20, 30); // pass 3 (> 2) @@ -92,23 +101,13 @@ f1: # arguments passed is 3 Notice: Array to string conversion in %s/functions/basics.php on line 25 arg[2] = >Array< - -Warning: %a - -Notice: Undefined variable: p1 in %s/functions/basics.php on line 49 - -Notice: Undefined variable: p2 in %s/functions/basics.php on line 50 -f2: $p1 = NULL, $p2 = NULL - -Warning: %s - -Notice: Undefined variable: p2 in %s/functions/basics.php on line 50 -f2: $p1 = 10, $p2 = NULL +Too few arguments to function f2(), 0 passed in %s on line %d and exactly 2 expected +Too few arguments to function f2(), 1 passed in %s on line %d and exactly 2 expected f2: $p1 = 10, $p2 = 20 f2: $p1 = 10, $p2 = 20 5 squared = 25 -Notice: Use of undefined constant square - assumed 'square' in %s/functions/basics.php on line 65 +Notice: Use of undefined constant square - assumed 'square' in %s/functions/basics.php on line 74 string(6) "square" float(5.29) 7 diff --git a/tests/functions/default_arguments.phpt b/tests/functions/default_arguments.phpt index 36693f3..ed02053 100644 --- a/tests/functions/default_arguments.phpt +++ b/tests/functions/default_arguments.phpt @@ -36,7 +36,7 @@ f1(10, 20, 30, 40, 50, 60); f1(1, 2, 3, 4, 5, 6, 7); //*/ ///* -// 2 default followed by one non-default; unusual, but permitted +// 2 default followed by one non-default; function f2($p1 = 100, $p2 = 1.23, $p3) { @@ -52,13 +52,31 @@ function f2($p1 = 100, $p2 = 1.23, $p3) ", \$p3: ".($p3 == NULL ? "NULL" : $p3)."\n"; } -f2(); -f2(10); -f2(10, 20); +// if a non-default parameter is present and not all the arguments before it are provided, +// an ArgumentCountError is thrown + +try { + f2(); +} +catch (ArgumentCountError $e) { + echo $e->getMessage() . PHP_EOL; +} +try { + f2(10); +} +catch (ArgumentCountError $e) { + echo $e->getMessage() . PHP_EOL; +} +try { + f2(10, 20); +} +catch (ArgumentCountError $e) { + echo $e->getMessage() . PHP_EOL; +} f2(10, 20, 30); //*/ ///* -// 1 default followed by one non-default followed by 1 default; unusual, but permitted +// 1 default followed by one non-default followed by 1 default; function f3($p1 = 100, $p2, $p3 = "abc") { @@ -74,8 +92,21 @@ function f3($p1 = 100, $p2, $p3 = "abc") ", \$p3: ".($p3 == NULL ? "NULL" : $p3)."\n"; } -f3(); -f3(10); +// if a non-default parameter is present and not all the arguments before it are provided, +// an ArgumentCountError is thrown + +try { + f3(); +} +catch (ArgumentCountError $e) { + echo $e->getMessage() . PHP_EOL; +} +try { + f3(10); +} +catch (ArgumentCountError $e) { + echo $e->getMessage() . PHP_EOL; +} f3(10, 20); f3(10, 20, 30); //*/ @@ -96,7 +127,15 @@ function f4($p1, $p2 = 1.23, $p3 = "abc") ", \$p3: ".($p3 == NULL ? "NULL" : $p3)."\n"; } -f4(); +// if a non-default parameter is present and not all the arguments before it are provided, +// an ArgumentCountError is thrown + +try { + f4(); +} +catch (ArgumentCountError $e) { + echo $e->getMessage() . PHP_EOL; +} f4(10); f4(10, 20); f4(10, 20, 30); @@ -104,37 +143,37 @@ f4(10, 20, 30); --EXPECTF-- f1: # arguments passed is 0 -Notice: Array to string conversion in %s/functions/default_arguments.php on line 23 +Notice: Array to string conversion %s $p1: 10, $p2: 1.23, $p3: 1, $p4: , $p5: abc, $p6: Array f1: # arguments passed is 1 arg[0] = >20< -Notice: Array to string conversion in %s/functions/default_arguments.php on line 23 +Notice: Array to string conversion %s $p1: 20, $p2: 1.23, $p3: 1, $p4: , $p5: abc, $p6: Array f1: # arguments passed is 2 arg[0] = >10< arg[1] = >1< -Notice: Array to string conversion in %s/functions/default_arguments.php on line 23 +Notice: Array to string conversion %s $p1: 10, $p2: 1, $p3: 1, $p4: , $p5: abc, $p6: Array f1: # arguments passed is 3 arg[0] = >< arg[1] = >12< arg[2] = >1.234< -Notice: Array to string conversion in %s/functions/default_arguments.php on line 23 +Notice: Array to string conversion %s $p1: , $p2: 12, $p3: 1.234, $p4: , $p5: abc, $p6: Array f1: # arguments passed is 4 arg[0] = >< arg[1] = >1200< -Notice: Array to string conversion in %s/functions/default_arguments.php on line 21 +Notice: Array to string conversion %s arg[2] = >Array< arg[3] = >abc< -Notice: Array to string conversion in %s/functions/default_arguments.php on line 23 +Notice: Array to string conversion %s -Notice: Array to string conversion in %s/functions/default_arguments.php on line 23 +Notice: Array to string conversion %s $p1: , $p2: 1200, $p3: Array, $p4: abc, $p5: abc, $p6: Array f1: # arguments passed is 5 arg[0] = >9< @@ -143,7 +182,7 @@ f1: # arguments passed is 5 arg[3] = >6< arg[4] = >5< -Notice: Array to string conversion in %s/functions/default_arguments.php on line 23 +Notice: Array to string conversion %s $p1: 9, $p2: 8, $p3: 7, $p4: 6, $p5: 5, $p6: Array f1: # arguments passed is 6 arg[0] = >10< @@ -162,45 +201,16 @@ f1: # arguments passed is 7 arg[5] = >6< arg[6] = >7< $p1: 1, $p2: 2, $p3: 3, $p4: 4, $p5: 5, $p6: 6 - -Warning: %s -f2: # arguments passed is 0 - -Notice: Undefined variable: p3 in %s/functions/default_arguments.php on line 49 -$p1: 100, $p2: 1.23, $p3: NULL - -Warning: %s -f2: # arguments passed is 1 - arg[0] = >10< - -Notice: Undefined variable: p3 in %s/functions/default_arguments.php on line 49 -$p1: 10, $p2: 1.23, $p3: NULL - -Warning: %s -f2: # arguments passed is 2 - arg[0] = >10< - arg[1] = >20< - -Notice: Undefined variable: p3 in %s/functions/default_arguments.php on line 49 -$p1: 10, $p2: 20, $p3: NULL +Too few arguments to function f2(), 0 passed in %s and exactly 3 expected +Too few arguments to function f2(), 1 passed in %s and exactly 3 expected +Too few arguments to function f2(), 2 passed in %s and exactly 3 expected f2: # arguments passed is 3 arg[0] = >10< arg[1] = >20< arg[2] = >30< $p1: 10, $p2: 20, $p3: 30 - -Warning: %s -f3: # arguments passed is 0 - -Notice: Undefined variable: p2 in %s/functions/default_arguments.php on line 70 -$p1: 100, $p2: NULL, $p3: abc - -Warning: %s -f3: # arguments passed is 1 - arg[0] = >10< - -Notice: Undefined variable: p2 in %s/functions/default_arguments.php on line 70 -$p1: 10, $p2: NULL, $p3: abc +Too few arguments to function f3(), 0 passed in %s and at least 2 expected +Too few arguments to function f3(), 1 passed in %s and at least 2 expected f3: # arguments passed is 2 arg[0] = >10< arg[1] = >20< @@ -210,12 +220,7 @@ f3: # arguments passed is 3 arg[1] = >20< arg[2] = >30< $p1: 10, $p2: 20, $p3: 30 - -Warning: %s -f4: # arguments passed is 0 - -Notice: Undefined variable: p1 in %s/functions/default_arguments.php on line 91 -$p1: NULL, $p2: 1.23, $p3: abc +Too few arguments to function f4(), 0 passed in %s and at least 1 expected f4: # arguments passed is 1 arg[0] = >10< $p1: 10, $p2: 1.23, $p3: abc diff --git a/tests/functions/passing_by_reference.phpt b/tests/functions/passing_by_reference.phpt index 3b232c2..ac9d8a7 100644 --- a/tests/functions/passing_by_reference.phpt +++ b/tests/functions/passing_by_reference.phpt @@ -53,9 +53,8 @@ var_dump($a); // so using it will raise a fatal error." var_dump($a); -f(); // So just what is f's $p aliased to? Presumably, nothing; $p is simply - // undefined on entry to f. Then when assigned 200, $p becomes a local - // variable that dies when it goes out of scope when the function terminates. +// f(); // PHP7.1, Fatal error: Uncaught ArgumentCountError: Too few arguments + // to function f(), 0 passed //*/ ///* @@ -71,7 +70,7 @@ function g(&$p = "red") // pass a variable by reference; f changes its value -g(); // like the f() call above +g(); // Unlike the f() call above, here the default parameter is used $a = 10; var_dump($a); @@ -103,13 +102,6 @@ f In: $p: 10 f Out: $p: 200 int(200) int(200) - -Warning: %s -$p is not set - -Notice: Undefined variable: p in %s/functions/passing_by_reference.php on line 34 -f In: $p: -f Out: $p: 200 $p is set g In: $p: red g Out: $p: 200 diff --git a/tests/functions/using_byrefs_to_undefined_variables.phpt b/tests/functions/using_byrefs_to_undefined_variables.phpt index 6e18e24..756f630 100644 --- a/tests/functions/using_byrefs_to_undefined_variables.phpt +++ b/tests/functions/using_byrefs_to_undefined_variables.phpt @@ -31,7 +31,8 @@ function g(&$q) $q = -10; } -f(); +// f(); // PHP7.1, Fatal error: Uncaught ArgumentCountError: Too few arguments + // to function f(), 0 passed var_dump($x); f($x); // non-existant variable going in @@ -63,7 +64,8 @@ function h(&$p) var_dump($b); } -h(); +// h(); // PHP7.1, Fatal error: Uncaught ArgumentCountError: Too few arguments + // to function f(), 0 passed var_dump($x); h($x); // non-existant variable going in @@ -130,13 +132,7 @@ $d = &m2(); var_dump($d); //*/ --EXPECTF-- -Warning: %s -$p is not set -$q is not set -$p is set -int(-10) - -Notice: Undefined variable: x in %s/functions/using_byrefs_to_undefined_variables.php on line 33 +Notice: Undefined variable: x %s NULL $p is not set $q is not set @@ -193,12 +189,6 @@ array(5) { ["red"]=> int(-10) } - -Warning: %s -$p is not set -$p is not set -NULL -NULL int(-10) $p is set $p is set diff --git a/tests/functions/void_disallowed1.phpt b/tests/functions/void_disallowed1.phpt index b20f129..708ef27 100644 --- a/tests/functions/void_disallowed1.phpt +++ b/tests/functions/void_disallowed1.phpt @@ -9,4 +9,4 @@ function foo(): void { // Note the lack of function call: function validated at compile-time --EXPECTF-- -Fatal error: A void function must not return a value in %s on line %d +Fatal error: A void function must not return a value (did you mean "return;" instead of "return null;"?) in %s diff --git a/tests/traits/traits.phpt b/tests/traits/traits.phpt index 9526b73..4aebc6d 100644 --- a/tests/traits/traits.phpt +++ b/tests/traits/traits.phpt @@ -227,7 +227,7 @@ trait T7 echo "Inside " . __TRAIT__ . "\n"; echo "Inside " . __CLASS__ . "\n"; echo "Inside " . __METHOD__ . "\n"; - var_dump($this); + // var_dump($this); // Fatal error: Uncaught Error: Using $this when not in object context } public static function g() @@ -339,9 +339,6 @@ $v = 2 %AInside T7 Inside T7 Inside T7::f - -Notice: Undefined variable: this in %s/traits/traits.php on line 227 -NULL ------- Inside T7 Inside T7
« previous php.standards.cvs (#374) next »