com php-langspec: Fix constant uses in basic.phpt: tests/functions/basics.phpt
| From: | Nikita Popov | Date: | Mon, 08 Apr 2019 06:59:24 +0000 |
| Subject: | com php-langspec: Fix constant uses in basic.phpt: tests/functions/basics.phpt | ||
| Groups: | php.standards.cvs | ||
| Request: | Send a blank email to standards--cvs+get-436@lists.php.net to get a copy of this message | ||
Commit: dc2e8d9593bd6b5826d10afcfbb86140733d4b13
Author: Nikita Popov <nikita.ppv@gmail.com> Mon, 8 Apr 2019 08:59:24 +0200
Parents: fe55bee01293a925120cfe330b62a94fc5140e35
Branches: master
Link: http://git.php.net/?p=php-langspec.git;a=commitdiff;h=dc2e8d9593bd6b5826d10afcfbb86140733d4b13
Log:
Fix constant uses in basic.phpt
These are no longer legal in PHP 8. This is supposed to be testing
dynamic function calls, for which we should be using the string and
not rely on the bareword fallback.
Changed paths:
M tests/functions/basics.phpt
Diff:
diff --git a/tests/functions/basics.phpt b/tests/functions/basics.phpt
index f8e1bec..2a3bc2c 100644
--- a/tests/functions/basics.phpt
+++ b/tests/functions/basics.phpt
@@ -30,11 +30,9 @@ function f1()
}
var_dump(f1()); // call f1, default return value is NULL
-f1; // valid, but vacuous, as it has no side effect and its value is not used
-var_dump(f1); // string with value "f1"
-$f = f1; // assign this string to a variable
+$f = "f1"; // assign the name of the function to a variable
$f(); // call f1 indirectly via $f
-//"f1"(); // call f1 via the string "f1" -- Can't be a string literal!!!
+"f1"(); // call f1 via the string "f1"
// f1() = 123; // a function return is not an lvalue
@@ -74,20 +72,14 @@ f2(10, 20, 30); // pass 3 (> 2)
function square($v) { return $v * $v; }
echo "5 squared = ".square(5)."\n";
-var_dump($funct = square);
+$funct = "square";
var_dump($funct(-2.3));
echo strlen("abcedfg")."\n";
--EXPECTF--
f1: # arguments passed is 0
NULL
-
-Warning: Use of undefined constant f1 - assumed 'f1' (this will throw an Error in a
future version of PHP) in %s/functions/basics.php on line 30
-
-Warning: Use of undefined constant f1 - assumed 'f1' (this will throw an Error in a
future version of PHP) in %s/functions/basics..php on line 31
-string(2) "f1"
-
-Warning: Use of undefined constant f1 - assumed 'f1' (this will throw an Error in a
future version of PHP) in %s/functions/basics.php on line 32
+f1: # arguments passed is 0
f1: # arguments passed is 0
f1: # arguments passed is 0
f1: # arguments passed is 1
@@ -106,8 +98,5 @@ Too few arguments to function f2(), 1 passed in %s on line %d and exactly 2 expe
f2: $p1 = 10, $p2 = 20
f2: $p1 = 10, $p2 = 20
5 squared = 25
-
-Warning: Use of undefined constant square - assumed 'square' (this will throw an Error in
a future version of PHP) in %s/functions/basics.php on line 74
-string(6) "square"
float(5.29)
7