diff --git a/src/PHPCensor/Plugin.php b/src/PHPCensor/Plugin.php index c05e544c..8b28b2b5 100644 --- a/src/PHPCensor/Plugin.php +++ b/src/PHPCensor/Plugin.php @@ -21,7 +21,7 @@ abstract class Plugin /** * @var \PHPCensor\Builder */ - protected $phpci; + protected $builder; /** * @var \PHPCensor\Model\Build @@ -34,17 +34,17 @@ abstract class Plugin protected $options; /** - * @param Builder $phpci + * @param Builder $builder * @param Build $build * @param array $options */ - public function __construct(Builder $phpci, Build $build, array $options = []) + public function __construct(Builder $builder, Build $build, array $options = []) { - $this->phpci = $phpci; + $this->builder = $builder; $this->build = $build; $this->options = $options; - $this->phpci->logDebug('Plugin options: ' . json_encode($options)); + $this->builder->logDebug('Plugin options: ' . json_encode($options)); } /** diff --git a/src/PHPCensor/Plugin/Atoum.php b/src/PHPCensor/Plugin/Atoum.php index 42b4de0a..b1254752 100644 --- a/src/PHPCensor/Plugin/Atoum.php +++ b/src/PHPCensor/Plugin/Atoum.php @@ -29,14 +29,14 @@ class Atoum extends Plugin /** * {@inheritdoc} */ - public function __construct(Builder $phpci, Build $build, array $options = []) + public function __construct(Builder $builder, Build $build, array $options = []) { - parent::__construct($phpci, $build, $options); + parent::__construct($builder, $build, $options); if (isset($options['executable'])) { - $this->executable = $this->phpci->buildPath . DIRECTORY_SEPARATOR.$options['executable']; + $this->executable = $this->builder->buildPath . DIRECTORY_SEPARATOR.$options['executable']; } else { - $this->executable = $this->phpci->findBinary('atoum'); + $this->executable = $this->builder->findBinary('atoum'); } if (isset($options['args'])) { @@ -67,21 +67,21 @@ class Atoum extends Plugin $cmd .= " -c '{$this->config}'"; } if ($this->directory !== null) { - $dirPath = $this->phpci->buildPath . DIRECTORY_SEPARATOR . $this->directory; + $dirPath = $this->builder->buildPath . DIRECTORY_SEPARATOR . $this->directory; $cmd .= " -d '{$dirPath}'"; } - chdir($this->phpci->buildPath); + chdir($this->builder->buildPath); $output = ''; $status = true; exec($cmd, $output); if (count(preg_grep("/Success \(/", $output)) == 0) { $status = false; - $this->phpci->log($output); + $this->builder->log($output); } if (count($output) == 0) { $status = false; - $this->phpci->log(Lang::get('no_tests_performed')); + $this->builder->log(Lang::get('no_tests_performed')); } return $status; diff --git a/src/PHPCensor/Plugin/Behat.php b/src/PHPCensor/Plugin/Behat.php index 01fbb5ad..7c8b78af 100644 --- a/src/PHPCensor/Plugin/Behat.php +++ b/src/PHPCensor/Plugin/Behat.php @@ -30,16 +30,16 @@ class Behat extends Plugin /** * {@inheritdoc} */ - public function __construct(Builder $phpci, Build $build, array $options = []) + public function __construct(Builder $builder, Build $build, array $options = []) { - parent::__construct($phpci, $build, $options); + parent::__construct($builder, $build, $options); $this->features = ''; if (isset($options['executable'])) { $this->executable = $options['executable']; } else { - $this->executable = $this->phpci->findBinary('behat'); + $this->executable = $this->builder->findBinary('behat'); } if (!empty($options['features'])) { @@ -53,17 +53,17 @@ class Behat extends Plugin public function execute() { $current_dir = getcwd(); - chdir($this->phpci->buildPath); + chdir($this->builder->buildPath); $behat = $this->executable; if (!$behat) { - $this->phpci->logFailure(Lang::get('could_not_find', 'behat')); + $this->builder->logFailure(Lang::get('could_not_find', 'behat')); return false; } - $success = $this->phpci->executeCommand($behat . ' %s', $this->features); + $success = $this->builder->executeCommand($behat . ' %s', $this->features); chdir($current_dir); list($errorCount, $data) = $this->parseBehatOutput(); @@ -81,7 +81,7 @@ class Behat extends Plugin */ public function parseBehatOutput() { - $output = $this->phpci->getLastOutput(); + $output = $this->builder->getLastOutput(); $parts = explode('---', $output); @@ -113,7 +113,7 @@ class Behat extends Plugin ]; $this->build->reportError( - $this->phpci, + $this->builder, 'behat', 'Behat scenario failed.', BuildError::SEVERITY_HIGH, diff --git a/src/PHPCensor/Plugin/Campfire.php b/src/PHPCensor/Plugin/Campfire.php index 1e4ac6c4..54242cb5 100644 --- a/src/PHPCensor/Plugin/Campfire.php +++ b/src/PHPCensor/Plugin/Campfire.php @@ -34,15 +34,15 @@ class Campfire extends Plugin /** * {@inheritdoc} */ - public function __construct(Builder $phpci, Build $build, array $options = []) + public function __construct(Builder $builder, Build $build, array $options = []) { - parent::__construct($phpci, $build, $options); + parent::__construct($builder, $build, $options); $this->message = $options['message']; $this->userAgent = "PHP Censor/1.0"; $this->cookie = "php-censor-cookie"; - $buildSettings = $this->phpci->getConfig('build_settings'); + $buildSettings = $this->builder->getConfig('build_settings'); if (isset($buildSettings['campfire'])) { $campfire = $buildSettings['campfire']; diff --git a/src/PHPCensor/Plugin/CleanBuild.php b/src/PHPCensor/Plugin/CleanBuild.php index 47e2aa68..b4b30af6 100644 --- a/src/PHPCensor/Plugin/CleanBuild.php +++ b/src/PHPCensor/Plugin/CleanBuild.php @@ -27,9 +27,9 @@ class CleanBuild extends Plugin /** * {@inheritdoc} */ - public function __construct(Builder $phpci, Build $build, array $options = []) + public function __construct(Builder $builder, Build $build, array $options = []) { - parent::__construct($phpci, $build, $options); + parent::__construct($builder, $build, $options); $this->remove = isset($options['remove']) && is_array($options['remove']) ? $options['remove'] : []; } @@ -43,13 +43,13 @@ class CleanBuild extends Plugin if (IS_WIN) { $cmd = 'rmdir /S /Q "%s"'; } - $this->phpci->executeCommand($cmd, $this->phpci->buildPath . 'composer.phar'); - $this->phpci->executeCommand($cmd, $this->phpci->buildPath . 'composer.lock'); + $this->builder->executeCommand($cmd, $this->builder->buildPath . 'composer.phar'); + $this->builder->executeCommand($cmd, $this->builder->buildPath . 'composer.lock'); $success = true; foreach ($this->remove as $file) { - $ok = $this->phpci->executeCommand($cmd, $this->phpci->buildPath . $file); + $ok = $this->builder->executeCommand($cmd, $this->builder->buildPath . $file); if (!$ok) { $success = false; diff --git a/src/PHPCensor/Plugin/Codeception.php b/src/PHPCensor/Plugin/Codeception.php index 106711c0..585c867f 100644 --- a/src/PHPCensor/Plugin/Codeception.php +++ b/src/PHPCensor/Plugin/Codeception.php @@ -43,14 +43,14 @@ class Codeception extends Plugin implements ZeroConfigPlugin /** * {@inheritdoc} */ - public function __construct(Builder $phpci, Build $build, array $options = []) + public function __construct(Builder $builder, Build $build, array $options = []) { - parent::__construct($phpci, $build, $options); + parent::__construct($builder, $build, $options); $this->path = 'tests' . DIRECTORY_SEPARATOR . '_output' . DIRECTORY_SEPARATOR; if (empty($options['config'])) { - $this->ymlConfigFile = self::findConfigFile($this->phpci->buildPath); + $this->ymlConfigFile = self::findConfigFile($this->builder->buildPath); } else { $this->ymlConfigFile = $options['config']; } @@ -112,12 +112,12 @@ class Codeception extends Plugin implements ZeroConfigPlugin */ protected function runConfigFile($configPath) { - $this->phpci->logExecOutput(false); + $this->builder->logExecOutput(false); - $codeception = $this->phpci->findBinary('codecept'); + $codeception = $this->builder->findBinary('codecept'); if (!$codeception) { - $this->phpci->logFailure(Lang::get('could_not_find', 'codecept')); + $this->builder->logFailure(Lang::get('could_not_find', 'codecept')); return false; } @@ -128,16 +128,16 @@ class Codeception extends Plugin implements ZeroConfigPlugin $cmd = 'cd /d "%s" && ' . $codeception . ' run -c "%s" --xml ' . $this->args; } - $configPath = $this->phpci->buildPath . $configPath; - $success = $this->phpci->executeCommand($cmd, $this->phpci->buildPath, $configPath); + $configPath = $this->builder->buildPath . $configPath; + $success = $this->builder->executeCommand($cmd, $this->builder->buildPath, $configPath); - $this->phpci->log( - 'Codeception XML path: '. $this->phpci->buildPath . $this->path . 'report.xml', + $this->builder->log( + 'Codeception XML path: '. $this->builder->buildPath . $this->path . 'report.xml', Loglevel::DEBUG ); - $xml = file_get_contents($this->phpci->buildPath . $this->path . 'report.xml', false); - $parser = new Parser($this->phpci, $xml); + $xml = file_get_contents($this->builder->buildPath . $this->path . 'report.xml', false); + $parser = new Parser($this->builder, $xml); $output = $parser->parse(); $meta = [ @@ -149,7 +149,7 @@ class Codeception extends Plugin implements ZeroConfigPlugin $this->build->storeMeta('codeception-meta', $meta); $this->build->storeMeta('codeception-data', $output); $this->build->storeMeta('codeception-errors', $parser->getTotalFailures()); - $this->phpci->logExecOutput(true); + $this->builder->logExecOutput(true); return $success; } diff --git a/src/PHPCensor/Plugin/Composer.php b/src/PHPCensor/Plugin/Composer.php index fad5a992..bd02aec4 100644 --- a/src/PHPCensor/Plugin/Composer.php +++ b/src/PHPCensor/Plugin/Composer.php @@ -33,11 +33,11 @@ class Composer extends Plugin implements ZeroConfigPlugin /** * {@inheritdoc} */ - public function __construct(Builder $phpci, Build $build, array $options = []) + public function __construct(Builder $builder, Build $build, array $options = []) { - parent::__construct($phpci, $build, $options); + parent::__construct($builder, $build, $options); - $path = $this->phpci->buildPath; + $path = $this->builder->buildPath; $this->directory = $path; $this->action = 'install'; $this->preferDist = false; @@ -94,7 +94,7 @@ class Composer extends Plugin implements ZeroConfigPlugin */ public function execute() { - $composerLocation = $this->phpci->findBinary(['composer', 'composer.phar']); + $composerLocation = $this->builder->findBinary(['composer', 'composer.phar']); $cmd = ''; @@ -105,27 +105,27 @@ class Composer extends Plugin implements ZeroConfigPlugin $cmd .= $composerLocation . ' --no-ansi --no-interaction '; if ($this->preferDist) { - $this->phpci->log('Using --prefer-dist flag'); + $this->builder->log('Using --prefer-dist flag'); $cmd .= ' --prefer-dist'; } if ($this->preferSource) { - $this->phpci->log('Using --prefer-source flag'); + $this->builder->log('Using --prefer-source flag'); $cmd .= ' --prefer-source'; } if ($this->nodev) { - $this->phpci->log('Using --no-dev flag'); + $this->builder->log('Using --no-dev flag'); $cmd .= ' --no-dev'; } if ($this->ignorePlatformReqs) { - $this->phpci->log('Using --ignore-platform-reqs flag'); + $this->builder->log('Using --ignore-platform-reqs flag'); $cmd .= ' --ignore-platform-reqs'; } $cmd .= ' --working-dir="%s" %s'; - return $this->phpci->executeCommand($cmd, $this->directory, $this->action); + return $this->builder->executeCommand($cmd, $this->directory, $this->action); } } diff --git a/src/PHPCensor/Plugin/CopyBuild.php b/src/PHPCensor/Plugin/CopyBuild.php index 44087de9..e36a9d8e 100644 --- a/src/PHPCensor/Plugin/CopyBuild.php +++ b/src/PHPCensor/Plugin/CopyBuild.php @@ -29,11 +29,11 @@ class CopyBuild extends Plugin /** * {@inheritdoc} */ - public function __construct(Builder $phpci, Build $build, array $options = []) + public function __construct(Builder $builder, Build $build, array $options = []) { - parent::__construct($phpci, $build, $options); + parent::__construct($builder, $build, $options); - $path = $this->phpci->buildPath; + $path = $this->builder->buildPath; $this->directory = isset($options['directory']) ? $options['directory'] : $path; $this->wipe = isset($options['wipe']) ? (bool)$options['wipe'] : false; $this->ignore = isset($options['respect_ignore']) ? (bool)$options['respect_ignore'] : false; @@ -44,7 +44,7 @@ class CopyBuild extends Plugin */ public function execute() { - $build = $this->phpci->buildPath; + $build = $this->builder->buildPath; if ($this->directory == $build) { return false; @@ -57,7 +57,7 @@ class CopyBuild extends Plugin $cmd = 'mkdir -p "%s" && xcopy /E "%s" "%s"'; } - $success = $this->phpci->executeCommand($cmd, $this->directory, $build, $this->directory); + $success = $this->builder->executeCommand($cmd, $this->directory, $build, $this->directory); $this->deleteIgnoredFiles(); @@ -72,7 +72,7 @@ class CopyBuild extends Plugin { if ($this->wipe === true && $this->directory != '/' && is_dir($this->directory)) { $cmd = 'rm -Rf "%s*"'; - $success = $this->phpci->executeCommand($cmd, $this->directory); + $success = $this->builder->executeCommand($cmd, $this->directory); if (!$success) { throw new \Exception(Lang::get('failed_to_wipe', $this->directory)); @@ -86,12 +86,12 @@ class CopyBuild extends Plugin protected function deleteIgnoredFiles() { if ($this->ignore) { - foreach ($this->phpci->ignore as $file) { + foreach ($this->builder->ignore as $file) { $cmd = 'rm -Rf "%s/%s"'; if (IS_WIN) { $cmd = 'rmdir /S /Q "%s\%s"'; } - $this->phpci->executeCommand($cmd, $this->directory, $file); + $this->builder->executeCommand($cmd, $this->directory, $file); } } } diff --git a/src/PHPCensor/Plugin/Deployer.php b/src/PHPCensor/Plugin/Deployer.php index 07391a55..31519936 100644 --- a/src/PHPCensor/Plugin/Deployer.php +++ b/src/PHPCensor/Plugin/Deployer.php @@ -29,9 +29,9 @@ class Deployer extends Plugin /** * {@inheritdoc} */ - public function __construct(Builder $phpci, Build $build, array $options = []) + public function __construct(Builder $builder, Build $build, array $options = []) { - parent::__construct($phpci, $build, $options); + parent::__construct($builder, $build, $options); $this->reason = 'PHP Censor Build #%BUILD% - %COMMIT_MESSAGE%'; if (isset($options['webhook_url'])) { @@ -51,17 +51,17 @@ class Deployer extends Plugin public function execute() { if (empty($this->webhookUrl)) { - $this->phpci->logFailure('You must specify a webhook URL.'); + $this->builder->logFailure('You must specify a webhook URL.'); return false; } $http = new HttpClient(); $response = $http->post($this->webhookUrl, [ - 'reason' => $this->phpci->interpolate($this->reason), + 'reason' => $this->builder->interpolate($this->reason), 'source' => 'PHP Censor', - 'url' => $this->phpci->interpolate('%BUILD_URI%'), - 'branch' => $this->phpci->interpolate('%BRANCH%'), + 'url' => $this->builder->interpolate('%BUILD_URI%'), + 'branch' => $this->builder->interpolate('%BRANCH%'), 'update_only' => $this->updateOnly ]); diff --git a/src/PHPCensor/Plugin/Email.php b/src/PHPCensor/Plugin/Email.php index b13e2116..74760480 100644 --- a/src/PHPCensor/Plugin/Email.php +++ b/src/PHPCensor/Plugin/Email.php @@ -46,7 +46,15 @@ class Email extends Plugin $buildStatus = $this->build->isSuccessful() ? "Passing Build" : "Failing Build"; $projectName = $this->build->getProject()->getTitle(); - $view = $this->getMailTemplate(); + try { + $view = $this->getMailTemplate(); + } catch (ViewRuntimeException $e) { + $this->builder->log( + sprintf('Unknown mail template "%s", falling back to default.', $this->options['template']), + LogLevel::WARNING + ); + $view = $this->getDefaultMailTemplate(); + } $view->build = $this->build; $view->project = $this->build->getProject(); @@ -64,8 +72,8 @@ class Email extends Plugin ); // This is a success if we've not failed to send anything. - $this->phpci->log(Lang::get('n_emails_sent', (count($addresses) - $sendFailures))); - $this->phpci->log(Lang::get('n_emails_failed', $sendFailures)); + $this->builder->log(Lang::get('n_emails_sent', (count($addresses) - $sendFailures))); + $this->builder->log(Lang::get('n_emails_failed', $sendFailures)); return ($sendFailures === 0); } @@ -93,7 +101,7 @@ class Email extends Plugin } } - return $email->send($this->phpci); + return $email->send($this->builder); } /** @@ -131,8 +139,8 @@ class Email extends Plugin $addresses = []; $committer = $this->build->getCommitterEmail(); - $this->phpci->logDebug(sprintf("Committer email: '%s'", $committer)); - $this->phpci->logDebug(sprintf( + $this->builder->logDebug(sprintf("Committer email: '%s'", $committer)); + $this->builder->logDebug(sprintf( "Committer option: '%s'", (!empty($this->options['committer']) && $this->options['committer']) ? 'true' : 'false' )); @@ -143,7 +151,7 @@ class Email extends Plugin } } - $this->phpci->logDebug(sprintf( + $this->builder->logDebug(sprintf( "Addresses option: '%s'", (!empty($this->options['addresses']) && is_array($this->options['addresses'])) ? implode(', ', $this->options['addresses']) : 'false' )); @@ -154,7 +162,7 @@ class Email extends Plugin } } - $this->phpci->logDebug(sprintf( + $this->builder->logDebug(sprintf( "Default mailTo option: '%s'", !empty($this->options['default_mailto_address']) ? $this->options['default_mailto_address'] : 'false' )); @@ -191,17 +199,8 @@ class Email extends Plugin */ protected function getMailTemplate() { - try { - if (isset($this->options['template'])) { - return new View('Email/' . $this->options['template']); - } - } catch (ViewRuntimeException $e) { - $this->phpci->log( - sprintf('Unknown mail template "%s", falling back to default.', $this->options['template']), - LogLevel::WARNING - ); - - return $this->getDefaultMailTemplate(); + if (isset($this->options['template'])) { + return new View('Email/' . $this->options['template']); } return $this->getDefaultMailTemplate(); diff --git a/src/PHPCensor/Plugin/Env.php b/src/PHPCensor/Plugin/Env.php index b623419c..5619ded2 100644 --- a/src/PHPCensor/Plugin/Env.php +++ b/src/PHPCensor/Plugin/Env.php @@ -39,9 +39,9 @@ class Env extends Plugin $env_var = "$key=$value"; } - if (!putenv($this->phpci->interpolate($env_var))) { + if (!putenv($this->builder->interpolate($env_var))) { $success = false; - $this->phpci->logFailure(Lang::get('unable_to_set_env')); + $this->builder->logFailure(Lang::get('unable_to_set_env')); } } return $success; diff --git a/src/PHPCensor/Plugin/FlowdockNotify.php b/src/PHPCensor/Plugin/FlowdockNotify.php index 98c365e2..0ff09906 100644 --- a/src/PHPCensor/Plugin/FlowdockNotify.php +++ b/src/PHPCensor/Plugin/FlowdockNotify.php @@ -32,9 +32,9 @@ class FlowdockNotify extends Plugin /** * {@inheritdoc} */ - public function __construct(Builder $phpci, Build $build, array $options = []) + public function __construct(Builder $builder, Build $build, array $options = []) { - parent::__construct($phpci, $build, $options); + parent::__construct($builder, $build, $options); if (!is_array($options) || !isset($options['api_key'])) { throw new \Exception('Please define the api_key for Flowdock Notify plugin!'); @@ -52,7 +52,7 @@ class FlowdockNotify extends Plugin public function execute() { - $message = $this->phpci->interpolate($this->message); + $message = $this->builder->interpolate($this->message); $successfulBuild = $this->build->isSuccessful() ? 'Success' : 'Failed'; $push = new Push($this->api_key); $flowMessage = TeamInboxMessage::create() diff --git a/src/PHPCensor/Plugin/Git.php b/src/PHPCensor/Plugin/Git.php index 848d8861..df9a9b03 100644 --- a/src/PHPCensor/Plugin/Git.php +++ b/src/PHPCensor/Plugin/Git.php @@ -30,7 +30,7 @@ class Git extends Plugin */ public function execute() { - $buildPath = $this->phpci->buildPath; + $buildPath = $this->builder->buildPath; // Check if there are any actions to be run for the branch we're running on: if (!array_key_exists($this->build->getBranch(), $this->actions)) { @@ -89,8 +89,8 @@ class Git extends Plugin { if (array_key_exists('branch', $options)) { $cmd = 'cd "%s" && git checkout %s && git merge "%s"'; - $path = $this->phpci->buildPath; - return $this->phpci->executeCommand($cmd, $path, $options['branch'], $this->build->getBranch()); + $path = $this->builder->buildPath; + return $this->builder->executeCommand($cmd, $path, $options['branch'], $this->build->getBranch()); } } @@ -105,15 +105,15 @@ class Git extends Plugin $message = Lang::get('tag_created', date('Y-m-d H:i:s')); if (array_key_exists('name', $options)) { - $tagName = $this->phpci->interpolate($options['name']); + $tagName = $this->builder->interpolate($options['name']); } if (array_key_exists('message', $options)) { - $message = $this->phpci->interpolate($options['message']); + $message = $this->builder->interpolate($options['message']); } $cmd = 'git tag %s -m "%s"'; - return $this->phpci->executeCommand($cmd, $tagName, $message); + return $this->builder->executeCommand($cmd, $tagName, $message); } /** @@ -127,14 +127,14 @@ class Git extends Plugin $remote = 'origin'; if (array_key_exists('branch', $options)) { - $branch = $this->phpci->interpolate($options['branch']); + $branch = $this->builder->interpolate($options['branch']); } if (array_key_exists('remote', $options)) { - $remote = $this->phpci->interpolate($options['remote']); + $remote = $this->builder->interpolate($options['remote']); } - return $this->phpci->executeCommand('git pull %s %s', $remote, $branch); + return $this->builder->executeCommand('git pull %s %s', $remote, $branch); } /** @@ -148,13 +148,13 @@ class Git extends Plugin $remote = 'origin'; if (array_key_exists('branch', $options)) { - $branch = $this->phpci->interpolate($options['branch']); + $branch = $this->builder->interpolate($options['branch']); } if (array_key_exists('remote', $options)) { - $remote = $this->phpci->interpolate($options['remote']); + $remote = $this->builder->interpolate($options['remote']); } - return $this->phpci->executeCommand('git push %s %s', $remote, $branch); + return $this->builder->executeCommand('git push %s %s', $remote, $branch); } } diff --git a/src/PHPCensor/Plugin/Grunt.php b/src/PHPCensor/Plugin/Grunt.php index f7e49a85..63d883dc 100644 --- a/src/PHPCensor/Plugin/Grunt.php +++ b/src/PHPCensor/Plugin/Grunt.php @@ -30,14 +30,14 @@ class Grunt extends Plugin /** * {@inheritdoc} */ - public function __construct(Builder $phpci, Build $build, array $options = []) + public function __construct(Builder $builder, Build $build, array $options = []) { - parent::__construct($phpci, $build, $options); + parent::__construct($builder, $build, $options); - $path = $this->phpci->buildPath; + $path = $this->builder->buildPath; $this->directory = $path; $this->task = null; - $this->grunt = $this->phpci->findBinary('grunt'); + $this->grunt = $this->builder->findBinary('grunt'); $this->gruntfile = 'Gruntfile.js'; // Handle options: @@ -68,7 +68,7 @@ class Grunt extends Plugin if (IS_WIN) { $cmd = 'cd /d %s && npm install'; } - if (!$this->phpci->executeCommand($cmd, $this->directory)) { + if (!$this->builder->executeCommand($cmd, $this->directory)) { return false; } @@ -82,6 +82,6 @@ class Grunt extends Plugin $cmd .= ' %s'; // the task that will be executed // and execute it - return $this->phpci->executeCommand($cmd, $this->directory, $this->gruntfile, $this->task); + return $this->builder->executeCommand($cmd, $this->directory, $this->gruntfile, $this->task); } } diff --git a/src/PHPCensor/Plugin/Gulp.php b/src/PHPCensor/Plugin/Gulp.php index 2ea6665b..b0058df6 100644 --- a/src/PHPCensor/Plugin/Gulp.php +++ b/src/PHPCensor/Plugin/Gulp.php @@ -30,14 +30,14 @@ class Gulp extends Plugin /** * {@inheritdoc} */ - public function __construct(Builder $phpci, Build $build, array $options = []) + public function __construct(Builder $builder, Build $build, array $options = []) { - parent::__construct($phpci, $build, $options); + parent::__construct($builder, $build, $options); - $path = $this->phpci->buildPath; + $path = $this->builder->buildPath; $this->directory = $path; $this->task = null; - $this->gulp = $this->phpci->findBinary('gulp'); + $this->gulp = $this->builder->findBinary('gulp'); $this->gulpfile = 'gulpfile.js'; // Handle options: @@ -68,7 +68,7 @@ class Gulp extends Plugin if (IS_WIN) { $cmd = 'cd /d %s && npm install'; } - if (!$this->phpci->executeCommand($cmd, $this->directory)) { + if (!$this->builder->executeCommand($cmd, $this->directory)) { return false; } @@ -82,6 +82,6 @@ class Gulp extends Plugin $cmd .= ' %s'; // the task that will be executed // and execute it - return $this->phpci->executeCommand($cmd, $this->directory, $this->gulpfile, $this->task); + return $this->builder->executeCommand($cmd, $this->directory, $this->gulpfile, $this->task); } } diff --git a/src/PHPCensor/Plugin/HipchatNotify.php b/src/PHPCensor/Plugin/HipchatNotify.php index 21196bf4..27a43556 100644 --- a/src/PHPCensor/Plugin/HipchatNotify.php +++ b/src/PHPCensor/Plugin/HipchatNotify.php @@ -34,9 +34,9 @@ class HipchatNotify extends Plugin /** * {@inheritdoc} */ - public function __construct(Builder $phpci, Build $build, array $options = []) + public function __construct(Builder $builder, Build $build, array $options = []) { - parent::__construct($phpci, $build, $options); + parent::__construct($builder, $build, $options); $this->userAgent = "PHP Censor/1.0"; $this->cookie = "php-censor-cookie"; @@ -74,7 +74,7 @@ class HipchatNotify extends Plugin public function execute() { $hipChat = new HipChat($this->authToken); - $message = $this->phpci->interpolate($this->message); + $message = $this->builder->interpolate($this->message); $result = true; if (is_array($this->room)) { diff --git a/src/PHPCensor/Plugin/Irc.php b/src/PHPCensor/Plugin/Irc.php index 4887793d..6aa3ee65 100644 --- a/src/PHPCensor/Plugin/Irc.php +++ b/src/PHPCensor/Plugin/Irc.php @@ -31,12 +31,12 @@ class Irc extends Plugin /** * {@inheritdoc} */ - public function __construct(Builder $phpci, Build $build, array $options = []) + public function __construct(Builder $builder, Build $build, array $options = []) { - parent::__construct($phpci, $build, $options); + parent::__construct($builder, $build, $options); $this->message = $options['message']; - $buildSettings = $this->phpci->getConfig('build_settings'); + $buildSettings = $this->builder->getConfig('build_settings'); if (isset($buildSettings['irc'])) { $irc = $buildSettings['irc']; @@ -54,10 +54,10 @@ class Irc extends Plugin */ public function execute() { - $msg = $this->phpci->interpolate($this->message); + $msg = $this->builder->interpolate($this->message); if (empty($this->server) || empty($this->room) || empty($this->nick)) { - $this->phpci->logFailure(Lang::get('irc_settings')); + $this->builder->logFailure(Lang::get('irc_settings')); } if (empty($this->port)) { diff --git a/src/PHPCensor/Plugin/Lint.php b/src/PHPCensor/Plugin/Lint.php index 71a0dd17..e659e78e 100644 --- a/src/PHPCensor/Plugin/Lint.php +++ b/src/PHPCensor/Plugin/Lint.php @@ -29,12 +29,12 @@ class Lint extends Plugin /** * {@inheritdoc} */ - public function __construct(Builder $phpci, Build $build, array $options = []) + public function __construct(Builder $builder, Build $build, array $options = []) { - parent::__construct($phpci, $build, $options); + parent::__construct($builder, $build, $options); $this->directories = ['']; - $this->ignore = $this->phpci->ignore; + $this->ignore = $this->builder->ignore; if (!empty($options['directory'])) { $this->directories[] = $options['directory']; @@ -54,10 +54,10 @@ class Lint extends Plugin */ public function execute() { - $this->phpci->quiet = true; + $this->builder->quiet = true; $success = true; - $php = $this->phpci->findBinary('php'); + $php = $this->builder->findBinary('php'); foreach ($this->directories as $dir) { if (!$this->lintDirectory($php, $dir)) { @@ -65,7 +65,7 @@ class Lint extends Plugin } } - $this->phpci->quiet = false; + $this->builder->quiet = false; return $success; } @@ -99,7 +99,7 @@ class Lint extends Plugin protected function lintDirectory($php, $path) { $success = true; - $directory = new \DirectoryIterator($this->phpci->buildPath . $path); + $directory = new \DirectoryIterator($this->builder->buildPath . $path); foreach ($directory as $item) { if ($item->isDot()) { @@ -130,8 +130,8 @@ class Lint extends Plugin { $success = true; - if (!$this->phpci->executeCommand($php . ' -l "%s"', $this->phpci->buildPath . $path)) { - $this->phpci->logFailure($path); + if (!$this->builder->executeCommand($php . ' -l "%s"', $this->builder->buildPath . $path)) { + $this->builder->logFailure($path); $success = false; } diff --git a/src/PHPCensor/Plugin/Mysql.php b/src/PHPCensor/Plugin/Mysql.php index 130141c4..d53b7878 100644 --- a/src/PHPCensor/Plugin/Mysql.php +++ b/src/PHPCensor/Plugin/Mysql.php @@ -43,9 +43,9 @@ class Mysql extends Plugin /** * {@inheritdoc} */ - public function __construct(Builder $phpci, Build $build, array $options = []) + public function __construct(Builder $builder, Build $build, array $options = []) { - parent::__construct($phpci, $build, $options); + parent::__construct($builder, $build, $options); $config = Database::getConnection('write')->getDetails(); @@ -53,18 +53,18 @@ class Mysql extends Plugin $this->user = $config['user']; $this->pass = $config['pass']; - $buildSettings = $this->phpci->getConfig('build_settings'); + $buildSettings = $this->builder->getConfig('build_settings'); if (!isset($buildSettings['mysql'])) { return; } if (!empty($buildSettings['mysql']['host'])) { - $this->host = $this->phpci->interpolate($buildSettings['mysql']['host']); + $this->host = $this->builder->interpolate($buildSettings['mysql']['host']); } if (!empty($buildSettings['mysql']['user'])) { - $this->user = $this->phpci->interpolate($buildSettings['mysql']['user']); + $this->user = $this->builder->interpolate($buildSettings['mysql']['user']); } if (array_key_exists('pass', $buildSettings['mysql'])) { @@ -85,7 +85,7 @@ class Mysql extends Plugin foreach ($this->options as $query) { if (!is_array($query)) { // Simple query - $pdo->query($this->phpci->interpolate($query)); + $pdo->query($this->builder->interpolate($query)); } elseif (isset($query['import'])) { // SQL file execution $this->executeFile($query['import']); @@ -94,7 +94,7 @@ class Mysql extends Plugin } } } catch (\Exception $ex) { - $this->phpci->logFailure($ex->getMessage()); + $this->builder->logFailure($ex->getMessage()); return false; } return true; @@ -111,15 +111,15 @@ class Mysql extends Plugin throw new \Exception(Lang::get('import_file_key')); } - $import_file = $this->phpci->buildPath . $this->phpci->interpolate($query['file']); + $import_file = $this->builder->buildPath . $this->builder->interpolate($query['file']); if (!is_readable($import_file)) { throw new \Exception(Lang::get('cannot_open_import', $import_file)); } - $database = isset($query['database']) ? $this->phpci->interpolate($query['database']) : null; + $database = isset($query['database']) ? $this->builder->interpolate($query['database']) : null; $import_command = $this->getImportCommand($import_file, $database); - if (!$this->phpci->executeCommand($import_command)) { + if (!$this->builder->executeCommand($import_command)) { throw new \Exception(Lang::get('unable_to_execute')); } diff --git a/src/PHPCensor/Plugin/PackageBuild.php b/src/PHPCensor/Plugin/PackageBuild.php index 5965d714..b25cd359 100644 --- a/src/PHPCensor/Plugin/PackageBuild.php +++ b/src/PHPCensor/Plugin/PackageBuild.php @@ -28,11 +28,11 @@ class PackageBuild extends Plugin /** * {@inheritdoc} */ - public function __construct(Builder $phpci, Build $build, array $options = []) + public function __construct(Builder $builder, Build $build, array $options = []) { - parent::__construct($phpci, $build, $options); + parent::__construct($builder, $build, $options); - $path = $this->phpci->buildPath; + $path = $this->builder->buildPath; $this->directory = isset($options['directory']) ? $options['directory'] : $path; $this->filename = isset($options['filename']) ? $options['filename'] : 'build'; $this->format = isset($options['format']) ? $options['format'] : 'zip'; @@ -43,7 +43,7 @@ class PackageBuild extends Plugin */ public function execute() { - $path = $this->phpci->buildPath; + $path = $this->builder->buildPath; $build = $this->build; if ($this->directory == $path) { @@ -59,7 +59,7 @@ class PackageBuild extends Plugin $filename = preg_replace('/([^a-zA-Z0-9_-]+)/', '', $filename); $curdir = getcwd(); - chdir($this->phpci->buildPath); + chdir($this->builder->buildPath); if (!is_array($this->format)) { $this->format = [$this->format]; @@ -76,7 +76,7 @@ class PackageBuild extends Plugin break; } - $success = $this->phpci->executeCommand($cmd, $this->directory, $filename); + $success = $this->builder->executeCommand($cmd, $this->directory, $filename); } chdir($curdir); diff --git a/src/PHPCensor/Plugin/Pdepend.php b/src/PHPCensor/Plugin/Pdepend.php index 43480ab1..365f00da 100644 --- a/src/PHPCensor/Plugin/Pdepend.php +++ b/src/PHPCensor/Plugin/Pdepend.php @@ -52,17 +52,17 @@ class Pdepend extends Plugin /** * {@inheritdoc} */ - public function __construct(Builder $phpci, Build $build, array $options = []) + public function __construct(Builder $builder, Build $build, array $options = []) { - parent::__construct($phpci, $build, $options); + parent::__construct($builder, $build, $options); - $this->directory = isset($options['directory']) ? $options['directory'] : $this->phpci->buildPath; + $this->directory = isset($options['directory']) ? $options['directory'] : $this->builder->buildPath; - $title = $this->phpci->getBuildProjectTitle(); + $title = $this->builder->getBuildProjectTitle(); $this->summary = $title . '-summary.xml'; $this->pyramid = $title . '-pyramid.svg'; $this->chart = $title . '-chart.svg'; - $this->location = $this->phpci->buildPath . '..' . DIRECTORY_SEPARATOR . 'pdepend'; + $this->location = $this->builder->buildPath . '..' . DIRECTORY_SEPARATOR . 'pdepend'; } /** @@ -77,20 +77,20 @@ class Pdepend extends Plugin throw new \Exception(sprintf('The location %s is not writable or does not exist.', $this->location)); } - $pdepend = $this->phpci->findBinary('pdepend'); + $pdepend = $this->builder->findBinary('pdepend'); $cmd = $pdepend . ' --summary-xml="%s" --jdepend-chart="%s" --overview-pyramid="%s" %s "%s"'; $this->removeBuildArtifacts(); // If we need to ignore directories - if (count($this->phpci->ignore)) { - $ignore = ' --ignore=' . implode(',', $this->phpci->ignore); + if (count($this->builder->ignore)) { + $ignore = ' --ignore=' . implode(',', $this->builder->ignore); } else { $ignore = ''; } - $success = $this->phpci->executeCommand( + $success = $this->builder->executeCommand( $cmd, $this->location . DIRECTORY_SEPARATOR . $this->summary, $this->location . DIRECTORY_SEPARATOR . $this->chart, @@ -99,10 +99,10 @@ class Pdepend extends Plugin $this->directory ); - $config = $this->phpci->getSystemConfig('php-censor'); + $config = $this->builder->getSystemConfig('php-censor'); if ($success) { - $this->phpci->logSuccess( + $this->builder->logSuccess( sprintf( "Pdepend successful. You can use %s\n, ![Chart](%s \"Pdepend Chart\")\n and ![Pyramid](%s \"Pdepend Pyramid\")\n diff --git a/src/PHPCensor/Plugin/Pgsql.php b/src/PHPCensor/Plugin/Pgsql.php index f527f21d..fdaa11e6 100644 --- a/src/PHPCensor/Plugin/Pgsql.php +++ b/src/PHPCensor/Plugin/Pgsql.php @@ -40,11 +40,11 @@ class Pgsql extends Plugin /** * {@inheritdoc} */ - public function __construct(Builder $phpci, Build $build, array $options = []) + public function __construct(Builder $builder, Build $build, array $options = []) { - parent::__construct($phpci, $build, $options); + parent::__construct($builder, $build, $options); - $buildSettings = $this->phpci->getConfig('build_settings'); + $buildSettings = $this->builder->getConfig('build_settings'); if (isset($buildSettings['pgsql'])) { $sql = $buildSettings['pgsql']; @@ -65,10 +65,10 @@ class Pgsql extends Plugin $pdo = new PDO('pgsql:host=' . $this->host, $this->user, $this->pass, $opts); foreach ($this->options as $query) { - $pdo->query($this->phpci->interpolate($query)); + $pdo->query($this->builder->interpolate($query)); } } catch (\Exception $ex) { - $this->phpci->logFailure($ex->getMessage()); + $this->builder->logFailure($ex->getMessage()); return false; } return true; diff --git a/src/PHPCensor/Plugin/Phar.php b/src/PHPCensor/Plugin/Phar.php index 4502c0a8..0a8bafd0 100644 --- a/src/PHPCensor/Plugin/Phar.php +++ b/src/PHPCensor/Plugin/Phar.php @@ -41,9 +41,9 @@ class Phar extends Plugin /** * {@inheritdoc} */ - public function __construct(Builder $phpci, Build $build, array $options = []) + public function __construct(Builder $builder, Build $build, array $options = []) { - parent::__construct($phpci, $build, $options); + parent::__construct($builder, $build, $options); // Directory? if (isset($options['directory'])) { @@ -86,7 +86,7 @@ class Phar extends Plugin public function getDirectory() { if (!isset($this->directory)) { - $this->setDirectory($this->phpci->buildPath); + $this->setDirectory($this->builder->buildPath); } return $this->directory; } @@ -172,7 +172,7 @@ class Phar extends Plugin $content = ''; $filename = $this->getStub(); if ($filename) { - $content = file_get_contents($this->phpci->buildPath . DIRECTORY_SEPARATOR . $this->getStub()); + $content = file_get_contents($this->builder->buildPath . DIRECTORY_SEPARATOR . $this->getStub()); } return $content; } @@ -188,7 +188,7 @@ class Phar extends Plugin try { $file = $this->getDirectory() . DIRECTORY_SEPARATOR . $this->getFilename(); $phar = new PHPPhar($file, 0, $this->getFilename()); - $phar->buildFromDirectory($this->phpci->buildPath, $this->getRegExp()); + $phar->buildFromDirectory($this->builder->buildPath, $this->getRegExp()); $stub = $this->getStubContent(); if ($stub) { @@ -197,8 +197,8 @@ class Phar extends Plugin $success = true; } catch (Exception $e) { - $this->phpci->log(Lang::get('phar_internal_error')); - $this->phpci->log($e->getMessage()); + $this->builder->log(Lang::get('phar_internal_error')); + $this->builder->log($e->getMessage()); } return $success; diff --git a/src/PHPCensor/Plugin/Phing.php b/src/PHPCensor/Plugin/Phing.php index 82ac794e..bf082320 100644 --- a/src/PHPCensor/Plugin/Phing.php +++ b/src/PHPCensor/Plugin/Phing.php @@ -33,17 +33,17 @@ class Phing extends Plugin /** * {@inheritdoc} */ - public function __construct(Builder $phpci, Build $build, array $options = []) + public function __construct(Builder $builder, Build $build, array $options = []) { - parent::__construct($phpci, $build, $options); + parent::__construct($builder, $build, $options); /* * Set working directory */ if (isset($options['directory'])) { - $directory = $this->phpci->buildPath . DIRECTORY_SEPARATOR . $options['directory']; + $directory = $this->builder->buildPath . DIRECTORY_SEPARATOR . $options['directory']; } else { - $directory = $this->phpci->buildPath; + $directory = $this->builder->buildPath; } $this->setDirectory($directory); @@ -73,7 +73,7 @@ class Phing extends Plugin */ public function execute() { - $phingExecutable = $this->phpci->findBinary('phing'); + $phingExecutable = $this->builder->findBinary('phing'); $cmd[] = $phingExecutable . ' -f ' . $this->getBuildFilePath(); @@ -87,7 +87,7 @@ class Phing extends Plugin $cmd[] = $this->targetsToString(); $cmd[] = '2>&1'; - return $this->phpci->executeCommand(implode(' ', $cmd), $this->directory, $this->targets); + return $this->builder->executeCommand(implode(' ', $cmd), $this->directory, $this->targets); } /** diff --git a/src/PHPCensor/Plugin/PhpCodeSniffer.php b/src/PHPCensor/Plugin/PhpCodeSniffer.php index 2557ac7e..74f40d23 100644 --- a/src/PHPCensor/Plugin/PhpCodeSniffer.php +++ b/src/PHPCensor/Plugin/PhpCodeSniffer.php @@ -73,17 +73,17 @@ class PhpCodeSniffer extends Plugin implements ZeroConfigPlugin /** * {@inheritdoc} */ - public function __construct(Builder $phpci, Build $build, array $options = []) + public function __construct(Builder $builder, Build $build, array $options = []) { - parent::__construct($phpci, $build, $options); + parent::__construct($builder, $build, $options); $this->suffixes = ['php']; - $this->directory = $this->phpci->buildPath; + $this->directory = $this->builder->buildPath; $this->standard = 'PSR2'; $this->tab_width = ''; $this->encoding = ''; $this->path = ''; - $this->ignore = $this->phpci->ignore; + $this->ignore = $this->builder->ignore; $this->allowed_warnings = 0; $this->allowed_errors = 0; @@ -128,25 +128,25 @@ class PhpCodeSniffer extends Plugin implements ZeroConfigPlugin { list($ignore, $standard, $suffixes) = $this->getFlags(); - $phpcs = $this->phpci->findBinary('phpcs'); + $phpcs = $this->builder->findBinary('phpcs'); - $this->phpci->logExecOutput(false); + $this->builder->logExecOutput(false); $cmd = $phpcs . ' --report=json %s %s %s %s %s "%s"'; - $this->phpci->executeCommand( + $this->builder->executeCommand( $cmd, $standard, $suffixes, $ignore, $this->tab_width, $this->encoding, - $this->phpci->buildPath . $this->path + $this->builder->buildPath . $this->path ); - $output = $this->phpci->getLastOutput(); + $output = $this->builder->getLastOutput(); list($errors, $warnings) = $this->processReport($output); - $this->phpci->logExecOutput(true); + $this->builder->logExecOutput(true); $success = true; $this->build->storeMeta('phpcs-warnings', $warnings); @@ -199,7 +199,7 @@ class PhpCodeSniffer extends Plugin implements ZeroConfigPlugin $data = json_decode(trim($output), true); if (!is_array($data)) { - $this->phpci->log($output); + $this->builder->log($output); throw new \Exception(PHPCensor\Helper\Lang::get('could_not_process_report')); } @@ -207,11 +207,11 @@ class PhpCodeSniffer extends Plugin implements ZeroConfigPlugin $warnings = $data['totals']['warnings']; foreach ($data['files'] as $fileName => $file) { - $fileName = str_replace($this->phpci->buildPath, '', $fileName); + $fileName = str_replace($this->builder->buildPath, '', $fileName); foreach ($file['messages'] as $message) { $this->build->reportError( - $this->phpci, + $this->builder, 'php_code_sniffer', 'PHPCS: ' . $message['message'], $message['type'] == 'ERROR' ? BuildError::SEVERITY_HIGH : BuildError::SEVERITY_LOW, diff --git a/src/PHPCensor/Plugin/PhpCpd.php b/src/PHPCensor/Plugin/PhpCpd.php index 3b77fa68..b9e0e49c 100644 --- a/src/PHPCensor/Plugin/PhpCpd.php +++ b/src/PHPCensor/Plugin/PhpCpd.php @@ -40,17 +40,17 @@ class PhpCpd extends Plugin /** * {@inheritdoc} */ - public function __construct(Builder $phpci, Build $build, array $options = []) + public function __construct(Builder $builder, Build $build, array $options = []) { - parent::__construct($phpci, $build, $options); + parent::__construct($builder, $build, $options); - $this->path = $this->phpci->buildPath; - $this->ignore = $this->phpci->ignore; + $this->path = $this->builder->buildPath; + $this->ignore = $this->builder->ignore; if (!empty($options['path'])) { - $this->path = $this->phpci->buildPath . $options['path']; + $this->path = $this->builder->buildPath . $options['path']; } - + if (!empty($options['ignore'])) { $this->ignore = $options['ignore']; } @@ -79,14 +79,14 @@ class PhpCpd extends Plugin $ignore = implode('', $ignore); } - $phpcpd = $this->phpci->findBinary('phpcpd'); + $phpcpd = $this->builder->findBinary('phpcpd'); $tmpfilename = tempnam('/tmp', 'phpcpd'); $cmd = $phpcpd . ' --log-pmd "%s" %s "%s"'; - $success = $this->phpci->executeCommand($cmd, $tmpfilename, $ignore, $this->path); + $success = $this->builder->executeCommand($cmd, $tmpfilename, $ignore, $this->path); - print $this->phpci->getLastOutput(); + print $this->builder->getLastOutput(); $errorCount = $this->processReport(file_get_contents($tmpfilename)); $this->build->storeMeta('phpcpd-warnings', $errorCount); @@ -107,7 +107,7 @@ class PhpCpd extends Plugin $xml = simplexml_load_string($xmlString); if ($xml === false) { - $this->phpci->log($xmlString); + $this->builder->log($xmlString); throw new \Exception(Lang::get('could_not_process_report')); } @@ -115,7 +115,7 @@ class PhpCpd extends Plugin foreach ($xml->duplication as $duplication) { foreach ($duplication->file as $file) { $fileName = (string)$file['path']; - $fileName = str_replace($this->phpci->buildPath, '', $fileName); + $fileName = str_replace($this->builder->buildPath, '', $fileName); $message = <<build->reportError( - $this->phpci, + $this->builder, 'php_cpd', $message, BuildError::SEVERITY_NORMAL, diff --git a/src/PHPCensor/Plugin/PhpCsFixer.php b/src/PHPCensor/Plugin/PhpCsFixer.php index c317db34..2f51618c 100644 --- a/src/PHPCensor/Plugin/PhpCsFixer.php +++ b/src/PHPCensor/Plugin/PhpCsFixer.php @@ -30,11 +30,11 @@ class PhpCsFixer extends Plugin /** * {@inheritdoc} */ - public function __construct(Builder $phpci, Build $build, array $options = []) + public function __construct(Builder $builder, Build $build, array $options = []) { - parent::__construct($phpci, $build, $options); + parent::__construct($builder, $build, $options); - $this->workingDir = $this->phpci->buildPath; + $this->workingDir = $this->builder->buildPath; $this->buildArgs($options); } @@ -47,10 +47,10 @@ class PhpCsFixer extends Plugin $curdir = getcwd(); chdir($this->workingDir); - $phpcsfixer = $this->phpci->findBinary('php-cs-fixer'); + $phpcsfixer = $this->builder->findBinary('php-cs-fixer'); $cmd = $phpcsfixer . ' fix . %s %s %s'; - $success = $this->phpci->executeCommand($cmd, $this->verbose, $this->diff, $this->level); + $success = $this->builder->executeCommand($cmd, $this->verbose, $this->diff, $this->level); chdir($curdir); @@ -76,7 +76,7 @@ class PhpCsFixer extends Plugin } if (isset($options['workingdir']) && $options['workingdir']) { - $this->workingDir = $this->phpci->buildPath . $options['workingdir']; + $this->workingDir = $this->builder->buildPath . $options['workingdir']; } } diff --git a/src/PHPCensor/Plugin/PhpDocblockChecker.php b/src/PHPCensor/Plugin/PhpDocblockChecker.php index b4711749..96d69272 100644 --- a/src/PHPCensor/Plugin/PhpDocblockChecker.php +++ b/src/PHPCensor/Plugin/PhpDocblockChecker.php @@ -41,11 +41,11 @@ class PhpDocblockChecker extends Plugin implements ZeroConfigPlugin /** * {@inheritdoc} */ - public function __construct(Builder $phpci, Build $build, array $options = []) + public function __construct(Builder $builder, Build $build, array $options = []) { - parent::__construct($phpci, $build, $options); + parent::__construct($builder, $build, $options); - $this->ignore = $this->phpci->ignore; + $this->ignore = $this->builder->ignore; $this->path = ''; $this->allowed_warnings = 0; @@ -92,7 +92,7 @@ class PhpDocblockChecker extends Plugin implements ZeroConfigPlugin public function execute() { // Check that the binary exists: - $checker = $this->phpci->findBinary('phpdoccheck'); + $checker = $this->builder->findBinary('phpdoccheck'); // Build ignore string: $ignore = ''; @@ -111,14 +111,14 @@ class PhpDocblockChecker extends Plugin implements ZeroConfigPlugin } // Build command string: - $path = $this->phpci->buildPath . $this->path; + $path = $this->builder->buildPath . $this->path; $cmd = $checker . ' --json --directory="%s"%s%s'; // Disable exec output logging, as we don't want the XML report in the log: - $this->phpci->logExecOutput(false); + $this->builder->logExecOutput(false); // Run checker: - $this->phpci->executeCommand( + $this->builder->executeCommand( $cmd, $path, $ignore, @@ -126,9 +126,9 @@ class PhpDocblockChecker extends Plugin implements ZeroConfigPlugin ); // Re-enable exec output logging: - $this->phpci->logExecOutput(true); + $this->builder->logExecOutput(true); - $output = json_decode($this->phpci->getLastOutput(), true); + $output = json_decode($this->builder->getLastOutput(), true); $errors = count($output); $success = true; @@ -158,7 +158,7 @@ class PhpDocblockChecker extends Plugin implements ZeroConfigPlugin } $this->build->reportError( - $this->phpci, + $this->builder, 'php_docblock_checker', $message, $severity, diff --git a/src/PHPCensor/Plugin/PhpLoc.php b/src/PHPCensor/Plugin/PhpLoc.php index 8a1dcd1d..69317d76 100644 --- a/src/PHPCensor/Plugin/PhpLoc.php +++ b/src/PHPCensor/Plugin/PhpLoc.php @@ -47,11 +47,11 @@ class PhpLoc extends Plugin implements ZeroConfigPlugin /** * {@inheritdoc} */ - public function __construct(Builder $phpci, Build $build, array $options = []) + public function __construct(Builder $builder, Build $build, array $options = []) { - parent::__construct($phpci, $build, $options); + parent::__construct($builder, $build, $options); - $this->directory = $this->phpci->buildPath; + $this->directory = $this->builder->buildPath; if (isset($options['directory'])) { $this->directory .= $options['directory']; @@ -65,19 +65,19 @@ class PhpLoc extends Plugin implements ZeroConfigPlugin { $ignore = ''; - if (count($this->phpci->ignore)) { + if (count($this->builder->ignore)) { $map = function ($item) { return ' --exclude ' . rtrim($item, DIRECTORY_SEPARATOR); }; - $ignore = array_map($map, $this->phpci->ignore); + $ignore = array_map($map, $this->builder->ignore); $ignore = implode('', $ignore); } - $phploc = $this->phpci->findBinary('phploc'); + $phploc = $this->builder->findBinary('phploc'); - $success = $this->phpci->executeCommand($phploc . ' %s "%s"', $ignore, $this->directory); - $output = $this->phpci->getLastOutput(); + $success = $this->builder->executeCommand($phploc . ' %s "%s"', $ignore, $this->directory); + $output = $this->builder->getLastOutput(); if (preg_match_all('/\((LOC|CLOC|NCLOC|LLOC)\)\s+([0-9]+)/', $output, $matches)) { $data = []; diff --git a/src/PHPCensor/Plugin/PhpMessDetector.php b/src/PHPCensor/Plugin/PhpMessDetector.php index 11f55ff3..40894864 100644 --- a/src/PHPCensor/Plugin/PhpMessDetector.php +++ b/src/PHPCensor/Plugin/PhpMessDetector.php @@ -51,12 +51,12 @@ class PhpMessDetector extends Plugin implements ZeroConfigPlugin /** * {@inheritdoc} */ - public function __construct(Builder $phpci, Build $build, array $options = []) + public function __construct(Builder $builder, Build $build, array $options = []) { - parent::__construct($phpci, $build, $options); + parent::__construct($builder, $build, $options); $this->suffixes = ['php']; - $this->ignore = $this->phpci->ignore; + $this->ignore = $this->builder->ignore; $this->path = ''; $this->rules = ['codesize', 'unusedcode', 'naming']; $this->allowed_warnings = 0; @@ -103,11 +103,11 @@ class PhpMessDetector extends Plugin implements ZeroConfigPlugin return false; } - $phpmdBinaryPath = $this->phpci->findBinary('phpmd'); + $phpmdBinaryPath = $this->builder->findBinary('phpmd'); $this->executePhpMd($phpmdBinaryPath); - $errorCount = $this->processReport(trim($this->phpci->getLastOutput())); + $errorCount = $this->processReport(trim($this->builder->getLastOutput())); $this->build->storeMeta('phpmd-warnings', $errorCount); return $this->wasLastExecSuccessful($errorCount); @@ -127,8 +127,11 @@ class PhpMessDetector extends Plugin implements ZeroConfigPlugin /** * Process PHPMD's XML output report. + * * @param $xmlString - * @return array + * + * @return integer + * * @throws \Exception */ protected function processReport($xmlString) @@ -136,7 +139,7 @@ class PhpMessDetector extends Plugin implements ZeroConfigPlugin $xml = simplexml_load_string($xmlString); if ($xml === false) { - $this->phpci->log($xmlString); + $this->builder->log($xmlString); throw new \Exception('Could not process PHPMD report XML.'); } @@ -144,13 +147,13 @@ class PhpMessDetector extends Plugin implements ZeroConfigPlugin foreach ($xml->file as $file) { $fileName = (string)$file['name']; - $fileName = str_replace($this->phpci->buildPath, '', $fileName); + $fileName = str_replace($this->builder->buildPath, '', $fileName); foreach ($file->violation as $violation) { $warnings++; $this->build->reportError( - $this->phpci, + $this->builder, 'php_mess_detector', (string)$violation, PHPCensor\Model\BuildError::SEVERITY_HIGH, @@ -165,19 +168,19 @@ class PhpMessDetector extends Plugin implements ZeroConfigPlugin } /** - * Try and process the rules parameter from phpci.yml. + * Try and process the rules parameter from .php-censor.yml. * @return bool */ protected function tryAndProcessRules() { if (!empty($this->rules) && !is_array($this->rules)) { - $this->phpci->logFailure('The "rules" option must be an array.'); + $this->builder->logFailure('The "rules" option must be an array.'); return false; } foreach ($this->rules as &$rule) { if (strpos($rule, '/') !== false) { - $rule = $this->phpci->buildPath . $rule; + $rule = $this->builder->buildPath . $rule; } } @@ -205,10 +208,10 @@ class PhpMessDetector extends Plugin implements ZeroConfigPlugin } // Disable exec output logging, as we don't want the XML report in the log: - $this->phpci->logExecOutput(false); + $this->builder->logExecOutput(false); // Run PHPMD: - $this->phpci->executeCommand( + $this->builder->executeCommand( $cmd, $path, implode(',', $this->rules), @@ -217,7 +220,7 @@ class PhpMessDetector extends Plugin implements ZeroConfigPlugin ); // Re-enable exec output logging: - $this->phpci->logExecOutput(true); + $this->builder->logExecOutput(true); } /** @@ -226,7 +229,7 @@ class PhpMessDetector extends Plugin implements ZeroConfigPlugin */ protected function getTargetPath() { - $path = $this->phpci->buildPath . $this->path; + $path = $this->builder->buildPath . $this->path; if (!empty($this->path) && $this->path{0} == '/') { $path = $this->path; return $path; diff --git a/src/PHPCensor/Plugin/PhpParallelLint.php b/src/PHPCensor/Plugin/PhpParallelLint.php index f495e0cd..daf2dac5 100644 --- a/src/PHPCensor/Plugin/PhpParallelLint.php +++ b/src/PHPCensor/Plugin/PhpParallelLint.php @@ -34,15 +34,15 @@ class PhpParallelLint extends Plugin /** * {@inheritdoc} */ - public function __construct(Builder $phpci, Build $build, array $options = []) + public function __construct(Builder $builder, Build $build, array $options = []) { - parent::__construct($phpci, $build, $options); + parent::__construct($builder, $build, $options); - $this->directory = $this->phpci->buildPath; - $this->ignore = $this->phpci->ignore; + $this->directory = $this->builder->buildPath; + $this->ignore = $this->builder->ignore; if (isset($options['directory'])) { - $this->directory = $this->phpci->buildPath.$options['directory']; + $this->directory = $this->builder->buildPath.$options['directory']; } if (isset($options['ignore'])) { @@ -57,16 +57,16 @@ class PhpParallelLint extends Plugin { list($ignore) = $this->getFlags(); - $phplint = $this->phpci->findBinary('parallel-lint'); + $phplint = $this->builder->findBinary('parallel-lint'); $cmd = $phplint . ' %s "%s"'; - $success = $this->phpci->executeCommand( + $success = $this->builder->executeCommand( $cmd, $ignore, $this->directory ); - $output = $this->phpci->getLastOutput(); + $output = $this->builder->getLastOutput(); $matches = []; if (preg_match_all('/Parse error\:/', $output, $matches)) { @@ -84,7 +84,7 @@ class PhpParallelLint extends Plugin { $ignoreFlags = []; foreach ($this->ignore as $ignoreDir) { - $ignoreFlags[] = '--exclude "' . $this->phpci->buildPath . $ignoreDir . '"'; + $ignoreFlags[] = '--exclude "' . $this->builder->buildPath . $ignoreDir . '"'; } $ignore = implode(' ', $ignoreFlags); diff --git a/src/PHPCensor/Plugin/PhpSpec.php b/src/PHPCensor/Plugin/PhpSpec.php index 0f6d6a12..b6a21703 100644 --- a/src/PHPCensor/Plugin/PhpSpec.php +++ b/src/PHPCensor/Plugin/PhpSpec.php @@ -28,12 +28,12 @@ class PhpSpec extends Plugin public function execute() { $curdir = getcwd(); - chdir($this->phpci->buildPath); + chdir($this->builder->buildPath); - $phpspec = $this->phpci->findBinary(['phpspec', 'phpspec.php']); + $phpspec = $this->builder->findBinary(['phpspec', 'phpspec.php']); - $success = $this->phpci->executeCommand($phpspec . ' --format=junit --no-code-generation run'); - $output = $this->phpci->getLastOutput(); + $success = $this->builder->executeCommand($phpspec . ' --format=junit --no-code-generation run'); + $output = $this->builder->getLastOutput(); chdir($curdir); diff --git a/src/PHPCensor/Plugin/PhpTalLint.php b/src/PHPCensor/Plugin/PhpTalLint.php index 3a40f9fa..2a9e03cb 100644 --- a/src/PHPCensor/Plugin/PhpTalLint.php +++ b/src/PHPCensor/Plugin/PhpTalLint.php @@ -16,6 +16,7 @@ use PHPCensor\Plugin; /** * PHPTAL Lint Plugin - Provides access to PHPTAL lint functionality. + * * @author Stephen Ball * @package PHPCI * @subpackage Plugins @@ -50,13 +51,13 @@ class PhpTalLint extends Plugin /** * {@inheritdoc} */ - public function __construct(Builder $phpci, Build $build, array $options = []) + public function __construct(Builder $builder, Build $build, array $options = []) { - parent::__construct($phpci, $build, $options); + parent::__construct($builder, $build, $options); $this->directories = ['']; $this->suffixes = ['zpt']; - $this->ignore = $this->phpci->ignore; + $this->ignore = $this->builder->ignore; $this->allowed_warnings = 0; $this->allowed_errors = 0; @@ -75,15 +76,15 @@ class PhpTalLint extends Plugin */ public function execute() { - $this->phpci->quiet = true; - $this->phpci->logExecOutput(false); + $this->builder->quiet = true; + $this->builder->logExecOutput(false); foreach ($this->directories as $dir) { $this->lintDirectory($dir); } - $this->phpci->quiet = false; - $this->phpci->logExecOutput(true); + $this->builder->quiet = false; + $this->builder->logExecOutput(true); $errors = 0; $warnings = 0; @@ -142,7 +143,7 @@ class PhpTalLint extends Plugin protected function lintDirectory($path) { $success = true; - $directory = new \DirectoryIterator($this->phpci->buildPath . $path); + $directory = new \DirectoryIterator($this->builder->buildPath . $path); foreach ($directory as $item) { if ($item->isDot()) { @@ -179,9 +180,9 @@ class PhpTalLint extends Plugin $lint .= 'tools' . DIRECTORY_SEPARATOR . 'phptal_lint.php'; $cmd = '/usr/bin/env php ' . $lint . ' %s %s "%s"'; - $this->phpci->executeCommand($cmd, $suffixes, $tales, $this->phpci->buildPath . $path); + $this->builder->executeCommand($cmd, $suffixes, $tales, $this->builder->buildPath . $path); - $output = $this->phpci->getLastOutput(); + $output = $this->builder->getLastOutput(); if (preg_match('/Found (.+?) (error|warning)/i', $output, $matches)) { $rows = explode(PHP_EOL, $output); @@ -224,7 +225,7 @@ class PhpTalLint extends Plugin { $tales = ''; if (!empty($this->tales)) { - $tales = ' -i ' . $this->phpci->buildPath . $this->tales; + $tales = ' -i ' . $this->builder->buildPath . $this->tales; } $suffixes = ''; diff --git a/src/PHPCensor/Plugin/PhpUnit.php b/src/PHPCensor/Plugin/PhpUnit.php index 5c8082e7..d2b18846 100644 --- a/src/PHPCensor/Plugin/PhpUnit.php +++ b/src/PHPCensor/Plugin/PhpUnit.php @@ -1,5 +1,4 @@ options = new PhpUnitOptions($options); } @@ -78,11 +77,11 @@ class PhpUnit extends Plugin implements ZeroConfigPlugin $xmlConfigFiles = $this->options->getConfigFiles($this->build->getBuildPath()); $directories = $this->options->getDirectories(); if (empty($xmlConfigFiles) && empty($directories)) { - $this->phpci->logFailure(Lang::get('phpunit_fail_init')); + $this->builder->logFailure(Lang::get('phpunit_fail_init')); return false; } - $success = array(); + $success = []; // Run any directories if (!empty($directories)) { @@ -119,9 +118,9 @@ class PhpUnit extends Plugin implements ZeroConfigPlugin // Removes any current configurations files $options->removeArgument('configuration'); - $arguments = $this->phpci->interpolate($options->buildArgumentString()); - $cmd = $this->phpci->findBinary('phpunit') . ' %s "%s"'; - $success = $this->phpci->executeCommand($cmd, $arguments, $directory); + $arguments = $this->builder->interpolate($options->buildArgumentString()); + $cmd = $this->builder->findBinary('phpunit') . ' %s "%s"'; + $success = $this->builder->executeCommand($cmd, $arguments, $directory); $this->processResults($jsonFile); @@ -149,9 +148,9 @@ class PhpUnit extends Plugin implements ZeroConfigPlugin // Only the add the configuration file been passed $options->addArgument('configuration', $buildPath . $configFile); - $arguments = $this->phpci->interpolate($options->buildArgumentString()); - $cmd = $this->phpci->findBinary('phpunit') . ' %s %s'; - $success = $this->phpci->executeCommand($cmd, $arguments, $options->getTestsPath()); + $arguments = $this->builder->interpolate($options->buildArgumentString()); + $cmd = $this->builder->findBinary('phpunit') . ' %s %s'; + $success = $this->builder->executeCommand($cmd, $arguments, $options->getTestsPath()); $this->processResults($jsonFile); @@ -176,7 +175,7 @@ class PhpUnit extends Plugin implements ZeroConfigPlugin foreach ($parser->getErrors() as $error) { $severity = $error['severity'] == $parser::SEVERITY_ERROR ? BuildError::SEVERITY_CRITICAL : BuildError::SEVERITY_HIGH; $this->build->reportError( - $this->phpci, 'php_unit', $error['message'], $severity, $error['file'], $error['line'] + $this->builder, 'php_unit', $error['message'], $severity, $error['file'], $error['line'] ); } @unlink($jsonFile); diff --git a/src/PHPCensor/Plugin/Shell.php b/src/PHPCensor/Plugin/Shell.php index b78d4578..dc3edba2 100644 --- a/src/PHPCensor/Plugin/Shell.php +++ b/src/PHPCensor/Plugin/Shell.php @@ -31,13 +31,13 @@ class Shell extends Plugin /** * {@inheritdoc} */ - public function __construct(Builder $phpci, Build $build, array $options = []) + public function __construct(Builder $builder, Build $build, array $options = []) { - parent::__construct($phpci, $build, $options); + parent::__construct($builder, $build, $options); if (isset($options['command'])) { // Keeping this for backwards compatibility, new projects should use interpolation vars. - $options['command'] = str_replace("%buildpath%", $this->phpci->buildPath, $options['command']); + $options['command'] = str_replace("%buildpath%", $this->builder->buildPath, $options['command']); $this->commands = [$options['command']]; return; } @@ -62,9 +62,9 @@ class Shell extends Plugin $success = true; foreach ($this->commands as $command) { - $command = $this->phpci->interpolate($command); + $command = $this->builder->interpolate($command); - if (!$this->phpci->executeCommand($command)) { + if (!$this->builder->executeCommand($command)) { $success = false; } } diff --git a/src/PHPCensor/Plugin/SlackNotify.php b/src/PHPCensor/Plugin/SlackNotify.php index d1408d77..7250a7ec 100644 --- a/src/PHPCensor/Plugin/SlackNotify.php +++ b/src/PHPCensor/Plugin/SlackNotify.php @@ -17,6 +17,7 @@ use Maknz\Slack\AttachmentField; /** * Slack Plugin + * * @author Stephen Ball * @package PHPCI * @subpackage Plugins @@ -33,9 +34,9 @@ class SlackNotify extends Plugin /** * {@inheritdoc} */ - public function __construct(Builder $phpci, Build $build, array $options = []) + public function __construct(Builder $builder, Build $build, array $options = []) { - parent::__construct($phpci, $build, $options); + parent::__construct($builder, $build, $options); if (is_array($options) && isset($options['webhook_url'])) { $this->webHook = trim($options['webhook_url']); @@ -80,7 +81,7 @@ class SlackNotify extends Plugin */ public function execute() { - $body = $this->phpci->interpolate($this->message); + $body = $this->builder->interpolate($this->message); $client = new Client($this->webHook); diff --git a/src/PHPCensor/Plugin/Sqlite.php b/src/PHPCensor/Plugin/Sqlite.php index 6de94530..6cd14e7d 100644 --- a/src/PHPCensor/Plugin/Sqlite.php +++ b/src/PHPCensor/Plugin/Sqlite.php @@ -35,11 +35,11 @@ class Sqlite extends Plugin /** * {@inheritdoc} */ - public function __construct(Builder $phpci, Build $build, array $options = []) + public function __construct(Builder $builder, Build $build, array $options = []) { - parent::__construct($phpci, $build, $options); + parent::__construct($builder, $build, $options); - $buildSettings = $this->phpci->getConfig('build_settings'); + $buildSettings = $this->builder->getConfig('build_settings'); if (isset($buildSettings['sqlite'])) { $sql = $buildSettings['sqlite']; @@ -58,10 +58,10 @@ class Sqlite extends Plugin $pdo = new PDO('sqlite:' . $this->path, $opts); foreach ($this->queries as $query) { - $pdo->query($this->phpci->interpolate($query)); + $pdo->query($this->builder->interpolate($query)); } } catch (\Exception $ex) { - $this->phpci->logFailure($ex->getMessage()); + $this->builder->logFailure($ex->getMessage()); return false; } return true; diff --git a/src/PHPCensor/Plugin/TechnicalDebt.php b/src/PHPCensor/Plugin/TechnicalDebt.php index de1d93fb..c941f550 100755 --- a/src/PHPCensor/Plugin/TechnicalDebt.php +++ b/src/PHPCensor/Plugin/TechnicalDebt.php @@ -58,14 +58,14 @@ class TechnicalDebt extends Plugin implements ZeroConfigPlugin /** * {@inheritdoc} */ - public function __construct(Builder $phpci, Build $build, array $options = []) + public function __construct(Builder $builder, Build $build, array $options = []) { - parent::__construct($phpci, $build, $options); + parent::__construct($builder, $build, $options); $this->suffixes = ['php']; - $this->directory = $this->phpci->buildPath; + $this->directory = $this->builder->buildPath; $this->path = ''; - $this->ignore = $this->phpci->ignore; + $this->ignore = $this->builder->ignore; $this->allowed_errors = 0; $this->searches = ['TODO', 'FIXME', 'TO DO', 'FIX ME']; @@ -101,11 +101,11 @@ class TechnicalDebt extends Plugin implements ZeroConfigPlugin public function execute() { $success = true; - $this->phpci->logExecOutput(false); + $this->builder->logExecOutput(false); $errorCount = $this->getErrorList(); - $this->phpci->log("Found $errorCount instances of " . implode(', ', $this->searches)); + $this->builder->log("Found $errorCount instances of " . implode(', ', $this->searches)); $this->build->storeMeta('technical_debt-warnings', $errorCount); @@ -171,7 +171,7 @@ class TechnicalDebt extends Plugin implements ZeroConfigPlugin $fileName = str_replace($this->directory, '', $file); $this->build->reportError( - $this->phpci, + $this->builder, 'technical_debt', $content, PHPCensor\Model\BuildError::SEVERITY_LOW, diff --git a/src/PHPCensor/Plugin/Util/ComposerPluginInformation.php b/src/PHPCensor/Plugin/Util/ComposerPluginInformation.php index 7202ade0..d25baa57 100644 --- a/src/PHPCensor/Plugin/Util/ComposerPluginInformation.php +++ b/src/PHPCensor/Plugin/Util/ComposerPluginInformation.php @@ -6,6 +6,7 @@ use PHPCensor\Plugin; /** * Class ComposerPluginInformation + * * @package PHPCensor\Plugin\Util */ class ComposerPluginInformation implements InstalledPluginInformation @@ -34,15 +35,6 @@ class ComposerPluginInformation implements InstalledPluginInformation return new self($installed); } - /** - * @param \stdClass[] $composerPackages This should be the contents of the - * installed.json file created by composer - */ - public function __construct(array $composerPackages) - { - $this->composerPackages = $composerPackages; - } - /** * Returns an array of objects. Each one represents an available plugin * and will have the following properties: @@ -52,7 +44,6 @@ class ComposerPluginInformation implements InstalledPluginInformation */ public function getInstalledPlugins() { - $this->loadPluginInfo(); return $this->pluginInfo; } @@ -72,44 +63,6 @@ class ComposerPluginInformation implements InstalledPluginInformation ); } - /** - * Load a list of available plugins from the installed composer packages. - */ - protected function loadPluginInfo() - { - if ($this->pluginInfo !== null) { - return; - } - $this->pluginInfo = []; - foreach ($this->composerPackages as $package) { - $this->addPluginsFromPackage($package); - } - } - - /** - * @param \stdClass $package - */ - protected function addPluginsFromPackage($package) - { - if (isset($package->extra->phpci)) { - $phpciData = $package->extra->phpci; - - if (isset($phpciData->pluginNamespace)) { - $rootNamespace = $phpciData->pluginNamespace; - } else { - $rootNamespace = ""; - } - - if (is_array($phpciData->suppliedPlugins)) { - $this->addPlugins( - $phpciData->suppliedPlugins, - $package->name, - $rootNamespace - ); - } - } - } - /** * @param \stdClass[] $plugins * @param string $sourcePackageName diff --git a/src/PHPCensor/Plugin/Util/Executor.php b/src/PHPCensor/Plugin/Util/Executor.php index f37f6952..43c44577 100644 --- a/src/PHPCensor/Plugin/Util/Executor.php +++ b/src/PHPCensor/Plugin/Util/Executor.php @@ -20,7 +20,7 @@ class Executor /** * @var \PHPCensor\Builder */ - protected $phpci; + protected $builder; /** * @var \PHPCensor\Model\Build @@ -38,16 +38,16 @@ class Executor protected $store; /** - * @param Builder $phpci + * @param Builder $builder * @param Build $build * @param BuildLogger $logger */ - public function __construct(Builder $phpci, Build $build, BuildLogger $logger) + public function __construct(Builder $builder, Build $build, BuildLogger $logger) { - $this->phpci = $phpci; - $this->build = $build; - $this->logger = $logger; - $this->store = StoreFactory::getStore('Build'); + $this->builder = $builder; + $this->build = $build; + $this->logger = $logger; + $this->store = StoreFactory::getStore('Build'); } /** @@ -199,7 +199,7 @@ class Executor } try { - return (new $class($this->phpci, $this->build, $options))->execute(); + return (new $class($this->builder, $this->build, $options))->execute(); } catch (\Exception $ex) { $this->logger->logFailure(Lang::get('exception') . $ex->getMessage(), $ex); diff --git a/src/PHPCensor/Plugin/Util/TestResultParsers/Codeception.php b/src/PHPCensor/Plugin/Util/TestResultParsers/Codeception.php index 4a8347d9..346099f5 100644 --- a/src/PHPCensor/Plugin/Util/TestResultParsers/Codeception.php +++ b/src/PHPCensor/Plugin/Util/TestResultParsers/Codeception.php @@ -12,23 +12,21 @@ use PHPCensor\Builder; */ class Codeception implements ParserInterface { - protected $phpci; + protected $builder; protected $resultsXml; - protected $results; - protected $totalTests; protected $totalTimeTaken; protected $totalFailures; protected $totalErrors; /** - * @param Builder $phpci + * @param Builder $builder * @param $resultsXml */ - public function __construct(Builder $phpci, $resultsXml) + public function __construct(Builder $builder, $resultsXml) { - $this->phpci = $phpci; + $this->builder = $builder; $this->resultsXml = $resultsXml; $this->totalTests = 0; } @@ -51,7 +49,7 @@ class Codeception implements ParserInterface foreach ($test_suite->testcase as $test_case) { $test_result = [ 'suite' => (string)$test_suite['name'], - 'file' => str_replace($this->phpci->buildPath, '/', (string) $test_case['file']), + 'file' => str_replace($this->builder->buildPath, '/', (string) $test_case['file']), 'name' => (string)$test_case['name'], 'feature' => (string)$test_case['feature'], 'assertions' => (int)$test_case['assertions'], diff --git a/src/PHPCensor/Plugin/Wipe.php b/src/PHPCensor/Plugin/Wipe.php index 014302ed..c72fb5a0 100644 --- a/src/PHPCensor/Plugin/Wipe.php +++ b/src/PHPCensor/Plugin/Wipe.php @@ -26,12 +26,12 @@ class Wipe extends Plugin /** * {@inheritdoc} */ - public function __construct(Builder $phpci, Build $build, array $options = []) + public function __construct(Builder $builder, Build $build, array $options = []) { - parent::__construct($phpci, $build, $options); + parent::__construct($builder, $build, $options); - $path = $this->phpci->buildPath; - $this->directory = isset($options['directory']) ? $this->phpci->interpolate($options['directory']) : $path; + $path = $this->builder->buildPath; + $this->directory = isset($options['directory']) ? $this->builder->interpolate($options['directory']) : $path; } /** @@ -39,7 +39,7 @@ class Wipe extends Plugin */ public function execute() { - $build = $this->phpci->buildPath; + $build = $this->builder->buildPath; if ($this->directory == $build || empty($this->directory)) { return true; @@ -49,7 +49,7 @@ class Wipe extends Plugin if (IS_WIN) { $cmd = 'rmdir /S /Q "%s"'; } - return $this->phpci->executeCommand($cmd, $this->directory); + return $this->builder->executeCommand($cmd, $this->directory); } return true; } diff --git a/src/PHPCensor/Plugin/Xmpp.php b/src/PHPCensor/Plugin/Xmpp.php index 02d173c8..cc9c5c68 100644 --- a/src/PHPCensor/Plugin/Xmpp.php +++ b/src/PHPCensor/Plugin/Xmpp.php @@ -61,9 +61,9 @@ class XMPP extends Plugin /** * {@inheritdoc} */ - public function __construct(Builder $phpci, Build $build, array $options = []) + public function __construct(Builder $builder, Build $build, array $options = []) { - parent::__construct($phpci, $build, $options); + parent::__construct($builder, $build, $options); $this->username = ''; $this->password = ''; @@ -111,8 +111,8 @@ class XMPP extends Plugin */ public function findConfigFile() { - if (file_exists($this->phpci->buildPath . DIRECTORY_SEPARATOR . '.sendxmpprc')) { - if (md5(file_get_contents($this->phpci->buildPath . DIRECTORY_SEPARATOR . '.sendxmpprc')) + if (file_exists($this->builder->buildPath . DIRECTORY_SEPARATOR . '.sendxmpprc')) { + if (md5(file_get_contents($this->builder->buildPath . DIRECTORY_SEPARATOR . '.sendxmpprc')) !== md5($this->getConfigFormat())) { return null; } @@ -128,7 +128,7 @@ class XMPP extends Plugin */ public function execute() { - $sendxmpp = $this->phpci->findBinary('sendxmpp'); + $sendxmpp = $this->builder->findBinary('sendxmpp'); /* * Without recipients we can't send notification @@ -140,7 +140,7 @@ class XMPP extends Plugin /* * Try to build conf file */ - $config_file = $this->phpci->buildPath . DIRECTORY_SEPARATOR . '.sendxmpprc'; + $config_file = $this->builder->buildPath . DIRECTORY_SEPARATOR . '.sendxmpprc'; if (is_null($this->findConfigFile())) { file_put_contents($config_file, $this->getConfigFormat()); chmod($config_file, 0600); @@ -154,7 +154,7 @@ class XMPP extends Plugin $tls = ' -t'; } - $message_file = $this->phpci->buildPath . DIRECTORY_SEPARATOR . uniqid('xmppmessage'); + $message_file = $this->builder->buildPath . DIRECTORY_SEPARATOR . uniqid('xmppmessage'); if ($this->buildMessage($message_file) === false) { return false; } @@ -165,14 +165,14 @@ class XMPP extends Plugin $cmd = $sendxmpp . "%s -f %s -m %s %s"; $recipients = implode(' ', $this->recipients); - $success = $this->phpci->executeCommand($cmd, $tls, $config_file, $message_file, $recipients); + $success = $this->builder->executeCommand($cmd, $tls, $config_file, $message_file, $recipients); - print $this->phpci->getLastOutput(); + print $this->builder->getLastOutput(); /* * Remove temp message file */ - $this->phpci->executeCommand("rm -rf ".$message_file); + $this->builder->executeCommand("rm -rf ".$message_file); return $success; }