diff --git a/src/CheckerCommand.php b/src/CheckerCommand.php index 17dce8e..c8a1ee8 100644 --- a/src/CheckerCommand.php +++ b/src/CheckerCommand.php @@ -194,7 +194,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } if ($error['type'] == 'param-mismatch') { - $this->output->write('' . $error['class'] . '::' . $error['method'] . ' - @param '.$error['param'] . ' ('.$error['doc-type'].') does not match method signature ('.$error['param-type'].').'); + $this->output->write('' . $error['class'] . '::' . $error['method'] . ' - @param '.$error['param'] . ' ('.$error['doc-type'].') does not match method signature ('.$error['param-type'].').'); } if ($error['type'] == 'return-missing') { @@ -202,7 +202,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } if ($error['type'] == 'return-mismatch') { - $this->output->write('' . $error['class'] . '::' . $error['method'] . ' - @return '.$error['doc-type'] . ' does not match method signature ('.$error['return-type'].').'); + $this->output->write('' . $error['class'] . '::' . $error['method'] . ' - @return '.$error['doc-type'] . ' does not match method signature ('.$error['return-type'].').'); } $this->output->writeln(''); @@ -323,7 +323,10 @@ protected function processFile($file) ]; } } elseif (!empty($type) && $method['docblock']['params'][$param] !== $type) { - if ($type === 'array' && substr($method['docblock']['params'][$param], -2) === '[]') { + if ( + ($type === 'array' && substr($method['docblock']['params'][$param], -2) === '[]') + || $method['docblock']['params'][$param] === 'mixed' + ) { // Do nothing because this is fine. } else { $warnings = true; @@ -345,6 +348,10 @@ protected function processFile($file) if (!empty($method['return'])) { if (empty($method['docblock']['return'])) { + // https://bugs.php.net/bug.php?id=75263 + if ($method['name'] === '__construct') { + continue; + } $warnings = true; $this->warnings[] = [ 'type' => 'return-missing', @@ -368,7 +375,11 @@ protected function processFile($file) ]; } } elseif ($method['docblock']['return'] !== $method['return']) { - if ($method['return'] === 'array' && substr($method['docblock']['return'], -2) === '[]') { + if ( + ($method['return'] === 'array' && substr($method['docblock']['return'], -2) === '[]') + || $method['docblock']['return'] === 'mixed' + || (strpos($method['docblock']['return'], '|') !== false && PHP_MAJOR_VERSION < 8) + ) { // Do nothing because this is fine. } else { $warnings = true; diff --git a/src/DocBlockParser.php b/src/DocBlockParser.php index cef3600..fbb170c 100644 --- a/src/DocBlockParser.php +++ b/src/DocBlockParser.php @@ -131,11 +131,16 @@ protected function parseComment($comment) } // Default the trailing values $parts = array_pad($parts, $count, null); - // Store as a mapped array - $this->tags[$tag][] = array_combine( + $mapped = array_combine( self::$vectors[$tag], $parts ); + + if (isset($mapped['var']) && substr( $mapped['var'], 0, 3) === '...') { + $mapped['var'] = substr($mapped['var'], 3); + } + // Store as a mapped array + $this->tags[$tag][] = $mapped; } else { // The tagged block is only text