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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: werlos at gmail dot com
New email:
PHP Version: OS:

 

 [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: Wed Apr 24 18:01:28 2024 UTC