Skip to content
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

[PSR-5] param tag with optional values #164

Closed
jaapio opened this issue Nov 15, 2022 · 0 comments
Closed

[PSR-5] param tag with optional values #164

jaapio opened this issue Nov 15, 2022 · 0 comments

Comments

@jaapio
Copy link
Contributor

jaapio commented Nov 15, 2022

The param requires a paramname, however, this could be omitted when the param tag is describing just a single argument method or all other params are adequately documented. For example:

/**
 * @param int
 * /
 public function foo($arg): void 
{}
/**
 * @param int $arg
 * @param int Optional description
 * /
 public function foo($arg, $second): void 
{}

I do see this as edge cased, but it makes makes more sense when you align this with other tags for example the @var tag. Which has the same behavior.

class Foo {
    /** @var int */
   public $bar
}
class Foo {
    /** 
     * @var int
     * @var string $foo
     */
   public $bar $foo
}

I'm working on a pr to support this.

jaapio added a commit to jaapio/phpdoc-parser that referenced this issue Nov 15, 2022
Accoring to the PRS-5 standard paramnames are optional. The
parser does not force docblocks to be fully valid, so it's ok to
have multiple param tags without variable name. However this should
never happen in real world docblocks.

Fixes phpstan#164
@jaapio jaapio closed this as completed May 13, 2024
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 a pull request may close this issue.

1 participant