Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Namespace support #1

Closed
fabpot opened this issue Jun 20, 2011 · 2 comments
Closed

Namespace support #1

fabpot opened this issue Jun 20, 2011 · 2 comments

Comments

@fabpot
Copy link
Contributor

fabpot commented Jun 20, 2011

When the code uses namespaces, the namespace node should be the root node for all the code within the namespace:

namespace Foo {
    echo 'Hello';
}

namespace Bar {
    echo 'Hello';
}

Current output:

0: Stmt_Namespace(
    ns: Name(
        parts: array(
            0: Foo
        )
    )
)
1: array(
    0: Stmt_Echo(
        exprs: array(
            0: Scalar_String(
                value: Hello
                isBinary: false
                type: 0
            )
        )
    )
)
2: Stmt_Namespace(
    ns: Name(
        parts: array(
            0: Bar
        )
    )
)
3: array(
    0: Stmt_Echo(
        exprs: array(
            0: Scalar_String(
                value: Hello
                isBinary: false
                type: 0
            )
        )
    )
)
@nikic
Copy link
Owner

nikic commented Jun 26, 2011

My original reasoning was that normally people use semicolon style namespaces instead of the braced onces and thus it should be put as a seperate statement. But you are probably right that it makes more sense to regard the statements as subnodes of the namespace. I changed the behavior towards that in fb45e8a.

@nikic nikic closed this as completed Jun 26, 2011
@fabpot
Copy link
Contributor Author

fabpot commented Jun 26, 2011

Fantastic, thanks!

TysonAndre pushed a commit to TysonAndre/PHP-Parser that referenced this issue Mar 21, 2017
Saw the below error in php 7.1

```
Fatal error: Uncaught Error: Declaration of PhpParser\ErrorHandler\Throwing::handleError() must be compatible with that of PhpParser\ErrorHandler::handleError() in .../vendor/nikic/php-parser/lib/PhpParser/ErrorHandler/
Throwing.php:13
Stack trace:
\#0 .../vendor/nikic/php-parser/lib/PhpParser/Autoloader.php(36): include()
\nikic#1 ..../vendor/nikic/php-parser/lib/PhpParser/ParserAbstract.php(144): PhpParser\Autoloader::autoload()
...
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants