diff --git a/PHPCI/Helper/MailerFactory.php b/PHPCI/Helper/MailerFactory.php index f3c08aa2..d8625630 100644 --- a/PHPCI/Helper/MailerFactory.php +++ b/PHPCI/Helper/MailerFactory.php @@ -10,9 +10,9 @@ class MailerFactory */ protected $emailConfig; - public function __construct($phpCiConfig = null) + public function __construct($config = null) { - $this->emailConfig = isset($phpCiSettings['email_settings']) ?: array(); + $this->emailConfig = isset($config['email_settings']) ?: array(); } /** diff --git a/PHPCI/Logging/Handler.php b/PHPCI/Logging/Handler.php index 05fd5ac8..b38c37a1 100644 --- a/PHPCI/Logging/Handler.php +++ b/PHPCI/Logging/Handler.php @@ -73,8 +73,8 @@ class Handler $fatal_error = error_get_last(); try { - if (($e = error_get_last()) !== null) { - $e = new \ErrorException( + if (($error = error_get_last()) !== null) { + $error = new \ErrorException( sprintf( '%s: %s in %s line %d', $fatal_error['type'], @@ -87,10 +87,10 @@ class Handler $fatal_error['file'], $fatal_error['line'] ); - $this->log($e); + $this->log($error); } } catch (\Exception $e) { - $e = new \ErrorException( + $error = new \ErrorException( sprintf( '%s: %s in %s line %d', $fatal_error['type'], @@ -103,7 +103,7 @@ class Handler $fatal_error['file'], $fatal_error['line'] ); - $this->log($e); + $this->log($error); } } diff --git a/PHPCI/Plugin/Behat.php b/PHPCI/Plugin/Behat.php index e4b72155..640e7167 100644 --- a/PHPCI/Plugin/Behat.php +++ b/PHPCI/Plugin/Behat.php @@ -21,11 +21,13 @@ use PHPCI\Model\Build; class Behat implements \PHPCI\Plugin { protected $phpci; + protected $build; protected $features; public function __construct(Builder $phpci, Build $build, array $options = array()) { $this->phpci = $phpci; + $this->build = $build; $this->features = ''; if (isset($options['executable'])) { diff --git a/PHPCI/Plugin/CleanBuild.php b/PHPCI/Plugin/CleanBuild.php index a7db4fc9..73a7305f 100644 --- a/PHPCI/Plugin/CleanBuild.php +++ b/PHPCI/Plugin/CleanBuild.php @@ -23,10 +23,12 @@ class CleanBuild implements \PHPCI\Plugin { protected $remove; protected $phpci; + protected $build; public function __construct(Builder $phpci, Build $build, array $options = array()) { $this->phpci = $phpci; + $this->build = $build; $this->remove = isset($options['remove']) && is_array($options['remove']) ? $options['remove'] : array(); } diff --git a/PHPCI/Plugin/Codeception.php b/PHPCI/Plugin/Codeception.php index 2f43fee5..5b811896 100644 --- a/PHPCI/Plugin/Codeception.php +++ b/PHPCI/Plugin/Codeception.php @@ -30,6 +30,8 @@ class Codeception implements \PHPCI\Plugin */ protected $phpci; + protected $build; + /** * @var string|string[] $xmlConfigFile The path (or array of paths) of an xml config for PHPUnit */ @@ -38,6 +40,7 @@ class Codeception implements \PHPCI\Plugin public function __construct(Builder $phpci, Build $build, array $options = array()) { $this->phpci = $phpci; + $this->build = $build; if (isset($options['config'])) { $this->xmlConfigFile = $options['config']; diff --git a/PHPCI/Plugin/Composer.php b/PHPCI/Plugin/Composer.php index 6be4d281..3a13b672 100644 --- a/PHPCI/Plugin/Composer.php +++ b/PHPCI/Plugin/Composer.php @@ -25,6 +25,7 @@ class Composer implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin protected $action; protected $preferDist; protected $phpci; + protected $build; public static function canExecute($stage, Builder $builder, Build $build) { @@ -41,6 +42,7 @@ class Composer implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin { $path = $phpci->buildPath; $this->phpci = $phpci; + $this->build = $build; $this->directory = isset($options['directory']) ? $path . '/' . $options['directory'] : $path; $this->action = isset($options['action']) ? $options['action'] : 'install'; $this->preferDist = isset($options['prefer_dist']) ? $options['prefer_dist'] : true; diff --git a/PHPCI/Plugin/CopyBuild.php b/PHPCI/Plugin/CopyBuild.php index 39d41e3f..021d5e80 100644 --- a/PHPCI/Plugin/CopyBuild.php +++ b/PHPCI/Plugin/CopyBuild.php @@ -23,11 +23,13 @@ class CopyBuild implements \PHPCI\Plugin protected $directory; protected $ignore; protected $phpci; + protected $build; public function __construct(Builder $phpci, Build $build, array $options = array()) { $path = $phpci->buildPath; $this->phpci = $phpci; + $this->build = $build; $this->directory = isset($options['directory']) ? $options['directory'] : $path; $this->ignore = isset($options['respect_ignore']) ? (bool)$options['respect_ignore'] : false; } diff --git a/PHPCI/Plugin/Env.php b/PHPCI/Plugin/Env.php index 09ffbb5a..a55cf47d 100644 --- a/PHPCI/Plugin/Env.php +++ b/PHPCI/Plugin/Env.php @@ -21,11 +21,13 @@ use PHPCI\Model\Build; class Env implements \PHPCI\Plugin { protected $phpci; + protected $build; protected $env_vars; public function __construct(Builder $phpci, Build $build, array $options = array()) { - $this->phpci = $phpci; + $this->phpci = $phpci; + $this->build = $build; $this->env_vars = $options; } diff --git a/PHPCI/Plugin/Grunt.php b/PHPCI/Plugin/Grunt.php index ddbe7aa3..0c845184 100644 --- a/PHPCI/Plugin/Grunt.php +++ b/PHPCI/Plugin/Grunt.php @@ -24,12 +24,14 @@ class Grunt implements \PHPCI\Plugin protected $task; protected $preferDist; protected $phpci; + protected $build; protected $grunt; protected $gruntfile; public function __construct(Builder $phpci, Build $build, array $options = array()) { $path = $phpci->buildPath; + $this->build = $build; $this->phpci = $phpci; $this->directory = $path; $this->task = null; diff --git a/PHPCI/Plugin/Irc.php b/PHPCI/Plugin/Irc.php index 6b294d66..0defc037 100644 --- a/PHPCI/Plugin/Irc.php +++ b/PHPCI/Plugin/Irc.php @@ -13,16 +13,18 @@ use PHPCI\Model\Build; */ class Irc implements \PHPCI\Plugin { - private $phpci; - private $message; - private $server; - private $port; - private $room; - private $nick; + protected $phpci; + protected $build; + protected $message; + protected $server; + protected $port; + protected $room; + protected $nick; public function __construct(Builder $phpci, Build $build, array $options = array()) { $this->phpci = $phpci; + $this->build = $build; $this->message = $options['message']; $buildSettings = $phpci->getConfig('build_settings'); diff --git a/PHPCI/Plugin/Lint.php b/PHPCI/Plugin/Lint.php index 73b4beaf..3ca785ec 100644 --- a/PHPCI/Plugin/Lint.php +++ b/PHPCI/Plugin/Lint.php @@ -25,10 +25,12 @@ class Lint implements PHPCI\Plugin protected $recursive = true; protected $ignore; protected $phpci; + protected $build; public function __construct(Builder $phpci, Build $build, array $options = array()) { $this->phpci = $phpci; + $this->build = $build; $this->directories = array(''); $this->ignore = $phpci->ignore; diff --git a/PHPCI/Plugin/Mysql.php b/PHPCI/Plugin/Mysql.php index e2fda714..c66f77cb 100755 --- a/PHPCI/Plugin/Mysql.php +++ b/PHPCI/Plugin/Mysql.php @@ -27,6 +27,7 @@ class Mysql implements \PHPCI\Plugin * @var \PHPCI\Builder */ protected $phpci; + protected $build; protected $queries = array(); protected $host; @@ -42,6 +43,8 @@ class Mysql implements \PHPCI\Plugin public function __construct(Builder $phpci, Build $build, array $options = array()) { $this->phpci = $phpci; + $this->build = $build; + $this->queries = $options; $config = \b8\Database::getConnection('write')->getDetails(); diff --git a/PHPCI/Plugin/Pgsql.php b/PHPCI/Plugin/Pgsql.php index 45155ecf..a05068d2 100644 --- a/PHPCI/Plugin/Pgsql.php +++ b/PHPCI/Plugin/Pgsql.php @@ -22,6 +22,7 @@ use PHPCI\Model\Build; class Pgsql implements \PHPCI\Plugin { protected $phpci; + protected $build; protected $queries = array(); protected $host; @@ -30,13 +31,14 @@ class Pgsql implements \PHPCI\Plugin public function __construct(Builder $phpci, Build $build, array $options = array()) { - $this->phpci = $phpci; - $this->queries = $options; + $this->phpci = $phpci; + $this->build = $build; + $this->queries = $options; $buildSettings = $phpci->getConfig('build_settings'); if (isset($buildSettings['pgsql'])) { - $sql = $buildSettings['pgsql']; + $sql = $buildSettings['pgsql']; $this->host = $sql['host']; $this->user = $sql['user']; $this->pass = $sql['pass']; diff --git a/PHPCI/Plugin/Phing.php b/PHPCI/Plugin/Phing.php index e90d4b4a..270b3aa9 100644 --- a/PHPCI/Plugin/Phing.php +++ b/PHPCI/Plugin/Phing.php @@ -29,10 +29,12 @@ class Phing implements \PHPCI\Plugin private $propertyFile; protected $phpci; + protected $build; public function __construct(Builder $phpci, Build $build, array $options = array()) { $this->setPhpci($phpci); + $this->build = $build; /* * Set working directory diff --git a/PHPCI/Plugin/PhpCpd.php b/PHPCI/Plugin/PhpCpd.php index bbefd7e6..2e0b908e 100644 --- a/PHPCI/Plugin/PhpCpd.php +++ b/PHPCI/Plugin/PhpCpd.php @@ -23,6 +23,7 @@ class PhpCpd implements \PHPCI\Plugin protected $directory; protected $args; protected $phpci; + protected $build; /** * @var string, based on the assumption the root may not hold the code to be @@ -38,6 +39,8 @@ class PhpCpd implements \PHPCI\Plugin public function __construct(Builder $phpci, Build $build, array $options = array()) { $this->phpci = $phpci; + $this->build = $build; + $this->path = $phpci->buildPath; $this->standard = 'PSR1'; $this->ignore = $phpci->ignore; diff --git a/PHPCI/Plugin/PhpCsFixer.php b/PHPCI/Plugin/PhpCsFixer.php index ca07e9ef..7b1cff2a 100644 --- a/PHPCI/Plugin/PhpCsFixer.php +++ b/PHPCI/Plugin/PhpCsFixer.php @@ -20,8 +20,16 @@ use PHPCI\Model\Build; */ class PhpCsFixer implements \PHPCI\Plugin { + /** + * @var \PHPCI\Builder + */ protected $phpci; + /** + * @var \PHPCI\Model\Build + */ + protected $build; + protected $workingDir = ''; protected $level = ' --level=all'; protected $verbose = ''; @@ -31,6 +39,8 @@ class PhpCsFixer implements \PHPCI\Plugin public function __construct(Builder $phpci, Build $build, array $options = array()) { $this->phpci = $phpci; + $this->build = $build; + $this->workingdir = $this->phpci->buildPath; $this->buildArgs($options); } diff --git a/PHPCI/Plugin/PhpMessDetector.php b/PHPCI/Plugin/PhpMessDetector.php index ce9f0193..2be7fed4 100755 --- a/PHPCI/Plugin/PhpMessDetector.php +++ b/PHPCI/Plugin/PhpMessDetector.php @@ -26,6 +26,11 @@ class PhpMessDetector implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin */ protected $phpci; + /** + * @var \PHPCI\Model\Build + */ + protected $build; + /** * @var array */ @@ -59,10 +64,7 @@ class PhpMessDetector implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin return false; } - /** - * @param \PHPCI\Builder $phpci - * @param array $options - */ + public function __construct(Builder $phpci, Build $build, array $options = array()) { $this->phpci = $phpci; diff --git a/PHPCI/Plugin/PhpSpec.php b/PHPCI/Plugin/PhpSpec.php index 843017b9..c8a36253 100644 --- a/PHPCI/Plugin/PhpSpec.php +++ b/PHPCI/Plugin/PhpSpec.php @@ -21,11 +21,26 @@ use PHPCI\Model\Build; */ class PhpSpec implements PHPCI\Plugin { + /** + * @var \PHPCI\Builder + */ protected $phpci; + /** + * @var \PHPCI\Model\Build + */ + protected $build; + + /** + * @var array + */ + protected $options; + public function __construct(Builder $phpci, Build $build, array $options = array()) { - $this->phpci = $phpci; + $this->phpci = $phpci; + $this->build = $build; + $this->options = $options; } /** diff --git a/PHPCI/Plugin/Shell.php b/PHPCI/Plugin/Shell.php index b9949cd3..73439cad 100644 --- a/PHPCI/Plugin/Shell.php +++ b/PHPCI/Plugin/Shell.php @@ -20,9 +20,18 @@ use PHPCI\Model\Build; */ class Shell implements \PHPCI\Plugin { - protected $args; + /** + * @var \PHPCI\Builder + */ protected $phpci; + /** + * @var \PHPCI\Model\Build + */ + protected $build; + + protected $args; + /** * @var string[] $commands The commands to be executed */ @@ -30,7 +39,8 @@ class Shell implements \PHPCI\Plugin public function __construct(Builder $phpci, Build $build, array $options = array()) { - $this->phpci = $phpci; + $this->phpci = $phpci; + $this->build = $build; if (isset($options['command'])) { // Keeping this for backwards compatibility, new projects should use interpolation vars. diff --git a/PHPCI/Plugin/Util/TapParser.php b/PHPCI/Plugin/Util/TapParser.php index 610e1696..595e83ef 100644 --- a/PHPCI/Plugin/Util/TapParser.php +++ b/PHPCI/Plugin/Util/TapParser.php @@ -33,8 +33,8 @@ class TapParser // trim all of the lines so there's no leading or trailing whitespace. $lines = explode("\n", $this->tapString); $lines = array_map(function ($line) { - return trim($line); - }, $lines); + return trim($line); + }, $lines); // Check TAP version: $versionLine = array_shift($lines); @@ -55,7 +55,19 @@ class TapParser $totalTests = (int)$matches[2]; } + $rtn = $this->processTestLines($lines); + + if ($totalTests != count($rtn)) { + throw new \Exception('Invalid TAP string, number of tests does not match specified test count.'); + } + + return $rtn; + } + + protected function processTestLines($lines) + { $rtn = array(); + foreach ($lines as $line) { $matches = array(); @@ -78,10 +90,6 @@ class TapParser } } - if ($totalTests != count($rtn)) { - throw new \Exception('Invalid TAP string, number of tests does not match specified test count.'); - } - return $rtn; } diff --git a/PHPCI/Plugin/Wipe.php b/PHPCI/Plugin/Wipe.php index 3efd8a44..7a0c2107 100644 --- a/PHPCI/Plugin/Wipe.php +++ b/PHPCI/Plugin/Wipe.php @@ -20,13 +20,24 @@ use PHPCI\Model\Build; */ class Wipe implements \PHPCI\Plugin { - protected $directory; + /** + * @var \PHPCI\Builder + */ protected $phpci; + /** + * @var \PHPCI\Model\Build + */ + protected $build; + + protected $directory; + + public function __construct(Builder $phpci, Build $build, array $options = array()) { $path = $phpci->buildPath; $this->phpci = $phpci; + $this->build = $build; $this->directory = isset($options['directory']) ? $options['directory'] : $path; }