Req #79044 [NEW]: Curly Braces Throw T_LNUMBER Error

From: Date: Sun, 29 Dec 2019 15:52:26 +0000
Subject: Req #79044 [NEW]: Curly Braces Throw T_LNUMBER Error
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224594@lists.php.net to get a copy of this message
From:             thebluewalrus at gmail dot com
Operating system: Mac OSX 10.12.4
PHP version:      7.4.1
Package:          Compile Failure
Bug Type:         Feature/Change Request
Bug description:Curly Braces Throw T_LNUMBER Error

Description:
------------
Using curly braces and a backreference in double quotes in regex
replacement produces a 'T_LNUMBER' error for an invalid variable name.
This behavior is inconsistent with other behavior though, e.g. uncurled
the "variable" doesn't throw parser error.

Test script:
---------------
Correct behavior:

preg_replace('/(a)/', "$1test", 'a');

Incorrect behavior:

preg_replace('/(a)/', "{$1}test", 'a');

Expected result:
----------------
In regex context this behaviors is incorrect because '{$3}' should
produce '{capture group three value}', as it does outside the curly
braces.

Actual result:
--------------
Parse error: syntax error, unexpected '1' (T_LNUMBER), expecting
variable (T_VARIABLE) or '{' or '$'

-- 
Edit bug report at https://bugs.php.net/bug.php?id=79044&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=79044&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=79044&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=79044&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=79044&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=79044&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=79044&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=79044&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=79044&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=79044&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=79044&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79044&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=79044&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=79044&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=79044&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=79044&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=79044&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=79044&r=mysqlcfg


Thread (9 messages)

« previous php.bugs (#224594) next »