Renaming canExecute() to canRunZeroConfig() to avoid confusion with isAllowedInStage()

This commit is contained in:
Dan Cryer 2015-11-13 14:45:18 +00:00
parent 29a6c9767a
commit e437e9b855
12 changed files with 30 additions and 11 deletions

View file

@ -168,7 +168,7 @@ class Build extends BuildBase
}
foreach (array('setup', 'test', 'complete', 'success', 'failure') as $stage) {
if ($className::canExecute($stage, $builder, $this)) {
if ($className::canRunZeroConfig($stage, $builder, $this)) {
$config[$stage][$className] = array(
'zero_config' => true
);

View file

@ -9,12 +9,16 @@
namespace PHPCI;
use PHPCI\Builder;
use PHPCI\Model\Build;
/**
* PHPCI Plugin Interface - Used by all build plugins.
* @author Dan Cryer <dan@block8.co.uk>
*/
interface Plugin
{
public static function canRunZeroConfig($stage, Builder $builder, Build $build);
public function isAllowedInStage($stage);
public function execute();
}

View file

@ -2,6 +2,8 @@
namespace PHPCI\Plugin;
use PHPCI\Builder;
use PHPCI\Model\Build;
use PHPCI\Plugin;
/**
@ -12,7 +14,7 @@ abstract class AbstractPlugin implements Plugin
{
/**
* Define the stages that this plugin is allowed to run in.
* @see AbstractPlugin::canExecute()
* @see AbstractPlugin::isAllowedInStage()
* @var array
*/
protected $allowedStages = array('setup', 'test', 'complete', 'success', 'failure', 'fixed', 'broken');
@ -27,6 +29,19 @@ abstract class AbstractPlugin implements Plugin
return in_array($stage, $this->allowedStages);
}
/**
* Check whether or not this plugin can execute in zero config mode.
* Many plugins will check if their required config files can be found here.
* @param string $stage
* @param Builder $builder
* @param Build $build
* @return bool
*/
public static function canRunZeroConfig($stage, Builder $builder, Build $build)
{
return false;
}
/**
* Execute the plugin and return its success or failure.
* @return bool

View file

@ -56,7 +56,7 @@ class Codeception extends AbstractPlugin implements ZeroConfigPlugin
* @param Build $build
* @return bool
*/
public static function canExecute($stage, Builder $builder, Build $build)
public static function canRunZeroConfig($stage, Builder $builder, Build $build)
{
return $stage == 'test' && !is_null(self::findConfigFile($builder->buildPath));
}

View file

@ -37,7 +37,7 @@ class Composer extends AbstractPlugin implements ZeroConfigPlugin
* @param Build $build
* @return bool
*/
public static function canExecute($stage, Builder $builder, Build $build)
public static function canRunZeroConfig($stage, Builder $builder, Build $build)
{
$path = $builder->buildPath . DIRECTORY_SEPARATOR . 'composer.json';

View file

@ -86,7 +86,7 @@ class PhpCodeSniffer extends AbstractPlugin implements ZeroConfigPlugin
* @param Build $build
* @return bool
*/
public static function canExecute($stage, Builder $builder, Build $build)
public static function canRunZeroConfig($stage, Builder $builder, Build $build)
{
if ($stage == 'test') {
return true;

View file

@ -58,7 +58,7 @@ class PhpDocblockChecker extends AbstractPlugin implements ZeroConfigPlugin
* @param Build $build
* @return bool
*/
public static function canExecute($stage, Builder $builder, Build $build)
public static function canRunZeroConfig($stage, Builder $builder, Build $build)
{
if ($stage == 'test') {
return true;

View file

@ -38,7 +38,7 @@ class PhpLoc extends AbstractPlugin implements ZeroConfigPlugin
* @param Build $build
* @return bool
*/
public static function canExecute($stage, Builder $builder, Build $build)
public static function canRunZeroConfig($stage, Builder $builder, Build $build)
{
if ($stage == 'test') {
return true;

View file

@ -68,7 +68,7 @@ class PhpMessDetector extends AbstractPlugin implements ZeroConfigPlugin
* @param Build $build
* @return bool
*/
public static function canExecute($stage, Builder $builder, Build $build)
public static function canRunZeroConfig($stage, Builder $builder, Build $build)
{
if ($stage == 'test') {
return true;

View file

@ -62,7 +62,7 @@ class PhpUnit extends AbstractPlugin implements ZeroConfigPlugin
* @param Build $build
* @return bool
*/
public static function canExecute($stage, Builder $builder, Build $build)
public static function canRunZeroConfig($stage, Builder $builder, Build $build)
{
if ($stage == 'test' && !is_null(self::findConfigFile($builder->buildPath))) {
return true;

View file

@ -73,7 +73,7 @@ class TechnicalDebt extends AbstractPlugin implements ZeroConfigPlugin
* @param Build $build
* @return bool
*/
public static function canExecute($stage, Builder $builder, Build $build)
public static function canRunZeroConfig($stage, Builder $builder, Build $build)
{
if ($stage == 'test') {
return true;

View file

@ -17,5 +17,5 @@ use PHPCI\Model\Build;
*/
interface ZeroConfigPlugin
{
public static function canExecute($stage, Builder $builder, Build $build);
public static function canRunZeroConfig($stage, Builder $builder, Build $build);
}