-
Notifications
You must be signed in to change notification settings - Fork 8k
Add DocComments for function parameters #21279
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
Merged
DanielEScherzer
merged 19 commits into
php:master
from
chschneider:parameter-doccomments
Apr 2, 2026
Merged
Changes from 7 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
6d13363
Add DocComments for function parameters
1bab302
Add missing arg_info doc_comment handling for accelerator/persist
a873d33
Remove interning string as it seems to cause problems
86279be
Add tests for methods, closures, // comments and parameters with DocC…
a85e262
Do not add @tentative-return-type for newly introduced methods
a0f0577
Commit generated declaration files
eb3114e
Add test for property hook parameter
30aed7d
Fix comment and vim folding
9616fa9
Change wording from "behind" to "after"
4a848e5
Add test for arrow function, use more descriptive naming
1db2e55
Merge branch 'master' into parameter-doccomments
chschneider f7985cb
Update generated files after merging from master
10dd8b5
Merge branch 'php:master' into parameter-doccomments
chschneider 0b06250
Fix doc comments for properties with property hooks and add tests
b2c92ad
Fix memory leak when doc comments are present before and after the pa…
9c9c0b8
Merge branch 'php:master' into parameter-doccomments
chschneider 8e86c33
Fix handling of hooked properties
TimWolla 3d91300
Tests for indented code
DanielEScherzer a1f0533
Added ReflectionParameter::getDocComment()
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
194 changes: 194 additions & 0 deletions
194
ext/reflection/tests/ReflectionParameter_getDocComment_basic.phpt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,194 @@ | ||
| --TEST-- | ||
|
chschneider marked this conversation as resolved.
|
||
| Test ReflectionParameter::getDocComment() usage. | ||
| --INI-- | ||
|
chschneider marked this conversation as resolved.
|
||
| opcache.save_comments=1 | ||
| --FILE-- | ||
| <?php | ||
|
|
||
| class A | ||
| { | ||
|
chschneider marked this conversation as resolved.
|
||
| function func( | ||
| /** | ||
| * My Doc Comment for $a | ||
| * | ||
| */ | ||
| $a, $b, $c, | ||
| /** | ||
| * My Doc Comment for $d | ||
| */ | ||
| $d, | ||
| // Not a doc comment | ||
| /**Not a doc comment */ | ||
| $e, | ||
| /** | ||
| * Doc comment for $f | ||
| */ | ||
| $f, | ||
| $g /** Doc comment for $g behind parameter */, | ||
|
chschneider marked this conversation as resolved.
Outdated
|
||
| /** Doc comment for $h */ | ||
| $h /** Doc comment for $h behind parameter */, | ||
| ) {} | ||
|
|
||
| public string $property { | ||
| set( | ||
| /** Doc Comment for property hook parameter $value */ | ||
| string $value | ||
| ) { $this->property = $value; } | ||
| } | ||
| } | ||
|
|
||
| function func( | ||
| /** | ||
| * My Doc Comment for $a | ||
| * | ||
| */ | ||
| $a, $b, $c, | ||
| /** | ||
| * My Doc Comment for $d | ||
| */ | ||
| $d, | ||
| // Not a doc comment | ||
| /**Not a doc comment */ | ||
| $e, | ||
| /** | ||
| * Doc comment for $f | ||
| */ | ||
| $f, | ||
| $g /** Doc comment for $g behind parameter */, | ||
| /** Doc comment for $h */ | ||
| $h /** Doc comment for $h behind parameter */, | ||
| ) {} | ||
|
|
||
| $func = function( | ||
|
chschneider marked this conversation as resolved.
Outdated
|
||
| /** | ||
| * My Doc Comment for $a | ||
| * | ||
| */ | ||
| $a, $b, $c, | ||
| /** | ||
| * My Doc Comment for $d | ||
| */ | ||
| $d, | ||
| // Not a doc comment | ||
| /**Not a doc comment */ | ||
| $e, | ||
| /** | ||
| * Doc comment for $f | ||
| */ | ||
| $f, | ||
| $g /** Doc comment for $g behind parameter */, | ||
| /** Doc comment for $h */ | ||
| $h /** Doc comment for $h behind parameter */, | ||
| ) {}; | ||
|
|
||
| foreach([ | ||
| 'A::func' => (new ReflectionClass('A'))->getMethod('func'), | ||
| 'func' => new ReflectionFunction('func'), | ||
| 'closure' => new ReflectionFunction($func), | ||
| 'property hook' => (new ReflectionClass('A'))->getProperty('property')->getHook(PropertyHookType::Set), | ||
| ] as $function => $rc) { | ||
| $rps = $rc->getParameters(); | ||
| foreach($rps as $rp) { | ||
| echo "\n---> Doc comment for $function parameter $" . $rp->getName() . ":\n"; | ||
| var_dump($rp->getDocComment()); | ||
| } | ||
| } | ||
|
|
||
| ?> | ||
| --EXPECTF-- | ||
| ---> Doc comment for A::func parameter $a: | ||
| string(%d) "/** | ||
| * My Doc Comment for $a | ||
| * | ||
| */" | ||
|
|
||
|
chschneider marked this conversation as resolved.
|
||
| ---> Doc comment for A::func parameter $b: | ||
| bool(false) | ||
|
|
||
| ---> Doc comment for A::func parameter $c: | ||
| bool(false) | ||
|
|
||
| ---> Doc comment for A::func parameter $d: | ||
| string(%d) "/** | ||
| * My Doc Comment for $d | ||
| */" | ||
|
|
||
| ---> Doc comment for A::func parameter $e: | ||
| bool(false) | ||
|
|
||
| ---> Doc comment for A::func parameter $f: | ||
| string(%d) "/** | ||
| * Doc comment for $f | ||
| */" | ||
|
|
||
| ---> Doc comment for A::func parameter $g: | ||
| string(%d) "/** Doc comment for $g behind parameter */" | ||
|
|
||
| ---> Doc comment for A::func parameter $h: | ||
| string(%d) "/** Doc comment for $h behind parameter */" | ||
|
|
||
| ---> Doc comment for func parameter $a: | ||
| string(%d) "/** | ||
| * My Doc Comment for $a | ||
| * | ||
| */" | ||
|
|
||
| ---> Doc comment for func parameter $b: | ||
| bool(false) | ||
|
|
||
| ---> Doc comment for func parameter $c: | ||
| bool(false) | ||
|
|
||
| ---> Doc comment for func parameter $d: | ||
| string(%d) "/** | ||
| * My Doc Comment for $d | ||
| */" | ||
|
|
||
| ---> Doc comment for func parameter $e: | ||
| bool(false) | ||
|
|
||
| ---> Doc comment for func parameter $f: | ||
| string(%d) "/** | ||
| * Doc comment for $f | ||
| */" | ||
|
|
||
| ---> Doc comment for func parameter $g: | ||
| string(%d) "/** Doc comment for $g behind parameter */" | ||
|
|
||
| ---> Doc comment for func parameter $h: | ||
| string(%d) "/** Doc comment for $h behind parameter */" | ||
|
|
||
| ---> Doc comment for closure parameter $a: | ||
| string(%d) "/** | ||
| * My Doc Comment for $a | ||
| * | ||
| */" | ||
|
|
||
| ---> Doc comment for closure parameter $b: | ||
| bool(false) | ||
|
|
||
| ---> Doc comment for closure parameter $c: | ||
| bool(false) | ||
|
|
||
| ---> Doc comment for closure parameter $d: | ||
| string(%d) "/** | ||
| * My Doc Comment for $d | ||
| */" | ||
|
|
||
| ---> Doc comment for closure parameter $e: | ||
| bool(false) | ||
|
|
||
| ---> Doc comment for closure parameter $f: | ||
| string(%d) "/** | ||
| * Doc comment for $f | ||
| */" | ||
|
|
||
| ---> Doc comment for closure parameter $g: | ||
| string(%d) "/** Doc comment for $g behind parameter */" | ||
|
|
||
| ---> Doc comment for closure parameter $h: | ||
| string(%d) "/** Doc comment for $h behind parameter */" | ||
|
|
||
| ---> Doc comment for property hook parameter $value: | ||
| string(%d) "/** Doc Comment for property hook parameter $value */" | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.