Code style fixes

This commit is contained in:
Dmitry Khomutov 2016-04-21 10:58:09 +06:00
commit 6891b8a75f
87 changed files with 598 additions and 603 deletions

View file

@ -17,7 +17,7 @@ class BuildBase extends Model
/**
* @var array
*/
public static $sleepable = array();
public static $sleepable = [];
/**
* @var string
@ -32,155 +32,155 @@ class BuildBase extends Model
/**
* @var array
*/
protected $data = array(
'id' => null,
'project_id' => null,
'commit_id' => null,
'status' => null,
'log' => null,
'branch' => null,
'created' => null,
'started' => null,
'finished' => null,
protected $data = [
'id' => null,
'project_id' => null,
'commit_id' => null,
'status' => null,
'log' => null,
'branch' => null,
'created' => null,
'started' => null,
'finished' => null,
'committer_email' => null,
'commit_message' => null,
'extra' => null,
);
'commit_message' => null,
'extra' => null,
];
/**
* @var array
*/
protected $getters = array(
protected $getters = [
// Direct property getters:
'id' => 'getId',
'project_id' => 'getProjectId',
'commit_id' => 'getCommitId',
'status' => 'getStatus',
'log' => 'getLog',
'branch' => 'getBranch',
'created' => 'getCreated',
'started' => 'getStarted',
'finished' => 'getFinished',
'id' => 'getId',
'project_id' => 'getProjectId',
'commit_id' => 'getCommitId',
'status' => 'getStatus',
'log' => 'getLog',
'branch' => 'getBranch',
'created' => 'getCreated',
'started' => 'getStarted',
'finished' => 'getFinished',
'committer_email' => 'getCommitterEmail',
'commit_message' => 'getCommitMessage',
'extra' => 'getExtra',
'commit_message' => 'getCommitMessage',
'extra' => 'getExtra',
// Foreign key getters:
'Project' => 'getProject',
);
];
/**
* @var array
*/
protected $setters = array(
protected $setters = [
// Direct property setters:
'id' => 'setId',
'project_id' => 'setProjectId',
'commit_id' => 'setCommitId',
'status' => 'setStatus',
'log' => 'setLog',
'branch' => 'setBranch',
'created' => 'setCreated',
'started' => 'setStarted',
'finished' => 'setFinished',
'id' => 'setId',
'project_id' => 'setProjectId',
'commit_id' => 'setCommitId',
'status' => 'setStatus',
'log' => 'setLog',
'branch' => 'setBranch',
'created' => 'setCreated',
'started' => 'setStarted',
'finished' => 'setFinished',
'committer_email' => 'setCommitterEmail',
'commit_message' => 'setCommitMessage',
'extra' => 'setExtra',
'commit_message' => 'setCommitMessage',
'extra' => 'setExtra',
// Foreign key setters:
'Project' => 'setProject',
);
];
/**
* @var array
*/
public $columns = array(
'id' => array(
'type' => 'int',
'length' => 11,
'primary_key' => true,
public $columns = [
'id' => [
'type' => 'int',
'length' => 11,
'primary_key' => true,
'auto_increment' => true,
'default' => null,
],
'project_id' => [
'type' => 'int',
'length' => 11,
'default' => null,
),
'project_id' => array(
'type' => 'int',
'length' => 11,
],
'commit_id' => [
'type' => 'varchar',
'length' => 50,
'default' => null,
),
'commit_id' => array(
'type' => 'varchar',
'length' => 50,
],
'status' => [
'type' => 'int',
'length' => 11,
'default' => null,
),
'status' => array(
'type' => 'int',
'length' => 11,
'default' => null,
),
'log' => array(
'type' => 'mediumtext',
],
'log' => [
'type' => 'mediumtext',
'nullable' => true,
'default' => null,
),
'branch' => array(
'type' => 'varchar',
'length' => 50,
'default' => null,
],
'branch' => [
'type' => 'varchar',
'length' => 50,
'default' => 'master',
),
'created' => array(
'type' => 'datetime',
],
'created' => [
'type' => 'datetime',
'nullable' => true,
'default' => null,
),
'started' => array(
'type' => 'datetime',
'default' => null,
],
'started' => [
'type' => 'datetime',
'nullable' => true,
'default' => null,
),
'finished' => array(
'type' => 'datetime',
'default' => null,
],
'finished' => [
'type' => 'datetime',
'nullable' => true,
'default' => null,
),
'committer_email' => array(
'type' => 'varchar',
'length' => 512,
'default' => null,
],
'committer_email' => [
'type' => 'varchar',
'length' => 512,
'nullable' => true,
'default' => null,
),
'commit_message' => array(
'type' => 'text',
'default' => null,
],
'commit_message' => [
'type' => 'text',
'nullable' => true,
'default' => null,
),
'extra' => array(
'type' => 'text',
'default' => null,
],
'extra' => [
'type' => 'text',
'nullable' => true,
'default' => null,
),
);
'default' => null,
],
];
/**
* @var array
*/
public $indexes = array(
'PRIMARY' => array('unique' => true, 'columns' => 'id'),
'project_id' => array('columns' => 'project_id'),
'idx_status' => array('columns' => 'status'),
);
public $indexes = [
'PRIMARY' => ['unique' => true, 'columns' => 'id'],
'project_id' => ['columns' => 'project_id'],
'idx_status' => ['columns' => 'status'],
];
/**
* @var array
*/
public $foreignKeys = array(
'build_ibfk_1' => array(
'local_col' => 'project_id',
'update' => 'CASCADE',
'delete' => 'CASCADE',
'table' => 'project',
'col' => 'id'
),
);
public $foreignKeys = [
'build_ibfk_1' => [
'local_col' => 'project_id',
'update' => 'CASCADE',
'delete' => 'CASCADE',
'table' => 'project',
'col' => 'id'
],
];
/**
* Get the value of Id / id.

View file

@ -17,7 +17,7 @@ class BuildErrorBase extends Model
/**
* @var array
*/
public static $sleepable = array();
public static $sleepable = [];
/**
* @var string
@ -32,131 +32,131 @@ class BuildErrorBase extends Model
/**
* @var array
*/
protected $data = array(
'id' => null,
'build_id' => null,
'plugin' => null,
'file' => null,
'line_start' => null,
'line_end' => null,
'severity' => null,
'message' => null,
protected $data = [
'id' => null,
'build_id' => null,
'plugin' => null,
'file' => null,
'line_start' => null,
'line_end' => null,
'severity' => null,
'message' => null,
'created_date' => null,
);
];
/**
* @var array
*/
protected $getters = array(
protected $getters = [
// Direct property getters:
'id' => 'getId',
'build_id' => 'getBuildId',
'plugin' => 'getPlugin',
'file' => 'getFile',
'line_start' => 'getLineStart',
'line_end' => 'getLineEnd',
'severity' => 'getSeverity',
'message' => 'getMessage',
'id' => 'getId',
'build_id' => 'getBuildId',
'plugin' => 'getPlugin',
'file' => 'getFile',
'line_start' => 'getLineStart',
'line_end' => 'getLineEnd',
'severity' => 'getSeverity',
'message' => 'getMessage',
'created_date' => 'getCreatedDate',
// Foreign key getters:
'Build' => 'getBuild',
);
];
/**
* @var array
*/
protected $setters = array(
protected $setters = [
// Direct property setters:
'id' => 'setId',
'build_id' => 'setBuildId',
'plugin' => 'setPlugin',
'file' => 'setFile',
'line_start' => 'setLineStart',
'line_end' => 'setLineEnd',
'severity' => 'setSeverity',
'message' => 'setMessage',
'id' => 'setId',
'build_id' => 'setBuildId',
'plugin' => 'setPlugin',
'file' => 'setFile',
'line_start' => 'setLineStart',
'line_end' => 'setLineEnd',
'severity' => 'setSeverity',
'message' => 'setMessage',
'created_date' => 'setCreatedDate',
// Foreign key setters:
'Build' => 'setBuild',
);
];
/**
* @var array
*/
public $columns = array(
'id' => array(
'type' => 'int',
'length' => 11,
'primary_key' => true,
public $columns = [
'id' => [
'type' => 'int',
'length' => 11,
'primary_key' => true,
'auto_increment' => true,
'default' => null,
],
'build_id' => [
'type' => 'int',
'length' => 11,
'default' => null,
),
'build_id' => array(
'type' => 'int',
'length' => 11,
],
'plugin' => [
'type' => 'varchar',
'length' => 100,
'default' => null,
),
'plugin' => array(
'type' => 'varchar',
'length' => 100,
'default' => null,
),
'file' => array(
'type' => 'varchar',
'length' => 250,
],
'file' => [
'type' => 'varchar',
'length' => 250,
'nullable' => true,
'default' => null,
),
'line_start' => array(
'type' => 'int',
'length' => 11,
'default' => null,
],
'line_start' => [
'type' => 'int',
'length' => 11,
'nullable' => true,
'default' => null,
),
'line_end' => array(
'type' => 'int',
'length' => 11,
'default' => null,
],
'line_end' => [
'type' => 'int',
'length' => 11,
'nullable' => true,
'default' => null,
],
'severity' => [
'type' => 'tinyint',
'length' => 3,
'default' => null,
),
'severity' => array(
'type' => 'tinyint',
'length' => 3,
],
'message' => [
'type' => 'varchar',
'length' => 250,
'default' => null,
),
'message' => array(
'type' => 'varchar',
'length' => 250,
],
'created_date' => [
'type' => 'datetime',
'default' => null,
),
'created_date' => array(
'type' => 'datetime',
'default' => null,
),
);
],
];
/**
* @var array
*/
public $indexes = array(
'PRIMARY' => array('unique' => true, 'columns' => 'id'),
'build_id' => array('columns' => 'build_id, created_date'),
);
public $indexes = [
'PRIMARY' => ['unique' => true, 'columns' => 'id'],
'build_id' => ['columns' => 'build_id, created_date'],
];
/**
* @var array
*/
public $foreignKeys = array(
'build_error_ibfk_1' => array(
'local_col' => 'build_id',
'update' => 'CASCADE',
'delete' => 'CASCADE',
'table' => 'build',
'col' => 'id'
),
);
public $foreignKeys = [
'build_error_ibfk_1' => [
'local_col' => 'build_id',
'update' => 'CASCADE',
'delete' => 'CASCADE',
'table' => 'build',
'col' => 'id'
],
];
/**
* Get the value of Id / id.
@ -165,7 +165,7 @@ class BuildErrorBase extends Model
*/
public function getId()
{
$rtn = $this->data['id'];
$rtn = $this->data['id'];
return $rtn;
}
@ -177,7 +177,7 @@ class BuildErrorBase extends Model
*/
public function getBuildId()
{
$rtn = $this->data['build_id'];
$rtn = $this->data['build_id'];
return $rtn;
}
@ -189,7 +189,7 @@ class BuildErrorBase extends Model
*/
public function getPlugin()
{
$rtn = $this->data['plugin'];
$rtn = $this->data['plugin'];
return $rtn;
}
@ -201,7 +201,7 @@ class BuildErrorBase extends Model
*/
public function getFile()
{
$rtn = $this->data['file'];
$rtn = $this->data['file'];
return $rtn;
}
@ -213,7 +213,7 @@ class BuildErrorBase extends Model
*/
public function getLineStart()
{
$rtn = $this->data['line_start'];
$rtn = $this->data['line_start'];
return $rtn;
}
@ -225,7 +225,7 @@ class BuildErrorBase extends Model
*/
public function getLineEnd()
{
$rtn = $this->data['line_end'];
$rtn = $this->data['line_end'];
return $rtn;
}
@ -237,7 +237,7 @@ class BuildErrorBase extends Model
*/
public function getSeverity()
{
$rtn = $this->data['severity'];
$rtn = $this->data['severity'];
return $rtn;
}
@ -249,7 +249,7 @@ class BuildErrorBase extends Model
*/
public function getMessage()
{
$rtn = $this->data['message'];
$rtn = $this->data['message'];
return $rtn;
}
@ -261,10 +261,10 @@ class BuildErrorBase extends Model
*/
public function getCreatedDate()
{
$rtn = $this->data['created_date'];
$rtn = $this->data['created_date'];
if (!empty($rtn)) {
$rtn = new \DateTime($rtn);
$rtn = new \DateTime($rtn);
}
return $rtn;

View file

@ -17,7 +17,7 @@ class BuildMetaBase extends Model
/**
* @var array
*/
public static $sleepable = array();
public static $sleepable = [];
/**
* @var string
@ -32,106 +32,104 @@ class BuildMetaBase extends Model
/**
* @var array
*/
protected $data = array(
'id' => null,
protected $data = [
'id' => null,
'project_id' => null,
'build_id' => null,
'meta_key' => null,
'build_id' => null,
'meta_key' => null,
'meta_value' => null,
);
];
/**
* @var array
*/
protected $getters = array(
protected $getters = [
// Direct property getters:
'id' => 'getId',
'id' => 'getId',
'project_id' => 'getProjectId',
'build_id' => 'getBuildId',
'meta_key' => 'getMetaKey',
'build_id' => 'getBuildId',
'meta_key' => 'getMetaKey',
'meta_value' => 'getMetaValue',
// Foreign key getters:
'Project' => 'getProject',
'Build' => 'getBuild',
);
'Project' => 'getProject',
'Build' => 'getBuild',
];
/**
* @var array
*/
protected $setters = array(
protected $setters = [
// Direct property setters:
'id' => 'setId',
'id' => 'setId',
'project_id' => 'setProjectId',
'build_id' => 'setBuildId',
'meta_key' => 'setMetaKey',
'build_id' => 'setBuildId',
'meta_key' => 'setMetaKey',
'meta_value' => 'setMetaValue',
// Foreign key setters:
'Project' => 'setProject',
'Build' => 'setBuild',
);
'Project' => 'setProject',
'Build' => 'setBuild',
];
/**
* @var array
*/
public $columns = array(
'id' => array(
'type' => 'int',
'length' => 10,
'primary_key' => true,
public $columns = [
'id' => [
'type' => 'int',
'length' => 10,
'primary_key' => true,
'auto_increment' => true,
'default' => null,
],
'project_id' => [
'type' => 'int',
'length' => 11,
'default' => null,
),
'project_id' => array(
'type' => 'int',
'length' => 11,
],
'build_id' => [
'type' => 'int',
'length' => 11,
'default' => null,
),
'build_id' => array(
'type' => 'int',
'length' => 11,
],
'meta_key' => [
'type' => 'varchar',
'length' => 250,
'default' => null,
),
'meta_key' => array(
'type' => 'varchar',
'length' => 250,
],
'meta_value' => [
'type' => 'mediumtext',
'default' => null,
),
'meta_value' => array(
'type' => 'mediumtext',
'default' => null,
),
);
],
];
/**
* @var array
*/
public $indexes = array(
'PRIMARY' => array('unique' => true, 'columns' => 'id'),
'idx_meta_id' => array('unique' => true, 'columns' => 'build_id, meta_key'),
'project_id' => array('columns' => 'project_id'),
);
public $indexes = [
'PRIMARY' => ['unique' => true, 'columns' => 'id'],
'idx_meta_id' => ['unique' => true, 'columns' => 'build_id, meta_key'],
'project_id' => ['columns' => 'project_id'],
];
/**
* @var array
*/
public $foreignKeys = array(
'build_meta_ibfk_1' => array(
'local_col' => 'project_id',
'update' => 'CASCADE',
'delete' => 'CASCADE',
'table' => 'project',
'col' => 'id'
),
'fk_meta_build_id' => array(
'local_col' => 'build_id',
'update' => 'CASCADE',
'delete' => 'CASCADE',
'table' => 'build',
'col' => 'id'
),
);
public $foreignKeys = [
'build_meta_ibfk_1' => [
'local_col' => 'project_id',
'update' => 'CASCADE',
'delete' => 'CASCADE',
'table' => 'project',
'col' => 'id'
],
'fk_meta_build_id' => [
'local_col' => 'build_id',
'update' => 'CASCADE',
'delete' => 'CASCADE',
'table' => 'build',
'col' => 'id'
],
];
/**
* Get the value of Id / id.

View file

@ -17,7 +17,7 @@ class ProjectBase extends Model
/**
* @var array
*/
public static $sleepable = array();
public static $sleepable = [];
/**
* @var string

View file

@ -17,7 +17,7 @@ class ProjectGroupBase extends Model
/**
* @var array
*/
public static $sleepable = array();
public static $sleepable = [];
/**
* @var string

View file

@ -17,7 +17,7 @@ class UserBase extends Model
/**
* @var array
*/
public static $sleepable = array();
public static $sleepable = [];
/**
* @var string

View file

@ -80,17 +80,17 @@ class GithubBuild extends RemoteGitBuild
$phpciUrl = \b8\Config::getInstance()->get('phpci.url');
$params = array(
'state' => $status,
'target_url' => $phpciUrl . '/build/view/' . $this->getId(),
$params = [
'state' => $status,
'target_url' => $phpciUrl . '/build/view/' . $this->getId(),
'description' => $description,
'context' => 'PHPCI',
);
'context' => 'PHPCI',
];
$headers = array(
$headers = [
'Authorization: token ' . $token,
'Content-Type: application/x-www-form-urlencoded'
);
];
$http->setHeaders($headers);
$http->request('POST', $url, json_encode($params));
@ -141,7 +141,7 @@ class GithubBuild extends RemoteGitBuild
$branch = $this->getBranch();
if ($this->getExtra('build_type') == 'pull_request') {
$matches = array();
$matches = [];
preg_match('/[\/:]([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)/', $this->getExtra('remote_url'), $matches);
$reference = $matches[1];

View file

@ -29,7 +29,7 @@ class Atoum implements \PHPCI\Plugin
* @param Build $build
* @param array $options
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$this->phpci = $phpci;
$this->build = $build;

View file

@ -38,7 +38,7 @@ class Behat implements \PHPCI\Plugin
* @param Build $build
* @param array $options
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$this->phpci = $phpci;
$this->build = $build;
@ -94,13 +94,13 @@ class Behat implements \PHPCI\Plugin
$parts = explode('---', $output);
if (count($parts) <= 1) {
return array(0, array());
return [0, []];
}
$lines = explode(PHP_EOL, $parts[1]);
$storeFailures = false;
$data = array();
$data = [];
foreach ($lines as $line) {
$line = trim($line);
@ -115,10 +115,10 @@ class Behat implements \PHPCI\Plugin
if ($storeFailures) {
$lineParts = explode(':', $line);
$data[] = array(
$data[] = [
'file' => $lineParts[0],
'line' => $lineParts[1]
);
];
$this->build->reportError(
$this->phpci,
@ -133,6 +133,6 @@ class Behat implements \PHPCI\Plugin
$errorCount = count($data);
return array($errorCount, $data);
return [$errorCount, $data];
}
}

View file

@ -36,7 +36,7 @@ class Campfire implements \PHPCI\Plugin
* @param array $options
* @throws \Exception
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$this->phpci = $phpci;
$this->build = $build;
@ -108,7 +108,7 @@ class Campfire implements \PHPCI\Plugin
$type = 'TextMessage';
}
return $this->getPageByPost($page, array('message' => array('type' => $type, 'body' => $message)));
return $this->getPageByPost($page, ['message' => ['type' => $type, 'body' => $message]]);
}
@ -134,7 +134,7 @@ class Campfire implements \PHPCI\Plugin
curl_setopt($handle, CURLOPT_VERBOSE, $this->verbose);
curl_setopt($handle, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($handle, CURLOPT_USERPWD, $this->authToken . ':x');
curl_setopt($handle, CURLOPT_HTTPHEADER, array("Content-type: application/json"));
curl_setopt($handle, CURLOPT_HTTPHEADER, ["Content-type: application/json"]);
curl_setopt($handle, CURLOPT_COOKIEFILE, $this->cookie);
curl_setopt($handle, CURLOPT_POSTFIELDS, $json);

View file

@ -37,11 +37,11 @@ class CleanBuild implements \PHPCI\Plugin
* @param Build $build
* @param array $options
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$this->phpci = $phpci;
$this->build = $build;
$this->remove = isset($options['remove']) && is_array($options['remove']) ? $options['remove'] : array();
$this->remove = isset($options['remove']) && is_array($options['remove']) ? $options['remove'] : [];
}
/**

View file

@ -79,7 +79,7 @@ class Codeception implements \PHPCI\Plugin, \PHPCI\ZeroConfigPlugin
* @param Build $build
* @param array $options
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$this->phpci = $phpci;
$this->build = $build;
@ -147,11 +147,11 @@ class Codeception implements \PHPCI\Plugin, \PHPCI\ZeroConfigPlugin
$parser = new Parser($this->phpci, $xml);
$output = $parser->parse();
$meta = array(
$meta = [
'tests' => $parser->getTotalTests(),
'timetaken' => $parser->getTotalTimeTaken(),
'failures' => $parser->getTotalFailures()
);
];
$this->build->storeMeta('codeception-meta', $meta);
$this->build->storeMeta('codeception-data', $output);

View file

@ -53,7 +53,7 @@ class Composer implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
* @param Build $build
* @param array $options
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$path = $phpci->buildPath;
$this->phpci = $phpci;
@ -91,7 +91,7 @@ class Composer implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
*/
public function execute()
{
$composerLocation = $this->phpci->findBinary(array('composer', 'composer.phar'));
$composerLocation = $this->phpci->findBinary(['composer', 'composer.phar']);
$cmd = '';

View file

@ -33,7 +33,7 @@ class CopyBuild implements \PHPCI\Plugin
* @param Build $build
* @param array $options
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$path = $phpci->buildPath;
$this->phpci = $phpci;

View file

@ -31,7 +31,7 @@ class Deployer implements \PHPCI\Plugin
* @param Build $build
* @param array $options
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$this->phpci = $phpci;
$this->build = $build;
@ -60,13 +60,13 @@ class Deployer implements \PHPCI\Plugin
$http = new HttpClient();
$response = $http->post($this->webhookUrl, array(
'reason' => $this->phpci->interpolate($this->reason),
'source' => 'PHPCI',
'url' => $this->phpci->interpolate('%BUILD_URI%'),
'branch' => $this->phpci->interpolate('%BRANCH%'),
$response = $http->post($this->webhookUrl, [
'reason' => $this->phpci->interpolate($this->reason),
'source' => 'PHPCI',
'url' => $this->phpci->interpolate('%BUILD_URI%'),
'branch' => $this->phpci->interpolate('%BRANCH%'),
'update_only' => $this->updateOnly
));
]);
return $response['success'];
}

View file

@ -50,7 +50,7 @@ class Email implements \PHPCI\Plugin
public function __construct(
Builder $phpci,
Build $build,
array $options = array()
array $options = []
) {
$this->phpci = $phpci;
$this->build = $build;
@ -161,7 +161,7 @@ class Email implements \PHPCI\Plugin
*/
protected function getEmailAddresses()
{
$addresses = array();
$addresses = [];
$committer = $this->build->getCommitterEmail();
if (isset($this->options['committer']) && !empty($committer)) {
@ -188,7 +188,7 @@ class Email implements \PHPCI\Plugin
*/
protected function getCcAddresses()
{
$ccAddresses = array();
$ccAddresses = [];
if (isset($this->options['cc'])) {
foreach ($this->options['cc'] as $address) {

View file

@ -31,7 +31,7 @@ class Env implements \PHPCI\Plugin
* @param Build $build
* @param array $options
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$this->phpci = $phpci;
$this->build = $build;

View file

@ -33,7 +33,7 @@ class FlowdockNotify implements \PHPCI\Plugin
* @param array $options
* @throws \Exception
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$this->phpci = $phpci;
$this->build = $build;
@ -65,7 +65,7 @@ class FlowdockNotify implements \PHPCI\Plugin
->setLink($this->build->getBranchLink())
->setContent($message);
if (!$push->sendTeamInboxMessage($flowMessage, array('connect_timeout' => 5000, 'timeout' => 5000))) {
if (!$push->sendTeamInboxMessage($flowMessage, ['connect_timeout' => 5000, 'timeout' => 5000])) {
throw new \Exception(sprintf('Flowdock Failed: %s', $flowMessage->getResponseErrors()));
}
return true;

View file

@ -23,7 +23,7 @@ class Git implements \PHPCI\Plugin
{
protected $phpci;
protected $build;
protected $actions = array();
protected $actions = [];
/**
* Set up the plugin, configure options, etc.
@ -31,7 +31,7 @@ class Git implements \PHPCI\Plugin
* @param Build $build
* @param array $options
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$this->phpci = $phpci;
$this->build = $build;
@ -74,7 +74,7 @@ class Git implements \PHPCI\Plugin
* @param array $options
* @return bool
*/
protected function runAction($action, array $options = array())
protected function runAction($action, array $options = [])
{
switch ($action) {
case 'merge':

View file

@ -40,7 +40,7 @@ class Grunt implements \PHPCI\Plugin
* @param Build $build
* @param array $options
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$path = $phpci->buildPath;
$this->build = $build;

View file

@ -40,7 +40,7 @@ class Gulp implements \PHPCI\Plugin
* @param Build $build
* @param array $options
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$path = $phpci->buildPath;
$this->build = $build;

View file

@ -32,7 +32,7 @@ class HipchatNotify implements \PHPCI\Plugin
* @param array $options
* @throws \Exception
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$this->phpci = $phpci;
$this->build = $build;

View file

@ -41,7 +41,7 @@ class Irc implements \PHPCI\Plugin
* @param Build $build
* @param array $options
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$this->phpci = $phpci;
$this->build = $build;
@ -79,10 +79,10 @@ class Irc implements \PHPCI\Plugin
$sock = fsockopen($this->server, $this->port);
stream_set_timeout($sock, 1);
$connectCommands = array(
$connectCommands = [
'USER ' . $this->nick . ' 0 * :' . $this->nick,
'NICK ' . $this->nick,
);
];
$this->executeIrcCommands($sock, $connectCommands);
$this->executeIrcCommand($sock, 'JOIN ' . $this->room);
$this->executeIrcCommand($sock, 'PRIVMSG ' . $this->room . ' :' . $msg);
@ -107,7 +107,7 @@ class Irc implements \PHPCI\Plugin
// almost all servers expect pingback!
while ($response = fgets($socket)) {
$matches = array();
$matches = [];
if (preg_match('/^PING \\:([A-Z0-9]+)/', $response, $matches)) {
$pingBack = $matches[1];
}
@ -127,6 +127,6 @@ class Irc implements \PHPCI\Plugin
*/
private function executeIrcCommand($socket, $command)
{
return $this->executeIrcCommands($socket, array($command));
return $this->executeIrcCommands($socket, [$command]);
}
}

View file

@ -39,11 +39,11 @@ class Lint implements PHPCI\Plugin
* @param Build $build
* @param array $options
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$this->phpci = $phpci;
$this->build = $build;
$this->directories = array('');
$this->directories = [''];
$this->ignore = $phpci->ignore;
if (!empty($options['directory'])) {

View file

@ -36,7 +36,7 @@ class Mysql implements \PHPCI\Plugin
/**
* @var array
*/
protected $queries = array();
protected $queries = [];
/**
* @var string
@ -58,7 +58,7 @@ class Mysql implements \PHPCI\Plugin
* @param Build $build
* @param array $options
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$this->phpci = $phpci;
$this->build = $build;
@ -97,7 +97,7 @@ class Mysql implements \PHPCI\Plugin
public function execute()
{
try {
$opts = array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION);
$opts = [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION];
$pdo = new PDO('mysql:host=' . $this->host, $this->user, $this->pass, $opts);
foreach ($this->queries as $query) {
@ -152,10 +152,10 @@ class Mysql implements \PHPCI\Plugin
*/
protected function getImportCommand($import_file, $database = null)
{
$decompression = array(
$decompression = [
'bz2' => '| bzip2 --decompress',
'gz' => '| gzip --decompress',
);
'gz' => '| gzip --decompress',
];
$extension = strtolower(pathinfo($import_file, PATHINFO_EXTENSION));
$decomp_cmd = '';
@ -163,14 +163,14 @@ class Mysql implements \PHPCI\Plugin
$decomp_cmd = $decompression[$extension];
}
$args = array(
$args = [
':import_file' => escapeshellarg($import_file),
':decomp_cmd' => $decomp_cmd,
':host' => escapeshellarg($this->host),
':user' => escapeshellarg($this->user),
':pass' => escapeshellarg($this->pass),
':database' => ($database === null)? '': escapeshellarg($database),
);
':decomp_cmd' => $decomp_cmd,
':host' => escapeshellarg($this->host),
':user' => escapeshellarg($this->user),
':pass' => escapeshellarg($this->pass),
':database' => ($database === null)? '': escapeshellarg($database),
];
return strtr('cat :import_file :decomp_cmd | mysql -h:host -u:user -p:pass :database', $args);
}
}

View file

@ -31,7 +31,7 @@ class PackageBuild implements \PHPCI\Plugin
* @param Build $build
* @param array $options
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$path = $phpci->buildPath;
$this->build = $build;
@ -65,7 +65,7 @@ class PackageBuild implements \PHPCI\Plugin
chdir($this->phpci->buildPath);
if (!is_array($this->format)) {
$this->format = array($this->format);
$this->format = [$this->format];
}
foreach ($this->format as $format) {

View file

@ -54,7 +54,7 @@ class Pdepend implements \PHPCI\Plugin
* @param Build $build
* @param array $options
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$this->phpci = $phpci;
$this->build = $build;
@ -126,7 +126,7 @@ class Pdepend implements \PHPCI\Plugin
protected function removeBuildArtifacts()
{
//Remove the created files first
foreach (array($this->summary, $this->chart, $this->pyramid) as $file) {
foreach ([$this->summary, $this->chart, $this->pyramid] as $file) {
if (file_exists($this->location . DIRECTORY_SEPARATOR . $file)) {
unlink($this->location . DIRECTORY_SEPARATOR . $file);
}

View file

@ -34,7 +34,7 @@ class Pgsql implements \PHPCI\Plugin
/**
* @var array
*/
protected $queries = array();
protected $queries = [];
/**
* @var string
@ -56,7 +56,7 @@ class Pgsql implements \PHPCI\Plugin
* @param Build $build
* @param array $options
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$this->phpci = $phpci;
$this->build = $build;
@ -79,8 +79,8 @@ class Pgsql implements \PHPCI\Plugin
public function execute()
{
try {
$opts = array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION);
$pdo = new PDO('pgsql:host=' . $this->host, $this->user, $this->pass, $opts);
$opts = [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION];
$pdo = new PDO('pgsql:host=' . $this->host, $this->user, $this->pass, $opts);
foreach ($this->queries as $query) {
$pdo->query($this->phpci->interpolate($query));

View file

@ -60,7 +60,7 @@ class Phar implements \PHPCI\Plugin
* @param Build $build
* @param array $options
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
// Basic
$this->phpci = $phpci;

View file

@ -24,9 +24,9 @@ class Phing implements \PHPCI\Plugin
{
private $directory;
private $buildFile = 'build.xml';
private $targets = array('build');
private $properties = array();
private $buildFile = 'build.xml';
private $targets = ['build'];
private $properties = [];
private $propertyFile;
protected $phpci;
@ -38,7 +38,7 @@ class Phing implements \PHPCI\Plugin
* @param Build $build
* @param array $options
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$this->setPhpci($phpci);
$this->build = $build;
@ -157,7 +157,7 @@ class Phing implements \PHPCI\Plugin
public function setTargets($targets)
{
if (is_string($targets)) {
$targets = array($targets);
$targets = [$targets];
}
$this->targets = $targets;
@ -216,7 +216,7 @@ class Phing implements \PHPCI\Plugin
$this->properties['project.basedir'] = $this->getDirectory();
}
$propertiesString = array();
$propertiesString = [];
foreach ($this->properties as $name => $value) {
$propertiesString[] = '-D' . $name . '="' . $value . '"';
@ -233,7 +233,7 @@ class Phing implements \PHPCI\Plugin
public function setProperties($properties)
{
if (is_string($properties)) {
$properties = array($properties);
$properties = [$properties];
}
$this->properties = $properties;

View file

@ -94,11 +94,11 @@ class PhpCodeSniffer implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
* @param \PHPCI\Model\Build $build
* @param array $options
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$this->phpci = $phpci;
$this->build = $build;
$this->suffixes = array('php');
$this->suffixes = ['php'];
$this->directory = $phpci->buildPath;
$this->standard = 'PSR2';
$this->tab_width = '';
@ -134,7 +134,7 @@ class PhpCodeSniffer implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
*/
protected function setOptions($options)
{
foreach (array('directory', 'standard', 'path', 'ignore', 'allowed_warnings', 'allowed_errors') as $key) {
foreach (['directory', 'standard', 'path', 'ignore', 'allowed_warnings', 'allowed_errors'] as $key) {
if (array_key_exists($key, $options)) {
$this->{$key} = $options[$key];
}
@ -205,7 +205,7 @@ class PhpCodeSniffer implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
$suffixes = ' --extensions=' . implode(',', $this->suffixes);
}
return array($ignore, $standard, $suffixes);
return [$ignore, $standard, $suffixes];
}
/**
@ -241,6 +241,6 @@ class PhpCodeSniffer implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
}
}
return array($errors, $warnings);
return [$errors, $warnings];
}
}

View file

@ -44,7 +44,7 @@ class PhpCpd implements \PHPCI\Plugin
* @param Build $build
* @param array $options
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$this->phpci = $phpci;
$this->build = $build;

View file

@ -35,7 +35,7 @@ class PhpCsFixer implements \PHPCI\Plugin
protected $level = ' --level=psr2';
protected $verbose = '';
protected $diff = '';
protected $levels = array('psr0', 'psr1', 'psr2', 'symfony');
protected $levels = ['psr0', 'psr1', 'psr2', 'symfony'];
/**
* Standard Constructor
@ -49,7 +49,7 @@ class PhpCsFixer implements \PHPCI\Plugin
* @param Build $build
* @param array $options
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$this->phpci = $phpci;
$this->build = $build;

View file

@ -67,7 +67,7 @@ class PhpDocblockChecker implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
* @param Build $build
* @param array $options
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$this->phpci = $phpci;
$this->build = $build;

View file

@ -52,7 +52,7 @@ class PhpLoc implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
* @param Build $build
* @param array $options
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$this->phpci = $phpci;
$this->build = $build;
@ -85,7 +85,7 @@ class PhpLoc implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
$output = $this->phpci->getLastOutput();
if (preg_match_all('/\((LOC|CLOC|NCLOC|LLOC)\)\s+([0-9]+)/', $output, $matches)) {
$data = array();
$data = [];
foreach ($matches[1] as $k => $v) {
$data[$v] = (int)$matches[2][$k];
}

View file

@ -83,14 +83,14 @@ class PhpMessDetector implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
* @param Build $build
* @param array $options
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$this->phpci = $phpci;
$this->build = $build;
$this->suffixes = array('php');
$this->suffixes = ['php'];
$this->ignore = $phpci->ignore;
$this->path = '';
$this->rules = array('codesize', 'unusedcode', 'naming');
$this->rules = ['codesize', 'unusedcode', 'naming'];
$this->allowed_warnings = 0;
if (isset($options['zero_config']) && $options['zero_config']) {
@ -105,7 +105,7 @@ class PhpMessDetector implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
$this->allowed_warnings = (int)$options['allowed_warnings'];
}
foreach (array('rules', 'ignore', 'suffixes') as $key) {
foreach (['rules', 'ignore', 'suffixes'] as $key) {
$this->overrideSetting($options, $key);
}
}

View file

@ -53,7 +53,7 @@ class PhpParallelLint implements \PHPCI\Plugin
* @param Build $build
* @param array $options
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$this->phpci = $phpci;
$this->build = $build;
@ -87,7 +87,7 @@ class PhpParallelLint implements \PHPCI\Plugin
$output = $this->phpci->getLastOutput();
$matches = array();
$matches = [];
if (preg_match_all('/Parse error\:/', $output, $matches)) {
$this->build->storeMeta('phplint-errors', count($matches[0]));
}
@ -101,12 +101,12 @@ class PhpParallelLint implements \PHPCI\Plugin
*/
protected function getFlags()
{
$ignoreFlags = array();
$ignoreFlags = [];
foreach ($this->ignore as $ignoreDir) {
$ignoreFlags[] = '--exclude "' . $this->phpci->buildPath . $ignoreDir . '"';
}
$ignore = implode(' ', $ignoreFlags);
return array($ignore);
return [$ignore];
}
}

View file

@ -42,7 +42,7 @@ class PhpSpec implements PHPCI\Plugin
* @param Build $build
* @param array $options
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$this->phpci = $phpci;
$this->build = $build;
@ -57,7 +57,7 @@ class PhpSpec implements PHPCI\Plugin
$curdir = getcwd();
chdir($this->phpci->buildPath);
$phpspec = $this->phpci->findBinary(array('phpspec', 'phpspec.php'));
$phpspec = $this->phpci->findBinary(['phpspec', 'phpspec.php']);
$success = $this->phpci->executeCommand($phpspec . ' --format=junit --no-code-generation run');
$output = $this->phpci->getLastOutput();
@ -76,47 +76,45 @@ class PhpSpec implements PHPCI\Plugin
$xml = new \SimpleXMLElement($output);
$attr = $xml->attributes();
$data = array(
'time' => (float)$attr['time'],
'tests' => (int)$attr['tests'],
$data = [
'time' => (float)$attr['time'],
'tests' => (int)$attr['tests'],
'failures' => (int)$attr['failures'],
'errors' => (int)$attr['errors'],
'errors' => (int)$attr['errors'],
// now all the tests
'suites' => array()
);
'suites' => []
];
/**
* @var \SimpleXMLElement $group
*/
foreach ($xml->xpath('testsuite') as $group) {
$attr = $group->attributes();
$suite = array(
'name' => (String)$attr['name'],
'time' => (float)$attr['time'],
'tests' => (int)$attr['tests'],
$attr = $group->attributes();
$suite = [
'name' => (String)$attr['name'],
'time' => (float)$attr['time'],
'tests' => (int)$attr['tests'],
'failures' => (int)$attr['failures'],
'errors' => (int)$attr['errors'],
'skipped' => (int)$attr['skipped'],
'errors' => (int)$attr['errors'],
'skipped' => (int)$attr['skipped'],
// now the cases
'cases' => array()
);
'cases' => []
];
/**
* @var \SimpleXMLElement $child
*/
foreach ($group->xpath('testcase') as $child) {
$attr = $child->attributes();
$case = array(
'name' => (String)$attr['name'],
$case = [
'name' => (String)$attr['name'],
'classname' => (String)$attr['classname'],
'time' => (float)$attr['time'],
'status' => (String)$attr['status'],
);
'time' => (float)$attr['time'],
'status' => (String)$attr['status'],
];
if ($case['status']=='failed') {
$error = array();
$error = [];
/*
* ok, sad, we had an error
*

View file

@ -54,7 +54,7 @@ class PhpTalLint implements PHPCI\Plugin
/**
* @var array The results of the lint scan
*/
protected $failedPaths = array();
protected $failedPaths = [];
/**
* Standard Constructor
@ -63,19 +63,19 @@ class PhpTalLint implements PHPCI\Plugin
* @param Build $build
* @param array $options
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$this->phpci = $phpci;
$this->build = $build;
$this->directories = array('');
$this->suffixes = array('zpt');
$this->directories = [''];
$this->suffixes = ['zpt'];
$this->ignore = $phpci->ignore;
$this->allowed_warnings = 0;
$this->allowed_errors = 0;
if (!empty($options['directory'])) {
$this->directories = array($options['directory']);
$this->directories = [$options['directory']];
}
if (isset($options['suffixes'])) {
@ -91,7 +91,7 @@ class PhpTalLint implements PHPCI\Plugin
*/
protected function setOptions($options)
{
foreach (array('directories', 'tales', 'allowed_warnings', 'allowed_errors') as $key) {
foreach (['directories', 'tales', 'allowed_warnings', 'allowed_errors'] as $key) {
if (array_key_exists($key, $options)) {
$this->{$key} = $options[$key];
}
@ -230,12 +230,12 @@ class PhpTalLint implements PHPCI\Plugin
$message = trim($parts[0]);
$line = str_replace(')', '', $parts[1]);
$this->failedPaths[] = array(
'file' => $path,
'line' => $line,
'type' => $matches[2],
$this->failedPaths[] = [
'file' => $path,
'line' => $line,
'type' => $matches[2],
'message' => $message
);
];
}
$success = false;
@ -260,6 +260,6 @@ class PhpTalLint implements PHPCI\Plugin
$suffixes = ' -e ' . implode(',', $this->suffixes);
}
return array($suffixes, $tales);
return [$suffixes, $tales];
}
}

View file

@ -103,7 +103,7 @@ class PhpUnit implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
* @param Build $build
* @param array $options
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$this->phpci = $phpci;
$this->build = $build;
@ -190,7 +190,7 @@ class PhpUnit implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
protected function runConfigFile($configPath)
{
if (is_array($configPath)) {
return $this->recurseArg($configPath, array($this, "runConfigFile"));
return $this->recurseArg($configPath, [$this, "runConfigFile"]);
} else {
if ($this->runFrom) {
$curdir = getcwd();
@ -218,7 +218,7 @@ class PhpUnit implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
protected function runDir($directory)
{
if (is_array($directory)) {
return $this->recurseArg($directory, array($this, "runDir"));
return $this->recurseArg($directory, [$this, "runDir"]);
} else {
$curdir = getcwd();
chdir($this->phpci->buildPath);

View file

@ -36,7 +36,7 @@ class Shell implements \PHPCI\Plugin
/**
* @var string[] $commands The commands to be executed
*/
protected $commands = array();
protected $commands = [];
/**
* Standard Constructor
@ -50,7 +50,7 @@ class Shell implements \PHPCI\Plugin
* @param Build $build
* @param array $options
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$this->phpci = $phpci;
$this->build = $build;
@ -58,7 +58,7 @@ class Shell implements \PHPCI\Plugin
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']);
$this->commands = array($options['command']);
$this->commands = [$options['command']];
return;
}

View file

@ -33,7 +33,7 @@ class SlackNotify implements \PHPCI\Plugin
* @param array $options
* @throws \Exception
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$this->phpci = $phpci;
$this->build = $build;
@ -112,18 +112,18 @@ class SlackNotify implements \PHPCI\Plugin
}
// Build up the attachment data
$attachment = new \Maknz\Slack\Attachment(array(
$attachment = new \Maknz\Slack\Attachment([
'fallback' => $body,
'pretext' => $body,
'color' => $color,
'fields' => array(
new \Maknz\Slack\AttachmentField(array(
'fields' => [
new \Maknz\Slack\AttachmentField([
'title' => 'Status',
'value' => $status,
'short' => false
))
)
));
])
]
]);
$message->attach($attachment);

View file

@ -34,7 +34,7 @@ class Sqlite implements \PHPCI\Plugin
/**
* @var array
*/
protected $queries = array();
protected $queries = [];
/**
* @var string
@ -46,7 +46,7 @@ class Sqlite implements \PHPCI\Plugin
* @param Build $build
* @param array $options
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$this->phpci = $phpci;
$this->build = $build;
@ -66,8 +66,8 @@ class Sqlite implements \PHPCI\Plugin
public function execute()
{
try {
$opts = array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION);
$pdo = new PDO('sqlite:' . $this->path, $opts);
$opts = [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION];
$pdo = new PDO('sqlite:' . $this->path, $opts);
foreach ($this->queries as $query) {
$pdo->query($this->phpci->interpolate($query));

View file

@ -81,16 +81,16 @@ class TechnicalDebt implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
* @param \PHPCI\Model\Build $build
* @param array $options
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$this->phpci = $phpci;
$this->build = $build;
$this->suffixes = array('php');
$this->suffixes = ['php'];
$this->directory = $phpci->buildPath;
$this->path = '';
$this->ignore = $this->phpci->ignore;
$this->allowed_errors = 0;
$this->searches = array('TODO', 'FIXME', 'TO DO', 'FIX ME');
$this->searches = ['TODO', 'FIXME', 'TO DO', 'FIX ME'];
if (isset($options['searches']) && is_array($options['searches'])) {
$this->searches = $options['searches'];
@ -109,7 +109,7 @@ class TechnicalDebt implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
*/
protected function setOptions($options)
{
foreach (array('directory', 'path', 'ignore', 'allowed_errors') as $key) {
foreach (['directory', 'path', 'ignore', 'allowed_errors'] as $key) {
if (array_key_exists($key, $options)) {
$this->{$key} = $options[$key];
}
@ -145,10 +145,10 @@ class TechnicalDebt implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
public function getErrorList()
{
$dirIterator = new \RecursiveDirectoryIterator($this->directory);
$iterator = new \RecursiveIteratorIterator($dirIterator, \RecursiveIteratorIterator::SELF_FIRST);
$files = array();
$iterator = new \RecursiveIteratorIterator($dirIterator, \RecursiveIteratorIterator::SELF_FIRST);
$files = [];
$ignores = $this->ignore;
$ignores = $this->ignore;
$ignores[] = 'phpci.yml';
$ignores[] = '.phpci.yml';

View file

@ -29,7 +29,7 @@ class ComposerPluginInformation implements InstalledPluginInformation
if (file_exists($filePath)) {
$installed = json_decode(file_get_contents($filePath));
} else {
$installed = array();
$installed = [];
}
return new self($installed);
}
@ -80,7 +80,7 @@ class ComposerPluginInformation implements InstalledPluginInformation
if ($this->pluginInfo !== null) {
return;
}
$this->pluginInfo = array();
$this->pluginInfo = [];
foreach ($this->composerPackages as $package) {
$this->addPluginsFromPackage($package);
}

View file

@ -49,8 +49,8 @@ class Executor
*/
public function executePlugins(&$config, $stage)
{
$success = true;
$pluginsToExecute = array();
$success = true;
$pluginsToExecute = [];
// If we have global plugins to execute for this stage, add them to the list to be executed:
if (array_key_exists($stage, $config) && is_array($config[$stage])) {
@ -99,7 +99,7 @@ class Executor
switch ($runOption) {
// Replace standard plugin set for this stage with just the branch-specific ones:
case 'replace':
$pluginsToExecute = array();
$pluginsToExecute = [];
$pluginsToExecute[] = $plugins;
break;
@ -207,7 +207,7 @@ class Executor
$summary = $this->getBuildSummary();
if (!isset($summary[$stage][$plugin])) {
$summary[$stage][$plugin] = array();
$summary[$stage][$plugin] = [];
}
$summary[$stage][$plugin]['status'] = $status;
@ -230,7 +230,7 @@ class Executor
{
$build = $this->pluginFactory->getResourceFor('PHPCI\Model\Build');
$metas = $this->store->getMeta('plugin-summary', $build->getProjectId(), $build->getId());
return isset($metas[0]['meta_value']) ? $metas[0]['meta_value'] : array();
return isset($metas[0]['meta_value']) ? $metas[0]['meta_value'] : [];
}
/**

View file

@ -82,7 +82,7 @@ class Factory
* @throws \InvalidArgumentException if $className doesn't represent a valid plugin
* @return \PHPCI\Plugin
*/
public function buildPlugin($className, $options = array())
public function buildPlugin($className, $options = [])
{
$this->currentPluginOptions = $options;
@ -97,7 +97,7 @@ class Factory
$constructor = $reflectedPlugin->getConstructor();
if ($constructor) {
$argsToUse = array();
$argsToUse = [];
foreach ($constructor->getParameters() as $param) {
$argsToUse = $this->addArgFromParam($argsToUse, $param);
}

View file

@ -81,7 +81,7 @@ class FilesPluginInformation implements InstalledPluginInformation
*/
protected function loadPluginInfo()
{
$this->pluginInfo = array();
$this->pluginInfo = [];
foreach ($this->files as $fileInfo) {
if ($fileInfo instanceof \SplFileInfo) {
if ($fileInfo->isFile() && $fileInfo->getExtension() == 'php') {
@ -118,14 +118,14 @@ class FilesPluginInformation implements InstalledPluginInformation
protected function getFullClassFromFile(\SplFileInfo $fileInfo)
{
$contents = file_get_contents($fileInfo->getRealPath());
$matches = array();
$matches = [];
preg_match('#class +([A-Za-z]+) +implements#i', $contents, $matches);
if (isset($matches[1])) {
$className = $matches[1];
$matches = array();
$matches = [];
preg_match('#namespace +([A-Za-z\\\\]+);#i', $contents, $matches);
$namespace = $matches[1];

View file

@ -11,7 +11,7 @@ class PluginInformationCollection implements InstalledPluginInformation
/**
* @var InstalledPluginInformation[]
*/
protected $pluginInformations = array();
protected $pluginInformations = [];
/**
* Add a plugin to the collection.
@ -31,7 +31,7 @@ class PluginInformationCollection implements InstalledPluginInformation
*/
public function getInstalledPlugins()
{
$arr = array();
$arr = [];
foreach ($this->pluginInformations as $single) {
$arr = array_merge($arr, $single->getInstalledPlugins());
@ -48,7 +48,7 @@ class PluginInformationCollection implements InstalledPluginInformation
*/
public function getPluginClasses()
{
$arr = array();
$arr = [];
foreach ($this->pluginInformations as $single) {
$arr = array_merge($arr, $single->getPluginClasses());

View file

@ -68,7 +68,7 @@ class TapParser
$this->lineNumber = 0;
$this->testCount = false;
$this->results = array();
$this->results = [];
$header = $this->findTapLog();
@ -208,11 +208,11 @@ class TapParser
*/
protected function processTestLine($result, $message, $directive, $reason)
{
$test = array(
$test = [
'pass' => true,
'message' => $message,
'severity' => 'success',
);
];
if ($result !== 'ok') {
$test['pass'] = false;
@ -237,7 +237,7 @@ class TapParser
{
$startLine = $this->lineNumber + 1;
$endLine = $indent . '...';
$yamlLines = array();
$yamlLines = [];
do {
$line = $this->nextLine();

View file

@ -38,7 +38,7 @@ class Codeception implements ParserInterface
*/
public function parse()
{
$rtn = array();
$rtn = [];
$this->results = new \SimpleXMLElement($this->resultsXml);
@ -50,14 +50,14 @@ class Codeception implements ParserInterface
$this->totalErrors += (int) $testsuite['errors'];
foreach ($testsuite->testcase as $testcase) {
$testresult = array(
'suite' => (string) $testsuite['name'],
'file' => str_replace($this->phpci->buildPath, '/', (string) $testcase['file']),
'name' => (string) $testcase['name'],
'feature' => (string) $testcase['feature'],
$testresult = [
'suite' => (string) $testsuite['name'],
'file' => str_replace($this->phpci->buildPath, '/', (string) $testcase['file']),
'name' => (string) $testcase['name'],
'feature' => (string) $testcase['feature'],
'assertions' => (int) $testcase['assertions'],
'time' => (float) $testcase['time']
);
'time' => (float) $testcase['time']
];
if (isset($testcase['class'])) {
$testresult['class'] = (string) $testcase['class'];

View file

@ -38,7 +38,7 @@ class Wipe implements \PHPCI\Plugin
* @param Build $build
* @param array $options
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$path = $phpci->buildPath;
$this->phpci = $phpci;

View file

@ -65,7 +65,7 @@ class XMPP implements \PHPCI\Plugin
* @param Build $build
* @param array $options
*/
public function __construct(Builder $phpci, Build $build, array $options = array())
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$this->phpci = $phpci;
$this->build = $build;
@ -74,7 +74,7 @@ class XMPP implements \PHPCI\Plugin
$this->password = '';
$this->server = '';
$this->alias = '';
$this->recipients = array();
$this->recipients = [];
$this->tls = false;
$this->date_format = '%c';
@ -83,7 +83,7 @@ class XMPP implements \PHPCI\Plugin
*/
if (!empty($options['recipients'])) {
if (is_string($options['recipients'])) {
$this->recipients = array($options['recipients']);
$this->recipients = [$options['recipients']];
} elseif (is_array($options['recipients'])) {
$this->recipients = $options['recipients'];
}
@ -99,7 +99,7 @@ class XMPP implements \PHPCI\Plugin
*/
protected function setOptions($options)
{
foreach (array('username', 'password', 'alias', 'tls', 'server', 'date_format') as $key) {
foreach (['username', 'password', 'alias', 'tls', 'server', 'date_format'] as $key) {
if (array_key_exists($key, $options)) {
$this->{$key} = $options[$key];
}

View file

@ -159,15 +159,15 @@ class BuildService
return;
}
$config = Config::getInstance();
$config = Config::getInstance();
$settings = $config->get('phpci.worker', []);
if (!empty($settings['host']) && !empty($settings['queue'])) {
try {
$jobData = array(
'type' => 'phpci.build',
$jobData = [
'type' => 'phpci.build',
'build_id' => $build->getId(),
);
];
if ($config->get('using_custom_file')) {
$jobData['config'] = $config->getArray();

View file

@ -34,10 +34,10 @@ class BuildStatusService
protected $url;
/** @var array */
protected $finishedStatusIds = array(
protected $finishedStatusIds = [
Build::STATUS_SUCCESS,
Build::STATUS_FAILED,
);
];
/**
* @param $branch
@ -208,15 +208,15 @@ class BuildStatusService
public function toArray()
{
if (!$this->build) {
return array();
return [];
}
return array(
'name' => $this->getName(),
'activity' => $this->getActivity(),
'lastBuildLabel' => $this->getLastBuildLabel(),
return [
'name' => $this->getName(),
'activity' => $this->getActivity(),
'lastBuildLabel' => $this->getLastBuildLabel(),
'lastBuildStatus' => $this->getLastBuildStatus(),
'lastBuildTime' => $this->getLastBuildTime(),
'webUrl' => $this->getBuildUrl(),
);
'lastBuildTime' => $this->getLastBuildTime(),
'webUrl' => $this->getBuildUrl(),
];
}
}

View file

@ -40,7 +40,7 @@ class ProjectService
* @param array $options
* @return \PHPCI\Model\Project
*/
public function createProject($title, $type, $reference, $options = array())
public function createProject($title, $type, $reference, $options = [])
{
// Create base project and use updateProject() to set its properties:
$project = new Project();
@ -56,7 +56,7 @@ class ProjectService
* @param array $options
* @return \PHPCI\Model\Project
*/
public function updateProject(Project $project, $title, $type, $reference, $options = array())
public function updateProject(Project $project, $title, $type, $reference, $options = [])
{
// Set basic properties:
$project->setTitle($title);
@ -117,11 +117,11 @@ class ProjectService
*/
protected function processAccessInformation(Project &$project)
{
$matches = array();
$matches = [];
$reference = $project->getReference();
if ($project->getType() == 'gitlab') {
$info = array();
$info = [];
if (preg_match('`^(.+)@(.+):([0-9]*)\/?(.+)\.git`', $reference, $matches)) {
$info['user'] = $matches[1];

View file

@ -77,9 +77,9 @@ class BuildErrorStoreBase extends Store
$count = count($rtn);
return array('items' => $rtn, 'count' => $count);
return ['items' => $rtn, 'count' => $count];
} else {
return array('items' => array(), 'count' => 0);
return ['items' => [], 'count' => 0];
}
}
}

View file

@ -77,9 +77,9 @@ class BuildMetaStoreBase extends Store
$count = count($rtn);
return array('items' => $rtn, 'count' => $count);
return ['items' => $rtn, 'count' => $count];
} else {
return array('items' => array(), 'count' => 0);
return ['items' => [], 'count' => 0];
}
}
@ -109,9 +109,9 @@ class BuildMetaStoreBase extends Store
$count = count($rtn);
return array('items' => $rtn, 'count' => $count);
return ['items' => $rtn, 'count' => $count];
} else {
return array('items' => array(), 'count' => 0);
return ['items' => [], 'count' => 0];
}
}
}

View file

@ -77,9 +77,9 @@ class BuildStoreBase extends Store
$count = count($rtn);
return array('items' => $rtn, 'count' => $count);
return ['items' => $rtn, 'count' => $count];
} else {
return array('items' => array(), 'count' => 0);
return ['items' => [], 'count' => 0];
}
}
@ -109,9 +109,9 @@ class BuildStoreBase extends Store
$count = count($rtn);
return array('items' => $rtn, 'count' => $count);
return ['items' => $rtn, 'count' => $count];
} else {
return array('items' => array(), 'count' => 0);
return ['items' => [], 'count' => 0];
}
}
}

View file

@ -77,9 +77,9 @@ class ProjectStoreBase extends Store
$count = count($rtn);
return array('items' => $rtn, 'count' => $count);
return ['items' => $rtn, 'count' => $count];
} else {
return array('items' => array(), 'count' => 0);
return ['items' => [], 'count' => 0];
}
}
@ -109,9 +109,9 @@ class ProjectStoreBase extends Store
$count = count($rtn);
return array('items' => $rtn, 'count' => $count);
return ['items' => $rtn, 'count' => $count];
} else {
return array('items' => array(), 'count' => 0);
return ['items' => [], 'count' => 0];
}
}
}

View file

@ -100,9 +100,9 @@ class UserStoreBase extends Store
$count = count($rtn);
return array('items' => $rtn, 'count' => $count);
return ['items' => $rtn, 'count' => $count];
} else {
return array('items' => array(), 'count' => 0);
return ['items' => [], 'count' => 0];
}
}
}

View file

@ -51,7 +51,7 @@ class BuildErrorStore extends BuildErrorStoreBase
return $rtn;
} else {
return array();
return [];
}
}

View file

@ -45,7 +45,7 @@ class BuildMetaStore extends BuildMetaStoreBase
return $rtn;
} else {
return array();
return [];
}
}
}

View file

@ -53,7 +53,7 @@ class BuildStore extends BuildStoreBase
return $rtn;
} else {
return array();
return [];
}
}
@ -75,7 +75,7 @@ class BuildStore extends BuildStoreBase
return new Build($data);
}
} else {
return array();
return [];
}
}
@ -101,9 +101,9 @@ class BuildStore extends BuildStoreBase
$rtn = array_map($map, $res);
return array('items' => $rtn, 'count' => count($rtn));
return ['items' => $rtn, 'count' => count($rtn)];
} else {
return array('items' => array(), 'count' => 0);
return ['items' => [], 'count' => 0];
}
}
@ -124,7 +124,7 @@ class BuildStore extends BuildStoreBase
$res = $stmt->fetchAll(\PDO::FETCH_COLUMN);
return $res;
} else {
return array();
return [];
}
}

View file

@ -42,7 +42,7 @@ class ProjectStore extends ProjectStoreBase
return $rtn;
} else {
return array();
return [];
}
}
@ -66,9 +66,9 @@ class ProjectStore extends ProjectStoreBase
$count = count($rtn);
return array('items' => $rtn, 'count' => $count);
return ['items' => $rtn, 'count' => $count];
} else {
return array('items' => array(), 'count' => 0);
return ['items' => [], 'count' => 0];
}
}
@ -101,9 +101,9 @@ class ProjectStore extends ProjectStoreBase
$count = count($rtn);
return array('items' => $rtn, 'count' => $count);
return ['items' => $rtn, 'count' => $count];
} else {
return array('items' => array(), 'count' => 0);
return ['items' => [], 'count' => 0];
}
}
}

View file

@ -67,7 +67,7 @@
<div class="col-lg-3 col-md-4 col-sm-4">
<?php if (in_array($project->getType(), array('github', 'gitlab', 'bitbucket'))): ?>
<?php if (in_array($project->getType(), ['github', 'gitlab', 'bitbucket'])): ?>
<div class="box box-info">
<div class="box-header">
<h4 class="box-title"><?php Lang::out('webhooks'); ?></h4>

View file

@ -2,13 +2,12 @@
use PHPCI\Helper\Lang;
foreach($projects as $project):
$statuses = array();
$statuses = [];
$failures = 0;
$subcls = 'yellow';
$cls = '';
$success = null;
$failure = null;
$subcls = 'yellow';
$cls = '';
$success = null;
$failure = null;
if (count($builds[$project->getId()])) {
// Get the most recent build status to determine the main block colour.