From 3cebeb784e57b349efba9913fbbd448e1c2f500e Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Fri, 20 Apr 2018 07:37:02 +0700 Subject: [PATCH] Fixed PHPDockblockChecker for PHP 7.2. Issue #170. --- src/Plugin/PhpDocblockChecker.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Plugin/PhpDocblockChecker.php b/src/Plugin/PhpDocblockChecker.php index 7a18d735..df1a3aab 100644 --- a/src/Plugin/PhpDocblockChecker.php +++ b/src/Plugin/PhpDocblockChecker.php @@ -133,12 +133,17 @@ class PhpDocblockChecker extends Plugin implements ZeroConfigPluginInterface // Re-enable exec output logging: $this->builder->logExecOutput(true); - $output = json_decode($this->builder->getLastOutput(), true); - $errors = count($output); - $success = true; + $output = json_decode($this->builder->getLastOutput(), true); + $errors = 0; + if ($output && is_array($output)) { + $errors = count($output); + + $this->reportErrors($output); + } $this->build->storeMeta('phpdoccheck-warnings', $errors); - $this->reportErrors($output); + + $success = true; if ($this->allowedWarnings != -1 && $errors > $this->allowedWarnings) { $success = false; @@ -151,7 +156,7 @@ class PhpDocblockChecker extends Plugin implements ZeroConfigPluginInterface * Report all of the errors we've encountered line-by-line. * @param array $output */ - protected function reportErrors($output) + protected function reportErrors(array $output) { foreach ($output as $error) { switch ($error['type']) {