Skip to content

Commit

Permalink
Fixed exception when plugin runs without options (Like "php_parallel_…
Browse files Browse the repository at this point in the history
…lint: "). Issue #44
  • Loading branch information
corpsee committed Apr 2, 2017
1 parent a3ef15b commit 78c66a4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/PHPCensor/Plugin/Util/Executor.php
Expand Up @@ -193,7 +193,7 @@ public function executePlugin($plugin, $options)

try {
// Build and run it
$obj = $this->pluginFactory->buildPlugin($class, $options);
$obj = $this->pluginFactory->buildPlugin($class, (is_null($options) ? [] : $options));

return $obj->execute();
} catch (\Exception $ex) {
Expand Down
5 changes: 5 additions & 0 deletions src/PHPCensor/Plugin/Util/Factory.php
Expand Up @@ -2,6 +2,7 @@

namespace PHPCensor\Plugin\Util;

use PHPCensor\Plugin;
use Pimple\Container;

/**
Expand Down Expand Up @@ -69,7 +70,9 @@ public function getLastOptions()
*
* @param $className
* @param array|null $options
*
* @throws \InvalidArgumentException if $className doesn't represent a valid plugin
*
* @return \PHPCensor\Plugin
*/
public function buildPlugin($className, $options = [])
Expand All @@ -89,8 +92,10 @@ public function buildPlugin($className, $options = [])
$argsToUse = $this->addArgFromParam($argsToUse, $param);
}
}
/** @var Plugin $plugin */
$plugin = $reflectedPlugin->newInstanceArgs($argsToUse);
} else {
/** @var Plugin $plugin */
$plugin = $reflectedPlugin->newInstance();
}

Expand Down

0 comments on commit 78c66a4

Please sign in to comment.