Skip to content

Commit dc2e8d9

Browse files
committed
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.
1 parent fe55bee commit dc2e8d9

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

tests/functions/basics.phpt

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,9 @@ function f1()
3030
}
3131

3232
var_dump(f1()); // call f1, default return value is NULL
33-
f1; // valid, but vacuous, as it has no side effect and its value is not used
34-
var_dump(f1); // string with value "f1"
35-
$f = f1; // assign this string to a variable
33+
$f = "f1"; // assign the name of the function to a variable
3634
$f(); // call f1 indirectly via $f
37-
//"f1"(); // call f1 via the string "f1" -- Can't be a string literal!!!
35+
"f1"(); // call f1 via the string "f1"
3836

3937
// f1() = 123; // a function return is not an lvalue
4038

@@ -74,20 +72,14 @@ f2(10, 20, 30); // pass 3 (> 2)
7472

7573
function square($v) { return $v * $v; }
7674
echo "5 squared = ".square(5)."\n";
77-
var_dump($funct = square);
75+
$funct = "square";
7876
var_dump($funct(-2.3));
7977

8078
echo strlen("abcedfg")."\n";
8179
--EXPECTF--
8280
f1: # arguments passed is 0
8381
NULL
84-
85-
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
86-
87-
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
88-
string(2) "f1"
89-
90-
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
82+
f1: # arguments passed is 0
9183
f1: # arguments passed is 0
9284
f1: # arguments passed is 0
9385
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
10698
f2: $p1 = 10, $p2 = 20
10799
f2: $p1 = 10, $p2 = 20
108100
5 squared = 25
109-
110-
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
111-
string(6) "square"
112101
float(5.29)
113102
7

0 commit comments

Comments
 (0)