php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81342 New ampersand token parsing depends on new line after it
Submitted: 2021-08-10 05:56 UTC Modified: -
From: werlos at gmail dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 8.1.0beta2 OS: linux
Private report: No CVE-ID: None
 [2021-08-10 05:56 UTC] 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"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-08-10 15:11 UTC] git@php.net
Automatic comment on behalf of nikic
Revision: https://github.com/php/php-src/commit/607be654fde997743ca17e20b57802429528f922
Log: Fixed bug #81342
 [2021-08-10 15:11 UTC] git@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 07:01:28 2024 UTC