Bug #81342 [Opn->Csd]: New ampersand token parsing depends on new line after it

From: Date: Tue, 10 Aug 2021 15:11:49 +0000
Subject: Bug #81342 [Opn->Csd]: New ampersand token parsing depends on new line after it
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-235739@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81342&edit=1 ID: 81342 Updated by: git@php.net Reported by: werlos at gmail dot com Summary: New ampersand token parsing depends on new line after it -Status: Open +Status: Closed Type: Bug Package: Scripting Engine problem Operating System: linux PHP Version: 8.1.0beta2 Block user comment: N Private report: N New Comment: Automatic comment on behalf of nikic Revision: https://github.com/php/php-src/commit/607be654fde997743ca17e20b57802429528f922 Log: Fixed bug #81342 Previous Comments: ------------------------------------------------------------------------ [2021-08-10 05:56:45] werlos at gmail dot com Description: ------------ The "&" token is parsed as T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG when space and then variable follows, but it's parsed to T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG when newline and then variable follows. Test script: --------------- <?php $tokens = token_get_all('<?php $x & $x; $x & $baz; '); var_dump($tokens[3][1]); var_dump(token_name($tokens[3][0])); var_dump($tokens[10][1]); var_dump(token_name($tokens[10][0])); Expected result: ---------------- string(1) "&" string(37) "T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG" string(1) "&" string(37) "T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG" Actual result: -------------- string(1) "&" string(37) "T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG" string(1) "&" string(41) "T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG" ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=81342&edit=1

« previous php.bugs (#235739) next »