Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions src/CheckerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

if ($error['type'] == 'param-mismatch') {
$this->output->write('<info>' . $error['class'] . '::' . $error['method'] . '</info> - @param <fg=blue>'.$error['param'] . '</> ('.$error['doc-type'].') does not match method signature ('.$error['param-type'].').');
$this->output->write('<info>' . $error['class'] . '::' . $error['method'] . '</info> - @param <fg=blue>'.$error['param'] . '</> ('.$error['doc-type'].') does not match method signature ('.$error['param-type'].').');
}

if ($error['type'] == 'return-missing') {
$this->output->write('<info>' . $error['class'] . '::' . $error['method'] . '</info> - @return missing.');
}

if ($error['type'] == 'return-mismatch') {
$this->output->write('<info>' . $error['class'] . '::' . $error['method'] . '</info> - @return <fg=blue>'.$error['doc-type'] . '</> does not match method signature ('.$error['return-type'].').');
$this->output->write('<info>' . $error['class'] . '::' . $error['method'] . '</info> - @return <fg=blue>'.$error['doc-type'] . '</> does not match method signature ('.$error['return-type'].').');
}

$this->output->writeln('');
Expand Down Expand Up @@ -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;
Expand All @@ -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',
Expand All @@ -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;
Expand Down
9 changes: 7 additions & 2 deletions src/DocBlockParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down