Skip to content

Commit 23302c0

Browse files
committed
Remove depreacted curly brace offset syntax
1 parent f4b4631 commit 23302c0

8 files changed

+22
-80
lines changed

Zend/tests/036.phpt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,7 @@ try {
88
} catch (Error $e) {
99
echo $e->getMessage(), "\n";
1010
}
11-
try {
12-
$a{function() { }} = 1;
13-
} catch (Error $e) {
14-
echo $e->getMessage(), "\n";
15-
}
1611

1712
?>
18-
--EXPECTF--
19-
Deprecated: Array and string offset access syntax with curly braces is deprecated in %s on line %d
20-
Illegal offset type
13+
--EXPECT--
2114
Illegal offset type
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
--TEST--
2+
Alternative offset syntax should emit E_COMPILE_ERROR in const expression
3+
--FILE--
4+
<?php
5+
const FOO_COMPILE_ERROR = "BAR"{0};
6+
var_dump(FOO_COMPILE_ERROR);
7+
?>
8+
--EXPECTF--
9+
Fatal error: Array and string offset access syntax with curly braces is no longer supported in %s on line 2
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
--TEST--
2+
Alternative offset syntax should emit E_COMPILE_ERROR outside const expression
3+
--FILE--
4+
<?php
5+
$foo = 'BAR';
6+
var_dump($foo{0});
7+
?>
8+
--EXPECTF--
9+
Fatal error: Array and string offset access syntax with curly braces is no longer supported in %s on line 3

Zend/tests/constant_expressions_coalesce.phpt

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,13 @@ Constant expressions with null coalescing operator ??
55

66
const A = [1 => [[]]];
77

8-
// should produce deprecation notices
9-
const D_1 = null ?? A[1]{'undefined'}['index'] ?? 1;
10-
const D_2 = null ?? A['undefined']{'index'} ?? 2;
11-
const D_3 = null ?? A[1]{0}{2} ?? 3; // 2 deprecation notices
12-
const D_4 = A[1]{0} ?? 4;
13-
148
const T_1 = null ?? A[1]['undefined']['index'] ?? 1;
159
const T_2 = null ?? A['undefined']['index'] ?? 2;
1610
const T_3 = null ?? A[1][0][2] ?? 3;
1711
const T_4 = A[1][0][2] ?? 4;
1812
const T_5 = null ?? __LINE__;
1913
const T_6 = __LINE__ ?? "bar";
2014

21-
var_dump(D_1);
22-
var_dump(D_2);
23-
var_dump(D_3);
24-
var_dump(D_4);
25-
2615
var_dump(T_1);
2716
var_dump(T_2);
2817
var_dump(T_3);
@@ -42,21 +31,6 @@ var_dump((new class { public $var = A[1][0][2] ?? 4; })->var);
4231

4332
?>
4433
--EXPECTF--
45-
46-
Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d
47-
48-
Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d
49-
50-
Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d
51-
52-
Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d
53-
54-
Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d
55-
int(1)
56-
int(2)
57-
int(3)
58-
array(0) {
59-
}
6034
int(1)
6135
int(2)
6236
int(3)

Zend/tests/varSyntax/newVariable.phpt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,13 @@ $weird = [0 => (object) ['foo' => 'Test']];
1515

1616
var_dump(new $className);
1717
var_dump(new $array['className']);
18-
var_dump(new $array{'className'});
1918
var_dump(new $obj->className);
2019
var_dump(new Test::$className);
2120
var_dump(new $test::$className);
2221
var_dump(new $weird[0]->foo::$className);
2322

2423
?>
2524
--EXPECTF--
26-
Deprecated: Array and string offset access syntax with curly braces is deprecated in %s on line %d
27-
object(stdClass)#%d (0) {
28-
}
2925
object(stdClass)#%d (0) {
3026
}
3127
object(stdClass)#%d (0) {

Zend/zend_compile.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2614,9 +2614,8 @@ static inline void zend_emit_assign_znode(zend_ast *var_ast, znode *value_node)
26142614
static zend_op *zend_delayed_compile_dim(znode *result, zend_ast *ast, uint32_t type) /* {{{ */
26152615
{
26162616
if (ast->attr == ZEND_DIM_ALTERNATIVE_SYNTAX) {
2617-
zend_error(E_DEPRECATED, "Array and string offset access syntax with curly braces is deprecated");
2617+
zend_error(E_COMPILE_ERROR, "Array and string offset access syntax with curly braces is no longer supported");
26182618
}
2619-
26202619
zend_ast *var_ast = ast->child[0];
26212620
zend_ast *dim_ast = ast->child[1];
26222621
zend_op *opline;
@@ -9162,7 +9161,7 @@ void zend_eval_const_expr(zend_ast **ast_ptr) /* {{{ */
91629161

91639162
if (ast->attr & ZEND_DIM_ALTERNATIVE_SYNTAX) {
91649163
ast->attr &= ~ZEND_DIM_ALTERNATIVE_SYNTAX; /* remove flag to avoid duplicate warning */
9165-
zend_error(E_DEPRECATED, "Array and string offset access syntax with curly braces is deprecated");
9164+
zend_error(E_COMPILE_ERROR, "Array and string offset access syntax with curly braces is no longer supported");
91669165
}
91679166

91689167
/* Set isset fetch indicator here, opcache disallows runtime altering of the AST */

ext/iconv/tests/eucjp2iso2022jp.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ error_reporting=2039
1111
function hexdump($str) {
1212
$len = strlen($str);
1313
for ($i = 0; $i < $len; ++$i) {
14-
printf("%02x", ord($str{$i}));
14+
printf("%02x", ord($str[$i]));
1515
}
1616
print "\n";
1717
}

tests/strings/offsets_general.phpt

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,8 @@ var_dump(isset($string[0][0]));
1212
var_dump($string["foo"]);
1313
var_dump(isset($string["foo"]["bar"]));
1414

15-
const FOO_DEPRECATED = "BAR"{0};
16-
var_dump(FOO_DEPRECATED);
17-
var_dump([$string{0}]); // 1 notice
18-
var_dump($string{1});
19-
var_dump(isset($string{0}));
20-
var_dump(isset($string{0}{0})); // 2 notices
21-
var_dump($string{"foo"});
22-
var_dump(isset($string{"foo"}{"bar"})); // 2 notices
2315
?>
2416
--EXPECTF--
25-
26-
Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d
27-
28-
Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d
29-
30-
Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d
31-
32-
Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d
33-
34-
Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d
35-
36-
Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d
37-
38-
Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d
39-
40-
Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d
41-
42-
Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d
4317
string(1) "B"
4418
string(1) "f"
4519
string(1) "o"
@@ -49,15 +23,3 @@ bool(true)
4923
Warning: Illegal string offset 'foo' in %s line %d
5024
string(1) "f"
5125
bool(false)
52-
string(1) "B"
53-
array(1) {
54-
[0]=>
55-
string(1) "f"
56-
}
57-
string(1) "o"
58-
bool(true)
59-
bool(true)
60-
61-
Warning: Illegal string offset 'foo' in %s line %d
62-
string(1) "f"
63-
bool(false)

0 commit comments

Comments
 (0)