phpstan/phpdoc-parser

parse error: `PHPDoc tag @param-out has invalid value`

staabm opened this issue · 1 comments

this phpdoc, taken from psalm stub file

/**
 * @psalm-pure
 * @template TFlags as int-mask<0, 256, 512>
 *
 * @param string $pattern
 * @param string $subject
 * @param mixed $matches
 * @param TFlags $flags
 * @param-out (TFlags is 256 ? array<array-key, array{string, 0|positive-int}|array{'', -1}> :
 *             TFlags is 512 ? array<array-key, string|null> :
 *             TFlags is 768 ? array<array-key, array{string, 0|positive-int}|array{null, -1}> :
 *                             array<array-key, string>
 *            ) $matches
 * @return 1|0|false
 * @psalm-ignore-falsable-return
 */
function preg_match($pattern, $subject, &$matches = [], int $flags = 0, int $offset = 0) {}

does not parse properly

Note: Using configuration file /home/runner/work/phpstan-src/phpstan-src/compiler/phpstan.neon.
 0/4 [░░░░░░░░░░░░░░░░░░░░░░░░░░░░]   0%
 4/4 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

Error: PHPDoc tag @param-out has invalid value ((TFlags is 256 ? array<array-key, array{string, 0|positive-int}|array{'', -1}> :
            TFlags is 512 ? array<array-key, string|null> :
            TFlags is 768 ? array<array-key, array{string, 0|positive-int}|array{null, -1}> :
                            array<array-key, string>
           ) $matches): Unexpected token "is", expected ')' at offset 270
 ------ ----------------------------------------------------------------------- 
  Line   ../stubs/core.stub                                                     
 ------ ----------------------------------------------------------------------- 
  212    PHPDoc tag @param-out has invalid value ((TFlags is 256 ?              
         array<array-key, array{string, 0|positive-int}|array{'', -1}> :        
                     TFlags is 512 ? array<array-key, string|null> :            
                     TFlags is 768 ? array<array-key, array{string,             
         0|positive-int}|array{null, -1}> :                                     
                                     array<array-key, string>                   
                    ) $matches): Unexpected token "is", expected ')' at offset  
         270                                                                    
 ------ ----------------------------------------------------------------------- 


Error:  [ERROR] Found 1 error                                                          

Error: Process completed with exit code 1.

when put into a phpstan stub file.

when adding parenthesis it works

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.