PHPMD cleanup

This commit is contained in:
Dan Cryer 2014-05-02 14:48:40 +01:00
parent aa9a787531
commit cf6e0471e4
21 changed files with 116 additions and 31 deletions

View file

@ -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();
}
/**

View file

@ -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);
}
}

View file

@ -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'])) {

View file

@ -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();
}

View file

@ -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'];

View file

@ -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;

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;

View file

@ -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');

View file

@ -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;

View file

@ -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();

View file

@ -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'];

View file

@ -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

View file

@ -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;

View file

@ -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);
}

View file

@ -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;

View file

@ -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;
}
/**

View file

@ -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.

View file

@ -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;
}

View file

@ -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;
}