forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support doc comments on enum cases (php#6984)
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
- Loading branch information
1 parent
87e4970
commit d60bc0e
Showing
5 changed files
with
39 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
23 changes: 23 additions & 0 deletions
23
ext/reflection/tests/ReflectionEnumUnitCase_getDocComment.phpt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--TEST-- | ||
ReflectionEnumUnitCase::getDocComment() | ||
--FILE-- | ||
<?php | ||
// enum cases should support doc comments, like class constants. | ||
|
||
enum Foo { | ||
/** Example doc comment */ | ||
case Bar; | ||
case Baz; | ||
} | ||
|
||
var_dump((new ReflectionEnumUnitCase(Foo::class, 'Bar'))->getDocComment()); | ||
var_dump((new ReflectionEnumUnitCase(Foo::class, 'Baz'))->getDocComment()); | ||
var_dump((new ReflectionClassConstant(Foo::class, 'Bar'))->getDocComment()); | ||
var_dump((new ReflectionClassConstant(Foo::class, 'Baz'))->getDocComment()); | ||
|
||
?> | ||
--EXPECT-- | ||
string(26) "/** Example doc comment */" | ||
bool(false) | ||
string(26) "/** Example doc comment */" | ||
bool(false) |