Skip to content

Commit 9a90bd7

Browse files
committed
1 parent 829f297 commit 9a90bd7

File tree

76 files changed

+195
-140
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+195
-140
lines changed

UPGRADING

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ PHP 8.2 UPGRADE NOTES
106106

107107
RFC: https://wiki.php.net/rfc/deprecate_partially_supported_callables
108108

109+
. The "${var}" and "${expr}" style string interpolations are deprecated and
110+
will be removed in PHP 9. Use "$var"/"{$var}" or "${expr}", respectively.
111+
RFC: https://wiki.php.net/rfc/deprecate_dollar_brace_string_interpolation
112+
109113
- Mbstring:
110114
. Use of QPrint, Base64, Uuencode, and HTML-ENTITIES 'text encodings' is
111115
deprecated for all Mbstring functions. Unlike all the other text

Zend/tests/bug61681.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ $la = "ooxx";
77
echo "${substr('laruence', 0, 2)}";
88

99
?>
10-
--EXPECT--
10+
--EXPECTF--
11+
Deprecated: Using ${expr} (variable variables) in strings is deprecated, use {${expr}} instead in %s on line %d
1112
ooxx
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
"${}" emits a deprecation
3+
--FILE--
4+
<?php
5+
6+
$foo = 'bar';
7+
var_dump("${foo}");
8+
9+
?>
10+
--EXPECTF--
11+
Deprecated: Using ${var} in strings is deprecated, use {$var} instead in %s on line %d
12+
string(3) "bar"

Zend/tests/exception_in_nested_rope.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ try {
1313
}
1414

1515
?>
16-
--EXPECT--
16+
--EXPECTF--
17+
Deprecated: Using ${expr} (variable variables) in strings is deprecated, use {${expr}} instead in %s on line %d
1718
Exception

Zend/tests/flexible-heredoc-complex-test1.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ var_dump(<<<DOC1
2121
DOC1);
2222
2323
?>
24-
--EXPECT--
24+
--EXPECTF--
25+
Deprecated: Using ${expr} (variable variables) in strings is deprecated, use {${expr}} instead in %s on line %d
26+
27+
Deprecated: Using ${expr} (variable variables) in strings is deprecated, use {${expr}} instead in %s on line %d
2528
string(5) "a
2629
b
2730
c"

Zend/tests/flexible-heredoc-complex-test2.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ var_dump(<<<DOC1
2121
DOC1);
2222
2323
?>
24-
--EXPECT--
24+
--EXPECTF--
25+
Deprecated: Using ${expr} (variable variables) in strings is deprecated, use {${expr}} instead in %s on line %d
26+
27+
Deprecated: Using ${expr} (variable variables) in strings is deprecated, use {${expr}} instead in %s on line %d
2528
string(5) "a
2629
b
2730
c"

Zend/tests/flexible-heredoc-complex-test3.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ var_dump(<<<DOC1
2121
DOC1);
2222
2323
?>
24-
--EXPECT--
24+
--EXPECTF--
25+
Deprecated: Using ${expr} (variable variables) in strings is deprecated, use {${expr}} instead in %s on line %d
26+
27+
Deprecated: Using ${expr} (variable variables) in strings is deprecated, use {${expr}} instead in %s on line %d
2528
string(8) " a
2629
b
2730
c"

Zend/tests/flexible-heredoc-complex-test4.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ the same delimiter name as the heredoc
2828
}
2929

3030
?>
31-
--EXPECT--
31+
--EXPECTF--
32+
Deprecated: Using ${expr} (variable variables) in strings is deprecated, use {${expr}} instead in %s on line %d
33+
34+
Deprecated: Using ${expr} (variable variables) in strings is deprecated, use {${expr}} instead in %s on line %d
3235
string(8) "Test
3336
FOO"
3437
string(16) " Test

Zend/tests/temporary_cleaning_016.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ try {
1111
}
1212
?>
1313
DONE
14-
--EXPECT--
14+
--EXPECTF--
15+
Deprecated: Using ${expr} (variable variables) in strings is deprecated, use {${expr}} instead in %s on line %d
1516
DONE

Zend/tests/warning_during_heredoc_scan_ahead.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ Warning: Octal escape sequence overflow \400 is greater than \377 in %s on line
1414

1515
Warning: Octal escape sequence overflow \400 is greater than \377 in %s on line %d
1616

17+
Deprecated: Using ${expr} (variable variables) in strings is deprecated, use {${expr}} instead in %s on line %d
18+
1719
Warning: Undefined variable $ in %s on line %d

Zend/zend_compile.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9504,7 +9504,16 @@ static void zend_compile_encaps_list(znode *result, zend_ast *ast) /* {{{ */
95049504
j = 0;
95059505
last_const_node.op_type = IS_UNUSED;
95069506
for (i = 0; i < list->children; i++) {
9507-
zend_compile_expr(&elem_node, list->child[i]);
9507+
zend_ast *encaps_var = list->child[i];
9508+
if (encaps_var->attr & (ZEND_ENCAPS_VAR_DOLLAR_CURLY|ZEND_ENCAPS_VAR_DOLLAR_CURLY_VAR_VAR)) {
9509+
if (encaps_var->attr & ZEND_ENCAPS_VAR_DOLLAR_CURLY_VAR_VAR) {
9510+
zend_error(E_DEPRECATED, "Using ${expr} (variable variables) in strings is deprecated, use {${expr}} instead");
9511+
} else {
9512+
zend_error(E_DEPRECATED, "Using ${var} in strings is deprecated, use {$var} instead");
9513+
}
9514+
}
9515+
9516+
zend_compile_expr(&elem_node, encaps_var);
95089517

95099518
if (elem_node.op_type == IS_CONST) {
95109519
convert_to_string(&elem_node.u.constant);

Zend/zend_compile.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,6 +1077,10 @@ static zend_always_inline bool zend_check_arg_send_type(const zend_function *zf,
10771077
/* Attribute for ternary inside parentheses */
10781078
#define ZEND_PARENTHESIZED_CONDITIONAL 1
10791079

1080+
/* Attributes for ${} encaps var in strings */
1081+
#define ZEND_ENCAPS_VAR_DOLLAR_CURLY (1<<0)
1082+
#define ZEND_ENCAPS_VAR_DOLLAR_CURLY_VAR_VAR (1<<1)
1083+
10801084
/* For "use" AST nodes and the seen symbol table */
10811085
#define ZEND_SYMBOL_CLASS (1<<0)
10821086
#define ZEND_SYMBOL_FUNCTION (1<<1)

Zend/zend_language_parser.y

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,11 +1490,11 @@ encaps_var:
14901490
{ $$ = zend_ast_create(ZEND_AST_NULLSAFE_PROP,
14911491
zend_ast_create(ZEND_AST_VAR, $1), $3); }
14921492
| T_DOLLAR_OPEN_CURLY_BRACES expr '}'
1493-
{ $$ = zend_ast_create(ZEND_AST_VAR, $2); }
1493+
{ $$ = zend_ast_create_ex(ZEND_AST_VAR, ZEND_ENCAPS_VAR_DOLLAR_CURLY_VAR_VAR, $2); }
14941494
| T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '}'
1495-
{ $$ = zend_ast_create(ZEND_AST_VAR, $2); }
1495+
{ $$ = zend_ast_create_ex(ZEND_AST_VAR, ZEND_ENCAPS_VAR_DOLLAR_CURLY, $2); }
14961496
| T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '[' expr ']' '}'
1497-
{ $$ = zend_ast_create(ZEND_AST_DIM,
1497+
{ $$ = zend_ast_create_ex(ZEND_AST_DIM, ZEND_ENCAPS_VAR_DOLLAR_CURLY,
14981498
zend_ast_create(ZEND_AST_VAR, $2), $4); }
14991499
| T_CURLY_OPEN variable '}' { $$ = $2; }
15001500
;

Zend/zend_vm_gen.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2865,7 +2865,7 @@ function gen_vm($def, $skel) {
28652865
out($f, "\t\t\t\t\tbreak;\n");
28662866
out($f, "\t\t\t\t}\n");
28672867
}
2868-
out($f, "\t\t\t\tspec = ${spec_dsc['spec_code']};\n");
2868+
out($f, "\t\t\t\tspec = {$spec_dsc['spec_code']};\n");
28692869
if (isset($spec_dsc["spec"]["COMMUTATIVE"]) && !isset($dsc["spec"]["COMMUTATIVE"])) {
28702870
out($f, "\t\t\t\tif (op->op1_type < op->op2_type) {\n");
28712871
out($f, "\t\t\t\t\tzend_swap_operands(op);\n");

build/gen_stub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,7 @@ public function getDeclaration(): string {
14841484
} else {
14851485
$escapedClassName = $arginfoType->classTypes[0]->toEscapedName();
14861486
$varEscapedClassName = $arginfoType->classTypes[0]->toVarEscapedName();
1487-
$code .= "\tzend_string *property_{$propertyName}_class_{$varEscapedClassName} = zend_string_init(\"{$escapedClassName}\", sizeof(\"${escapedClassName}\")-1, 1);\n";
1487+
$code .= "\tzend_string *property_{$propertyName}_class_{$varEscapedClassName} = zend_string_init(\"{$escapedClassName}\", sizeof(\"{$escapedClassName}\")-1, 1);\n";
14881488

14891489
$typeCode = "(zend_type) ZEND_TYPE_INIT_CLASS(property_{$propertyName}_class_{$varEscapedClassName}, 0, " . $arginfoType->toTypeMask() . ")";
14901490
}

ext/oci8/tests/lob_prefetch.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ $ora_sql =
3535
end loop;
3636
dbms_lob.createtemporary(b, false);
3737
dbms_lob.converttoblob(b, c, dbms_lob.lobmaxsize, dest_offset, src_offset, dbms_lob.default_csid, ctx, warn);
38-
insert /*+ APPEND */ into ${schema}${table_name} (id, clob, blob) values (j, c, b);
38+
insert /*+ APPEND */ into {$schema}{$table_name} (id, clob, blob) values (j, c, b);
3939
end loop;
4040
commit;
4141
end;";
@@ -119,7 +119,7 @@ try {
119119

120120
print("Test 3 - CLOB prefetch_lob_size 100000\n");
121121

122-
$sql = "select clob from ${schema}${table_name}" . " order by id";
122+
$sql = "select clob from {$schema}{$table_name}" . " order by id";
123123
$locarr = get_clob_loc($c, $sql, 100000);
124124
$inlinearr = get_clob_inline($c, $sql, 100000);
125125

@@ -138,7 +138,7 @@ check_clobs($locarr, $inlinearr);
138138

139139
print("Test 4 - BLOB prefetch_lob_size 100000\n");
140140

141-
$sql = "select blob from ${schema}${table_name}" . " order by id";
141+
$sql = "select blob from {$schema}{$table_name}" . " order by id";
142142
$locarr = get_blob_loc($c, $sql, 100000);
143143

144144
print(count($locarr) . "\n");

ext/oci8/tests/lob_prefetch_ini.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ $ora_sql =
3737
end loop;
3838
dbms_lob.createtemporary(b, false);
3939
dbms_lob.converttoblob(b, c, dbms_lob.lobmaxsize, dest_offset, src_offset, dbms_lob.default_csid, ctx, warn);
40-
insert /*+ APPEND */ into ${schema}${table_name} (id, clob, blob) values (j, c, b);
40+
insert /*+ APPEND */ into {$schema}{$table_name} (id, clob, blob) values (j, c, b);
4141
end loop;
4242
commit;
4343
end;";
@@ -108,7 +108,7 @@ var_dump($r);
108108

109109
print("Test 2 - CLOB with current oci8.prefetch_lob_size\n");
110110

111-
$sql = "select clob from ${schema}${table_name}" . " order by id";
111+
$sql = "select clob from {$schema}{$table_name}" . " order by id";
112112
$locarr = get_clob_loc($c, $sql, -1);
113113
$inlinearr = get_clob_inline($c, $sql, -1);
114114

@@ -136,7 +136,7 @@ check_clobs($locarr, $inlinearr);
136136

137137
print("Test 5 - BLOB with current ocig8.prefetch_lob_size \n");
138138

139-
$sql = "select blob from ${schema}${table_name}" . " order by id";
139+
$sql = "select blob from {$schema}{$table_name}" . " order by id";
140140
$locarr = get_blob_loc($c, $sql, -1);
141141

142142
print(count($locarr) . "\n");

ext/opcache/tests/opt/gh8140a.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ GH-8140 (Wrong first class callable by name optimization)
55
namespace Test;
66

77
function greeter(string $name) {
8-
echo "Hello, ${name}!";
8+
echo "Hello, {$name}!";
99
}
1010

1111
$mycallable = greeter(...);

ext/opcache/tests/opt/gh8140b.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ GH-8140 (Wrong first class callable by name optimization)
55
$mycallable = greeter(...);
66

77
function greeter(string $name) {
8-
echo "Hello, ${name}!";
8+
echo "Hello, {$name}!";
99
}
1010

1111
$mycallable("world");

ext/pgsql/tests/config.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ $view_name = "php_pgsql_viewtest";
1616
$view_def = "CREATE VIEW {$view_name} AS SELECT * FROM {$table_name};";
1717

1818
// Test table
19-
$table_def = "CREATE TABLE ${table_name} (num int, str text, bin bytea);";
20-
$table_def_92 = "CREATE TABLE ${table_name_92} (textary text[], jsn json);";
19+
$table_def = "CREATE TABLE {$table_name} (num int, str text, bin bytea);";
20+
$table_def_92 = "CREATE TABLE {$table_name_92} (textary text[], jsn json);";
2121
$field_name = "num"; // For pg_field_num()
2222

2323
?>

ext/phar/phar/clicommand.inc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ abstract class CLICommand
3030
$this->typs = self::getArgTyps($this);
3131

3232
if ($argc < 2) {
33-
self::error("No command given, check ${argv[0]} help\n");
33+
self::error("No command given, check {$argv[0]} help\n");
3434
} elseif (!isset($this->cmds[$argv[1]]['run'])) {
35-
self::error("Unknown command '${argv[1]}', check ${argv[0]} help\n");
35+
self::error("Unknown command '{$argv[1]}', check {$argv[0]} help\n");
3636
} else {
3737
$command = $argv[1];
3838
}
@@ -46,12 +46,12 @@ abstract class CLICommand
4646
if (strlen($argv[$i]) == 2 && isset($this->args[$argv[$i][1]])) {
4747
$arg = $argv[$i][1];
4848
if (++$i >= $argc) {
49-
self::error("Missing argument to parameter '$arg' of command '$command', check ${argv[0]} help\n");
49+
self::error("Missing argument to parameter '$arg' of command '$command', check {$argv[0]} help\n");
5050
} else {
5151
$this->args[$arg]['val'] = $this->checkArgTyp($arg, $i, $argc, $argv);
5252
}
5353
} else {
54-
self::error("Unknown parameter '${argv[$i]}' to command $command, check ${argv[0]} help\n");
54+
self::error("Unknown parameter '{$argv[$i]}' to command $command, check {$argv[0]} help\n");
5555
}
5656
} else {
5757
break;
@@ -61,7 +61,7 @@ abstract class CLICommand
6161
if (isset($this->args[''])) {
6262
if ($i >= $argc) {
6363
if (isset($this->args['']['require']) && $this->args['']['require']) {
64-
self::error("Missing default trailing arguments to command $command, check ${argv[0]} help\n");
64+
self::error("Missing default trailing arguments to command $command, check {$argv[0]} help\n");
6565
}
6666
} else {
6767
$this->args['']['val'] = array();
@@ -70,12 +70,12 @@ abstract class CLICommand
7070
}
7171
}
7272
} else if ($i < $argc) {
73-
self::error("Unexpected default arguments to command $command, check ${argv[0]} help\n");
73+
self::error("Unexpected default arguments to command $command, check {$argv[0]} help\n");
7474
}
7575

7676
foreach($this->args as $arg => $inf) {
7777
if (strlen($arg) && !isset($inf['val']) && isset($inf['required']) && $inf['required']) {
78-
$missing .= "Missing parameter '-$arg' to command $command, check ${argv[0]} help\n";
78+
$missing .= "Missing parameter '-$arg' to command $command, check {$argv[0]} help\n";
7979
}
8080
}
8181

@@ -265,7 +265,7 @@ abstract class CLICommand
265265
$sp3 = $this->cli_get_SP3($l, $ls, $inf);
266266
$l3 = strlen($sp3);
267267
foreach($conf['select'] as $opt => $what) {
268-
$inf .= $this->cli_wordwrap($sp2 . " " . sprintf("%-${ls}s ", $opt) . $what, $l3, $sp3) . "\n";
268+
$inf .= $this->cli_wordwrap($sp2 . " " . sprintf("%-{$ls}s ", $opt) . $what, $l3, $sp3) . "\n";
269269
}
270270
}
271271
}

ext/phar/phar/pharcommand.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1598,7 +1598,7 @@ class PharCommand extends CLICommand
15981598
if (is_bool($v)) {
15991599
$v = $v ? 'enabled' : 'disabled';
16001600
}
1601-
printf("%-${klen}s %s\n", $k.':', $v);
1601+
printf("%-{$klen}s %s\n", $k.':', $v);
16021602
}
16031603
}
16041604
// }}}

ext/session/tests/save_handler.inc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function open($save_path, $session_name) {
2727
global $session_save_path, $name;
2828
$session_save_path = $save_path;
2929
$name = $session_name;
30-
echo "Open [${session_save_path},${session_name}]\n";
30+
echo "Open [{$session_save_path},{$session_name}]\n";
3131

3232
// MUST return bool. Return TRUE for success.
3333
return true;
@@ -39,7 +39,7 @@ function close() {
3939
// NOTE: This function should unlock session data, if write() does not unlock it.
4040

4141
global $session_save_path, $name;
42-
echo "Close [${session_save_path},${name}]\n";
42+
echo "Close [{$session_save_path},{$name}]\n";
4343

4444
// MUST return bool. Return TRUE for success.
4545
return true;
@@ -54,7 +54,7 @@ function read($id) {
5454

5555
global $session_save_path, $name, $session_id;
5656
$session_id = $id;
57-
echo "Read [${session_save_path},${id}]\n";
57+
echo "Read [{$session_save_path},{$id}]\n";
5858
$session_file = "$session_save_path/".SESSION_FILE_PREFIX.$id;
5959
// read MUST create file. Otherwise, strict mode will not work
6060
touch($session_file);
@@ -74,7 +74,7 @@ function write($id, $session_data) {
7474

7575
global $session_save_path, $name, $session_id;
7676
$session_id = $id;
77-
echo "Write [${session_save_path},${id},${session_data}]\n";
77+
echo "Write [{$session_save_path},{$id},{$session_data}]\n";
7878
$session_file = "$session_save_path/".SESSION_FILE_PREFIX.$id;
7979
if ($fp = fopen($session_file, "w")) {
8080
$return = fwrite($fp, $session_data);
@@ -91,7 +91,7 @@ function destroy($id) {
9191
// string $id - Session ID string
9292

9393
global $session_save_path, $name;
94-
echo "Destroy [${session_save_path},${id}]\n";
94+
echo "Destroy [{$session_save_path},{$id}]\n";
9595
$session_file = "$session_save_path/".SESSION_FILE_PREFIX.$id;
9696
unlink($session_file);
9797

@@ -136,7 +136,7 @@ function create_sid() {
136136
// e.g. hash('sha2', random_bytes(64)) or use /dev/urandom
137137

138138
$id = ('PHPT-'.time());
139-
echo "CreateID [${id}]\n";
139+
echo "CreateID [{$id}]\n";
140140

141141
// MUST return session ID string.
142142
// Return FALSE for error.
@@ -148,7 +148,7 @@ function validate_sid($id) {
148148
// string $id - Session ID string
149149

150150
global $session_save_path, $name;
151-
echo "ValidateID [${session_save_path},${id}]\n";
151+
echo "ValidateID [{$session_save_path},{$id}]\n";
152152
$session_file = "$session_save_path/".SESSION_FILE_PREFIX.$id;
153153
$ret = file_exists($session_file);
154154

@@ -168,7 +168,7 @@ function update($id, $session_data) {
168168
// support time stamp updating, you must not define this.
169169

170170
global $session_save_path, $name;
171-
echo "Update [${session_save_path},${id}]\n";
171+
echo "Update [{$session_save_path},{$id}]\n";
172172
$session_file = "$session_save_path/".SESSION_FILE_PREFIX.$id;
173173
$ret = touch($session_file);
174174

ext/soap/tests/bug73037.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Content-Type: application/soap+xml; charset=UTF-8
8888
Accept: application/soap+xml, application/dime, multipart/related, text/*
8989
SOAPAction: "urn:adressen#adressen#SetAda"
9090
Expect: 100-continue
91-
Content-Length: ${len}
91+
Content-Length: {$len}
9292
HDRS;
9393
if ($b) {
9494
$hdrs .="\nContent-Encoding: gzip";

0 commit comments

Comments
 (0)