diff --git a/PHPCI/Controller/PluginController.php b/PHPCI/Controller/PluginController.php index 20675e46..cefcdbb5 100644 --- a/PHPCI/Controller/PluginController.php +++ b/PHPCI/Controller/PluginController.php @@ -126,7 +126,7 @@ class PluginController extends \PHPCI\Controller /** * Convert array to json and save composer.json - * + * * @param $array */ protected function setComposerJson($array) diff --git a/PHPCI/Controller/WebhookController.php b/PHPCI/Controller/WebhookController.php index cef7dc53..619eec16 100644 --- a/PHPCI/Controller/WebhookController.php +++ b/PHPCI/Controller/WebhookController.php @@ -157,6 +157,8 @@ class WebhookController extends \PHPCI\Controller * Handle the payload when Github sends a commit webhook. * @param $project * @param array $payload + * @param b8\Http\Response\JsonResponse $response + * @return b8\Http\Response\JsonResponse */ protected function githubCommitRequest($project, array $payload, b8\Http\Response\JsonResponse $response) { @@ -167,7 +169,6 @@ class WebhookController extends \PHPCI\Controller } try { - if (isset($payload['commits']) && is_array($payload['commits'])) { // If we have a list of commits, then add them all as builds to be tested: @@ -265,13 +266,10 @@ class WebhookController extends \PHPCI\Controller $payload = json_decode($payloadString, true); try { - - // build on merge request events if (isset($payload['object_kind']) && $payload['object_kind'] == 'merge_request') { $attributes = $payload['object_attributes']; if ($attributes['state'] == 'opened' || $attributes['state'] == 'reopened') { - $branch = $attributes['source_branch']; $commit = $attributes['last_commit']; $committer = $commit['author']['email']; diff --git a/PHPCI/Helper/BaseCommandExecutor.php b/PHPCI/Helper/BaseCommandExecutor.php index 4c2f1fa8..5435d597 100644 --- a/PHPCI/Helper/BaseCommandExecutor.php +++ b/PHPCI/Helper/BaseCommandExecutor.php @@ -160,7 +160,6 @@ abstract class BaseCommandExecutor implements CommandExecutor $this->logger->log(Lang::get('looking_for_binary', $bin), LogLevel::DEBUG); if (is_dir($composerBin) && is_file($composerBin.'/'.$bin)) { - $this->logger->log(Lang::get('found_in_path', $composerBin, $bin), LogLevel::DEBUG); $binaryPath = $composerBin . '/' . $bin; break; diff --git a/PHPCI/Helper/Github.php b/PHPCI/Helper/Github.php index 00d959df..67173eb4 100644 --- a/PHPCI/Helper/Github.php +++ b/PHPCI/Helper/Github.php @@ -48,24 +48,18 @@ class Github $res = $http->get($url, $params); foreach ($res['body'] as $item) { - $results[] = $item; - } foreach ($res['headers'] as $header) { - if (preg_match('/^Link: <([^>]+)>; rel="next"/', $header, $r)) { - $host = parse_url($r[1]); parse_str($host['query'], $params); $results = $this->makeRecursiveRequest($host['path'], $params, $results); break; - } - } return $results; diff --git a/PHPCI/Helper/LoginIsDisabled.php b/PHPCI/Helper/LoginIsDisabled.php index d30fcd9f..437b95cd 100644 --- a/PHPCI/Helper/LoginIsDisabled.php +++ b/PHPCI/Helper/LoginIsDisabled.php @@ -20,7 +20,7 @@ use b8\Config; class LoginIsDisabled { /** - * Checks if + * Checks if * @param $method * @param array $params * @return mixed|null diff --git a/PHPCI/Logging/Handler.php b/PHPCI/Logging/Handler.php index ebfa2620..e22351da 100644 --- a/PHPCI/Logging/Handler.php +++ b/PHPCI/Logging/Handler.php @@ -70,7 +70,6 @@ class Handler public function handleError($level, $message, $file, $line) { if (error_reporting() & $level) { - $exception_level = isset($this->levels[$level]) ? $this->levels[$level] : $level; throw new \ErrorException( @@ -140,7 +139,6 @@ class Handler protected function log(\Exception $exception) { if (null !== $this->logger) { - $message = sprintf( '%s: %s (uncaught exception) at %s line %s', get_class($exception), diff --git a/PHPCI/Plugin/Phar.php b/PHPCI/Plugin/Phar.php index f04580e7..0500fddc 100644 --- a/PHPCI/Plugin/Phar.php +++ b/PHPCI/Plugin/Phar.php @@ -227,7 +227,6 @@ class Phar implements \PHPCI\Plugin $success = false; try { - $phar = new PHPPhar($this->getDirectory() . '/' . $this->getFilename(), 0, $this->getFilename()); $phar->buildFromDirectory($this->getPHPCI()->buildPath, $this->getRegExp()); diff --git a/PHPCI/Plugin/PhpTalLint.php b/PHPCI/Plugin/PhpTalLint.php index 146b0479..e12b6c34 100644 --- a/PHPCI/Plugin/PhpTalLint.php +++ b/PHPCI/Plugin/PhpTalLint.php @@ -210,7 +210,6 @@ class PhpTalLint implements PHPCI\Plugin $output = $this->phpci->getLastOutput(); if (preg_match('/Found (.+?) (error|warning)/i', $output, $matches)) { - $rows = explode(PHP_EOL, $output); unset($rows[0]); diff --git a/PHPCI/Plugin/Util/Executor.php b/PHPCI/Plugin/Util/Executor.php index 9482c81f..8c74707e 100644 --- a/PHPCI/Plugin/Util/Executor.php +++ b/PHPCI/Plugin/Util/Executor.php @@ -50,10 +50,8 @@ class Executor // Try and execute it: if ($this->executePlugin($plugin, $options)) { - // Execution was successful: $this->logger->logSuccess(Lang::get('plugin_success')); - } elseif ($stage == 'setup') { // If we're in the "setup" stage, execution should not continue after // a plugin has failed: diff --git a/PHPCI/Plugin/Util/FilesPluginInformation.php b/PHPCI/Plugin/Util/FilesPluginInformation.php index 2593ae22..d5ccebd5 100644 --- a/PHPCI/Plugin/Util/FilesPluginInformation.php +++ b/PHPCI/Plugin/Util/FilesPluginInformation.php @@ -69,7 +69,7 @@ class FilesPluginInformation implements InstalledPluginInformation { return array_map( function (\stdClass $plugin) { - return $plugin->class; + return $plugin->class; }, $this->getInstalledPlugins() ); diff --git a/bootstrap.php b/bootstrap.php index 252697a8..e3f9985e 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -16,17 +16,13 @@ if (empty($timezone)) { date_default_timezone_set('UTC'); } -// If the PHPCI config file is not where we expect it, try looking in -// env for an alternative config path. $configFile = dirname(__FILE__) . '/PHPCI/config.yml'; - $configEnv = getenv('phpci_config_file'); -if (!empty($configEnv)) { + +if (!empty($configEnv) && file_exists($configEnv)) { $configFile = $configEnv; } -define('PHPCI_CONFIG_FILE', $configFile); - // If we don't have a config file at all, fail at this point and tell the user to install: if (!file_exists($configFile) && (!defined('PHPCI_IS_CONSOLE') || !PHPCI_IS_CONSOLE)) { $message = 'PHPCI has not yet been installed - Please use the command "./console phpci:install" '; diff --git a/vars.php b/vars.php index 2408d41d..aed6b6f8 100644 --- a/vars.php +++ b/vars.php @@ -29,3 +29,9 @@ if (!defined('PHPCI_IS_CONSOLE')) { if (!defined('IS_WIN')) { define('IS_WIN', ((strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? true : false)); } + +// If an environment variable is set defining our config location, use that +// otherwise fall back to PHPCI/config.yml. +if (!defined('PHPCI_CONFIG_FILE')) { + define('PHPCI_CONFIG_FILE', $configFile); +} \ No newline at end of file