Skip to content

Add DocComments for function parameters#21279

Open
chschneider wants to merge 17 commits intophp:masterfrom
chschneider:parameter-doccomments
Open

Add DocComments for function parameters#21279
chschneider wants to merge 17 commits intophp:masterfrom
chschneider:parameter-doccomments

Conversation

@chschneider
Copy link
Copy Markdown
Contributor

This PR implements DocComment support for function parameters as proposed in
https://wiki.php.net/rfc/parameter-doccomments

@mvorisek
Copy link
Copy Markdown
Contributor

Even if this harder to read syntax would be used, the return type/value cannot be commented. I personally do not support this feature.

Copy link
Copy Markdown
Member

@DanielEScherzer DanielEScherzer left a comment

Choose a reason for hiding this comment

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

looking better

@TimWolla
Copy link
Copy Markdown
Member

@chschneider Can you give this PR a fresh rebase onto the latest master to ensure the CI is current?

Copy link
Copy Markdown
Member

@TimWolla TimWolla left a comment

Choose a reason for hiding this comment

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

Can you add a test case for:

<?php

class Foo {
    public function __construct(
        /** $foo */
        public string $foo {
            /** setter */
            set(string $value /** $value */) {
                
            }
        }
    ) {}
}

to ensure that all the doc comments are correctly assigned if there's a property hook for constructor property promotion? The /** $foo */ should probably be applied to both the property and the parameter 🤔

@TimWolla
Copy link
Copy Markdown
Member

TimWolla commented Apr 1, 2026

@chschneider I've took the liberty to push one commit into your branch to add additional property hook test cases and simplify the implementation. The behavior is now consistent with properties where the doc comment needs to appear before the hooks (because there is no final delimiter for hooked properties).

Please double-check if you agree with that change.

@TimWolla TimWolla force-pushed the parameter-doccomments branch from 61a6861 to 8e86c33 Compare April 1, 2026 10:58
@chschneider
Copy link
Copy Markdown
Contributor Author

@chschneider I've took the liberty to push one commit into your branch to add additional property hook test cases and simplify the implementation. The behavior is now consistent with properties where the doc comment needs to appear before the hooks (because there is no final delimiter for hooked properties).

I like the simplification, looks good to me, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants