From 08cab04bde1a901c5c873e9d77f7644774cb4088 Mon Sep 17 00:00:00 2001 From: David Sloan Date: Mon, 26 Feb 2018 21:50:20 +0000 Subject: [PATCH 1/2] PHPDocBlockChecker Plugin Detailed Error Logging This PR logs the error from the PHPDocBlockChecker rather than just logging that the doc block is missing. --- src/PHPCensor/Plugin/PhpDocblockChecker.php | 41 ++++++++++++++++++--- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/src/PHPCensor/Plugin/PhpDocblockChecker.php b/src/PHPCensor/Plugin/PhpDocblockChecker.php index a590e5ad..bdf7cad9 100644 --- a/src/PHPCensor/Plugin/PhpDocblockChecker.php +++ b/src/PHPCensor/Plugin/PhpDocblockChecker.php @@ -154,12 +154,43 @@ class PhpDocblockChecker extends Plugin implements ZeroConfigPluginInterface protected function reportErrors($output) { foreach ($output as $error) { - $message = 'Class ' . $error['class'] . ' is missing a docblock.'; - $severity = BuildError::SEVERITY_LOW; + switch ($error['type']) { + case 'class': + $message = 'Class ' . $error['class'] . ' is missing a docblock.'; + $severity = BuildError::SEVERITY_NORMAL; + break; - if ($error['type'] == 'method') { - $message = $error['class'] . '::' . $error['method'] . ' is missing a docblock.'; - $severity = BuildError::SEVERITY_NORMAL; + case 'method': + $message = $error['class'] . '::' . $error['method'] . ' is missing a docblock.'; + $severity = BuildError::SEVERITY_NORMAL; + break; + + case 'param-missing': + $message = $error['class'] . '::' . $error['method'] . ' @param ' . $error['param'] . ' missing.'; + $severity = BuildError::SEVERITY_LOW; + break; + + case 'param-mismatch': + $message = $error['class'] . '::' . $error['method'] . ' @param ' . $error['param'] . + '(' . $error['doc-type'] . ') does not match method signature (' . $error['param-type'] . ')'; + $severity = BuildError::SEVERITY_LOW; + break; + + case 'return-missing': + $message = $error['class'] . '::' . $error['method'] . ' @return missing.'; + $severity = BuildError::SEVERITY_LOW; + break; + + case 'return-mismatch': + $message = $error['class'] . '::' . $error['method'] . ' @return ' . $error['doc-type'] . + ' does not match method signature (' . $error['return-type'] . ')'; + $severity = BuildError::SEVERITY_LOW; + break; + + default: + $message = 'Class ' . $error['class'] . ' invalid/missing a docblock.'; + $severity = BuildError::SEVERITY_LOW; + break; } $this->build->reportError( From 17d9917096edf17511d45c728931dfc78846d68d Mon Sep 17 00:00:00 2001 From: David Sloan Date: Mon, 26 Feb 2018 22:04:58 +0000 Subject: [PATCH 2/2] Ironically fix the docblock. --- src/PHPCensor/Plugin/PhpDocblockChecker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PHPCensor/Plugin/PhpDocblockChecker.php b/src/PHPCensor/Plugin/PhpDocblockChecker.php index bdf7cad9..7a18d735 100644 --- a/src/PHPCensor/Plugin/PhpDocblockChecker.php +++ b/src/PHPCensor/Plugin/PhpDocblockChecker.php @@ -149,7 +149,7 @@ class PhpDocblockChecker extends Plugin implements ZeroConfigPluginInterface /** * Report all of the errors we've encountered line-by-line. - * @param $output + * @param array $output */ protected function reportErrors($output) {