Homec4science

Improve parsing of namespaces

Authored by Joshua Spence <josh@freelancer.com> on Nov 17 2015, 21:14.

Description

Improve parsing of namespaces

Summary:
Currently PHP namespaces are parsed in two different ways, depending on the syntax used. For example, consider the following example:

<?php

namespace A;

class B {}

namespace A\B\C {
 class D {}
}

namespace {
  class A {}
}

This is currently parsed by XHPAST as follows (see https://secure.phabricator.com/xhpast/view/915/):

{F973991, size=full}

This generally makes it difficult to determine the namespace in which a class is declared (unless the namespace is defined using the namespace { ... } syntax, which is somewhat rare). Instead, always parse namespaces as if they were of the namespace { ... } form.

Test Plan:
Added unit tests. Also inspected the AST after this change:

{F973992, size=full}

Reviewers: jim_reed, #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: JolanYacht, Korvin

Differential Revision: https://secure.phabricator.com/D14498

Details

Committed
Joshua Spence <josh@freelancer.com>Nov 17 2015, 21:14
Pushed
aubortMar 17 2017, 12:03
Parents
rPHUe9ed72483a14: Apply phutil XHPAST linter standard
Branches
Unknown
Tags
Unknown

Event Timeline

Joshua Spence <josh@freelancer.com> committed rPHU7124fef0f0d0: Improve parsing of namespaces (authored by Joshua Spence <josh@freelancer.com>).Nov 17 2015, 21:14