Page MenuHomePhorge

Remove question mark suffix from optional @param types in PHPDoc
Closed, ResolvedPublic

Description

  • I cannot spot any difference in Diviner's rendering between a @param string? $bar Foo and a @param string $bar Foo, apart from printing that type as-is, like string? instead of string (example and source)
  • It's not consistently applied across the codebase
  • It seems to be a custom invention not mentioned on https://github.com/php-fig/fig-standards/blob/master/proposed/phpdoc.md
  • It throws PHPDoc tag @param has invalid value (string? $bar Foo...): Unexpected token "?", expected variable at offset 123 in PHPStan.

The param description should likely just mention "(optional)" as its first string instead.