Skip to content

PHP 8.2.0beta2 emits false positive deprecation warning before fatal error for "{$g{'h'}}"; #9263

Closed
@TysonAndre

Description

@TysonAndre

Description

The following code:

<?php $x = "{$g{'h'}}";

Resulted in this output:

Deprecated: Using ${expr} (variable variables) in strings is deprecated, use {${expr}} instead in php shell code on line 1

Fatal error: Array and string offset access syntax with curly braces is no longer supported in php shell code on line 1

But I expected this output instead:

Fatal error: Array and string offset access syntax with curly braces is no longer supported in php shell code on line 1

(i.e. there is no use of ${} for string interpolation)

The cause is that the constants used for ast node flags have identical values, causing this ambiguity.

#define ZEND_DIM_ALTERNATIVE_SYNTAX (1 << 1) /* deprecated curly brace usage */
#define ZEND_ENCAPS_VAR_DOLLAR_CURLY_VAR_VAR (1<<1)

PHP Version

PHP 8.2.0beta2

Operating System

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions