Skip to content

Conversation

@inxilpro
Copy link
Contributor

No description provided.

@msftclas
Copy link

msftclas commented Dec 28, 2019

CLA assistant check
All CLA requirements met.

@roblourens
Copy link
Member

Thanks for the PR! Can you tell me about why you want this change or what you are using this parser for?

@inxilpro
Copy link
Contributor Author

I'm working on a PHP linter that uses this parser, and I need to be able to query the nodes more easily. I originally was decorating the nodes, but decided to try a PR to see how receptive you'd be to this kind of improvement. Sorry about the really sparse PR!

Copy link
Member

@roblourens roblourens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this makes sense, thanks!

@roblourens roblourens merged commit e88ad9b into microsoft:master Jan 2, 2020
}

public function isPublic() : bool {
return $this->hasModifier(TokenKind::PublicKeyword);
Copy link
Contributor

@TysonAndre TysonAndre Jan 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

class X { function test() {}} still has an implicitly public method X::test(), but this returns false - I can see this being misunderstood in applications using this helper, for that edge case.

This is low priority for me, though

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's a good point. Could change isPublic to just check !isPrivate but it might be better to just expose hasModifier, I think the goal is to expose the AST but not necessarily "interpret" it...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be useful to have a link to projects using tolerant-php-parser in the documentation, as examples for people writing their own applications/libraries.

E.g. there's https://github.com/tysonandre/tolerant-php-parser-to-php-ast (part of Phan), https://github.com/felixfbecker/php-language-server , etc.

The first one is notable in trying to convert all of the information provided by various node types.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made that change and just left hasModifier, FYI @inxilpro

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could also see changing these to hasPublicModifier()/etc to be more clear about what question it's answering.

roblourens added a commit that referenced this pull request Jan 2, 2020
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

Successfully merging this pull request may close these issues.

4 participants