Refactored plugins
This commit is contained in:
parent
1a3a0a1993
commit
16a5add859
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,6 +2,5 @@
|
||||||
/composer.phar
|
/composer.phar
|
||||||
/runtime
|
/runtime
|
||||||
/app/loggerconfig.php
|
/app/loggerconfig.php
|
||||||
/app/pluginconfig.php
|
|
||||||
/app/config.yml
|
/app/config.yml
|
||||||
/public/assets/vendor
|
/public/assets/vendor
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
return function (PHPCensor\Plugin\Util\Factory $factory) {
|
|
||||||
$factory->registerResource(
|
|
||||||
// This function will be called when the resource is needed.
|
|
||||||
function() {
|
|
||||||
return [
|
|
||||||
'Foo' => "Stuff",
|
|
||||||
'Bar' => "More Stuff"
|
|
||||||
];
|
|
||||||
},
|
|
||||||
|
|
||||||
// In addition to the function for building the resource the system
|
|
||||||
// also needs to be told when to load the resource. Either or both
|
|
||||||
// of the following arguments can be used (null to ignore)
|
|
||||||
|
|
||||||
// This resource will only be given when the argument name is:
|
|
||||||
"ResourceArray",
|
|
||||||
|
|
||||||
// The resource will only be given when the type hint is:
|
|
||||||
PHPCensor\Plugin\Util\Factory::TYPE_ARRAY
|
|
||||||
);
|
|
||||||
};
|
|
|
@ -110,9 +110,7 @@ class Builder implements LoggerAwareInterface
|
||||||
|
|
||||||
$this->buildLogger = new BuildLogger($logger, $build);
|
$this->buildLogger = new BuildLogger($logger, $build);
|
||||||
|
|
||||||
$pluginFactory = $this->buildPluginFactory($build);
|
$this->pluginExecutor = new Plugin\Util\Executor($this, $build, $this->buildLogger);
|
||||||
$pluginFactory->addConfigFromFile(APP_DIR . "pluginconfig.php");
|
|
||||||
$this->pluginExecutor = new Plugin\Util\Executor($pluginFactory, $this->buildLogger);
|
|
||||||
|
|
||||||
$executorClass = 'PHPCensor\Helper\UnixCommandExecutor';
|
$executorClass = 'PHPCensor\Helper\UnixCommandExecutor';
|
||||||
if (IS_WIN) {
|
if (IS_WIN) {
|
||||||
|
@ -391,52 +389,4 @@ class Builder implements LoggerAwareInterface
|
||||||
{
|
{
|
||||||
$this->buildLogger->logDebug($message);
|
$this->buildLogger->logDebug($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a configured instance of the plugin factory.
|
|
||||||
*
|
|
||||||
* @param Build $build
|
|
||||||
* @return PluginFactory
|
|
||||||
*/
|
|
||||||
private function buildPluginFactory(Build $build)
|
|
||||||
{
|
|
||||||
$pluginFactory = new PluginFactory();
|
|
||||||
|
|
||||||
$self = $this;
|
|
||||||
$pluginFactory->registerResource(
|
|
||||||
function () use ($self) {
|
|
||||||
return $self;
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
'PHPCensor\Builder'
|
|
||||||
);
|
|
||||||
|
|
||||||
$pluginFactory->registerResource(
|
|
||||||
function () use ($build) {
|
|
||||||
return $build;
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
'PHPCensor\Model\Build'
|
|
||||||
);
|
|
||||||
|
|
||||||
$logger = $this->logger;
|
|
||||||
$pluginFactory->registerResource(
|
|
||||||
function () use ($logger) {
|
|
||||||
return $logger;
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
'Psr\Log\LoggerInterface'
|
|
||||||
);
|
|
||||||
|
|
||||||
$pluginFactory->registerResource(
|
|
||||||
function () use ($self) {
|
|
||||||
$factory = new MailerFactory($self->getSystemConfig('php-censor'));
|
|
||||||
return $factory->getSwiftMailerFromConfig();
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
'Swift_Mailer'
|
|
||||||
);
|
|
||||||
|
|
||||||
return $pluginFactory;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,11 +9,46 @@
|
||||||
|
|
||||||
namespace PHPCensor;
|
namespace PHPCensor;
|
||||||
|
|
||||||
|
use PHPCI\Model\Build;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPCI Plugin Interface - Used by all build plugins.
|
* PHPCI Plugin class - Used by all build plugins.
|
||||||
|
*
|
||||||
* @author Dan Cryer <dan@block8.co.uk>
|
* @author Dan Cryer <dan@block8.co.uk>
|
||||||
*/
|
*/
|
||||||
interface Plugin
|
abstract class Plugin
|
||||||
{
|
{
|
||||||
public function execute();
|
/**
|
||||||
|
* @var \PHPCI\Builder
|
||||||
|
*/
|
||||||
|
protected $phpci;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \PHPCI\Model\Build
|
||||||
|
*/
|
||||||
|
protected $build;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $options;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Builder $phpci
|
||||||
|
* @param Build $build
|
||||||
|
* @param array $options
|
||||||
|
*/
|
||||||
|
public function __construct(Builder $phpci, Build $build, array $options = [])
|
||||||
|
{
|
||||||
|
$this->phpci = $phpci;
|
||||||
|
$this->build = $build;
|
||||||
|
$this->options = $options;
|
||||||
|
|
||||||
|
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
abstract public function execute();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,24 +16,22 @@ use PHPCensor\Plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Atoum plugin, runs Atoum tests within a project.
|
* Atoum plugin, runs Atoum tests within a project.
|
||||||
|
*
|
||||||
* @package PHPCensor\Plugin
|
* @package PHPCensor\Plugin
|
||||||
*/
|
*/
|
||||||
class Atoum implements Plugin
|
class Atoum extends Plugin
|
||||||
{
|
{
|
||||||
private $args;
|
protected $executable;
|
||||||
private $config;
|
protected $args;
|
||||||
private $directory;
|
protected $config;
|
||||||
|
protected $directory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set up the plugin, configure options, etc.
|
* {@inheritdoc}
|
||||||
* @param Builder $phpci
|
|
||||||
* @param Build $build
|
|
||||||
* @param array $options
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
public function __construct(Builder $phpci, Build $build, array $options = [])
|
||||||
{
|
{
|
||||||
$this->phpci = $phpci;
|
parent::__construct($phpci, $build, $options);
|
||||||
$this->build = $build;
|
|
||||||
|
|
||||||
if (isset($options['executable'])) {
|
if (isset($options['executable'])) {
|
||||||
$this->executable = $this->phpci->buildPath . DIRECTORY_SEPARATOR.$options['executable'];
|
$this->executable = $this->phpci->buildPath . DIRECTORY_SEPARATOR.$options['executable'];
|
||||||
|
|
|
@ -17,32 +17,23 @@ use PHPCensor\Plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Behat BDD Plugin
|
* Behat BDD Plugin
|
||||||
|
*
|
||||||
* @author Dan Cryer <dan@block8.co.uk>
|
* @author Dan Cryer <dan@block8.co.uk>
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class Behat implements Plugin
|
class Behat extends Plugin
|
||||||
{
|
{
|
||||||
protected $phpci;
|
|
||||||
protected $build;
|
|
||||||
protected $features;
|
protected $features;
|
||||||
|
protected $executable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard Constructor
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* $options['directory'] Output Directory. Default: %BUILDPATH%
|
|
||||||
* $options['filename'] Phar Filename. Default: build.phar
|
|
||||||
* $options['regexp'] Regular Expression Filename Capture. Default: /\.php$/
|
|
||||||
* $options['stub'] Stub Content. No Default Value
|
|
||||||
*
|
|
||||||
* @param Builder $phpci
|
|
||||||
* @param Build $build
|
|
||||||
* @param array $options
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
public function __construct(Builder $phpci, Build $build, array $options = [])
|
||||||
{
|
{
|
||||||
$this->phpci = $phpci;
|
parent::__construct($phpci, $build, $options);
|
||||||
$this->build = $build;
|
|
||||||
$this->features = '';
|
$this->features = '';
|
||||||
|
|
||||||
if (isset($options['executable'])) {
|
if (isset($options['executable'])) {
|
||||||
|
@ -54,8 +45,6 @@ class Behat implements Plugin
|
||||||
if (!empty($options['features'])) {
|
if (!empty($options['features'])) {
|
||||||
$this->features = $options['features'];
|
$this->features = $options['features'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,7 +52,7 @@ class Behat implements Plugin
|
||||||
*/
|
*/
|
||||||
public function execute()
|
public function execute()
|
||||||
{
|
{
|
||||||
$curdir = getcwd();
|
$current_dir = getcwd();
|
||||||
chdir($this->phpci->buildPath);
|
chdir($this->phpci->buildPath);
|
||||||
|
|
||||||
$behat = $this->executable;
|
$behat = $this->executable;
|
||||||
|
@ -75,7 +64,7 @@ class Behat implements Plugin
|
||||||
}
|
}
|
||||||
|
|
||||||
$success = $this->phpci->executeCommand($behat . ' %s', $this->features);
|
$success = $this->phpci->executeCommand($behat . ' %s', $this->features);
|
||||||
chdir($curdir);
|
chdir($current_dir);
|
||||||
|
|
||||||
list($errorCount, $data) = $this->parseBehatOutput();
|
list($errorCount, $data) = $this->parseBehatOutput();
|
||||||
|
|
||||||
|
|
|
@ -21,31 +21,28 @@ use PHPCensor\Plugin;
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class Campfire implements Plugin
|
class Campfire extends Plugin
|
||||||
{
|
{
|
||||||
private $url;
|
protected $url;
|
||||||
private $authToken;
|
protected $authToken;
|
||||||
private $userAgent;
|
protected $userAgent;
|
||||||
private $cookie;
|
protected $cookie;
|
||||||
private $verbose;
|
protected $verbose;
|
||||||
private $roomId;
|
protected $roomId;
|
||||||
|
protected $message;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set up the plugin, configure options, etc.
|
* {@inheritdoc}
|
||||||
* @param Builder $phpci
|
|
||||||
* @param Build $build
|
|
||||||
* @param array $options
|
|
||||||
* @throws \Exception
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
public function __construct(Builder $phpci, Build $build, array $options = [])
|
||||||
{
|
{
|
||||||
$this->phpci = $phpci;
|
parent::__construct($phpci, $build, $options);
|
||||||
$this->build = $build;
|
|
||||||
$this->message = $options['message'];
|
$this->message = $options['message'];
|
||||||
$this->userAgent = "PHP Censor/1.0";
|
$this->userAgent = "PHP Censor/1.0";
|
||||||
$this->cookie = "php-censor-cookie";
|
$this->cookie = "php-censor-cookie";
|
||||||
|
|
||||||
$buildSettings = $phpci->getConfig('build_settings');
|
$buildSettings = $this->phpci->getConfig('build_settings');
|
||||||
|
|
||||||
if (isset($buildSettings['campfire'])) {
|
if (isset($buildSettings['campfire'])) {
|
||||||
$campfire = $buildSettings['campfire'];
|
$campfire = $buildSettings['campfire'];
|
||||||
|
|
|
@ -20,31 +20,18 @@ use PHPCensor\Plugin;
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class CleanBuild implements Plugin
|
class CleanBuild extends Plugin
|
||||||
{
|
{
|
||||||
protected $remove;
|
protected $remove;
|
||||||
protected $phpci;
|
|
||||||
protected $build;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard Constructor
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* $options['directory'] Output Directory. Default: %BUILDPATH%
|
|
||||||
* $options['filename'] Phar Filename. Default: build.phar
|
|
||||||
* $options['regexp'] Regular Expression Filename Capture. Default: /\.php$/
|
|
||||||
* $options['stub'] Stub Content. No Default Value
|
|
||||||
*
|
|
||||||
* @param Builder $phpci
|
|
||||||
* @param Build $build
|
|
||||||
* @param array $options
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
public function __construct(Builder $phpci, Build $build, array $options = [])
|
||||||
{
|
{
|
||||||
$this->phpci = $phpci;
|
parent::__construct($phpci, $build, $options);
|
||||||
$this->build = $build;
|
|
||||||
$this->remove = isset($options['remove']) && is_array($options['remove']) ? $options['remove'] : [];
|
|
||||||
|
|
||||||
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
|
$this->remove = isset($options['remove']) && is_array($options['remove']) ? $options['remove'] : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -25,17 +25,11 @@ use PHPCensor\ZeroConfigPlugin;
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class Codeception implements Plugin, ZeroConfigPlugin
|
class Codeception extends Plugin implements ZeroConfigPlugin
|
||||||
{
|
{
|
||||||
/** @var string */
|
/** @var string */
|
||||||
protected $args = '';
|
protected $args = '';
|
||||||
|
|
||||||
/** @var Builder */
|
|
||||||
protected $phpci;
|
|
||||||
|
|
||||||
/** @var Build */
|
|
||||||
protected $build;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string $ymlConfigFile The path of a yml config for Codeception
|
* @var string $ymlConfigFile The path of a yml config for Codeception
|
||||||
*/
|
*/
|
||||||
|
@ -46,6 +40,28 @@ class Codeception implements Plugin, ZeroConfigPlugin
|
||||||
*/
|
*/
|
||||||
protected $path;
|
protected $path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function __construct(Builder $phpci, Build $build, array $options = [])
|
||||||
|
{
|
||||||
|
parent::__construct($phpci, $build, $options);
|
||||||
|
|
||||||
|
$this->path = 'tests' . DIRECTORY_SEPARATOR . '_output' . DIRECTORY_SEPARATOR;
|
||||||
|
|
||||||
|
if (empty($options['config'])) {
|
||||||
|
$this->ymlConfigFile = self::findConfigFile($this->phpci->buildPath);
|
||||||
|
} else {
|
||||||
|
$this->ymlConfigFile = $options['config'];
|
||||||
|
}
|
||||||
|
if (isset($options['args'])) {
|
||||||
|
$this->args = (string) $options['args'];
|
||||||
|
}
|
||||||
|
if (isset($options['path'])) {
|
||||||
|
$this->path = $options['path'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $stage
|
* @param $stage
|
||||||
* @param Builder $builder
|
* @param Builder $builder
|
||||||
|
@ -75,33 +91,6 @@ class Codeception implements Plugin, ZeroConfigPlugin
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set up the plugin, configure options, etc.
|
|
||||||
* @param Builder $phpci
|
|
||||||
* @param Build $build
|
|
||||||
* @param array $options
|
|
||||||
*/
|
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
|
||||||
{
|
|
||||||
$this->phpci = $phpci;
|
|
||||||
$this->build = $build;
|
|
||||||
$this->path = 'tests' . DIRECTORY_SEPARATOR . '_output' . DIRECTORY_SEPARATOR;
|
|
||||||
|
|
||||||
if (empty($options['config'])) {
|
|
||||||
$this->ymlConfigFile = self::findConfigFile($this->phpci->buildPath);
|
|
||||||
} else {
|
|
||||||
$this->ymlConfigFile = $options['config'];
|
|
||||||
}
|
|
||||||
if (isset($options['args'])) {
|
|
||||||
$this->args = (string) $options['args'];
|
|
||||||
}
|
|
||||||
if (isset($options['path'])) {
|
|
||||||
$this->path = $options['path'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs Codeception tests
|
* Runs Codeception tests
|
||||||
*/
|
*/
|
||||||
|
@ -125,18 +114,18 @@ class Codeception implements Plugin, ZeroConfigPlugin
|
||||||
{
|
{
|
||||||
$this->phpci->logExecOutput(false);
|
$this->phpci->logExecOutput(false);
|
||||||
|
|
||||||
$codecept = $this->phpci->findBinary('codecept');
|
$codeception = $this->phpci->findBinary('codecept');
|
||||||
|
|
||||||
if (!$codecept) {
|
if (!$codeception) {
|
||||||
$this->phpci->logFailure(Lang::get('could_not_find', 'codecept'));
|
$this->phpci->logFailure(Lang::get('could_not_find', 'codecept'));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$cmd = 'cd "%s" && ' . $codecept . ' run -c "%s" --xml ' . $this->args;
|
$cmd = 'cd "%s" && ' . $codeception . ' run -c "%s" --xml ' . $this->args;
|
||||||
|
|
||||||
if (IS_WIN) {
|
if (IS_WIN) {
|
||||||
$cmd = 'cd /d "%s" && ' . $codecept . ' run -c "%s" --xml ' . $this->args;
|
$cmd = 'cd /d "%s" && ' . $codeception . ' run -c "%s" --xml ' . $this->args;
|
||||||
}
|
}
|
||||||
|
|
||||||
$configPath = $this->phpci->buildPath . $configPath;
|
$configPath = $this->phpci->buildPath . $configPath;
|
||||||
|
|
|
@ -12,6 +12,8 @@ namespace PHPCensor\Plugin;
|
||||||
use PHPCensor;
|
use PHPCensor;
|
||||||
use PHPCensor\Builder;
|
use PHPCensor\Builder;
|
||||||
use PHPCensor\Model\Build;
|
use PHPCensor\Model\Build;
|
||||||
|
use PHPCensor\Plugin;
|
||||||
|
use PHPCensor\ZeroConfigPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Composer Plugin - Provides access to Composer functionality.
|
* Composer Plugin - Provides access to Composer functionality.
|
||||||
|
@ -19,46 +21,23 @@ use PHPCensor\Model\Build;
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class Composer implements PHPCensor\Plugin, PHPCensor\ZeroConfigPlugin
|
class Composer extends Plugin implements ZeroConfigPlugin
|
||||||
{
|
{
|
||||||
protected $directory;
|
protected $directory;
|
||||||
protected $action;
|
protected $action;
|
||||||
protected $preferDist;
|
protected $preferDist;
|
||||||
protected $phpci;
|
|
||||||
protected $build;
|
|
||||||
protected $nodev;
|
protected $nodev;
|
||||||
protected $ignorePlatformReqs;
|
protected $ignorePlatformReqs;
|
||||||
protected $preferSource;
|
protected $preferSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if this plugin can be executed.
|
* {@inheritdoc}
|
||||||
* @param $stage
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param Build $build
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function canExecute($stage, Builder $builder, Build $build)
|
|
||||||
{
|
|
||||||
$path = $builder->buildPath . DIRECTORY_SEPARATOR . 'composer.json';
|
|
||||||
|
|
||||||
if (file_exists($path) && $stage == 'setup') {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set up the plugin, configure options, etc.
|
|
||||||
* @param Builder $phpci
|
|
||||||
* @param Build $build
|
|
||||||
* @param array $options
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
public function __construct(Builder $phpci, Build $build, array $options = [])
|
||||||
{
|
{
|
||||||
$path = $phpci->buildPath;
|
parent::__construct($phpci, $build, $options);
|
||||||
$this->phpci = $phpci;
|
|
||||||
$this->build = $build;
|
$path = $this->phpci->buildPath;
|
||||||
$this->directory = $path;
|
$this->directory = $path;
|
||||||
$this->action = 'install';
|
$this->action = 'install';
|
||||||
$this->preferDist = false;
|
$this->preferDist = false;
|
||||||
|
@ -90,8 +69,24 @@ class Composer implements PHPCensor\Plugin, PHPCensor\ZeroConfigPlugin
|
||||||
if (array_key_exists('ignore_platform_reqs', $options)) {
|
if (array_key_exists('ignore_platform_reqs', $options)) {
|
||||||
$this->ignorePlatformReqs = (bool)$options['ignore_platform_reqs'];
|
$this->ignorePlatformReqs = (bool)$options['ignore_platform_reqs'];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
|
/**
|
||||||
|
* Check if this plugin can be executed.
|
||||||
|
* @param $stage
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param Build $build
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function canExecute($stage, Builder $builder, Build $build)
|
||||||
|
{
|
||||||
|
$path = $builder->buildPath . DIRECTORY_SEPARATOR . 'composer.json';
|
||||||
|
|
||||||
|
if (file_exists($path) && $stage == 'setup') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -20,30 +20,23 @@ use PHPCensor\Plugin;
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class CopyBuild implements Plugin
|
class CopyBuild extends Plugin
|
||||||
{
|
{
|
||||||
protected $directory;
|
protected $directory;
|
||||||
protected $ignore;
|
protected $ignore;
|
||||||
protected $wipe;
|
protected $wipe;
|
||||||
protected $phpci;
|
|
||||||
protected $build;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set up the plugin, configure options, etc.
|
* {@inheritdoc}
|
||||||
* @param Builder $phpci
|
|
||||||
* @param Build $build
|
|
||||||
* @param array $options
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
public function __construct(Builder $phpci, Build $build, array $options = [])
|
||||||
{
|
{
|
||||||
$path = $phpci->buildPath;
|
parent::__construct($phpci, $build, $options);
|
||||||
$this->phpci = $phpci;
|
|
||||||
$this->build = $build;
|
$path = $this->phpci->buildPath;
|
||||||
$this->directory = isset($options['directory']) ? $options['directory'] : $path;
|
$this->directory = isset($options['directory']) ? $options['directory'] : $path;
|
||||||
$this->wipe = isset($options['wipe']) ? (bool)$options['wipe'] : false;
|
$this->wipe = isset($options['wipe']) ? (bool)$options['wipe'] : false;
|
||||||
$this->ignore = isset($options['respect_ignore']) ? (bool)$options['respect_ignore'] : false;
|
$this->ignore = isset($options['respect_ignore']) ? (bool)$options['respect_ignore'] : false;
|
||||||
|
|
||||||
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -20,24 +20,20 @@ use PHPCensor\Plugin;
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class Deployer implements Plugin
|
class Deployer extends Plugin
|
||||||
{
|
{
|
||||||
protected $webhookUrl;
|
protected $webhookUrl;
|
||||||
protected $reason;
|
protected $reason;
|
||||||
protected $updateOnly;
|
protected $updateOnly;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set up the plugin, configure options, etc.
|
* {@inheritdoc}
|
||||||
* @param Builder $phpci
|
|
||||||
* @param Build $build
|
|
||||||
* @param array $options
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
public function __construct(Builder $phpci, Build $build, array $options = [])
|
||||||
{
|
{
|
||||||
$this->phpci = $phpci;
|
parent::__construct($phpci, $build, $options);
|
||||||
$this->build = $build;
|
|
||||||
$this->reason = 'PHP Censor Build #%BUILD% - %COMMIT_MESSAGE%';
|
|
||||||
|
|
||||||
|
$this->reason = 'PHP Censor Build #%BUILD% - %COMMIT_MESSAGE%';
|
||||||
if (isset($options['webhook_url'])) {
|
if (isset($options['webhook_url'])) {
|
||||||
$this->webhookUrl = $options['webhook_url'];
|
$this->webhookUrl = $options['webhook_url'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,38 +26,8 @@ use PHPCensor\Plugin;
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class Email implements Plugin
|
class Email extends Plugin
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var \PHPCensor\Builder
|
|
||||||
*/
|
|
||||||
protected $phpci;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \PHPCensor\Model\Build
|
|
||||||
*/
|
|
||||||
protected $build;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $options;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set up the plugin, configure options, etc.
|
|
||||||
* @param Builder $phpci
|
|
||||||
* @param Build $build
|
|
||||||
* @param array $options
|
|
||||||
*/
|
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
|
||||||
{
|
|
||||||
$this->phpci = $phpci;
|
|
||||||
$this->build = $build;
|
|
||||||
$this->options = $options;
|
|
||||||
|
|
||||||
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a notification mail.
|
* Send a notification mail.
|
||||||
*
|
*
|
||||||
|
|
|
@ -20,34 +20,17 @@ use PHPCensor\Plugin;
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class Env implements Plugin
|
class Env extends Plugin
|
||||||
{
|
{
|
||||||
protected $phpci;
|
|
||||||
protected $build;
|
|
||||||
protected $env_vars;
|
protected $env_vars;
|
||||||
|
|
||||||
/**
|
|
||||||
* Set up the plugin, configure options, etc.
|
|
||||||
* @param Builder $phpci
|
|
||||||
* @param Build $build
|
|
||||||
* @param array $options
|
|
||||||
*/
|
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
|
||||||
{
|
|
||||||
$this->phpci = $phpci;
|
|
||||||
$this->build = $build;
|
|
||||||
$this->env_vars = $options;
|
|
||||||
|
|
||||||
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the specified environment variables to the builder environment
|
* Adds the specified environment variables to the builder environment
|
||||||
*/
|
*/
|
||||||
public function execute()
|
public function execute()
|
||||||
{
|
{
|
||||||
$success = true;
|
$success = true;
|
||||||
foreach ($this->env_vars as $key => $value) {
|
foreach ($this->options as $key => $value) {
|
||||||
if (is_numeric($key)) {
|
if (is_numeric($key)) {
|
||||||
// This allows the developer to specify env vars like " - FOO=bar" or " - FOO: bar"
|
// This allows the developer to specify env vars like " - FOO=bar" or " - FOO: bar"
|
||||||
$env_var = is_array($value)? key($value).'='.current($value): $value;
|
$env_var = is_array($value)? key($value).'='.current($value): $value;
|
||||||
|
|
|
@ -20,24 +20,22 @@ use PHPCensor\Plugin;
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class FlowdockNotify implements Plugin
|
class FlowdockNotify extends Plugin
|
||||||
{
|
{
|
||||||
private $api_key;
|
protected $api_key;
|
||||||
private $email;
|
protected $email;
|
||||||
|
protected $message;
|
||||||
|
|
||||||
const MESSAGE_DEFAULT = 'Build %BUILD% has finished for commit <a href="%COMMIT_URI%">%SHORT_COMMIT%</a>
|
const MESSAGE_DEFAULT = 'Build %BUILD% has finished for commit <a href="%COMMIT_URI%">%SHORT_COMMIT%</a>
|
||||||
(%COMMIT_EMAIL%)> on branch <a href="%BRANCH_URI%">%BRANCH%</a>';
|
(%COMMIT_EMAIL%)> on branch <a href="%BRANCH_URI%">%BRANCH%</a>';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set up the plugin, configure options, etc.
|
* {@inheritdoc}
|
||||||
* @param Builder $phpci
|
|
||||||
* @param Build $build
|
|
||||||
* @param array $options
|
|
||||||
* @throws \Exception
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
public function __construct(Builder $phpci, Build $build, array $options = [])
|
||||||
{
|
{
|
||||||
$this->phpci = $phpci;
|
parent::__construct($phpci, $build, $options);
|
||||||
$this->build = $build;
|
|
||||||
if (!is_array($options) || !isset($options['api_key'])) {
|
if (!is_array($options) || !isset($options['api_key'])) {
|
||||||
throw new \Exception('Please define the api_key for Flowdock Notify plugin!');
|
throw new \Exception('Please define the api_key for Flowdock Notify plugin!');
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,27 +20,10 @@ use PHPCensor\Plugin;
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class Git implements Plugin
|
class Git extends Plugin
|
||||||
{
|
{
|
||||||
protected $phpci;
|
|
||||||
protected $build;
|
|
||||||
protected $actions = [];
|
protected $actions = [];
|
||||||
|
|
||||||
/**
|
|
||||||
* Set up the plugin, configure options, etc.
|
|
||||||
* @param Builder $phpci
|
|
||||||
* @param Build $build
|
|
||||||
* @param array $options
|
|
||||||
*/
|
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
|
||||||
{
|
|
||||||
$this->phpci = $phpci;
|
|
||||||
$this->build = $build;
|
|
||||||
$this->actions = $options;
|
|
||||||
|
|
||||||
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run the Git plugin.
|
* Run the Git plugin.
|
||||||
* @return bool
|
* @return bool
|
||||||
|
|
|
@ -19,33 +19,22 @@ use PHPCensor\Plugin;
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class Grunt implements Plugin
|
class Grunt extends Plugin
|
||||||
{
|
{
|
||||||
protected $directory;
|
protected $directory;
|
||||||
protected $task;
|
protected $task;
|
||||||
protected $preferDist;
|
protected $preferDist;
|
||||||
protected $phpci;
|
|
||||||
protected $build;
|
|
||||||
protected $grunt;
|
protected $grunt;
|
||||||
protected $gruntfile;
|
protected $gruntfile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard Constructor
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* $options['directory'] Output Directory. Default: %BUILDPATH%
|
|
||||||
* $options['filename'] Phar Filename. Default: build.phar
|
|
||||||
* $options['regexp'] Regular Expression Filename Capture. Default: /\.php$/
|
|
||||||
* $options['stub'] Stub Content. No Default Value
|
|
||||||
*
|
|
||||||
* @param Builder $phpci
|
|
||||||
* @param Build $build
|
|
||||||
* @param array $options
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
public function __construct(Builder $phpci, Build $build, array $options = [])
|
||||||
{
|
{
|
||||||
$path = $phpci->buildPath;
|
parent::__construct($phpci, $build, $options);
|
||||||
$this->build = $build;
|
|
||||||
$this->phpci = $phpci;
|
$path = $this->phpci->buildPath;
|
||||||
$this->directory = $path;
|
$this->directory = $path;
|
||||||
$this->task = null;
|
$this->task = null;
|
||||||
$this->grunt = $this->phpci->findBinary('grunt');
|
$this->grunt = $this->phpci->findBinary('grunt');
|
||||||
|
@ -67,8 +56,6 @@ class Grunt implements Plugin
|
||||||
if (isset($options['gruntfile'])) {
|
if (isset($options['gruntfile'])) {
|
||||||
$this->gruntfile = $options['gruntfile'];
|
$this->gruntfile = $options['gruntfile'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -19,33 +19,22 @@ use PHPCensor\Plugin;
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class Gulp implements Plugin
|
class Gulp extends Plugin
|
||||||
{
|
{
|
||||||
protected $directory;
|
protected $directory;
|
||||||
protected $task;
|
protected $task;
|
||||||
protected $preferDist;
|
protected $preferDist;
|
||||||
protected $phpci;
|
|
||||||
protected $build;
|
|
||||||
protected $gulp;
|
protected $gulp;
|
||||||
protected $gulpfile;
|
protected $gulpfile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard Constructor
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* $options['directory'] Output Directory. Default: %BUILDPATH%
|
|
||||||
* $options['filename'] Phar Filename. Default: build.phar
|
|
||||||
* $options['regexp'] Regular Expression Filename Capture. Default: /\.php$/
|
|
||||||
* $options['stub'] Stub Content. No Default Value
|
|
||||||
*
|
|
||||||
* @param Builder $phpci
|
|
||||||
* @param Build $build
|
|
||||||
* @param array $options
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
public function __construct(Builder $phpci, Build $build, array $options = [])
|
||||||
{
|
{
|
||||||
$path = $phpci->buildPath;
|
parent::__construct($phpci, $build, $options);
|
||||||
$this->build = $build;
|
|
||||||
$this->phpci = $phpci;
|
$path = $this->phpci->buildPath;
|
||||||
$this->directory = $path;
|
$this->directory = $path;
|
||||||
$this->task = null;
|
$this->task = null;
|
||||||
$this->gulp = $this->phpci->findBinary('gulp');
|
$this->gulp = $this->phpci->findBinary('gulp');
|
||||||
|
@ -67,8 +56,6 @@ class Gulp implements Plugin
|
||||||
if (isset($options['gulpfile'])) {
|
if (isset($options['gulpfile'])) {
|
||||||
$this->gulpfile = $options['gulpfile'];
|
$this->gulpfile = $options['gulpfile'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -21,23 +21,22 @@ use HipChat\HipChat;
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class HipchatNotify implements Plugin
|
class HipchatNotify extends Plugin
|
||||||
{
|
{
|
||||||
protected $authToken;
|
protected $authToken;
|
||||||
protected $color;
|
protected $color;
|
||||||
protected $notify;
|
protected $notify;
|
||||||
|
protected $userAgent;
|
||||||
|
protected $cookie;
|
||||||
|
protected $message;
|
||||||
|
protected $room;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set up the plugin, configure options, etc.
|
* {@inheritdoc}
|
||||||
* @param Builder $phpci
|
|
||||||
* @param Build $build
|
|
||||||
* @param array $options
|
|
||||||
* @throws \Exception
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
public function __construct(Builder $phpci, Build $build, array $options = [])
|
||||||
{
|
{
|
||||||
$this->phpci = $phpci;
|
parent::__construct($phpci, $build, $options);
|
||||||
$this->build = $build;
|
|
||||||
|
|
||||||
$this->userAgent = "PHP Censor/1.0";
|
$this->userAgent = "PHP Censor/1.0";
|
||||||
$this->cookie = "php-censor-cookie";
|
$this->cookie = "php-censor-cookie";
|
||||||
|
|
|
@ -20,10 +20,8 @@ use PHPCensor\Plugin;
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class Irc implements Plugin
|
class Irc extends Plugin
|
||||||
{
|
{
|
||||||
protected $phpci;
|
|
||||||
protected $build;
|
|
||||||
protected $message;
|
protected $message;
|
||||||
protected $server;
|
protected $server;
|
||||||
protected $port;
|
protected $port;
|
||||||
|
@ -31,25 +29,14 @@ class Irc implements Plugin
|
||||||
protected $nick;
|
protected $nick;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard Constructor
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* $options['directory'] Output Directory. Default: %BUILDPATH%
|
|
||||||
* $options['filename'] Phar Filename. Default: build.phar
|
|
||||||
* $options['regexp'] Regular Expression Filename Capture. Default: /\.php$/
|
|
||||||
* $options['stub'] Stub Content. No Default Value
|
|
||||||
*
|
|
||||||
* @param Builder $phpci
|
|
||||||
* @param Build $build
|
|
||||||
* @param array $options
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
public function __construct(Builder $phpci, Build $build, array $options = [])
|
||||||
{
|
{
|
||||||
$this->phpci = $phpci;
|
parent::__construct($phpci, $build, $options);
|
||||||
$this->build = $build;
|
|
||||||
$this->message = $options['message'];
|
$this->message = $options['message'];
|
||||||
|
$buildSettings = $this->phpci->getConfig('build_settings');
|
||||||
$buildSettings = $phpci->getConfig('build_settings');
|
|
||||||
|
|
||||||
|
|
||||||
if (isset($buildSettings['irc'])) {
|
if (isset($buildSettings['irc'])) {
|
||||||
$irc = $buildSettings['irc'];
|
$irc = $buildSettings['irc'];
|
||||||
|
@ -59,8 +46,6 @@ class Irc implements Plugin
|
||||||
$this->room = $irc['room'];
|
$this->room = $irc['room'];
|
||||||
$this->nick = $irc['nick'];
|
$this->nick = $irc['nick'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -12,6 +12,7 @@ namespace PHPCensor\Plugin;
|
||||||
use PHPCensor;
|
use PHPCensor;
|
||||||
use PHPCensor\Builder;
|
use PHPCensor\Builder;
|
||||||
use PHPCensor\Model\Build;
|
use PHPCensor\Model\Build;
|
||||||
|
use PHPCensor\Plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHP Lint Plugin - Provides access to PHP lint functionality.
|
* PHP Lint Plugin - Provides access to PHP lint functionality.
|
||||||
|
@ -19,32 +20,21 @@ use PHPCensor\Model\Build;
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class Lint implements PHPCensor\Plugin
|
class Lint extends Plugin
|
||||||
{
|
{
|
||||||
protected $directories;
|
protected $directories;
|
||||||
protected $recursive = true;
|
protected $recursive = true;
|
||||||
protected $ignore;
|
protected $ignore;
|
||||||
protected $phpci;
|
|
||||||
protected $build;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard Constructor
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* $options['directory'] Output Directory. Default: %BUILDPATH%
|
|
||||||
* $options['filename'] Phar Filename. Default: build.phar
|
|
||||||
* $options['regexp'] Regular Expression Filename Capture. Default: /\.php$/
|
|
||||||
* $options['stub'] Stub Content. No Default Value
|
|
||||||
*
|
|
||||||
* @param Builder $phpci
|
|
||||||
* @param Build $build
|
|
||||||
* @param array $options
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
public function __construct(Builder $phpci, Build $build, array $options = [])
|
||||||
{
|
{
|
||||||
$this->phpci = $phpci;
|
parent::__construct($phpci, $build, $options);
|
||||||
$this->build = $build;
|
|
||||||
$this->directories = [''];
|
$this->directories = [''];
|
||||||
$this->ignore = $phpci->ignore;
|
$this->ignore = $this->phpci->ignore;
|
||||||
|
|
||||||
if (!empty($options['directory'])) {
|
if (!empty($options['directory'])) {
|
||||||
$this->directories[] = $options['directory'];
|
$this->directories[] = $options['directory'];
|
||||||
|
@ -57,8 +47,6 @@ class Lint implements PHPCensor\Plugin
|
||||||
if (array_key_exists('recursive', $options)) {
|
if (array_key_exists('recursive', $options)) {
|
||||||
$this->recursive = $options['recursive'];
|
$this->recursive = $options['recursive'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -23,23 +23,8 @@ use b8\Database;
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class Mysql implements Plugin
|
class Mysql extends Plugin
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var \PHPCensor\Builder
|
|
||||||
*/
|
|
||||||
protected $phpci;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \PHPCensor\Model\Build
|
|
||||||
*/
|
|
||||||
protected $build;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $queries = [];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
|
@ -56,16 +41,11 @@ class Mysql implements Plugin
|
||||||
protected $pass;
|
protected $pass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Builder $phpci
|
* {@inheritdoc}
|
||||||
* @param Build $build
|
|
||||||
* @param array $options
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
public function __construct(Builder $phpci, Build $build, array $options = [])
|
||||||
{
|
{
|
||||||
$this->phpci = $phpci;
|
parent::__construct($phpci, $build, $options);
|
||||||
$this->build = $build;
|
|
||||||
|
|
||||||
$this->queries = $options;
|
|
||||||
|
|
||||||
$config = Database::getConnection('write')->getDetails();
|
$config = Database::getConnection('write')->getDetails();
|
||||||
|
|
||||||
|
@ -73,7 +53,7 @@ class Mysql implements Plugin
|
||||||
$this->user = $config['user'];
|
$this->user = $config['user'];
|
||||||
$this->pass = $config['pass'];
|
$this->pass = $config['pass'];
|
||||||
|
|
||||||
$buildSettings = $phpci->getConfig('build_settings');
|
$buildSettings = $this->phpci->getConfig('build_settings');
|
||||||
|
|
||||||
if (!isset($buildSettings['mysql'])) {
|
if (!isset($buildSettings['mysql'])) {
|
||||||
return;
|
return;
|
||||||
|
@ -90,8 +70,6 @@ class Mysql implements Plugin
|
||||||
if (array_key_exists('pass', $buildSettings['mysql'])) {
|
if (array_key_exists('pass', $buildSettings['mysql'])) {
|
||||||
$this->pass = $buildSettings['mysql']['pass'];
|
$this->pass = $buildSettings['mysql']['pass'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -104,7 +82,7 @@ class Mysql implements Plugin
|
||||||
$opts = [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION];
|
$opts = [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION];
|
||||||
$pdo = new PDO('mysql:host=' . $this->host, $this->user, $this->pass, $opts);
|
$pdo = new PDO('mysql:host=' . $this->host, $this->user, $this->pass, $opts);
|
||||||
|
|
||||||
foreach ($this->queries as $query) {
|
foreach ($this->options as $query) {
|
||||||
if (!is_array($query)) {
|
if (!is_array($query)) {
|
||||||
// Simple query
|
// Simple query
|
||||||
$pdo->query($this->phpci->interpolate($query));
|
$pdo->query($this->phpci->interpolate($query));
|
||||||
|
|
|
@ -19,29 +19,23 @@ use PHPCensor\Plugin;
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class PackageBuild implements Plugin
|
class PackageBuild extends Plugin
|
||||||
{
|
{
|
||||||
protected $directory;
|
protected $directory;
|
||||||
protected $filename;
|
protected $filename;
|
||||||
protected $format;
|
protected $format;
|
||||||
protected $phpci;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set up the plugin, configure options, etc.
|
* {@inheritdoc}
|
||||||
* @param Builder $phpci
|
|
||||||
* @param Build $build
|
|
||||||
* @param array $options
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
public function __construct(Builder $phpci, Build $build, array $options = [])
|
||||||
{
|
{
|
||||||
$path = $phpci->buildPath;
|
parent::__construct($phpci, $build, $options);
|
||||||
$this->build = $build;
|
|
||||||
$this->phpci = $phpci;
|
$path = $this->phpci->buildPath;
|
||||||
$this->directory = isset($options['directory']) ? $options['directory'] : $path;
|
$this->directory = isset($options['directory']) ? $options['directory'] : $path;
|
||||||
$this->filename = isset($options['filename']) ? $options['filename'] : 'build';
|
$this->filename = isset($options['filename']) ? $options['filename'] : 'build';
|
||||||
$this->format = isset($options['format']) ? $options['format'] : 'zip';
|
$this->format = isset($options['format']) ? $options['format'] : 'zip';
|
||||||
|
|
||||||
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -19,29 +19,30 @@ use PHPCensor\Plugin;
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class Pdepend implements Plugin
|
class Pdepend extends Plugin
|
||||||
{
|
{
|
||||||
protected $args;
|
protected $args;
|
||||||
/**
|
|
||||||
* @var \PHPCensor\Builder
|
|
||||||
*/
|
|
||||||
protected $phpci;
|
|
||||||
/**
|
/**
|
||||||
* @var string Directory which needs to be scanned
|
* @var string Directory which needs to be scanned
|
||||||
*/
|
*/
|
||||||
protected $directory;
|
protected $directory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string File where the summary.xml is stored
|
* @var string File where the summary.xml is stored
|
||||||
*/
|
*/
|
||||||
protected $summary;
|
protected $summary;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string File where the chart.svg is stored
|
* @var string File where the chart.svg is stored
|
||||||
*/
|
*/
|
||||||
protected $chart;
|
protected $chart;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string File where the pyramid.svg is stored
|
* @var string File where the pyramid.svg is stored
|
||||||
*/
|
*/
|
||||||
protected $pyramid;
|
protected $pyramid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string Location on the server where the files are stored. Preferably in the webroot for inclusion
|
* @var string Location on the server where the files are stored. Preferably in the webroot for inclusion
|
||||||
* in the readme.md of the repository
|
* in the readme.md of the repository
|
||||||
|
@ -49,25 +50,19 @@ class Pdepend implements Plugin
|
||||||
protected $location;
|
protected $location;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set up the plugin, configure options, etc.
|
* {@inheritdoc}
|
||||||
* @param Builder $phpci
|
|
||||||
* @param Build $build
|
|
||||||
* @param array $options
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
public function __construct(Builder $phpci, Build $build, array $options = [])
|
||||||
{
|
{
|
||||||
$this->phpci = $phpci;
|
parent::__construct($phpci, $build, $options);
|
||||||
$this->build = $build;
|
|
||||||
|
|
||||||
$this->directory = isset($options['directory']) ? $options['directory'] : $phpci->buildPath;
|
$this->directory = isset($options['directory']) ? $options['directory'] : $this->phpci->buildPath;
|
||||||
|
|
||||||
$title = $phpci->getBuildProjectTitle();
|
$title = $this->phpci->getBuildProjectTitle();
|
||||||
$this->summary = $title . '-summary.xml';
|
$this->summary = $title . '-summary.xml';
|
||||||
$this->pyramid = $title . '-pyramid.svg';
|
$this->pyramid = $title . '-pyramid.svg';
|
||||||
$this->chart = $title . '-chart.svg';
|
$this->chart = $title . '-chart.svg';
|
||||||
$this->location = $this->phpci->buildPath . '..' . DIRECTORY_SEPARATOR . 'pdepend';
|
$this->location = $this->phpci->buildPath . '..' . DIRECTORY_SEPARATOR . 'pdepend';
|
||||||
|
|
||||||
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -20,23 +20,8 @@ use PHPCensor\Plugin;
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class Pgsql implements Plugin
|
class Pgsql extends Plugin
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var \PHPCensor\Builder
|
|
||||||
*/
|
|
||||||
protected $phpci;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \PHPCensor\Model\Build
|
|
||||||
*/
|
|
||||||
protected $build;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $queries = [];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
|
@ -53,17 +38,13 @@ class Pgsql implements Plugin
|
||||||
protected $pass;
|
protected $pass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Builder $phpci
|
* {@inheritdoc}
|
||||||
* @param Build $build
|
|
||||||
* @param array $options
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
public function __construct(Builder $phpci, Build $build, array $options = [])
|
||||||
{
|
{
|
||||||
$this->phpci = $phpci;
|
parent::__construct($phpci, $build, $options);
|
||||||
$this->build = $build;
|
|
||||||
$this->queries = $options;
|
|
||||||
|
|
||||||
$buildSettings = $phpci->getConfig('build_settings');
|
$buildSettings = $this->phpci->getConfig('build_settings');
|
||||||
|
|
||||||
if (isset($buildSettings['pgsql'])) {
|
if (isset($buildSettings['pgsql'])) {
|
||||||
$sql = $buildSettings['pgsql'];
|
$sql = $buildSettings['pgsql'];
|
||||||
|
@ -71,8 +52,6 @@ class Pgsql implements Plugin
|
||||||
$this->user = $sql['user'];
|
$this->user = $sql['user'];
|
||||||
$this->pass = $sql['pass'];
|
$this->pass = $sql['pass'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -85,7 +64,7 @@ class Pgsql implements Plugin
|
||||||
$opts = [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION];
|
$opts = [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION];
|
||||||
$pdo = new PDO('pgsql:host=' . $this->host, $this->user, $this->pass, $opts);
|
$pdo = new PDO('pgsql:host=' . $this->host, $this->user, $this->pass, $opts);
|
||||||
|
|
||||||
foreach ($this->queries as $query) {
|
foreach ($this->options as $query) {
|
||||||
$pdo->query($this->phpci->interpolate($query));
|
$pdo->query($this->phpci->interpolate($query));
|
||||||
}
|
}
|
||||||
} catch (\Exception $ex) {
|
} catch (\Exception $ex) {
|
||||||
|
|
|
@ -12,20 +12,8 @@ use PHPCensor\Plugin;
|
||||||
/**
|
/**
|
||||||
* Phar Plugin
|
* Phar Plugin
|
||||||
*/
|
*/
|
||||||
class Phar implements Plugin
|
class Phar extends Plugin
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* PHPCI
|
|
||||||
* @var Builder
|
|
||||||
*/
|
|
||||||
protected $phpci;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Build
|
|
||||||
* @var Build
|
|
||||||
*/
|
|
||||||
protected $build;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output Directory
|
* Output Directory
|
||||||
* @var string
|
* @var string
|
||||||
|
@ -51,22 +39,11 @@ class Phar implements Plugin
|
||||||
protected $stub;
|
protected $stub;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard Constructor
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* $options['directory'] Output Directory. Default: %BUILDPATH%
|
|
||||||
* $options['filename'] Phar Filename. Default: build.phar
|
|
||||||
* $options['regexp'] Regular Expression Filename Capture. Default: /\.php$/
|
|
||||||
* $options['stub'] Stub Content. No Default Value
|
|
||||||
*
|
|
||||||
* @param Builder $phpci
|
|
||||||
* @param Build $build
|
|
||||||
* @param array $options
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
public function __construct(Builder $phpci, Build $build, array $options = [])
|
||||||
{
|
{
|
||||||
// Basic
|
parent::__construct($phpci, $build, $options);
|
||||||
$this->phpci = $phpci;
|
|
||||||
$this->build = $build;
|
|
||||||
|
|
||||||
// Directory?
|
// Directory?
|
||||||
if (isset($options['directory'])) {
|
if (isset($options['directory'])) {
|
||||||
|
@ -87,28 +64,6 @@ class Phar implements Plugin
|
||||||
if (isset($options['stub'])) {
|
if (isset($options['stub'])) {
|
||||||
$this->setStub($options['stub']);
|
$this->setStub($options['stub']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns PHPCI
|
|
||||||
*
|
|
||||||
* @return Builder
|
|
||||||
*/
|
|
||||||
public function getPHPCI()
|
|
||||||
{
|
|
||||||
return $this->phpci;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns Build
|
|
||||||
*
|
|
||||||
* @return Build
|
|
||||||
*/
|
|
||||||
public function getBuild()
|
|
||||||
{
|
|
||||||
return $this->build;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -131,7 +86,7 @@ class Phar implements Plugin
|
||||||
public function getDirectory()
|
public function getDirectory()
|
||||||
{
|
{
|
||||||
if (!isset($this->directory)) {
|
if (!isset($this->directory)) {
|
||||||
$this->setDirectory($this->getPHPCI()->buildPath);
|
$this->setDirectory($this->phpci->buildPath);
|
||||||
}
|
}
|
||||||
return $this->directory;
|
return $this->directory;
|
||||||
}
|
}
|
||||||
|
@ -217,7 +172,7 @@ class Phar implements Plugin
|
||||||
$content = '';
|
$content = '';
|
||||||
$filename = $this->getStub();
|
$filename = $this->getStub();
|
||||||
if ($filename) {
|
if ($filename) {
|
||||||
$content = file_get_contents($this->getPHPCI()->buildPath . DIRECTORY_SEPARATOR . $this->getStub());
|
$content = file_get_contents($this->phpci->buildPath . DIRECTORY_SEPARATOR . $this->getStub());
|
||||||
}
|
}
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
@ -233,7 +188,7 @@ class Phar implements Plugin
|
||||||
try {
|
try {
|
||||||
$file = $this->getDirectory() . DIRECTORY_SEPARATOR . $this->getFilename();
|
$file = $this->getDirectory() . DIRECTORY_SEPARATOR . $this->getFilename();
|
||||||
$phar = new PHPPhar($file, 0, $this->getFilename());
|
$phar = new PHPPhar($file, 0, $this->getFilename());
|
||||||
$phar->buildFromDirectory($this->getPHPCI()->buildPath, $this->getRegExp());
|
$phar->buildFromDirectory($this->phpci->buildPath, $this->getRegExp());
|
||||||
|
|
||||||
$stub = $this->getStubContent();
|
$stub = $this->getStubContent();
|
||||||
if ($stub) {
|
if ($stub) {
|
||||||
|
@ -242,8 +197,8 @@ class Phar implements Plugin
|
||||||
|
|
||||||
$success = true;
|
$success = true;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->getPHPCI()->log(Lang::get('phar_internal_error'));
|
$this->phpci->log(Lang::get('phar_internal_error'));
|
||||||
$this->getPHPCI()->log($e->getMessage());
|
$this->phpci->log($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return $success;
|
return $success;
|
||||||
|
|
|
@ -21,36 +21,29 @@ use PHPCensor\Plugin;
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class Phing implements Plugin
|
class Phing extends Plugin
|
||||||
{
|
{
|
||||||
|
|
||||||
private $directory;
|
protected $directory;
|
||||||
private $buildFile = 'build.xml';
|
protected $buildFile = 'build.xml';
|
||||||
private $targets = ['build'];
|
protected $targets = ['build'];
|
||||||
private $properties = [];
|
protected $properties = [];
|
||||||
private $propertyFile;
|
protected $propertyFile;
|
||||||
|
|
||||||
protected $phpci;
|
|
||||||
protected $build;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set up the plugin, configure options, etc.
|
* {@inheritdoc}
|
||||||
* @param Builder $phpci
|
|
||||||
* @param Build $build
|
|
||||||
* @param array $options
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
public function __construct(Builder $phpci, Build $build, array $options = [])
|
||||||
{
|
{
|
||||||
$this->setPhpci($phpci);
|
parent::__construct($phpci, $build, $options);
|
||||||
$this->build = $build;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set working directory
|
* Set working directory
|
||||||
*/
|
*/
|
||||||
if (isset($options['directory'])) {
|
if (isset($options['directory'])) {
|
||||||
$directory = $phpci->buildPath . DIRECTORY_SEPARATOR . $options['directory'];
|
$directory = $this->phpci->buildPath . DIRECTORY_SEPARATOR . $options['directory'];
|
||||||
} else {
|
} else {
|
||||||
$directory = $phpci->buildPath;
|
$directory = $this->phpci->buildPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->setDirectory($directory);
|
$this->setDirectory($directory);
|
||||||
|
@ -97,24 +90,6 @@ class Phing implements Plugin
|
||||||
return $this->phpci->executeCommand(implode(' ', $cmd), $this->directory, $this->targets);
|
return $this->phpci->executeCommand(implode(' ', $cmd), $this->directory, $this->targets);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return \PHPCensor\Builder
|
|
||||||
*/
|
|
||||||
public function getPhpci()
|
|
||||||
{
|
|
||||||
return $this->phpci;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param \PHPCensor\Builder $phpci
|
|
||||||
*
|
|
||||||
* @return $this
|
|
||||||
*/
|
|
||||||
public function setPhpci($phpci)
|
|
||||||
{
|
|
||||||
$this->phpci = $phpci;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -13,6 +13,8 @@ use PHPCensor;
|
||||||
use PHPCensor\Builder;
|
use PHPCensor\Builder;
|
||||||
use PHPCensor\Model\Build;
|
use PHPCensor\Model\Build;
|
||||||
use PHPCensor\Model\BuildError;
|
use PHPCensor\Model\BuildError;
|
||||||
|
use PHPCensor\Plugin;
|
||||||
|
use PHPCensor\ZeroConfigPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHP Code Sniffer Plugin - Allows PHP Code Sniffer testing.
|
* PHP Code Sniffer Plugin - Allows PHP Code Sniffer testing.
|
||||||
|
@ -20,13 +22,8 @@ use PHPCensor\Model\BuildError;
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class PhpCodeSniffer implements PHPCensor\Plugin, PHPCensor\ZeroConfigPlugin
|
class PhpCodeSniffer extends Plugin implements ZeroConfigPlugin
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var \PHPCensor\Builder
|
|
||||||
*/
|
|
||||||
protected $phpci;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
|
@ -74,32 +71,14 @@ class PhpCodeSniffer implements PHPCensor\Plugin, PHPCensor\ZeroConfigPlugin
|
||||||
protected $ignore;
|
protected $ignore;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if this plugin can be executed.
|
* {@inheritdoc}
|
||||||
* @param $stage
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param Build $build
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function canExecute($stage, Builder $builder, Build $build)
|
|
||||||
{
|
|
||||||
if ($stage == 'test') {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param \PHPCensor\Builder $phpci
|
|
||||||
* @param \PHPCensor\Model\Build $build
|
|
||||||
* @param array $options
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
public function __construct(Builder $phpci, Build $build, array $options = [])
|
||||||
{
|
{
|
||||||
$this->phpci = $phpci;
|
parent::__construct($phpci, $build, $options);
|
||||||
$this->build = $build;
|
|
||||||
$this->suffixes = ['php'];
|
$this->suffixes = ['php'];
|
||||||
$this->directory = $phpci->buildPath;
|
$this->directory = $this->phpci->buildPath;
|
||||||
$this->standard = 'PSR2';
|
$this->standard = 'PSR2';
|
||||||
$this->tab_width = '';
|
$this->tab_width = '';
|
||||||
$this->encoding = '';
|
$this->encoding = '';
|
||||||
|
@ -124,23 +103,22 @@ class PhpCodeSniffer implements PHPCensor\Plugin, PHPCensor\ZeroConfigPlugin
|
||||||
if (!empty($options['encoding'])) {
|
if (!empty($options['encoding'])) {
|
||||||
$this->encoding = ' --encoding=' . $options['encoding'];
|
$this->encoding = ' --encoding=' . $options['encoding'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->setOptions($options);
|
|
||||||
|
|
||||||
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle this plugin's options.
|
* Check if this plugin can be executed.
|
||||||
* @param $options
|
* @param $stage
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param Build $build
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function setOptions($options)
|
public static function canExecute($stage, Builder $builder, Build $build)
|
||||||
{
|
{
|
||||||
foreach (['directory', 'standard', 'path', 'ignore', 'allowed_warnings', 'allowed_errors'] as $key) {
|
if ($stage == 'test') {
|
||||||
if (array_key_exists($key, $options)) {
|
return true;
|
||||||
$this->{$key} = $options[$key];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -21,12 +21,10 @@ use PHPCensor\Plugin;
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class PhpCpd implements Plugin
|
class PhpCpd extends Plugin
|
||||||
{
|
{
|
||||||
protected $directory;
|
protected $directory;
|
||||||
protected $args;
|
protected $args;
|
||||||
protected $phpci;
|
|
||||||
protected $build;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string, based on the assumption the root may not hold the code to be
|
* @var string, based on the assumption the root may not hold the code to be
|
||||||
|
@ -40,28 +38,22 @@ class PhpCpd implements Plugin
|
||||||
protected $ignore;
|
protected $ignore;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set up the plugin, configure options, etc.
|
* {@inheritdoc}
|
||||||
* @param Builder $phpci
|
|
||||||
* @param Build $build
|
|
||||||
* @param array $options
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
public function __construct(Builder $phpci, Build $build, array $options = [])
|
||||||
{
|
{
|
||||||
$this->phpci = $phpci;
|
parent::__construct($phpci, $build, $options);
|
||||||
$this->build = $build;
|
|
||||||
|
|
||||||
$this->path = $phpci->buildPath;
|
$this->path = $this->phpci->buildPath;
|
||||||
$this->ignore = $phpci->ignore;
|
$this->ignore = $this->phpci->ignore;
|
||||||
|
|
||||||
if (!empty($options['path'])) {
|
if (!empty($options['path'])) {
|
||||||
$this->path = $phpci->buildPath . $options['path'];
|
$this->path = $this->phpci->buildPath . $options['path'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($options['ignore'])) {
|
if (!empty($options['ignore'])) {
|
||||||
$this->ignore = $options['ignore'];
|
$this->ignore = $options['ignore'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -19,45 +19,23 @@ use PHPCensor\Plugin;
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class PhpCsFixer implements Plugin
|
class PhpCsFixer extends Plugin
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var \PHPCensor\Builder
|
|
||||||
*/
|
|
||||||
protected $phpci;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \PHPCensor\Model\Build
|
|
||||||
*/
|
|
||||||
protected $build;
|
|
||||||
|
|
||||||
protected $workingDir = '';
|
protected $workingDir = '';
|
||||||
protected $level = ' --level=psr2';
|
protected $level = ' --level=psr2';
|
||||||
protected $verbose = '';
|
protected $verbose = '';
|
||||||
protected $diff = '';
|
protected $diff = '';
|
||||||
protected $levels = array('psr0', 'psr1', 'psr2', 'symfony');
|
protected $levels = ['psr0', 'psr1', 'psr2', 'symfony'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard Constructor
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* $options['directory'] Output Directory. Default: %BUILDPATH%
|
|
||||||
* $options['filename'] Phar Filename. Default: build.phar
|
|
||||||
* $options['regexp'] Regular Expression Filename Capture. Default: /\.php$/
|
|
||||||
* $options['stub'] Stub Content. No Default Value
|
|
||||||
*
|
|
||||||
* @param Builder $phpci
|
|
||||||
* @param Build $build
|
|
||||||
* @param array $options
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
public function __construct(Builder $phpci, Build $build, array $options = [])
|
||||||
{
|
{
|
||||||
$this->phpci = $phpci;
|
parent::__construct($phpci, $build, $options);
|
||||||
$this->build = $build;
|
|
||||||
|
|
||||||
$this->workingdir = $this->phpci->buildPath;
|
$this->workingDir = $this->phpci->buildPath;
|
||||||
$this->buildArgs($options);
|
$this->buildArgs($options);
|
||||||
|
|
||||||
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,7 +45,7 @@ class PhpCsFixer implements Plugin
|
||||||
public function execute()
|
public function execute()
|
||||||
{
|
{
|
||||||
$curdir = getcwd();
|
$curdir = getcwd();
|
||||||
chdir($this->workingdir);
|
chdir($this->workingDir);
|
||||||
|
|
||||||
$phpcsfixer = $this->phpci->findBinary('php-cs-fixer');
|
$phpcsfixer = $this->phpci->findBinary('php-cs-fixer');
|
||||||
|
|
||||||
|
@ -98,7 +76,7 @@ class PhpCsFixer implements Plugin
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($options['workingdir']) && $options['workingdir']) {
|
if (isset($options['workingdir']) && $options['workingdir']) {
|
||||||
$this->workingdir = $this->phpci->buildPath . $options['workingdir'];
|
$this->workingDir = $this->phpci->buildPath . $options['workingdir'];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,8 @@ namespace PHPCensor\Plugin;
|
||||||
use PHPCensor;
|
use PHPCensor;
|
||||||
use PHPCensor\Builder;
|
use PHPCensor\Builder;
|
||||||
use PHPCensor\Model\Build;
|
use PHPCensor\Model\Build;
|
||||||
|
use PHPCensor\Plugin;
|
||||||
|
use PHPCensor\ZeroConfigPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHP Docblock Checker Plugin - Checks your PHP files for appropriate uses of Docblocks
|
* PHP Docblock Checker Plugin - Checks your PHP files for appropriate uses of Docblocks
|
||||||
|
@ -19,18 +21,8 @@ use PHPCensor\Model\Build;
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class PhpDocblockChecker implements PHPCensor\Plugin, PHPCensor\ZeroConfigPlugin
|
class PhpDocblockChecker extends Plugin implements ZeroConfigPlugin
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var \PHPCensor\Builder
|
|
||||||
*/
|
|
||||||
protected $phpci;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \PHPCensor\Model\Build
|
|
||||||
*/
|
|
||||||
protected $build;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string Based on the assumption the root may not hold the code to be
|
* @var string Based on the assumption the root may not hold the code to be
|
||||||
* tested, extends the build path.
|
* tested, extends the build path.
|
||||||
|
@ -44,34 +36,16 @@ class PhpDocblockChecker implements PHPCensor\Plugin, PHPCensor\ZeroConfigPlugin
|
||||||
|
|
||||||
protected $skipClasses = false;
|
protected $skipClasses = false;
|
||||||
protected $skipMethods = false;
|
protected $skipMethods = false;
|
||||||
|
protected $allowed_warnings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if this plugin can be executed.
|
* {@inheritdoc}
|
||||||
* @param $stage
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param Build $build
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function canExecute($stage, Builder $builder, Build $build)
|
|
||||||
{
|
|
||||||
if ($stage == 'test') {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set up the plugin, configure options, etc.
|
|
||||||
* @param Builder $phpci
|
|
||||||
* @param Build $build
|
|
||||||
* @param array $options
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
public function __construct(Builder $phpci, Build $build, array $options = [])
|
||||||
{
|
{
|
||||||
$this->phpci = $phpci;
|
parent::__construct($phpci, $build, $options);
|
||||||
$this->build = $build;
|
|
||||||
$this->ignore = $phpci->ignore;
|
$this->ignore = $this->phpci->ignore;
|
||||||
$this->path = '';
|
$this->path = '';
|
||||||
$this->allowed_warnings = 0;
|
$this->allowed_warnings = 0;
|
||||||
|
|
||||||
|
@ -94,8 +68,22 @@ class PhpDocblockChecker implements PHPCensor\Plugin, PHPCensor\ZeroConfigPlugin
|
||||||
if (array_key_exists('allowed_warnings', $options)) {
|
if (array_key_exists('allowed_warnings', $options)) {
|
||||||
$this->allowed_warnings = (int)$options['allowed_warnings'];
|
$this->allowed_warnings = (int)$options['allowed_warnings'];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
|
/**
|
||||||
|
* Check if this plugin can be executed.
|
||||||
|
* @param $stage
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param Build $build
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function canExecute($stage, Builder $builder, Build $build)
|
||||||
|
{
|
||||||
|
if ($stage == 'test') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -12,6 +12,8 @@ namespace PHPCensor\Plugin;
|
||||||
use PHPCensor;
|
use PHPCensor;
|
||||||
use PHPCensor\Builder;
|
use PHPCensor\Builder;
|
||||||
use PHPCensor\Model\Build;
|
use PHPCensor\Model\Build;
|
||||||
|
use PHPCensor\Plugin;
|
||||||
|
use PHPCensor\ZeroConfigPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHP Loc - Allows PHP Copy / Lines of Code testing.
|
* PHP Loc - Allows PHP Copy / Lines of Code testing.
|
||||||
|
@ -19,16 +21,12 @@ use PHPCensor\Model\Build;
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class PhpLoc implements PHPCensor\Plugin, PHPCensor\ZeroConfigPlugin
|
class PhpLoc extends Plugin implements ZeroConfigPlugin
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $directory;
|
protected $directory;
|
||||||
/**
|
|
||||||
* @var \PHPCensor\Builder
|
|
||||||
*/
|
|
||||||
protected $phpci;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if this plugin can be executed.
|
* Check if this plugin can be executed.
|
||||||
|
@ -47,22 +45,17 @@ class PhpLoc implements PHPCensor\Plugin, PHPCensor\ZeroConfigPlugin
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set up the plugin, configure options, etc.
|
* {@inheritdoc}
|
||||||
* @param Builder $phpci
|
|
||||||
* @param Build $build
|
|
||||||
* @param array $options
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
public function __construct(Builder $phpci, Build $build, array $options = [])
|
||||||
{
|
{
|
||||||
$this->phpci = $phpci;
|
parent::__construct($phpci, $build, $options);
|
||||||
$this->build = $build;
|
|
||||||
$this->directory = $phpci->buildPath;
|
$this->directory = $this->phpci->buildPath;
|
||||||
|
|
||||||
if (isset($options['directory'])) {
|
if (isset($options['directory'])) {
|
||||||
$this->directory .= $options['directory'];
|
$this->directory .= $options['directory'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -12,6 +12,8 @@ namespace PHPCensor\Plugin;
|
||||||
use PHPCensor;
|
use PHPCensor;
|
||||||
use PHPCensor\Builder;
|
use PHPCensor\Builder;
|
||||||
use PHPCensor\Model\Build;
|
use PHPCensor\Model\Build;
|
||||||
|
use PHPCensor\Plugin;
|
||||||
|
use PHPCensor\ZeroConfigPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHP Mess Detector Plugin - Allows PHP Mess Detector testing.
|
* PHP Mess Detector Plugin - Allows PHP Mess Detector testing.
|
||||||
|
@ -19,18 +21,8 @@ use PHPCensor\Model\Build;
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class PhpMessDetector implements PHPCensor\Plugin, PHPCensor\ZeroConfigPlugin
|
class PhpMessDetector extends Plugin implements ZeroConfigPlugin
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var \PHPCensor\Builder
|
|
||||||
*/
|
|
||||||
protected $phpci;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \PHPCensor\Model\Build
|
|
||||||
*/
|
|
||||||
protected $build;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
|
@ -54,41 +46,17 @@ class PhpMessDetector implements PHPCensor\Plugin, PHPCensor\ZeroConfigPlugin
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $rules;
|
protected $rules;
|
||||||
|
protected $allowed_warnings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if this plugin can be executed.
|
* {@inheritdoc}
|
||||||
* @param $stage
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param Build $build
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function canExecute($stage, Builder $builder, Build $build)
|
|
||||||
{
|
|
||||||
if ($stage == 'test') {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Standard Constructor
|
|
||||||
*
|
|
||||||
* $options['directory'] Output Directory. Default: %BUILDPATH%
|
|
||||||
* $options['filename'] Phar Filename. Default: build.phar
|
|
||||||
* $options['regexp'] Regular Expression Filename Capture. Default: /\.php$/
|
|
||||||
* $options['stub'] Stub Content. No Default Value
|
|
||||||
*
|
|
||||||
* @param Builder $phpci
|
|
||||||
* @param Build $build
|
|
||||||
* @param array $options
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
public function __construct(Builder $phpci, Build $build, array $options = [])
|
||||||
{
|
{
|
||||||
$this->phpci = $phpci;
|
parent::__construct($phpci, $build, $options);
|
||||||
$this->build = $build;
|
|
||||||
$this->suffixes = ['php'];
|
$this->suffixes = ['php'];
|
||||||
$this->ignore = $phpci->ignore;
|
$this->ignore = $this->phpci->ignore;
|
||||||
$this->path = '';
|
$this->path = '';
|
||||||
$this->rules = ['codesize', 'unusedcode', 'naming'];
|
$this->rules = ['codesize', 'unusedcode', 'naming'];
|
||||||
$this->allowed_warnings = 0;
|
$this->allowed_warnings = 0;
|
||||||
|
@ -108,8 +76,22 @@ class PhpMessDetector implements PHPCensor\Plugin, PHPCensor\ZeroConfigPlugin
|
||||||
foreach (['rules', 'ignore', 'suffixes'] as $key) {
|
foreach (['rules', 'ignore', 'suffixes'] as $key) {
|
||||||
$this->overrideSetting($options, $key);
|
$this->overrideSetting($options, $key);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
|
/**
|
||||||
|
* Check if this plugin can be executed.
|
||||||
|
* @param $stage
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param Build $build
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function canExecute($stage, Builder $builder, Build $build)
|
||||||
|
{
|
||||||
|
if ($stage == 'test') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -19,18 +19,8 @@ use PHPCensor\Plugin;
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class PhpParallelLint implements Plugin
|
class PhpParallelLint extends Plugin
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var \PHPCensor\Builder
|
|
||||||
*/
|
|
||||||
protected $phpci;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \PHPCensor\Model\Build
|
|
||||||
*/
|
|
||||||
protected $build;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
|
@ -42,33 +32,22 @@ class PhpParallelLint implements Plugin
|
||||||
protected $ignore;
|
protected $ignore;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard Constructor
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* $options['directory'] Output Directory. Default: %BUILDPATH%
|
|
||||||
* $options['filename'] Phar Filename. Default: build.phar
|
|
||||||
* $options['regexp'] Regular Expression Filename Capture. Default: /\.php$/
|
|
||||||
* $options['stub'] Stub Content. No Default Value
|
|
||||||
*
|
|
||||||
* @param Builder $phpci
|
|
||||||
* @param Build $build
|
|
||||||
* @param array $options
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
public function __construct(Builder $phpci, Build $build, array $options = [])
|
||||||
{
|
{
|
||||||
$this->phpci = $phpci;
|
parent::__construct($phpci, $build, $options);
|
||||||
$this->build = $build;
|
|
||||||
$this->directory = $phpci->buildPath;
|
$this->directory = $this->phpci->buildPath;
|
||||||
$this->ignore = $this->phpci->ignore;
|
$this->ignore = $this->phpci->ignore;
|
||||||
|
|
||||||
if (isset($options['directory'])) {
|
if (isset($options['directory'])) {
|
||||||
$this->directory = $phpci->buildPath.$options['directory'];
|
$this->directory = $this->phpci->buildPath.$options['directory'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($options['ignore'])) {
|
if (isset($options['ignore'])) {
|
||||||
$this->ignore = $options['ignore'];
|
$this->ignore = $options['ignore'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -12,6 +12,7 @@ namespace PHPCensor\Plugin;
|
||||||
use PHPCensor;
|
use PHPCensor;
|
||||||
use PHPCensor\Builder;
|
use PHPCensor\Builder;
|
||||||
use PHPCensor\Model\Build;
|
use PHPCensor\Model\Build;
|
||||||
|
use PHPCensor\Plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHP Spec Plugin - Allows PHP Spec testing.
|
* PHP Spec Plugin - Allows PHP Spec testing.
|
||||||
|
@ -19,38 +20,8 @@ use PHPCensor\Model\Build;
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class PhpSpec implements PHPCensor\Plugin
|
class PhpSpec extends Plugin
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var \PHPCensor\Builder
|
|
||||||
*/
|
|
||||||
protected $phpci;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \PHPCensor\Model\Build
|
|
||||||
*/
|
|
||||||
protected $build;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $options;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set up the plugin, configure options, etc.
|
|
||||||
* @param Builder $phpci
|
|
||||||
* @param Build $build
|
|
||||||
* @param array $options
|
|
||||||
*/
|
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
|
||||||
{
|
|
||||||
$this->phpci = $phpci;
|
|
||||||
$this->build = $build;
|
|
||||||
$this->options = $options;
|
|
||||||
|
|
||||||
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs PHP Spec tests.
|
* Runs PHP Spec tests.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -12,6 +12,7 @@ namespace PHPCensor\Plugin;
|
||||||
use PHPCensor;
|
use PHPCensor;
|
||||||
use PHPCensor\Builder;
|
use PHPCensor\Builder;
|
||||||
use PHPCensor\Model\Build;
|
use PHPCensor\Model\Build;
|
||||||
|
use PHPCensor\Plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPTAL Lint Plugin - Provides access to PHPTAL lint functionality.
|
* PHPTAL Lint Plugin - Provides access to PHPTAL lint functionality.
|
||||||
|
@ -19,23 +20,13 @@ use PHPCensor\Model\Build;
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class PhpTalLint implements PHPCensor\Plugin
|
class PhpTalLint extends Plugin
|
||||||
{
|
{
|
||||||
protected $directories;
|
protected $directories;
|
||||||
protected $recursive = true;
|
protected $recursive = true;
|
||||||
protected $suffixes;
|
protected $suffixes;
|
||||||
protected $ignore;
|
protected $ignore;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \PHPCensor\Builder
|
|
||||||
*/
|
|
||||||
protected $phpci;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \PHPCensor\Model\Build
|
|
||||||
*/
|
|
||||||
protected $build;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string The path to a file contain custom phptal_tales_ functions
|
* @var string The path to a file contain custom phptal_tales_ functions
|
||||||
*/
|
*/
|
||||||
|
@ -57,19 +48,15 @@ class PhpTalLint implements PHPCensor\Plugin
|
||||||
protected $failedPaths = [];
|
protected $failedPaths = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard Constructor
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* @param Builder $phpci
|
|
||||||
* @param Build $build
|
|
||||||
* @param array $options
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
public function __construct(Builder $phpci, Build $build, array $options = [])
|
||||||
{
|
{
|
||||||
$this->phpci = $phpci;
|
parent::__construct($phpci, $build, $options);
|
||||||
$this->build = $build;
|
|
||||||
$this->directories = [''];
|
$this->directories = [''];
|
||||||
$this->suffixes = ['zpt'];
|
$this->suffixes = ['zpt'];
|
||||||
$this->ignore = $phpci->ignore;
|
$this->ignore = $this->phpci->ignore;
|
||||||
|
|
||||||
$this->allowed_warnings = 0;
|
$this->allowed_warnings = 0;
|
||||||
$this->allowed_errors = 0;
|
$this->allowed_errors = 0;
|
||||||
|
@ -81,23 +68,6 @@ class PhpTalLint implements PHPCensor\Plugin
|
||||||
if (isset($options['suffixes'])) {
|
if (isset($options['suffixes'])) {
|
||||||
$this->suffixes = (array)$options['suffixes'];
|
$this->suffixes = (array)$options['suffixes'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->setOptions($options);
|
|
||||||
|
|
||||||
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle this plugin's options.
|
|
||||||
* @param $options
|
|
||||||
*/
|
|
||||||
protected function setOptions($options)
|
|
||||||
{
|
|
||||||
foreach (['directories', 'tales', 'allowed_warnings', 'allowed_errors'] as $key) {
|
|
||||||
if (array_key_exists($key, $options)) {
|
|
||||||
$this->{$key} = $options[$key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -17,6 +17,8 @@ use PHPCensor\Model\Build;
|
||||||
use PHPCensor\Model\BuildError;
|
use PHPCensor\Model\BuildError;
|
||||||
use PHPCensor\Plugin\Option\PhpUnitOptions;
|
use PHPCensor\Plugin\Option\PhpUnitOptions;
|
||||||
use PHPCensor\Plugin\Util\PhpUnitResult;
|
use PHPCensor\Plugin\Util\PhpUnitResult;
|
||||||
|
use PHPCensor\Plugin;
|
||||||
|
use PHPCensor\ZeroConfigPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHP Unit Plugin - A rewrite of the original PHP Unit plugin
|
* PHP Unit Plugin - A rewrite of the original PHP Unit plugin
|
||||||
|
@ -26,11 +28,8 @@ use PHPCensor\Plugin\Util\PhpUnitResult;
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class PhpUnit implements PHPCensor\Plugin, PHPCensor\ZeroConfigPlugin
|
class PhpUnit extends Plugin implements ZeroConfigPlugin
|
||||||
{
|
{
|
||||||
protected $phpci;
|
|
||||||
protected $build;
|
|
||||||
|
|
||||||
/** @var string[] Raw options from the PHPCI config file */
|
/** @var string[] Raw options from the PHPCI config file */
|
||||||
protected $options = array();
|
protected $options = array();
|
||||||
|
|
||||||
|
@ -48,8 +47,8 @@ class PhpUnit implements PHPCensor\Plugin, PHPCensor\ZeroConfigPlugin
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = array())
|
public function __construct(Builder $phpci, Build $build, array $options = array())
|
||||||
{
|
{
|
||||||
$this->phpci = $phpci;
|
parent::__construct($phpci, $build, $options);
|
||||||
$this->build = $build;
|
|
||||||
$this->options = new PhpUnitOptions($options);
|
$this->options = new PhpUnitOptions($options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,7 +167,6 @@ class PhpUnit implements PHPCensor\Plugin, PHPCensor\ZeroConfigPlugin
|
||||||
*/
|
*/
|
||||||
protected function processResults($jsonFile)
|
protected function processResults($jsonFile)
|
||||||
{
|
{
|
||||||
var_dump('fuck!');
|
|
||||||
if (file_exists($jsonFile)) {
|
if (file_exists($jsonFile)) {
|
||||||
$parser = new PhpUnitResult($jsonFile, $this->build->getBuildPath());
|
$parser = new PhpUnitResult($jsonFile, $this->build->getBuildPath());
|
||||||
|
|
||||||
|
|
|
@ -19,18 +19,8 @@ use PHPCensor\Plugin;
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class Shell implements Plugin
|
class Shell extends Plugin
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var \PHPCensor\Builder
|
|
||||||
*/
|
|
||||||
protected $phpci;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \PHPCensor\Model\Build
|
|
||||||
*/
|
|
||||||
protected $build;
|
|
||||||
|
|
||||||
protected $args;
|
protected $args;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,21 +29,11 @@ class Shell implements Plugin
|
||||||
protected $commands = [];
|
protected $commands = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard Constructor
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* $options['directory'] Output Directory. Default: %BUILDPATH%
|
|
||||||
* $options['filename'] Phar Filename. Default: build.phar
|
|
||||||
* $options['regexp'] Regular Expression Filename Capture. Default: /\.php$/
|
|
||||||
* $options['stub'] Stub Content. No Default Value
|
|
||||||
*
|
|
||||||
* @param Builder $phpci
|
|
||||||
* @param Build $build
|
|
||||||
* @param array $options
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
public function __construct(Builder $phpci, Build $build, array $options = [])
|
||||||
{
|
{
|
||||||
$this->phpci = $phpci;
|
parent::__construct($phpci, $build, $options);
|
||||||
$this->build = $build;
|
|
||||||
|
|
||||||
if (isset($options['command'])) {
|
if (isset($options['command'])) {
|
||||||
// Keeping this for backwards compatibility, new projects should use interpolation vars.
|
// Keeping this for backwards compatibility, new projects should use interpolation vars.
|
||||||
|
@ -72,8 +52,6 @@ class Shell implements Plugin
|
||||||
if (is_array($options)) {
|
if (is_array($options)) {
|
||||||
$this->commands = $options;
|
$this->commands = $options;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -21,7 +21,7 @@ use Maknz\Slack\AttachmentField;
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class SlackNotify implements Plugin
|
class SlackNotify extends Plugin
|
||||||
{
|
{
|
||||||
private $webHook;
|
private $webHook;
|
||||||
private $room;
|
private $room;
|
||||||
|
@ -31,16 +31,11 @@ class SlackNotify implements Plugin
|
||||||
private $show_status;
|
private $show_status;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set up the plugin, configure options, etc.
|
* {@inheritdoc}
|
||||||
* @param Builder $phpci
|
|
||||||
* @param Build $build
|
|
||||||
* @param array $options
|
|
||||||
* @throws \Exception
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
public function __construct(Builder $phpci, Build $build, array $options = [])
|
||||||
{
|
{
|
||||||
$this->phpci = $phpci;
|
parent::__construct($phpci, $build, $options);
|
||||||
$this->build = $build;
|
|
||||||
|
|
||||||
if (is_array($options) && isset($options['webhook_url'])) {
|
if (is_array($options) && isset($options['webhook_url'])) {
|
||||||
$this->webHook = trim($options['webhook_url']);
|
$this->webHook = trim($options['webhook_url']);
|
||||||
|
|
|
@ -20,18 +20,8 @@ use PHPCensor\Plugin;
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class Sqlite implements Plugin
|
class Sqlite extends Plugin
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var \PHPCensor\Builder
|
|
||||||
*/
|
|
||||||
protected $phpci;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \PHPCensor\Model\Build
|
|
||||||
*/
|
|
||||||
protected $build;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
|
@ -43,23 +33,18 @@ class Sqlite implements Plugin
|
||||||
protected $path;
|
protected $path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Builder $phpci
|
* {@inheritdoc}
|
||||||
* @param Build $build
|
|
||||||
* @param array $options
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
public function __construct(Builder $phpci, Build $build, array $options = [])
|
||||||
{
|
{
|
||||||
$this->phpci = $phpci;
|
parent::__construct($phpci, $build, $options);
|
||||||
$this->build = $build;
|
|
||||||
$this->queries = $options;
|
$buildSettings = $this->phpci->getConfig('build_settings');
|
||||||
$buildSettings = $phpci->getConfig('build_settings');
|
|
||||||
|
|
||||||
if (isset($buildSettings['sqlite'])) {
|
if (isset($buildSettings['sqlite'])) {
|
||||||
$sql = $buildSettings['sqlite'];
|
$sql = $buildSettings['sqlite'];
|
||||||
$this->path = $sql['path'];
|
$this->path = $sql['path'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -12,6 +12,8 @@ namespace PHPCensor\Plugin;
|
||||||
use PHPCensor;
|
use PHPCensor;
|
||||||
use PHPCensor\Builder;
|
use PHPCensor\Builder;
|
||||||
use PHPCensor\Model\Build;
|
use PHPCensor\Model\Build;
|
||||||
|
use PHPCensor\Plugin;
|
||||||
|
use PHPCensor\ZeroConfigPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Technical Debt Plugin - Checks for existence of "TODO", "FIXME", etc.
|
* Technical Debt Plugin - Checks for existence of "TODO", "FIXME", etc.
|
||||||
|
@ -20,13 +22,8 @@ use PHPCensor\Model\Build;
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class TechnicalDebt implements PHPCensor\Plugin, PHPCensor\ZeroConfigPlugin
|
class TechnicalDebt extends Plugin implements ZeroConfigPlugin
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var \PHPCensor\Builder
|
|
||||||
*/
|
|
||||||
protected $phpci;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
|
@ -58,6 +55,28 @@ class TechnicalDebt implements PHPCensor\Plugin, PHPCensor\ZeroConfigPlugin
|
||||||
*/
|
*/
|
||||||
protected $searches;
|
protected $searches;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function __construct(Builder $phpci, Build $build, array $options = [])
|
||||||
|
{
|
||||||
|
parent::__construct($phpci, $build, $options);
|
||||||
|
|
||||||
|
$this->suffixes = ['php'];
|
||||||
|
$this->directory = $this->phpci->buildPath;
|
||||||
|
$this->path = '';
|
||||||
|
$this->ignore = $this->phpci->ignore;
|
||||||
|
$this->allowed_errors = 0;
|
||||||
|
$this->searches = ['TODO', 'FIXME', 'TO DO', 'FIX ME'];
|
||||||
|
|
||||||
|
if (isset($options['searches']) && is_array($options['searches'])) {
|
||||||
|
$this->searches = $options['searches'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($options['zero_config']) && $options['zero_config']) {
|
||||||
|
$this->allowed_errors = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if this plugin can be executed.
|
* Check if this plugin can be executed.
|
||||||
|
@ -76,48 +95,6 @@ class TechnicalDebt implements PHPCensor\Plugin, PHPCensor\ZeroConfigPlugin
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param \PHPCensor\Builder $phpci
|
|
||||||
* @param \PHPCensor\Model\Build $build
|
|
||||||
* @param array $options
|
|
||||||
*/
|
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
|
||||||
{
|
|
||||||
$this->phpci = $phpci;
|
|
||||||
$this->build = $build;
|
|
||||||
$this->suffixes = ['php'];
|
|
||||||
$this->directory = $phpci->buildPath;
|
|
||||||
$this->path = '';
|
|
||||||
$this->ignore = $this->phpci->ignore;
|
|
||||||
$this->allowed_errors = 0;
|
|
||||||
$this->searches = ['TODO', 'FIXME', 'TO DO', 'FIX ME'];
|
|
||||||
|
|
||||||
if (isset($options['searches']) && is_array($options['searches'])) {
|
|
||||||
$this->searches = $options['searches'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($options['zero_config']) && $options['zero_config']) {
|
|
||||||
$this->allowed_errors = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->setOptions($options);
|
|
||||||
|
|
||||||
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle this plugin's options.
|
|
||||||
* @param $options
|
|
||||||
*/
|
|
||||||
protected function setOptions($options)
|
|
||||||
{
|
|
||||||
foreach (['directory', 'path', 'ignore', 'allowed_errors'] as $key) {
|
|
||||||
if (array_key_exists($key, $options)) {
|
|
||||||
$this->{$key} = $options[$key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs the plugin
|
* Runs the plugin
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -8,6 +8,7 @@ use PHPCensor\Helper\Lang;
|
||||||
use PHPCensor\Logging\BuildLogger;
|
use PHPCensor\Logging\BuildLogger;
|
||||||
use PHPCensor\Model\Build;
|
use PHPCensor\Model\Build;
|
||||||
use PHPCensor\Store\BuildStore;
|
use PHPCensor\Store\BuildStore;
|
||||||
|
use PHPCensor\Builder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugin Executor - Runs the configured plugins for a given build stage.
|
* Plugin Executor - Runs the configured plugins for a given build stage.
|
||||||
|
@ -15,6 +16,16 @@ use PHPCensor\Store\BuildStore;
|
||||||
*/
|
*/
|
||||||
class Executor
|
class Executor
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var \PHPCI\Builder
|
||||||
|
*/
|
||||||
|
protected $phpci;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \PHPCI\Model\Build
|
||||||
|
*/
|
||||||
|
protected $build;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var BuildLogger
|
* @var BuildLogger
|
||||||
*/
|
*/
|
||||||
|
@ -31,14 +42,16 @@ class Executor
|
||||||
protected $store;
|
protected $store;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Factory $pluginFactory
|
* @param Builder $phpci
|
||||||
|
* @param Build $build
|
||||||
* @param BuildLogger $logger
|
* @param BuildLogger $logger
|
||||||
*/
|
*/
|
||||||
public function __construct(Factory $pluginFactory, BuildLogger $logger, BuildStore $store = null)
|
public function __construct(Builder $phpci, Build $build, BuildLogger $logger)
|
||||||
{
|
{
|
||||||
$this->pluginFactory = $pluginFactory;
|
$this->phpci = $phpci;
|
||||||
|
$this->build = $build;
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
$this->store = $store ?: StoreFactory::getStore('Build');
|
$this->store = StoreFactory::getStore('Build');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,7 +91,7 @@ class Executor
|
||||||
protected function getBranchSpecificPlugins(&$config, $stage, $pluginsToExecute)
|
protected function getBranchSpecificPlugins(&$config, $stage, $pluginsToExecute)
|
||||||
{
|
{
|
||||||
/** @var \PHPCensor\Model\Build $build */
|
/** @var \PHPCensor\Model\Build $build */
|
||||||
$build = $this->pluginFactory->getResourceFor('PHPCensor\Model\Build');
|
$build = $this->build;
|
||||||
$branch = $build->getBranch();
|
$branch = $build->getBranch();
|
||||||
|
|
||||||
// If we don't have any branch-specific plugins:
|
// If we don't have any branch-specific plugins:
|
||||||
|
@ -190,10 +203,7 @@ class Executor
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Build and run it
|
return (new $class($this->phpci, $this->build, $options))->execute();
|
||||||
$obj = $this->pluginFactory->buildPlugin($class, $options);
|
|
||||||
|
|
||||||
return $obj->execute();
|
|
||||||
} catch (\Exception $ex) {
|
} catch (\Exception $ex) {
|
||||||
$this->logger->logFailure(Lang::get('exception') . $ex->getMessage(), $ex);
|
$this->logger->logFailure(Lang::get('exception') . $ex->getMessage(), $ex);
|
||||||
|
|
||||||
|
@ -235,7 +245,7 @@ class Executor
|
||||||
private function getBuildSummary()
|
private function getBuildSummary()
|
||||||
{
|
{
|
||||||
/** @var Build $build */
|
/** @var Build $build */
|
||||||
$build = $this->pluginFactory->getResourceFor('PHPCensor\Model\Build');
|
$build = $this->build;
|
||||||
$metas = $this->store->getMeta('plugin-summary', $build->getProjectId(), $build->getId());
|
$metas = $this->store->getMeta('plugin-summary', $build->getProjectId(), $build->getId());
|
||||||
return isset($metas[0]['meta_value']) ? $metas[0]['meta_value'] : [];
|
return isset($metas[0]['meta_value']) ? $metas[0]['meta_value'] : [];
|
||||||
}
|
}
|
||||||
|
@ -248,7 +258,7 @@ class Executor
|
||||||
private function setBuildSummary($summary)
|
private function setBuildSummary($summary)
|
||||||
{
|
{
|
||||||
/** @var Build $build */
|
/** @var Build $build */
|
||||||
$build = $this->pluginFactory->getResourceFor('PHPCensor\Model\Build');
|
$build = $this->build;
|
||||||
$this->store->setMeta($build->getProjectId(), $build->getId(), 'plugin-summary', json_encode($summary));
|
$this->store->setMeta($build->getProjectId(), $build->getId(), 'plugin-summary', json_encode($summary));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,216 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace PHPCensor\Plugin\Util;
|
|
||||||
|
|
||||||
use Pimple\Container;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Plugin Factory - Loads Plugins and passes required dependencies.
|
|
||||||
* @package PHPCensor\Plugin\Util
|
|
||||||
*/
|
|
||||||
class Factory
|
|
||||||
{
|
|
||||||
const TYPE_ARRAY = "array";
|
|
||||||
const TYPE_CALLABLE = "callable";
|
|
||||||
const INTERFACE_PLUGIN = '\PHPCensor\Plugin';
|
|
||||||
|
|
||||||
private $currentPluginOptions;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var Container
|
|
||||||
*/
|
|
||||||
private $container;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Container $container
|
|
||||||
*/
|
|
||||||
public function __construct(Container $container = null)
|
|
||||||
{
|
|
||||||
if ($container) {
|
|
||||||
$this->container = $container;
|
|
||||||
} else {
|
|
||||||
$this->container = new Container();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Trys to get a function from the file path specified. If the
|
|
||||||
* file returns a function then $this will be passed to it.
|
|
||||||
* This enables the config file to call any public methods.
|
|
||||||
*
|
|
||||||
* @param $configPath
|
|
||||||
* @return bool - true if the function exists else false.
|
|
||||||
*/
|
|
||||||
public function addConfigFromFile($configPath)
|
|
||||||
{
|
|
||||||
// The file is expected to return a function which can
|
|
||||||
// act on the pluginFactory to register any resources needed.
|
|
||||||
if (file_exists($configPath)) {
|
|
||||||
$configFunction = require($configPath);
|
|
||||||
if (is_callable($configFunction)) {
|
|
||||||
$configFunction($this);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get most recently used factory options.
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getLastOptions()
|
|
||||||
{
|
|
||||||
return $this->currentPluginOptions;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds an instance of plugin of class $className. $options will
|
|
||||||
* be passed along with any resources registered with the factory.
|
|
||||||
*
|
|
||||||
* @param $className
|
|
||||||
* @param array|null $options
|
|
||||||
* @throws \InvalidArgumentException if $className doesn't represent a valid plugin
|
|
||||||
* @return \PHPCensor\Plugin
|
|
||||||
*/
|
|
||||||
public function buildPlugin($className, $options = [])
|
|
||||||
{
|
|
||||||
$this->currentPluginOptions = $options;
|
|
||||||
|
|
||||||
$reflectedPlugin = new \ReflectionClass($className);
|
|
||||||
|
|
||||||
if (!$reflectedPlugin->implementsInterface(self::INTERFACE_PLUGIN)) {
|
|
||||||
throw new \InvalidArgumentException(
|
|
||||||
"Requested class must implement " . self:: INTERFACE_PLUGIN
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$constructor = $reflectedPlugin->getConstructor();
|
|
||||||
|
|
||||||
if ($constructor) {
|
|
||||||
$argsToUse = [];
|
|
||||||
foreach ($constructor->getParameters() as $param) {
|
|
||||||
if ('options' === $param->getName()) {
|
|
||||||
$argsToUse[] = $options;
|
|
||||||
} else {
|
|
||||||
$argsToUse = $this->addArgFromParam($argsToUse, $param);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$plugin = $reflectedPlugin->newInstanceArgs($argsToUse);
|
|
||||||
} else {
|
|
||||||
$plugin = $reflectedPlugin->newInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param callable $loader
|
|
||||||
* @param string|null $name
|
|
||||||
* @param string|null $type
|
|
||||||
* @throws \InvalidArgumentException
|
|
||||||
* @internal param mixed $resource
|
|
||||||
*/
|
|
||||||
public function registerResource(
|
|
||||||
$loader,
|
|
||||||
$name = null,
|
|
||||||
$type = null
|
|
||||||
) {
|
|
||||||
if ($name === null && $type === null) {
|
|
||||||
throw new \InvalidArgumentException(
|
|
||||||
"Type or Name must be specified"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!($loader instanceof \Closure)) {
|
|
||||||
throw new \InvalidArgumentException(
|
|
||||||
'$loader is expected to be a function'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$resourceID = $this->getInternalID($type, $name);
|
|
||||||
|
|
||||||
$this->container[$resourceID] = $loader;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get an internal resource ID.
|
|
||||||
* @param null $type
|
|
||||||
* @param null $name
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
private function getInternalID($type = null, $name = null)
|
|
||||||
{
|
|
||||||
$type = $type ? : "";
|
|
||||||
$name = $name ? : "";
|
|
||||||
return $type . "-" . $name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $type
|
|
||||||
* @param string $name
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getResourceFor($type = null, $name = null)
|
|
||||||
{
|
|
||||||
$fullId = $this->getInternalID($type, $name);
|
|
||||||
if (isset($this->container[$fullId])) {
|
|
||||||
return $this->container[$fullId];
|
|
||||||
}
|
|
||||||
|
|
||||||
$typeOnlyID = $this->getInternalID($type, null);
|
|
||||||
if (isset($this->container[$typeOnlyID])) {
|
|
||||||
return $this->container[$typeOnlyID];
|
|
||||||
}
|
|
||||||
|
|
||||||
$nameOnlyID = $this->getInternalID(null, $name);
|
|
||||||
if (isset($this->container[$nameOnlyID])) {
|
|
||||||
return $this->container[$nameOnlyID];
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param \ReflectionParameter $param
|
|
||||||
* @return null|string
|
|
||||||
*/
|
|
||||||
private function getParamType(\ReflectionParameter $param)
|
|
||||||
{
|
|
||||||
$class = $param->getClass();
|
|
||||||
if ($class) {
|
|
||||||
return $class->getName();
|
|
||||||
} elseif ($param->isArray()) {
|
|
||||||
return self::TYPE_ARRAY;
|
|
||||||
} elseif (is_callable($param)) {
|
|
||||||
return self::TYPE_CALLABLE;
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $existingArgs
|
|
||||||
* @param \ReflectionParameter $param
|
|
||||||
* @return array
|
|
||||||
* @throws \DomainException
|
|
||||||
*/
|
|
||||||
private function addArgFromParam($existingArgs, \ReflectionParameter $param)
|
|
||||||
{
|
|
||||||
$name = $param->getName();
|
|
||||||
$type = $this->getParamType($param);
|
|
||||||
$arg = $this->getResourceFor($type, $name);
|
|
||||||
|
|
||||||
if ($arg !== null) {
|
|
||||||
$existingArgs[] = $arg;
|
|
||||||
} elseif ($arg === null && $param->isOptional()) {
|
|
||||||
$existingArgs[] = $param->getDefaultValue();
|
|
||||||
} else {
|
|
||||||
throw new \DomainException(
|
|
||||||
"Unsatisfied dependency: " . $param->getName()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $existingArgs;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -19,34 +19,19 @@ use PHPCensor\Plugin;
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class Wipe implements Plugin
|
class Wipe extends Plugin
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var \PHPCensor\Builder
|
|
||||||
*/
|
|
||||||
protected $phpci;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \PHPCensor\Model\Build
|
|
||||||
*/
|
|
||||||
protected $build;
|
|
||||||
|
|
||||||
protected $directory;
|
protected $directory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set up the plugin, configure options, etc.
|
* {@inheritdoc}
|
||||||
* @param Builder $phpci
|
|
||||||
* @param Build $build
|
|
||||||
* @param array $options
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
public function __construct(Builder $phpci, Build $build, array $options = [])
|
||||||
{
|
{
|
||||||
$path = $phpci->buildPath;
|
parent::__construct($phpci, $build, $options);
|
||||||
$this->phpci = $phpci;
|
|
||||||
$this->build = $build;
|
|
||||||
$this->directory = isset($options['directory']) ? $this->phpci->interpolate($options['directory']) : $path;
|
|
||||||
|
|
||||||
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
|
$path = $this->phpci->buildPath;
|
||||||
|
$this->directory = isset($options['directory']) ? $this->phpci->interpolate($options['directory']) : $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -19,11 +19,9 @@ use PHPCensor\Plugin;
|
||||||
* @package PHPCI
|
* @package PHPCI
|
||||||
* @subpackage Plugins
|
* @subpackage Plugins
|
||||||
*/
|
*/
|
||||||
class XMPP implements Plugin
|
class XMPP extends Plugin
|
||||||
{
|
{
|
||||||
protected $directory;
|
protected $directory;
|
||||||
protected $phpci;
|
|
||||||
protected $build;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string, username of sender account xmpp
|
* @var string, username of sender account xmpp
|
||||||
|
@ -61,15 +59,11 @@ class XMPP implements Plugin
|
||||||
protected $date_format;
|
protected $date_format;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* {@inheritdoc}
|
||||||
* @param Builder $phpci
|
|
||||||
* @param Build $build
|
|
||||||
* @param array $options
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = [])
|
public function __construct(Builder $phpci, Build $build, array $options = [])
|
||||||
{
|
{
|
||||||
$this->phpci = $phpci;
|
parent::__construct($phpci, $build, $options);
|
||||||
$this->build = $build;
|
|
||||||
|
|
||||||
$this->username = '';
|
$this->username = '';
|
||||||
$this->password = '';
|
$this->password = '';
|
||||||
|
@ -89,24 +83,6 @@ class XMPP implements Plugin
|
||||||
$this->recipients = $options['recipients'];
|
$this->recipients = $options['recipients'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->setOptions($options);
|
|
||||||
|
|
||||||
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set options configuration for plugin
|
|
||||||
*
|
|
||||||
* @param array $options
|
|
||||||
*/
|
|
||||||
protected function setOptions($options)
|
|
||||||
{
|
|
||||||
foreach (['username', 'password', 'alias', 'tls', 'server', 'date_format'] as $key) {
|
|
||||||
if (array_key_exists($key, $options)) {
|
|
||||||
$this->{$key} = $options[$key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue