Zitat von Tyson Andre <tysonandre...@gmail.com>:

Earlier discussion about including this in PSR-5 is found in https://github.com/phpDocumentor/fig-standards/issues/153 , I'm re-opening the discussion here.   This shorthand isn't part of the PSR-5 draft : https://github.com/phpDocumentor/fig-standards/blob/master/proposed/phpdoc.md#abnf
    
   Reasons:
    
- Nullable types are part of the language syntax for real signatures, so adding this in PHPDoc makes some sense
       - @return ?string is shorter than @return string|null

- Many static analyzers support this syntax in PHPDoc already (Phan/Psalm/PHPStan (and phpdocumentor3 will?)).
    
   Questions that were already brought up:
    
- A canonical way to represent the union type after parsing it in union types - ?int|string, ?(int|string), ?int|?string, int|string|null are equivalent, but which should be preferred for the output of tools
     (not sure if that would need to be part of the standard)
- Operator precedence (e.g. ?string[]) - I suggested treating that as ?(string[]), others suggested forbidding ambiguous cases and forcing phpdoc authors to add brackets - either explicitly write (?string)[] or ?(string[]).

For the sake of unambiguousity I'd prefer the latter, i.e. forcing to use brackets. This would also solve the first question.
-------------------------
Jan Schneider
The Horde Project
https://www.horde.org/

--
You received this message because you are subscribed to the Google Groups "PHP 
Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to php-fig+unsubscr...@googlegroups.com.
To post to this group, send email to php-fig@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/php-fig/20181016072643.Horde.mLp9DEQavbMCoO3TNj3ksFx%40yunosh.horde.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to