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

Fix edge cases checking if namespaces use semicolons when converting to php-ast #10

Open
TysonAndre opened this issue Jul 9, 2017 · 2 comments

Comments

@TysonAndre
Copy link
Owner

PHP-Parser doesn't tell you if a namespace with a block originally used semicolons.

lib/PhpParser/PrettyPrinterAbstract.php

  • If all of the namespaces are not in the global namespace, use semicolons (Most common)
  • If at least one is the global namespace, then convert to block style.
@nikic
Copy link

nikic commented Sep 17, 2017

It probably makes sense to add an attribute for this in PHP-Parser.

@TysonAndre
Copy link
Owner Author

Right now, I'm checking the end line number of the namespace. If the end line number is smaller than any of the immediate descendants' end line numbers, this will assume it's namespace;, not namespace{}.

  • Line comments don't seem to have (end) line numbers

An attribute would definitely help, in case of files with one-liners (namespace Foo; interface InterfaceOnSameLine{})

@TysonAndre TysonAndre changed the title Assume namespaces use semicolons by default when converting to php-ast Fix edge cases checking if namespaces use semicolons when converting to php-ast Sep 18, 2017
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