Merge branch 'bugfix/phpmd-phpcs-cleanup' of https://github.com/Block8/PHPCI
This commit is contained in:
commit
f5950d0be3
|
@ -27,8 +27,7 @@ class Application extends b8\Application
|
|||
$opts = ['controller' => 'Home', 'action' => 'index'];
|
||||
|
||||
$this->router->clearRoutes();
|
||||
$this->router->register($route, $opts, function (&$route, Response &$response) use (&$request)
|
||||
{
|
||||
$this->router->register($route, $opts, function (&$route, Response &$response) use (&$request) {
|
||||
$skipValidation = in_array($route['controller'], array('session', 'webhook', 'build-status'));
|
||||
|
||||
if (!$skipValidation && !$this->validateSession()) {
|
||||
|
|
|
@ -197,8 +197,7 @@ class Builder implements LoggerAwareInterface
|
|||
// stages.
|
||||
if ($this->success) {
|
||||
$this->build->setStatus(Build::STATUS_SUCCESS);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$this->build->setStatus(Build::STATUS_FAILED);
|
||||
}
|
||||
|
||||
|
@ -208,8 +207,7 @@ class Builder implements LoggerAwareInterface
|
|||
if ($this->success) {
|
||||
$this->pluginExecutor->executePlugins($this->config, 'success');
|
||||
$this->buildLogger->logSuccess('BUILD SUCCESSFUL!');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$this->pluginExecutor->executePlugins($this->config, 'failure');
|
||||
$this->buildLogger->logFailure("BUILD FAILURE");
|
||||
}
|
||||
|
@ -266,8 +264,8 @@ class Builder implements LoggerAwareInterface
|
|||
*/
|
||||
protected function setupBuild()
|
||||
{
|
||||
$buildId = 'project' . $this->build->getProject()->getId(
|
||||
) . '-build' . $this->build->getId();
|
||||
$buildId = 'project' . $this->build->getProject()->getId()
|
||||
. '-build' . $this->build->getId();
|
||||
$this->ciDir = dirname(dirname(__FILE__) . '/../') . '/';
|
||||
$this->buildPath = $this->ciDir . 'build/' . $buildId . '/';
|
||||
$this->build->currentBuildPath = $this->buildPath;
|
||||
|
@ -338,7 +336,7 @@ class Builder implements LoggerAwareInterface
|
|||
|
||||
$self = $this;
|
||||
$pluginFactory->registerResource(
|
||||
function () use($self) {
|
||||
function () use ($self) {
|
||||
return $self;
|
||||
},
|
||||
null,
|
||||
|
@ -346,7 +344,7 @@ class Builder implements LoggerAwareInterface
|
|||
);
|
||||
|
||||
$pluginFactory->registerResource(
|
||||
function () use($build) {
|
||||
function () use ($build) {
|
||||
return $build;
|
||||
},
|
||||
null,
|
||||
|
|
|
@ -46,7 +46,7 @@ class CreateAdminCommand extends Command
|
|||
if (empty($adminEmail)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$adminPass = $this->ask('Admin password: ');
|
||||
$adminName = $this->ask('Admin name: ');
|
||||
|
||||
|
@ -64,7 +64,7 @@ class CreateAdminCommand extends Command
|
|||
} catch (\Exception $ex) {
|
||||
print 'There was a problem creating your account. :(' . PHP_EOL;
|
||||
print $ex->getMessage();
|
||||
print PHP_EOL;
|
||||
print PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,16 @@ class DaemoniseCommand extends Command
|
|||
*/
|
||||
protected $output;
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
*/
|
||||
protected $run;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $sleep;
|
||||
|
||||
/**
|
||||
* @param \Monolog\Logger $logger
|
||||
* @param string $name
|
||||
|
@ -67,14 +77,14 @@ class DaemoniseCommand extends Command
|
|||
$this->sleep = 0;
|
||||
$runner = new RunCommand($this->logger);
|
||||
|
||||
$in = new ArgvInput(array());
|
||||
$emptyInput = new ArgvInput(array());
|
||||
|
||||
while ($this->run) {
|
||||
|
||||
$buildCount = 0;
|
||||
|
||||
try {
|
||||
$buildCount = $runner->run($in, $output);
|
||||
$buildCount = $runner->run($emptyInput, $output);
|
||||
} catch (\Exception $e) {
|
||||
var_dump($e);
|
||||
}
|
||||
|
|
|
@ -80,7 +80,9 @@ class PollCommand extends Command
|
|||
$this->logger->info("Last commit to github for " . $project->getTitle() . " is " . $last_commit);
|
||||
|
||||
if ($project->getLastCommit() != $last_commit && $last_commit != "") {
|
||||
$this->logger->info("Last commit is different from database, adding new build for " . $project->getTitle());
|
||||
$this->logger->info(
|
||||
"Last commit is different from database, adding new build for " . $project->getTitle()
|
||||
);
|
||||
|
||||
$build = new Build();
|
||||
$build->setProjectId($project->getId());
|
||||
|
@ -101,4 +103,3 @@ class PollCommand extends Command
|
|||
$this->logger->addInfo("Finished processing builds");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,4 +4,4 @@ namespace PHPCI;
|
|||
abstract class Model extends \b8\Model
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,13 +41,13 @@ class Email implements \PHPCI\Plugin
|
|||
*/
|
||||
protected $fromAddress;
|
||||
|
||||
public function __construct(Builder $phpci,
|
||||
Build $build,
|
||||
\Swift_Mailer $mailer,
|
||||
array $options = array()
|
||||
public function __construct(
|
||||
Builder $phpci,
|
||||
Build $build,
|
||||
\Swift_Mailer $mailer,
|
||||
array $options = array()
|
||||
|
||||
)
|
||||
{
|
||||
) {
|
||||
$this->phpci = $phpci;
|
||||
$this->build = $build;
|
||||
$this->options = $options;
|
||||
|
@ -168,14 +168,14 @@ class Email implements \PHPCI\Plugin
|
|||
|
||||
protected function getCcAddresses()
|
||||
{
|
||||
$cc = array();
|
||||
$ccAddresses = array();
|
||||
|
||||
if (isset($this->options['cc'])) {
|
||||
foreach ($this->options['cc'] as $address) {
|
||||
$cc[] = $address;
|
||||
$ccAddresses[] = $address;
|
||||
}
|
||||
}
|
||||
|
||||
return $cc;
|
||||
return $ccAddresses;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,8 +23,7 @@ class ComposerPluginInformation implements InstalledPluginInformation
|
|||
{
|
||||
if (file_exists($filePath)) {
|
||||
$installed = json_decode(file_get_contents($filePath));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$installed = array();
|
||||
}
|
||||
return new self($installed);
|
||||
|
@ -60,12 +59,12 @@ class ComposerPluginInformation implements InstalledPluginInformation
|
|||
*/
|
||||
public function getPluginClasses()
|
||||
{
|
||||
return array_map(
|
||||
function($plugin) {
|
||||
return $plugin->class;
|
||||
},
|
||||
$this->getInstalledPlugins()
|
||||
);
|
||||
return array_map(
|
||||
function ($plugin) {
|
||||
return $plugin->class;
|
||||
},
|
||||
$this->getInstalledPlugins()
|
||||
);
|
||||
}
|
||||
|
||||
protected function loadPluginInfo()
|
||||
|
@ -74,7 +73,7 @@ class ComposerPluginInformation implements InstalledPluginInformation
|
|||
return;
|
||||
}
|
||||
$this->pluginInfo = array();
|
||||
foreach($this->composerPackages as $package) {
|
||||
foreach ($this->composerPackages as $package) {
|
||||
$this->addPluginsFromPackage($package);
|
||||
}
|
||||
}
|
||||
|
@ -89,8 +88,7 @@ class ComposerPluginInformation implements InstalledPluginInformation
|
|||
|
||||
if (isset($phpciData->pluginNamespace)) {
|
||||
$rootNamespace = $phpciData->pluginNamespace;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$rootNamespace = "";
|
||||
}
|
||||
|
||||
|
@ -112,9 +110,9 @@ class ComposerPluginInformation implements InstalledPluginInformation
|
|||
protected function addPlugins(
|
||||
array $plugins,
|
||||
$sourcePackageName,
|
||||
$rootNamespace = "")
|
||||
{
|
||||
foreach($plugins as $plugin) {
|
||||
$rootNamespace = ""
|
||||
) {
|
||||
foreach ($plugins as $plugin) {
|
||||
if (!isset($plugin->class)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -130,8 +128,8 @@ class ComposerPluginInformation implements InstalledPluginInformation
|
|||
protected function addPlugin(
|
||||
$plugin,
|
||||
$sourcePackageName,
|
||||
$rootNamespace = "")
|
||||
{
|
||||
$rootNamespace = ""
|
||||
) {
|
||||
$newPlugin = clone $plugin;
|
||||
|
||||
$newPlugin->class = $rootNamespace . $newPlugin->class;
|
||||
|
@ -144,4 +142,4 @@ class ComposerPluginInformation implements InstalledPluginInformation
|
|||
|
||||
$this->pluginInfo[] = $newPlugin;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ class Executor
|
|||
*/
|
||||
protected $pluginFactory;
|
||||
|
||||
function __construct(Factory $pluginFactory,BuildLogger $logger)
|
||||
public function __construct(Factory $pluginFactory, BuildLogger $logger)
|
||||
{
|
||||
$this->pluginFactory = $pluginFactory;
|
||||
$this->logger = $logger;
|
||||
|
@ -78,8 +78,7 @@ class Executor
|
|||
$class = str_replace('_', ' ', $plugin);
|
||||
$class = ucwords($class);
|
||||
$class = 'PHPCI\\Plugin\\' . str_replace(' ', '', $class);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$class = $plugin;
|
||||
}
|
||||
|
||||
|
@ -105,4 +104,4 @@ class Executor
|
|||
return $rtn;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ class Factory {
|
|||
|
||||
$self = $this;
|
||||
$this->registerResource(
|
||||
function() use ($self) {
|
||||
function () use ($self) {
|
||||
return $self->getLastOptions();
|
||||
},
|
||||
'options',
|
||||
|
@ -37,7 +37,8 @@ class Factory {
|
|||
);
|
||||
}
|
||||
|
||||
public function getLastOptions() {
|
||||
public function getLastOptions()
|
||||
{
|
||||
return $this->currentPluginOptions;
|
||||
}
|
||||
|
||||
|
@ -66,7 +67,7 @@ class Factory {
|
|||
|
||||
if ($constructor) {
|
||||
$argsToUse = array();
|
||||
foreach($constructor->getParameters() as $param) {
|
||||
foreach ($constructor->getParameters() as $param) {
|
||||
$argsToUse = $this->addArgFromParam($argsToUse, $param);
|
||||
}
|
||||
$plugin = $reflectedPlugin->newInstanceArgs($argsToUse);
|
||||
|
@ -84,11 +85,11 @@ class Factory {
|
|||
* @throws \InvalidArgumentException
|
||||
* @internal param mixed $resource
|
||||
*/
|
||||
public function registerResource($loader,
|
||||
$name = null,
|
||||
$type = null
|
||||
)
|
||||
{
|
||||
public function registerResource(
|
||||
$loader,
|
||||
$name = null,
|
||||
$type = null
|
||||
) {
|
||||
if ($name === null && $type === null) {
|
||||
throw new \InvalidArgumentException(
|
||||
"Type or Name must be specified"
|
||||
|
@ -138,9 +139,9 @@ class Factory {
|
|||
$class = $param->getClass();
|
||||
if ($class) {
|
||||
return $class->getName();
|
||||
} elseif($param->isArray()) {
|
||||
} elseif ($param->isArray()) {
|
||||
return self::TYPE_ARRAY;
|
||||
} elseif($param->isCallable()) {
|
||||
} elseif ($param->isCallable()) {
|
||||
return self::TYPE_CALLABLE;
|
||||
} else {
|
||||
return null;
|
||||
|
@ -165,4 +166,4 @@ class Factory {
|
|||
|
||||
return $existingArgs;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ class FilesPluginInformation implements InstalledPluginInformation
|
|||
return new self(new \DirectoryIterator($dirPath));
|
||||
}
|
||||
|
||||
function __construct(\Iterator $files)
|
||||
public function __construct(\Iterator $files)
|
||||
{
|
||||
$this->files = $files;
|
||||
}
|
||||
|
@ -55,17 +55,17 @@ class FilesPluginInformation implements InstalledPluginInformation
|
|||
public function getPluginClasses()
|
||||
{
|
||||
return array_map(
|
||||
function($plugin) {
|
||||
function ($plugin) {
|
||||
return $plugin->class;
|
||||
},
|
||||
$this->getInstalledPlugins()
|
||||
);
|
||||
},
|
||||
$this->getInstalledPlugins()
|
||||
);
|
||||
}
|
||||
|
||||
protected function loadPluginInfo()
|
||||
{
|
||||
$this->pluginInfo = array();
|
||||
foreach($this->files as $fileInfo) {
|
||||
foreach ($this->files as $fileInfo) {
|
||||
if ($fileInfo instanceof \SplFileInfo) {
|
||||
if ($fileInfo->isFile()) {
|
||||
$this->addPluginFromFile($fileInfo);
|
||||
|
@ -101,5 +101,4 @@ class FilesPluginInformation implements InstalledPluginInformation
|
|||
|
||||
return $namespace . '\\' . $className;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,4 +20,4 @@ interface InstalledPluginInformation
|
|||
* @return string[]
|
||||
*/
|
||||
public function getPluginClasses();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ class PluginInformationCollection implements InstalledPluginInformation
|
|||
public function getInstalledPlugins()
|
||||
{
|
||||
$arr = array();
|
||||
foreach($this->pluginInformations as $single) {
|
||||
foreach ($this->pluginInformations as $single) {
|
||||
$arr = array_merge($arr, $single->getInstalledPlugins());
|
||||
}
|
||||
return $arr;
|
||||
|
@ -39,10 +39,10 @@ class PluginInformationCollection implements InstalledPluginInformation
|
|||
public function getPluginClasses()
|
||||
{
|
||||
$arr = array();
|
||||
foreach($this->pluginInformations as $single) {
|
||||
foreach ($this->pluginInformations as $single) {
|
||||
$arr = array_merge($arr, $single->getPluginClasses());
|
||||
}
|
||||
return $arr;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,4 +4,4 @@ namespace PHPCI;
|
|||
abstract class Store extends \b8\Store
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue