Support doc comments on enum cases#6984
Merged
TysonAndre merged 1 commit intophp:masterfrom May 14, 2021
Merged
Conversation
Because php supports doc comments on class constants, I believe it would also make sense to support them on enum cases. I don't have strong opinions about whether attributes should be moved to be the last element or whether the doc comment should go after the attribute, but the ast will likely change again before php 8.1 is stable. So far, all attributes are the last ast child node. I didn't notice that doc comments weren't implemented due to php#6489 being a large change. https://wiki.php.net/rfc/enumerations did not mention whether or not doc comments were meant to be supported
nikic
approved these changes
May 14, 2021
TysonAndre
added a commit
to TysonAndre/php-ast
that referenced
this pull request
May 14, 2021
Requires php/php-src#6984 (php 8.1 has no public alphas yet)
TysonAndre
added a commit
to TysonAndre/php-ast
that referenced
this pull request
May 14, 2021
Requires php/php-src#6984 (php 8.1 has no public alphas yet)
TysonAndre
added a commit
to TysonAndre/php-ast
that referenced
this pull request
May 14, 2021
Requires php/php-src#6984 (php 8.1 has no public alphas yet)
TysonAndre
added a commit
to TysonAndre/php-ast
that referenced
this pull request
May 14, 2021
Requires php/php-src#6984 (php 8.1 has no public alphas yet)
iluuu1994
approved these changes
May 14, 2021
Member
iluuu1994
left a comment
There was a problem hiding this comment.
That was unintentional, thanks!
TysonAndre
added a commit
to nikic/php-ast
that referenced
this pull request
May 14, 2021
#204) * Support parsing php 8.1 enum doc comments Requires php/php-src#6984 (php 8.1 has no public alphas yet) * Combine equivalent case statements in generated code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Because php supports doc comments on class constants, I believe it would also
make sense to support them on enum cases.
I don't have strong opinions about whether attributes should be moved to be the
last element or whether the doc comment should go after the attribute,
but the ast will likely change again before php 8.1 is stable.
So far, all attributes are the last ast child node (by convention).
@nikic - thoughts for position https://github.com/nikic/php-ast or any other low-level integrations with the php ast that may exist, etc?
I didn't notice that doc comments weren't implemented due to
#6489 being a large change.
@iluuu1994 - thoughts on whether this makes sense to add?
https://wiki.php.net/rfc/enumerations
did not mention whether or not doc comments were meant to be supported and I don't remember it in the PR discussion
This implementation is based on what was already implemented for
AST_PROP_ELEMFor example, having the ability to read doc comments would be useful for