php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77880 Incorrect tree for scope resolution operator specified before class declaration
Submitted: 2019-04-12 05:58 UTC Modified: 2019-04-21 04:22 UTC
From: sobisht at adobe dot com Assigned:
Status: No Feedback Package: Scripting Engine problem
PHP Version: 7.1.28 OS: Win Mac
Private report: No CVE-ID: None
 [2019-04-12 05:58 UTC] sobisht at adobe dot com
Description:
------------
When we specify a class name with scope resolution operator just before the class description. Then the incorrect syntax tree is parsed by zend parser.

When a word is typed after the scope resolution operator, then zend parses correct syntax tree.

This issue starts occurring from zend parser for php-5.6 onwards.

This issue only occurs in the scenario when scope resolution operator is specified for same class whose declaration has been specified in the next statement.

A digraph generated for the syntax tree has been specified in the expected result and actual result.

As you can see, when scope resolution operator is specified, the label "SMTP" related to class name gets removed. 

Test script:
---------------
<?php

SMTP::

class SMTP
{
    const VERSION = '5.2.22';
}

?>

Expected result:
----------------
digraph dbg_AST {
rankdir=LR
node0 [shape=point, label="<notext>"]
node1 [shape=rect, label="SMTP"]
node0->node1
node2 [shape=octagon, label="SMTP"]
node0->node2
node3 [shape=point, label="<notext>"]
node2->node3
node4 [shape=point, label="<notext>"]
node2->node4
node5 [shape=point, label="<notext>"]
node4->node5
node6 [shape=hexagon, label="VERSION"]
node5->node6
node7 [shape=note, label="5.2.22"]
node6->node7
node8 [shape=rect, label="?>
¶"]
node0->node8
node9 [shape=rect, label="<internal>"]
node0->node9
node10 [shape=rect, label="
¶"]
node9->node10

}

Actual result:
--------------
digraph dbg_AST {
rankdir=LR
node0 [shape=point, label="<notext>"]
node1 [shape=point, label="<notext>"]
node0->node1
node2 [shape=note, label="5.2.22"]
node1->node2
node3 [shape=rect, label="?>
¶"]
node0->node3
node4 [shape=rect, label="<internal>"]
node0->node4
node5 [shape=rect, label="
¶"]
node4->node5

}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-04-12 07:38 UTC] nikic@php.net
-Status: Open +Status: Feedback
 [2019-04-12 07:38 UTC] nikic@php.net
Can you please provide the ASTs either in human readable format or rendered images?

Also, what is this "zend parser" you're talking about? PHP does not come with any tooling to produce ASTs, so you must be using something else to do so.
 [2019-04-21 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 02 12:01:29 2024 UTC