Code style fixes
This commit is contained in:
parent
6c4c669492
commit
0868eb9c69
63 changed files with 1413 additions and 1494 deletions
|
|
@ -32,8 +32,8 @@ class Application extends b8\Application
|
|||
public function init()
|
||||
{
|
||||
$request =& $this->request;
|
||||
$route = '/:controller/:action';
|
||||
$opts = array('controller' => 'Home', 'action' => 'index');
|
||||
$route = '/:controller/:action';
|
||||
$opts = ['controller' => 'Home', 'action' => 'index'];
|
||||
|
||||
// Inlined as a closure to fix "using $this when not in object context" on 5.3
|
||||
$validateSession = function () {
|
||||
|
|
@ -51,11 +51,11 @@ class Application extends b8\Application
|
|||
return false;
|
||||
};
|
||||
|
||||
$skipAuth = array($this, 'shouldSkipAuth');
|
||||
$skipAuth = [$this, 'shouldSkipAuth'];
|
||||
|
||||
// Handler for the route we're about to register, checks for a valid session where necessary:
|
||||
$routeHandler = function (&$route, Response &$response) use (&$request, $validateSession, $skipAuth) {
|
||||
$skipValidation = in_array($route['controller'], array('session', 'webhook', 'build-status'));
|
||||
$skipValidation = in_array($route['controller'], ['session', 'webhook', 'build-status']);
|
||||
|
||||
if (!$skipValidation && !$validateSession() && (!is_callable($skipAuth) || !$skipAuth())) {
|
||||
if ($request->isAjax()) {
|
||||
|
|
@ -121,10 +121,10 @@ class Application extends b8\Application
|
|||
*/
|
||||
protected function loadController($class)
|
||||
{
|
||||
$controller = parent::loadController($class);
|
||||
$controller->layout = new View('layout');
|
||||
$controller->layout->title = 'PHPCI';
|
||||
$controller->layout->breadcrumb = array();
|
||||
$controller = parent::loadController($class);
|
||||
$controller->layout = new View('layout');
|
||||
$controller->layout->title = 'PHPCI';
|
||||
$controller->layout->breadcrumb = [];
|
||||
|
||||
return $controller;
|
||||
}
|
||||
|
|
@ -135,12 +135,12 @@ class Application extends b8\Application
|
|||
*/
|
||||
protected function setLayoutVariables(View &$layout)
|
||||
{
|
||||
$groups = array();
|
||||
$groups = [];
|
||||
$groupStore = b8\Store\Factory::getStore('ProjectGroup');
|
||||
$groupList = $groupStore->getWhere(array(), 100, 0, array(), array('title' => 'ASC'));
|
||||
$groupList = $groupStore->getWhere([], 100, 0, [], ['title' => 'ASC']);
|
||||
|
||||
foreach ($groupList['items'] as $group) {
|
||||
$thisGroup = array('title' => $group->getTitle());
|
||||
$thisGroup = ['title' => $group->getTitle()];
|
||||
$projects = b8\Store\Factory::getStore('Project')->getByGroupId($group->getId());
|
||||
$thisGroup['projects'] = $projects['items'];
|
||||
$groups[] = $thisGroup;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class Builder implements LoggerAwareInterface
|
|||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
public $ignore = array();
|
||||
public $ignore = [];
|
||||
|
||||
/**
|
||||
* @var string
|
||||
|
|
@ -201,7 +201,7 @@ class Builder implements LoggerAwareInterface
|
|||
$this->setupBuild();
|
||||
|
||||
// Run the core plugin stages:
|
||||
foreach (array('setup', 'test') as $stage) {
|
||||
foreach (['setup', 'test'] as $stage) {
|
||||
$success &= $this->pluginExecutor->executePlugins($this->config, $stage);
|
||||
}
|
||||
|
||||
|
|
@ -350,7 +350,7 @@ class Builder implements LoggerAwareInterface
|
|||
* @param string $level
|
||||
* @param array $context
|
||||
*/
|
||||
public function log($message, $level = LogLevel::INFO, $context = array())
|
||||
public function log($message, $level = LogLevel::INFO, $context = [])
|
||||
{
|
||||
$this->buildLogger->log($message, $level, $context);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,13 +67,13 @@ class DaemonCommand extends Command
|
|||
'pid-file', 'p', InputOption::VALUE_REQUIRED,
|
||||
'Path of the PID file',
|
||||
implode(DIRECTORY_SEPARATOR,
|
||||
array(PHPCI_DIR, 'daemon', 'daemon.pid'))
|
||||
[PHPCI_DIR, 'daemon', 'daemon.pid'])
|
||||
)
|
||||
->addOption(
|
||||
'log-file', 'l', InputOption::VALUE_REQUIRED,
|
||||
'Path of the log file',
|
||||
implode(DIRECTORY_SEPARATOR,
|
||||
array(PHPCI_DIR, 'daemon', 'daemon.log'))
|
||||
[PHPCI_DIR, 'daemon', 'daemon.log'])
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -107,7 +107,7 @@ class DaemonCommand extends Command
|
|||
{
|
||||
$pid = $this->getRunningPid();
|
||||
if ($pid) {
|
||||
$this->logger->notice("Daemon already started", array('pid' => $pid));
|
||||
$this->logger->notice("Daemon already started", ['pid' => $pid]);
|
||||
return "alreadystarted";
|
||||
}
|
||||
|
||||
|
|
@ -132,7 +132,7 @@ class DaemonCommand extends Command
|
|||
return "notstarted";
|
||||
}
|
||||
|
||||
$this->logger->notice("Daemon started", array('pid' => $pid));
|
||||
$this->logger->notice("Daemon started", ['pid' => $pid]);
|
||||
return "started";
|
||||
}
|
||||
|
||||
|
|
@ -144,7 +144,7 @@ class DaemonCommand extends Command
|
|||
return "notstarted";
|
||||
}
|
||||
|
||||
$this->logger->info("Trying to terminate the daemon", array('pid' => $pid));
|
||||
$this->logger->info("Trying to terminate the daemon", ['pid' => $pid]);
|
||||
$this->processControl->kill($pid);
|
||||
|
||||
for ($i = 0; ($pid = $this->getRunningPid()) && $i < 5; $i++) {
|
||||
|
|
@ -152,7 +152,7 @@ class DaemonCommand extends Command
|
|||
}
|
||||
|
||||
if ($pid) {
|
||||
$this->logger->warning("The daemon is resiting, trying to kill it", array('pid' => $pid));
|
||||
$this->logger->warning("The daemon is resiting, trying to kill it", ['pid' => $pid]);
|
||||
$this->processControl->kill($pid, true);
|
||||
|
||||
for ($i = 0; ($pid = $this->getRunningPid()) && $i < 5; $i++) {
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ class DaemoniseCommand extends Command
|
|||
$runner->setMaxBuilds(1);
|
||||
$runner->setDaemon(true);
|
||||
|
||||
$emptyInput = new ArgvInput(array());
|
||||
$emptyInput = new ArgvInput([]);
|
||||
|
||||
while ($this->run) {
|
||||
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@ class GenerateCommand extends Command
|
|||
{
|
||||
$gen = new CodeGenerator(
|
||||
Database::getConnection(),
|
||||
array('default' => 'PHPCI'),
|
||||
array('default' => PHPCI_DIR),
|
||||
['default' => 'PHPCI'],
|
||||
['default' => PHPCI_DIR],
|
||||
false
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ class InstallCommand extends Command
|
|||
|
||||
$output->writeln('');
|
||||
|
||||
$conf = array();
|
||||
$conf = [];
|
||||
$conf['b8']['database'] = $db;
|
||||
|
||||
// ----
|
||||
|
|
@ -123,7 +123,7 @@ class InstallCommand extends Command
|
|||
}
|
||||
|
||||
// Check required extensions are present:
|
||||
$requiredExtensions = array('PDO', 'pdo_mysql');
|
||||
$requiredExtensions = ['PDO', 'pdo_mysql'];
|
||||
|
||||
foreach ($requiredExtensions as $extension) {
|
||||
if (!extension_loaded($extension)) {
|
||||
|
|
@ -134,7 +134,7 @@ class InstallCommand extends Command
|
|||
}
|
||||
|
||||
// Check required functions are callable:
|
||||
$requiredFunctions = array('exec', 'shell_exec');
|
||||
$requiredFunctions = ['exec', 'shell_exec'];
|
||||
|
||||
foreach ($requiredFunctions as $function) {
|
||||
if (!function_exists($function)) {
|
||||
|
|
@ -167,7 +167,7 @@ class InstallCommand extends Command
|
|||
*/
|
||||
protected function getAdminInformation(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$admin = array();
|
||||
$admin = [];
|
||||
|
||||
/**
|
||||
* @var \Symfony\Component\Console\Helper\DialogHelper
|
||||
|
|
@ -211,7 +211,7 @@ class InstallCommand extends Command
|
|||
*/
|
||||
protected function getPhpciConfigInformation(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$phpci = array();
|
||||
$phpci = [];
|
||||
|
||||
/**
|
||||
* @var \Symfony\Component\Console\Helper\DialogHelper
|
||||
|
|
@ -282,7 +282,7 @@ class InstallCommand extends Command
|
|||
*/
|
||||
protected function getDatabaseInformation(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$db = array();
|
||||
$db = [];
|
||||
|
||||
/**
|
||||
* @var \Symfony\Component\Console\Helper\DialogHelper
|
||||
|
|
@ -327,12 +327,12 @@ class InstallCommand extends Command
|
|||
'mysql:host='.$db['servers']['write'].';dbname='.$db['name'],
|
||||
$db['username'],
|
||||
$db['password'],
|
||||
array(
|
||||
\PDO::ATTR_PERSISTENT => false,
|
||||
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
|
||||
\PDO::ATTR_TIMEOUT => 2,
|
||||
[
|
||||
\PDO::ATTR_PERSISTENT => false,
|
||||
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
|
||||
\PDO::ATTR_TIMEOUT => 2,
|
||||
\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\'',
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
unset($pdo);
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ class PollCommand extends Command
|
|||
|
||||
foreach ($result['items'] as $project) {
|
||||
$http = new HttpClient('https://api.github.com');
|
||||
$commits = $http->get('/repos/' . $project->getReference() . '/commits', array('access_token' => $token));
|
||||
$commits = $http->get('/repos/' . $project->getReference() . '/commits', ['access_token' => $token]);
|
||||
|
||||
$last_commit = $commits['body'][0]['sha'];
|
||||
$last_committer = $commits['body'][0]['commit']['committer']['email'];
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ class RebuildCommand extends Command
|
|||
$lastBuild = array_shift($builds);
|
||||
$service->createDuplicateBuild($lastBuild);
|
||||
|
||||
$runner->run(new ArgvInput(array()), $output);
|
||||
$runner->run(new ArgvInput([]), $output);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -148,9 +148,9 @@ class RunCommand extends Command
|
|||
protected function validateRunningBuilds()
|
||||
{
|
||||
/** @var \PHPCI\Store\BuildStore $store */
|
||||
$store = Factory::getStore('Build');
|
||||
$store = Factory::getStore('Build');
|
||||
$running = $store->getByStatus(1);
|
||||
$rtn = array();
|
||||
$rtn = [];
|
||||
|
||||
$timeout = Config::getInstance()->get('phpci.build.failed_after', 1800);
|
||||
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ class BuildController extends \PHPCI\Controller
|
|||
*/
|
||||
protected function getUiPlugins()
|
||||
{
|
||||
$rtn = array();
|
||||
$rtn = [];
|
||||
$path = APPLICATION_PATH . 'public/assets/js/build-plugins/';
|
||||
$dir = opendir($path);
|
||||
|
||||
|
|
@ -132,7 +132,7 @@ class BuildController extends \PHPCI\Controller
|
|||
|
||||
if (!$build) {
|
||||
$response->setResponseCode(404);
|
||||
$response->setContent(array());
|
||||
$response->setContent([]);
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
|
@ -164,7 +164,7 @@ class BuildController extends \PHPCI\Controller
|
|||
*/
|
||||
protected function getBuildData(Build $build)
|
||||
{
|
||||
$data = array();
|
||||
$data = [];
|
||||
$data['status'] = (int)$build->getStatus();
|
||||
$data['log'] = $this->cleanLog($build->getLog());
|
||||
$data['created'] = !is_null($build->getCreated()) ? $build->getCreated()->format('Y-m-d H:i:s') : null;
|
||||
|
|
@ -242,10 +242,10 @@ class BuildController extends \PHPCI\Controller
|
|||
*/
|
||||
public function latest()
|
||||
{
|
||||
$rtn = array(
|
||||
$rtn = [
|
||||
'pending' => $this->formatBuilds($this->buildStore->getByStatus(Build::STATUS_NEW)),
|
||||
'running' => $this->formatBuilds($this->buildStore->getByStatus(Build::STATUS_RUNNING)),
|
||||
);
|
||||
];
|
||||
|
||||
$response = new JsonResponse();
|
||||
$response->setContent($rtn);
|
||||
|
|
@ -259,9 +259,9 @@ class BuildController extends \PHPCI\Controller
|
|||
*/
|
||||
protected function formatBuilds($builds)
|
||||
{
|
||||
Project::$sleepable = array('id', 'title', 'reference', 'type');
|
||||
Project::$sleepable = ['id', 'title', 'reference', 'type'];
|
||||
|
||||
$rtn = array('count' => $builds['count'], 'items' => array());
|
||||
$rtn = ['count' => $builds['count'], 'items' => []];
|
||||
|
||||
foreach ($builds['items'] as $build) {
|
||||
$item = $build->toArray(1);
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class BuildStatusController extends \PHPCI\Controller
|
|||
}
|
||||
|
||||
if (isset($project) && $project instanceof Project) {
|
||||
$build = $project->getLatestBuild($branch, array(2,3));
|
||||
$build = $project->getLatestBuild($branch, [2,3]);
|
||||
|
||||
if (isset($build) && $build instanceof Build && $build->getStatus() != 2) {
|
||||
$status = 'failed';
|
||||
|
|
@ -92,7 +92,7 @@ class BuildStatusController extends \PHPCI\Controller
|
|||
$branchList = $this->buildStore->getBuildBranches($projectId);
|
||||
|
||||
if (!$branchList) {
|
||||
$branchList = array($project->getBranch());
|
||||
$branchList = [$project->getBranch()];
|
||||
}
|
||||
|
||||
foreach ($branchList as $branch) {
|
||||
|
|
@ -191,9 +191,9 @@ class BuildStatusController extends \PHPCI\Controller
|
|||
*/
|
||||
protected function getLatestBuilds($projectId)
|
||||
{
|
||||
$criteria = array('project_id' => $projectId);
|
||||
$order = array('id' => 'DESC');
|
||||
$builds = $this->buildStore->getWhere($criteria, 10, 0, array(), $order);
|
||||
$criteria = ['project_id' => $projectId];
|
||||
$order = ['id' => 'DESC'];
|
||||
$builds = $this->buildStore->getWhere($criteria, 10, 0, [], $order);
|
||||
|
||||
foreach ($builds['items'] as &$build) {
|
||||
$build = BuildFactory::getBuild($build);
|
||||
|
|
|
|||
|
|
@ -44,14 +44,14 @@ class GroupController extends Controller
|
|||
{
|
||||
$this->requireAdmin();
|
||||
|
||||
$groups = array();
|
||||
$groupList = $this->groupStore->getWhere(array(), 100, 0, array(), array('title' => 'ASC'));
|
||||
$groups = [];
|
||||
$groupList = $this->groupStore->getWhere([], 100, 0, [], ['title' => 'ASC']);
|
||||
|
||||
foreach ($groupList['items'] as $group) {
|
||||
$thisGroup = array(
|
||||
$thisGroup = [
|
||||
'title' => $group->getTitle(),
|
||||
'id' => $group->getId(),
|
||||
);
|
||||
'id' => $group->getId(),
|
||||
];
|
||||
$projects = b8\Store\Factory::getStore('Project')->getByGroupId($group->getId());
|
||||
$thisGroup['projects'] = $projects['items'];
|
||||
$groups[] = $thisGroup;
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ class HomeController extends \PHPCI\Controller
|
|||
public function summary()
|
||||
{
|
||||
$this->response->disableLayout();
|
||||
$projects = $this->projectStore->getWhere(array(), 50, 0, array(), array('title' => 'ASC'));
|
||||
$projects = $this->projectStore->getWhere([], 50, 0, [], ['title' => 'ASC']);
|
||||
$this->response->setContent($this->getSummaryHtml($projects));
|
||||
return $this->response;
|
||||
}
|
||||
|
|
@ -93,20 +93,20 @@ class HomeController extends \PHPCI\Controller
|
|||
*/
|
||||
protected function getSummaryHtml($projects)
|
||||
{
|
||||
$summaryBuilds = array();
|
||||
$successes = array();
|
||||
$failures = array();
|
||||
$counts = array();
|
||||
$summaryBuilds = [];
|
||||
$successes = [];
|
||||
$failures = [];
|
||||
$counts = [];
|
||||
|
||||
foreach ($projects as $project) {
|
||||
$summaryBuilds[$project->getId()] = $this->buildStore->getLatestBuilds($project->getId());
|
||||
|
||||
$count = $this->buildStore->getWhere(
|
||||
array('project_id' => $project->getId()),
|
||||
['project_id' => $project->getId()],
|
||||
1,
|
||||
0,
|
||||
array(),
|
||||
array('id' => 'DESC')
|
||||
[],
|
||||
['id' => 'DESC']
|
||||
);
|
||||
$counts[$project->getId()] = $count['count'];
|
||||
|
||||
|
|
@ -132,7 +132,7 @@ class HomeController extends \PHPCI\Controller
|
|||
*/
|
||||
protected function getLatestBuildsHtml()
|
||||
{
|
||||
$builds = $this->buildStore->getWhere(array(), 5, 0, array(), array('id' => 'DESC'));
|
||||
$builds = $this->buildStore->getWhere([], 5, 0, [], ['id' => 'DESC']);
|
||||
$view = new b8\View('BuildsTable');
|
||||
|
||||
foreach ($builds['items'] as &$build) {
|
||||
|
|
@ -150,11 +150,11 @@ class HomeController extends \PHPCI\Controller
|
|||
*/
|
||||
protected function getGroupInfo()
|
||||
{
|
||||
$rtn = array();
|
||||
$groups = $this->groupStore->getWhere(array(), 100, 0, array(), array('title' => 'ASC'));
|
||||
$rtn = [];
|
||||
$groups = $this->groupStore->getWhere([], 100, 0, [], ['title' => 'ASC']);
|
||||
|
||||
foreach ($groups['items'] as $group) {
|
||||
$thisGroup = array('title' => $group->getTitle());
|
||||
$thisGroup = ['title' => $group->getTitle()];
|
||||
$projects = $this->projectStore->getByGroupId($group->getId());
|
||||
$thisGroup['projects'] = $projects['items'];
|
||||
$thisGroup['summary'] = $this->getSummaryHtml($thisGroup['projects']);
|
||||
|
|
|
|||
|
|
@ -163,14 +163,14 @@ class ProjectController extends PHPCI\Controller
|
|||
*/
|
||||
protected function getLatestBuildsHtml($projectId, $branch = '', $start = 0)
|
||||
{
|
||||
$criteria = array('project_id' => $projectId);
|
||||
$criteria = ['project_id' => $projectId];
|
||||
if (!empty($branch)) {
|
||||
$criteria['branch'] = $branch;
|
||||
}
|
||||
|
||||
$order = array('id' => 'DESC');
|
||||
$builds = $this->buildStore->getWhere($criteria, 10, $start, array(), $order);
|
||||
$view = new b8\View('BuildsTable');
|
||||
$order = ['id' => 'DESC'];
|
||||
$builds = $this->buildStore->getWhere($criteria, 10, $start, [], $order);
|
||||
$view = new b8\View('BuildsTable');
|
||||
|
||||
foreach ($builds['items'] as &$build) {
|
||||
$build = BuildFactory::getBuild($build);
|
||||
|
|
@ -178,7 +178,7 @@ class ProjectController extends PHPCI\Controller
|
|||
|
||||
$view->builds = $builds['items'];
|
||||
|
||||
return array($view->render(), $builds['count']);
|
||||
return [$view->render(), $builds['count']];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -214,18 +214,18 @@ class ProjectController extends PHPCI\Controller
|
|||
|
||||
return $view->render();
|
||||
} else {
|
||||
$title = $this->getParam('title', 'New Project');
|
||||
$title = $this->getParam('title', 'New Project');
|
||||
$reference = $this->getParam('reference', null);
|
||||
$type = $this->getParam('type', null);
|
||||
$type = $this->getParam('type', null);
|
||||
|
||||
$options = array(
|
||||
'ssh_private_key' => $this->getParam('key', null),
|
||||
'ssh_public_key' => $this->getParam('pubkey', null),
|
||||
'build_config' => $this->getParam('build_config', null),
|
||||
$options = [
|
||||
'ssh_private_key' => $this->getParam('key', null),
|
||||
'ssh_public_key' => $this->getParam('pubkey', null),
|
||||
'build_config' => $this->getParam('build_config', null),
|
||||
'allow_public_status' => $this->getParam('allow_public_status', 0),
|
||||
'branch' => $this->getParam('branch', null),
|
||||
'group' => $this->getParam('group_id', null),
|
||||
);
|
||||
'branch' => $this->getParam('branch', null),
|
||||
'group' => $this->getParam('group_id', null),
|
||||
];
|
||||
|
||||
$project = $this->projectService->createProject($title, $type, $reference, $options);
|
||||
|
||||
|
|
@ -282,15 +282,15 @@ class ProjectController extends PHPCI\Controller
|
|||
$reference = $this->getParam('reference', null);
|
||||
$type = $this->getParam('type', null);
|
||||
|
||||
$options = array(
|
||||
'ssh_private_key' => $this->getParam('key', null),
|
||||
'ssh_public_key' => $this->getParam('pubkey', null),
|
||||
'build_config' => $this->getParam('build_config', null),
|
||||
$options = [
|
||||
'ssh_private_key' => $this->getParam('key', null),
|
||||
'ssh_public_key' => $this->getParam('pubkey', null),
|
||||
'build_config' => $this->getParam('build_config', null),
|
||||
'allow_public_status' => $this->getParam('allow_public_status', 0),
|
||||
'archived' => $this->getParam('archived', 0),
|
||||
'branch' => $this->getParam('branch', null),
|
||||
'group' => $this->getParam('group_id', null),
|
||||
);
|
||||
'archived' => $this->getParam('archived', 0),
|
||||
'branch' => $this->getParam('branch', null),
|
||||
'group' => $this->getParam('group_id', null),
|
||||
];
|
||||
|
||||
$project = $this->projectService->updateProject($project, $title, $type, $reference, $options);
|
||||
|
||||
|
|
@ -310,16 +310,16 @@ class ProjectController extends PHPCI\Controller
|
|||
$form->addField(new Form\Element\Csrf('csrf'));
|
||||
$form->addField(new Form\Element\Hidden('pubkey'));
|
||||
|
||||
$options = array(
|
||||
'choose' => Lang::get('select_repository_type'),
|
||||
'github' => Lang::get('github'),
|
||||
$options = [
|
||||
'choose' => Lang::get('select_repository_type'),
|
||||
'github' => Lang::get('github'),
|
||||
'bitbucket' => Lang::get('bitbucket'),
|
||||
'gitlab' => Lang::get('gitlab'),
|
||||
'remote' => Lang::get('remote'),
|
||||
'local' => Lang::get('local'),
|
||||
'hg' => Lang::get('hg'),
|
||||
'svn' => Lang::get('svn'),
|
||||
);
|
||||
'gitlab' => Lang::get('gitlab'),
|
||||
'remote' => Lang::get('remote'),
|
||||
'local' => Lang::get('local'),
|
||||
'hg' => Lang::get('hg'),
|
||||
'svn' => Lang::get('svn'),
|
||||
];
|
||||
|
||||
$field = Form\Element\Select::create('type', Lang::get('where_hosted'), true);
|
||||
$field->setPattern('^(github|bitbucket|gitlab|remote|local|hg|svn)');
|
||||
|
|
@ -361,9 +361,9 @@ class ProjectController extends PHPCI\Controller
|
|||
$field = Form\Element\Select::create('group_id', 'Project Group', true);
|
||||
$field->setClass('form-control')->setContainerClass('form-group')->setValue(1);
|
||||
|
||||
$groups = array();
|
||||
$groups = [];
|
||||
$groupStore = b8\Store\Factory::getStore('ProjectGroup');
|
||||
$groupList = $groupStore->getWhere(array(), 100, 0, array(), array('title' => 'ASC'));
|
||||
$groupList = $groupStore->getWhere([], 100, 0, [], ['title' => 'ASC']);
|
||||
|
||||
foreach ($groupList['items'] as $group) {
|
||||
$groups[$group->getId()] = $group->getTitle();
|
||||
|
|
@ -416,28 +416,28 @@ class ProjectController extends PHPCI\Controller
|
|||
return function ($val) use ($values) {
|
||||
$type = $values['type'];
|
||||
|
||||
$validators = array(
|
||||
'hg' => array(
|
||||
'regex' => '/^(https?):\/\//',
|
||||
$validators = [
|
||||
'hg' => [
|
||||
'regex' => '/^(https?):\/\//',
|
||||
'message' => Lang::get('error_mercurial')
|
||||
),
|
||||
'remote' => array(
|
||||
'regex' => '/^(git|https?):\/\//',
|
||||
],
|
||||
'remote' => [
|
||||
'regex' => '/^(git|https?):\/\//',
|
||||
'message' => Lang::get('error_remote')
|
||||
),
|
||||
'gitlab' => array(
|
||||
'regex' => '`^(.*)@(.*):(.*)/(.*)\.git`',
|
||||
],
|
||||
'gitlab' => [
|
||||
'regex' => '`^(.*)@(.*):(.*)/(.*)\.git`',
|
||||
'message' => Lang::get('error_gitlab')
|
||||
),
|
||||
'github' => array(
|
||||
'regex' => '/^[a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-\.]+$/',
|
||||
],
|
||||
'github' => [
|
||||
'regex' => '/^[a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-\.]+$/',
|
||||
'message' => Lang::get('error_github')
|
||||
),
|
||||
'bitbucket' => array(
|
||||
'regex' => '/^[a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-\.]+$/',
|
||||
],
|
||||
'bitbucket' => [
|
||||
'regex' => '/^[a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-\.]+$/',
|
||||
'message' => Lang::get('error_bitbucket')
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
if (in_array($type, $validators) && !preg_match($validators[$type]['regex'], $val)) {
|
||||
throw new \Exception($validators[$type]['message']);
|
||||
|
|
|
|||
|
|
@ -56,33 +56,33 @@ class SettingsController extends Controller
|
|||
|
||||
$this->view->settings = $this->settings;
|
||||
|
||||
$basicSettings = array();
|
||||
$basicSettings = [];
|
||||
if (isset($this->settings['phpci']['basic'])) {
|
||||
$basicSettings = $this->settings['phpci']['basic'];
|
||||
}
|
||||
|
||||
$buildSettings = array();
|
||||
$buildSettings = [];
|
||||
if (isset($this->settings['phpci']['build'])) {
|
||||
$buildSettings = $this->settings['phpci']['build'];
|
||||
}
|
||||
|
||||
$emailSettings = array();
|
||||
$emailSettings = [];
|
||||
if (isset($this->settings['phpci']['email_settings'])) {
|
||||
$emailSettings = $this->settings['phpci']['email_settings'];
|
||||
}
|
||||
|
||||
$authSettings = array();
|
||||
$authSettings = [];
|
||||
if (isset($this->settings['phpci']['authentication_settings'])) {
|
||||
$authSettings = $this->settings['phpci']['authentication_settings'];
|
||||
}
|
||||
|
||||
$this->view->configFile = PHPCI_CONFIG_FILE;
|
||||
$this->view->basicSettings = $this->getBasicForm($basicSettings);
|
||||
$this->view->buildSettings = $this->getBuildForm($buildSettings);
|
||||
$this->view->github = $this->getGithubForm();
|
||||
$this->view->emailSettings = $this->getEmailForm($emailSettings);
|
||||
$this->view->configFile = PHPCI_CONFIG_FILE;
|
||||
$this->view->basicSettings = $this->getBasicForm($basicSettings);
|
||||
$this->view->buildSettings = $this->getBuildForm($buildSettings);
|
||||
$this->view->github = $this->getGithubForm();
|
||||
$this->view->emailSettings = $this->getEmailForm($emailSettings);
|
||||
$this->view->authenticationSettings = $this->getAuthenticationForm($authSettings);
|
||||
$this->view->isWriteable = $this->canWriteConfig();
|
||||
$this->view->isWriteable = $this->canWriteConfig();
|
||||
|
||||
if (!empty($this->settings['phpci']['github']['token'])) {
|
||||
$this->view->githubUser = $this->getGithubUser($this->settings['phpci']['github']['token']);
|
||||
|
|
@ -213,7 +213,7 @@ class SettingsController extends Controller
|
|||
if (!is_null($code)) {
|
||||
$http = new HttpClient();
|
||||
$url = 'https://github.com/login/oauth/access_token';
|
||||
$params = array('client_id' => $github['id'], 'client_secret' => $github['secret'], 'code' => $code);
|
||||
$params = ['client_id' => $github['id'], 'client_secret' => $github['secret'], 'code' => $code];
|
||||
$resp = $http->post($url, $params);
|
||||
|
||||
if ($resp['success']) {
|
||||
|
|
@ -298,7 +298,7 @@ class SettingsController extends Controller
|
|||
* @param array $values
|
||||
* @return Form
|
||||
*/
|
||||
protected function getEmailForm($values = array())
|
||||
protected function getEmailForm($values = [])
|
||||
{
|
||||
$form = new Form();
|
||||
$form->setMethod('POST');
|
||||
|
|
@ -351,7 +351,7 @@ class SettingsController extends Controller
|
|||
$form->addField($field);
|
||||
|
||||
$field = new Form\Element\Select('smtp_encryption');
|
||||
$field->setOptions(array('' => Lang::get('none'), 'tls' => Lang::get('tls'), 'ssl' => Lang::get('ssl')));
|
||||
$field->setOptions(['' => Lang::get('none'), 'tls' => Lang::get('tls'), 'ssl' => Lang::get('ssl')]);
|
||||
$field->setRequired(false);
|
||||
$field->setLabel(Lang::get('use_smtp_encryption'));
|
||||
$field->setContainerClass('form-group');
|
||||
|
|
@ -376,7 +376,7 @@ class SettingsController extends Controller
|
|||
protected function getGithubUser($token)
|
||||
{
|
||||
$http = new HttpClient('https://api.github.com');
|
||||
$user = $http->get('/user', array('access_token' => $token));
|
||||
$user = $http->get('/user', ['access_token' => $token]);
|
||||
|
||||
return $user['body'];
|
||||
}
|
||||
|
|
@ -395,7 +395,7 @@ class SettingsController extends Controller
|
|||
* @param array $values
|
||||
* @return Form
|
||||
*/
|
||||
protected function getBuildForm($values = array())
|
||||
protected function getBuildForm($values = [])
|
||||
{
|
||||
$form = new Form();
|
||||
$form->setMethod('POST');
|
||||
|
|
@ -406,13 +406,13 @@ class SettingsController extends Controller
|
|||
$field->setLabel(Lang::get('failed_after'));
|
||||
$field->setClass('form-control');
|
||||
$field->setContainerClass('form-group');
|
||||
$field->setOptions(array(
|
||||
$field->setOptions([
|
||||
300 => Lang::get('5_mins'),
|
||||
900 => Lang::get('15_mins'),
|
||||
1800 => Lang::get('30_mins'),
|
||||
3600 => Lang::get('1_hour'),
|
||||
10800 => Lang::get('3_hours'),
|
||||
));
|
||||
]);
|
||||
$field->setValue(1800);
|
||||
$form->addField($field);
|
||||
|
||||
|
|
@ -432,7 +432,7 @@ class SettingsController extends Controller
|
|||
* @param array $values
|
||||
* @return Form
|
||||
*/
|
||||
protected function getBasicForm($values = array())
|
||||
protected function getBasicForm($values = [])
|
||||
{
|
||||
$form = new Form();
|
||||
$form->setMethod('POST');
|
||||
|
|
@ -464,7 +464,7 @@ class SettingsController extends Controller
|
|||
* @param array $values
|
||||
* @return Form
|
||||
*/
|
||||
protected function getAuthenticationForm($values = array())
|
||||
protected function getAuthenticationForm($values = [])
|
||||
{
|
||||
$form = new Form();
|
||||
$form->setMethod('POST');
|
||||
|
|
|
|||
|
|
@ -48,9 +48,8 @@ class UserController extends Controller
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
$users = $this->userStore->getWhere(array(), 1000, 0, array(), array('email' => 'ASC'));
|
||||
$this->view->users = $users;
|
||||
|
||||
$users = $this->userStore->getWhere([], 1000, 0, [], ['email' => 'ASC']);
|
||||
$this->view->users = $users;
|
||||
$this->layout->title = Lang::get('manage_users');
|
||||
|
||||
return $this->view->render();
|
||||
|
|
@ -152,16 +151,16 @@ class UserController extends Controller
|
|||
if ($method == 'POST') {
|
||||
$values = $this->getParams();
|
||||
} else {
|
||||
$values = array();
|
||||
$values = [];
|
||||
}
|
||||
|
||||
$form = $this->userForm($values);
|
||||
|
||||
if ($method != 'POST' || ($method == 'POST' && !$form->validate())) {
|
||||
$view = new b8\View('UserForm');
|
||||
$view->type = 'add';
|
||||
$view->user = null;
|
||||
$view->form = $form;
|
||||
$view = new b8\View('UserForm');
|
||||
$view->type = 'add';
|
||||
$view->user = null;
|
||||
$view->form = $form;
|
||||
|
||||
return $view->render();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ class WebhookController extends \b8\Controller
|
|||
$response->setContent($data);
|
||||
} catch (Exception $ex) {
|
||||
$response->setResponseCode(500);
|
||||
$response->setContent(array('status' => 'failed', 'error' => $ex->getMessage()));
|
||||
$response->setContent(['status' => 'failed', 'error' => $ex->getMessage()]);
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
|
@ -142,8 +142,8 @@ class WebhookController extends \b8\Controller
|
|||
{
|
||||
$payload = json_decode($this->getParam('payload'), true);
|
||||
|
||||
$results = array();
|
||||
$status = 'failed';
|
||||
$results = [];
|
||||
$status = 'failed';
|
||||
foreach ($payload['commits'] as $commit) {
|
||||
try {
|
||||
$email = $commit['raw_author'];
|
||||
|
|
@ -159,11 +159,11 @@ class WebhookController extends \b8\Controller
|
|||
);
|
||||
$status = 'ok';
|
||||
} catch (Exception $ex) {
|
||||
$results[$commit['raw_node']] = array('status' => 'failed', 'error' => $ex->getMessage());
|
||||
$results[$commit['raw_node']] = ['status' => 'failed', 'error' => $ex->getMessage()];
|
||||
}
|
||||
}
|
||||
|
||||
return array('status' => $status, 'commits' => $results);
|
||||
return ['status' => $status, 'commits' => $results];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -173,7 +173,7 @@ class WebhookController extends \b8\Controller
|
|||
*/
|
||||
public function git($projectId)
|
||||
{
|
||||
$project = $this->fetchProject($projectId, array('local', 'remote'));
|
||||
$project = $this->fetchProject($projectId, ['local', 'remote']);
|
||||
$branch = $this->getParam('branch', $project->getBranch());
|
||||
$commit = $this->getParam('commit');
|
||||
$commitMessage = $this->getParam('message');
|
||||
|
|
@ -197,7 +197,7 @@ class WebhookController extends \b8\Controller
|
|||
$payload = json_decode($this->getParam('payload'), true);
|
||||
break;
|
||||
default:
|
||||
return array('status' => 'failed', 'error' => 'Content type not supported.', 'responseCode' => 401);
|
||||
return ['status' => 'failed', 'error' => 'Content type not supported.', 'responseCode' => 401];
|
||||
}
|
||||
|
||||
// Handle Pull Request web hooks:
|
||||
|
|
@ -210,7 +210,7 @@ class WebhookController extends \b8\Controller
|
|||
return $this->githubCommitRequest($project, $payload);
|
||||
}
|
||||
|
||||
return array('status' => 'ignored', 'message' => 'Unusable payload.');
|
||||
return ['status' => 'ignored', 'message' => 'Unusable payload.'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -227,17 +227,17 @@ class WebhookController extends \b8\Controller
|
|||
// Github sends a payload when you close a pull request with a
|
||||
// non-existent commit. We don't want this.
|
||||
if (array_key_exists('after', $payload) && $payload['after'] === '0000000000000000000000000000000000000000') {
|
||||
return array('status' => 'ignored');
|
||||
return ['status' => 'ignored'];
|
||||
}
|
||||
|
||||
if (isset($payload['commits']) && is_array($payload['commits'])) {
|
||||
// If we have a list of commits, then add them all as builds to be tested:
|
||||
|
||||
$results = array();
|
||||
$status = 'failed';
|
||||
$results = [];
|
||||
$status = 'failed';
|
||||
foreach ($payload['commits'] as $commit) {
|
||||
if (!$commit['distinct']) {
|
||||
$results[$commit['id']] = array('status' => 'ignored');
|
||||
$results[$commit['id']] = ['status' => 'ignored'];
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -253,10 +253,10 @@ class WebhookController extends \b8\Controller
|
|||
);
|
||||
$status = 'ok';
|
||||
} catch (Exception $ex) {
|
||||
$results[$commit['id']] = array('status' => 'failed', 'error' => $ex->getMessage());
|
||||
$results[$commit['id']] = ['status' => 'failed', 'error' => $ex->getMessage()];
|
||||
}
|
||||
}
|
||||
return array('status' => $status, 'commits' => $results);
|
||||
return ['status' => $status, 'commits' => $results];
|
||||
}
|
||||
|
||||
if (substr($payload['ref'], 0, 10) == 'refs/tags/') {
|
||||
|
|
@ -267,7 +267,7 @@ class WebhookController extends \b8\Controller
|
|||
return $this->createBuild($project, $payload['after'], $branch, $committer, $message);
|
||||
}
|
||||
|
||||
return array('status' => 'ignored', 'message' => 'Unusable payload.');
|
||||
return ['status' => 'ignored', 'message' => 'Unusable payload.'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -279,12 +279,12 @@ class WebhookController extends \b8\Controller
|
|||
protected function githubPullRequest(Project $project, array $payload)
|
||||
{
|
||||
// We only want to know about open pull requests:
|
||||
if (!in_array($payload['action'], array('opened', 'synchronize', 'reopened'))) {
|
||||
return array('status' => 'ok');
|
||||
if (!in_array($payload['action'], ['opened', 'synchronize', 'reopened'])) {
|
||||
return ['status' => 'ok'];
|
||||
}
|
||||
|
||||
$headers = array();
|
||||
$token = \b8\Config::getInstance()->get('phpci.github.token');
|
||||
$headers = [];
|
||||
$token = \b8\Config::getInstance()->get('phpci.github.token');
|
||||
|
||||
if (!empty($token)) {
|
||||
$headers[] = 'Authorization: token ' . $token;
|
||||
|
|
@ -300,39 +300,39 @@ class WebhookController extends \b8\Controller
|
|||
throw new Exception('Could not get commits, failed API request.');
|
||||
}
|
||||
|
||||
$results = array();
|
||||
$status = 'failed';
|
||||
$results = [];
|
||||
$status = 'failed';
|
||||
foreach ($response['body'] as $commit) {
|
||||
// Skip all but the current HEAD commit ID:
|
||||
$id = $commit['sha'];
|
||||
if ($id != $payload['pull_request']['head']['sha']) {
|
||||
$results[$id] = array('status' => 'ignored', 'message' => 'not branch head');
|
||||
$results[$id] = ['status' => 'ignored', 'message' => 'not branch head'];
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
$branch = str_replace('refs/heads/', '', $payload['pull_request']['base']['ref']);
|
||||
$branch = str_replace('refs/heads/', '', $payload['pull_request']['base']['ref']);
|
||||
$committer = $commit['commit']['author']['email'];
|
||||
$message = $commit['commit']['message'];
|
||||
$message = $commit['commit']['message'];
|
||||
|
||||
$remoteUrlKey = $payload['pull_request']['head']['repo']['private'] ? 'ssh_url' : 'clone_url';
|
||||
|
||||
$extra = array(
|
||||
'build_type' => 'pull_request',
|
||||
'pull_request_id' => $payload['pull_request']['id'],
|
||||
$extra = [
|
||||
'build_type' => 'pull_request',
|
||||
'pull_request_id' => $payload['pull_request']['id'],
|
||||
'pull_request_number' => $payload['number'],
|
||||
'remote_branch' => $payload['pull_request']['head']['ref'],
|
||||
'remote_url' => $payload['pull_request']['head']['repo'][$remoteUrlKey],
|
||||
);
|
||||
'remote_branch' => $payload['pull_request']['head']['ref'],
|
||||
'remote_url' => $payload['pull_request']['head']['repo'][$remoteUrlKey],
|
||||
];
|
||||
|
||||
$results[$id] = $this->createBuild($project, $id, $branch, $committer, $message, $extra);
|
||||
$status = 'ok';
|
||||
} catch (Exception $ex) {
|
||||
$results[$id] = array('status' => 'failed', 'error' => $ex->getMessage());
|
||||
$results[$id] = ['status' => 'failed', 'error' => $ex->getMessage()];
|
||||
}
|
||||
}
|
||||
|
||||
return array('status' => $status, 'commits' => $results);
|
||||
return ['status' => $status, 'commits' => $results];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -361,8 +361,8 @@ class WebhookController extends \b8\Controller
|
|||
if (isset($payload['commits']) && is_array($payload['commits'])) {
|
||||
// If we have a list of commits, then add them all as builds to be tested:
|
||||
|
||||
$results = array();
|
||||
$status = 'failed';
|
||||
$results = [];
|
||||
$status = 'failed';
|
||||
foreach ($payload['commits'] as $commit) {
|
||||
try {
|
||||
$branch = str_replace('refs/heads/', '', $payload['ref']);
|
||||
|
|
@ -376,13 +376,13 @@ class WebhookController extends \b8\Controller
|
|||
);
|
||||
$status = 'ok';
|
||||
} catch (Exception $ex) {
|
||||
$results[$commit['id']] = array('status' => 'failed', 'error' => $ex->getMessage());
|
||||
$results[$commit['id']] = ['status' => 'failed', 'error' => $ex->getMessage()];
|
||||
}
|
||||
}
|
||||
return array('status' => $status, 'commits' => $results);
|
||||
return ['status' => $status, 'commits' => $results];
|
||||
}
|
||||
|
||||
return array('status' => 'ignored', 'message' => 'Unusable payload.');
|
||||
return ['status' => 'ignored', 'message' => 'Unusable payload.'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -411,16 +411,16 @@ class WebhookController extends \b8\Controller
|
|||
$builds = $this->buildStore->getByProjectAndCommit($project->getId(), $commitId);
|
||||
|
||||
if ($builds['count']) {
|
||||
return array(
|
||||
'status' => 'ignored',
|
||||
return [
|
||||
'status' => 'ignored',
|
||||
'message' => sprintf('Duplicate of build #%d', $builds['items'][0]->getId())
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
// If not, create a new build job for it:
|
||||
$build = $this->buildService->createBuild($project, $commitId, $branch, $committer, $commitMessage, $extra);
|
||||
|
||||
return array('status' => 'ok', 'buildID' => $build->getID());
|
||||
return ['status' => 'ok', 'buildID' => $build->getID()];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class ErrorHandler
|
|||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $levels = array(
|
||||
protected $levels = [
|
||||
E_WARNING => 'Warning',
|
||||
E_NOTICE => 'Notice',
|
||||
E_USER_ERROR => 'User Error',
|
||||
|
|
@ -29,7 +29,7 @@ class ErrorHandler
|
|||
E_RECOVERABLE_ERROR => 'Catchable Fatal Error',
|
||||
E_DEPRECATED => 'Deprecated',
|
||||
E_USER_DEPRECATED => 'User Deprecated',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Registers an instance of the error handler to throw ErrorException.
|
||||
|
|
@ -37,7 +37,7 @@ class ErrorHandler
|
|||
public static function register()
|
||||
{
|
||||
$handler = new static();
|
||||
set_error_handler(array($handler, 'handleError'));
|
||||
set_error_handler([$handler, 'handleError']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -61,8 +61,8 @@ abstract class BaseCommandExecutor implements CommandExecutor
|
|||
{
|
||||
$this->logger = $logger;
|
||||
$this->quiet = $quiet;
|
||||
$this->verbose = $verbose;
|
||||
$this->lastOutput = array();
|
||||
$this->verbose = $verbose;
|
||||
$this->lastOutput = [];
|
||||
$this->rootDir = rtrim($rootDir, '/\\') . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
|
|
@ -71,9 +71,9 @@ abstract class BaseCommandExecutor implements CommandExecutor
|
|||
* @param array $args
|
||||
* @return bool Indicates success
|
||||
*/
|
||||
public function executeCommand($args = array())
|
||||
public function executeCommand($args = [])
|
||||
{
|
||||
$this->lastOutput = array();
|
||||
$this->lastOutput = [];
|
||||
|
||||
$command = call_user_func_array('sprintf', $args);
|
||||
$this->logger->logDebug($command);
|
||||
|
|
@ -83,13 +83,13 @@ abstract class BaseCommandExecutor implements CommandExecutor
|
|||
}
|
||||
|
||||
$status = 0;
|
||||
$descriptorSpec = array(
|
||||
0 => array("pipe", "r"), // stdin
|
||||
1 => array("pipe", "w"), // stdout
|
||||
2 => array("pipe", "w"), // stderr
|
||||
);
|
||||
$descriptorSpec = [
|
||||
0 => ["pipe", "r"], // stdin
|
||||
1 => ["pipe", "w"], // stdout
|
||||
2 => ["pipe", "w"], // stderr
|
||||
];
|
||||
|
||||
$pipes = array();
|
||||
$pipes = [];
|
||||
$process = proc_open($command, $descriptorSpec, $pipes, $this->buildPath, null);
|
||||
|
||||
if (is_resource($process)) {
|
||||
|
|
@ -152,7 +152,7 @@ abstract class BaseCommandExecutor implements CommandExecutor
|
|||
$composerBin = $this->getComposerBinDir(realpath($this->buildPath));
|
||||
|
||||
if (is_string($binary)) {
|
||||
$binary = array($binary);
|
||||
$binary = [$binary];
|
||||
}
|
||||
|
||||
foreach ($binary as $bin) {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class BuildInterpolator
|
|||
* @var mixed[]
|
||||
* @see setupInterpolationVars()
|
||||
*/
|
||||
protected $interpolation_vars = array();
|
||||
protected $interpolation_vars = [];
|
||||
|
||||
/**
|
||||
* Sets the variables that will be used for interpolation.
|
||||
|
|
@ -33,7 +33,7 @@ class BuildInterpolator
|
|||
*/
|
||||
public function setupInterpolationVars(Build $build, $buildPath, $phpCiUrl)
|
||||
{
|
||||
$this->interpolation_vars = array();
|
||||
$this->interpolation_vars = [];
|
||||
$this->interpolation_vars['%PHPCI%'] = 1;
|
||||
$this->interpolation_vars['%COMMIT%'] = $build->getCommitId();
|
||||
$this->interpolation_vars['%SHORT_COMMIT%'] = substr($build->getCommitId(), 0, 7);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class Diff
|
|||
return null;
|
||||
}
|
||||
|
||||
$rtn = array();
|
||||
$rtn = [];
|
||||
|
||||
$diffLines = explode(PHP_EOL, $diff);
|
||||
|
||||
|
|
|
|||
|
|
@ -20,11 +20,11 @@ class Email
|
|||
{
|
||||
const DEFAULT_FROM = 'PHPCI <no-reply@phptesting.org>';
|
||||
|
||||
protected $emailTo = array();
|
||||
protected $emailCc = array();
|
||||
protected $emailTo = [];
|
||||
protected $emailCc = [];
|
||||
protected $subject = 'Email from PHPCI';
|
||||
protected $body = '';
|
||||
protected $isHtml = false;
|
||||
protected $body = '';
|
||||
protected $isHtml = false;
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
|
|
@ -126,7 +126,7 @@ class Email
|
|||
|
||||
$headers .= 'From: ' . $this->getFrom() . PHP_EOL;
|
||||
|
||||
$emailTo = array();
|
||||
$emailTo = [];
|
||||
foreach ($this->emailTo as $email => $name) {
|
||||
$thisTo = $email;
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class Github
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function makeRecursiveRequest($url, $params, $results = array())
|
||||
public function makeRecursiveRequest($url, $params, $results = [])
|
||||
{
|
||||
$http = new HttpClient('https://api.github.com');
|
||||
$res = $http->get($url, $params);
|
||||
|
|
@ -80,17 +80,17 @@ class Github
|
|||
$rtn = $cache->get('phpci_github_repos');
|
||||
|
||||
if (!$rtn) {
|
||||
$orgs = $this->makeRequest('/user/orgs', array('access_token' => $token));
|
||||
$orgs = $this->makeRequest('/user/orgs', ['access_token' => $token]);
|
||||
|
||||
$params = array('type' => 'all', 'access_token' => $token);
|
||||
$repos = array('user' => array());
|
||||
$params = ['type' => 'all', 'access_token' => $token];
|
||||
$repos = ['user' => []];
|
||||
$repos['user'] = $this->makeRecursiveRequest('/user/repos', $params);
|
||||
|
||||
foreach ($orgs as $org) {
|
||||
$repos[$org['login']] = $this->makeRecursiveRequest('/orgs/'.$org['login'].'/repos', $params);
|
||||
}
|
||||
|
||||
$rtn = array();
|
||||
$rtn = [];
|
||||
foreach ($repos as $repoGroup) {
|
||||
foreach ($repoGroup as $repo) {
|
||||
$rtn['repos'][] = $repo['full_name'];
|
||||
|
|
@ -123,18 +123,18 @@ class Github
|
|||
|
||||
$url = '/repos/' . strtolower($repo) . '/pulls/' . $pullId . '/comments';
|
||||
|
||||
$params = array(
|
||||
'body' => $comment,
|
||||
$params = [
|
||||
'body' => $comment,
|
||||
'commit_id' => $commitId,
|
||||
'path' => $file,
|
||||
'position' => $line,
|
||||
);
|
||||
'path' => $file,
|
||||
'position' => $line,
|
||||
];
|
||||
|
||||
$http = new HttpClient('https://api.github.com');
|
||||
$http->setHeaders(array(
|
||||
$http->setHeaders([
|
||||
'Content-Type: application/x-www-form-urlencoded',
|
||||
'Authorization: Basic ' . base64_encode($token . ':x-oauth-basic'),
|
||||
));
|
||||
]);
|
||||
|
||||
$http->post($url, json_encode($params));
|
||||
}
|
||||
|
|
@ -158,17 +158,17 @@ class Github
|
|||
|
||||
$url = '/repos/' . strtolower($repo) . '/commits/' . $commitId . '/comments';
|
||||
|
||||
$params = array(
|
||||
'body' => $comment,
|
||||
'path' => $file,
|
||||
$params = [
|
||||
'body' => $comment,
|
||||
'path' => $file,
|
||||
'position' => $line,
|
||||
);
|
||||
];
|
||||
|
||||
$http = new HttpClient('https://api.github.com');
|
||||
$http->setHeaders(array(
|
||||
$http->setHeaders([
|
||||
'Content-Type: application/x-www-form-urlencoded',
|
||||
'Authorization: Basic ' . base64_encode($token . ':x-oauth-basic'),
|
||||
));
|
||||
]);
|
||||
|
||||
$http->post($url, json_encode($params));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,17 +26,17 @@ class Lang
|
|||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected static $languages = array();
|
||||
protected static $languages = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected static $strings = array();
|
||||
protected static $strings = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected static $en_strings = array();
|
||||
protected static $en_strings = [];
|
||||
|
||||
/**
|
||||
* Get a specific string from the language file.
|
||||
|
|
@ -64,7 +64,7 @@ class Lang
|
|||
*/
|
||||
public static function out()
|
||||
{
|
||||
print call_user_func_array(array('PHPCI\Helper\Lang', 'get'), func_get_args());
|
||||
print call_user_func_array(['PHPCI\Helper\Lang', 'get'], func_get_args());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -102,10 +102,10 @@ class Lang
|
|||
*/
|
||||
public static function getLanguageOptions()
|
||||
{
|
||||
$languages = array();
|
||||
$languages = [];
|
||||
|
||||
foreach (self::$languages as $language) {
|
||||
$strings = array();
|
||||
$strings = [];
|
||||
require(PHPCI_DIR . 'src/PHPCI/Languages/lang.' . $language . '.php');
|
||||
$languages[$language] = $strings['language_name'];
|
||||
}
|
||||
|
|
@ -195,7 +195,7 @@ class Lang
|
|||
*/
|
||||
protected static function loadAvailableLanguages()
|
||||
{
|
||||
$matches = array();
|
||||
$matches = [];
|
||||
foreach (glob(PHPCI_DIR . 'src/PHPCI/Languages/lang.*.php') as $file) {
|
||||
if (preg_match('/lang\.([a-z]{2}\-?[a-z]*)\.php/', $file, $matches)) {
|
||||
self::$languages[] = $matches[1];
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class LoginIsDisabled
|
|||
* @param array $params
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function __call($method, $params = array())
|
||||
public function __call($method, $params = [])
|
||||
{
|
||||
unset($method, $params);
|
||||
|
||||
|
|
|
|||
|
|
@ -24,13 +24,13 @@ class MailerFactory
|
|||
* Set the mailer factory configuration.
|
||||
* @param array $config
|
||||
*/
|
||||
public function __construct($config = array())
|
||||
public function __construct($config = [])
|
||||
{
|
||||
if (!is_array($config)) {
|
||||
$config = array();
|
||||
$config = [];
|
||||
}
|
||||
|
||||
$this->emailConfig = isset($config['email_settings']) ? $config['email_settings'] : array();
|
||||
$this->emailConfig = isset($config['email_settings']) ? $config['email_settings'] : [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class SshKey
|
|||
mkdir($tempPath);
|
||||
}
|
||||
|
||||
$return = array('private_key' => '', 'public_key' => '');
|
||||
$return = ['private_key' => '', 'public_key' => ''];
|
||||
|
||||
$output = @shell_exec('ssh-keygen -t rsa -b 2048 -f '.$keyFile.' -N "" -C "deploy@phpci"');
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class User
|
|||
* @param array $params
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function __call($method, $params = array())
|
||||
public function __call($method, $params = [])
|
||||
{
|
||||
$user = $_SESSION['phpci_user'];
|
||||
|
||||
|
|
@ -31,6 +31,6 @@ class User
|
|||
return null;
|
||||
}
|
||||
|
||||
return call_user_func_array(array($user, $method), $params);
|
||||
return call_user_func_array([$user, $method], $params);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
* @link https://www.phptesting.org/
|
||||
*/
|
||||
|
||||
$strings = array(
|
||||
$strings = [
|
||||
'language_name' => 'Dansk',
|
||||
'language' => 'Sprog',
|
||||
|
||||
|
|
@ -394,4 +394,4 @@ Kontrollér venligst nedenstående fejl før du fortsætter.',
|
|||
'property_file_missing' => 'Den angivne property-fil findes ikke',
|
||||
'could_not_process_report' => 'Kunne ikke behandle rapporten, som dette værktøj genererede.',
|
||||
'shell_not_enabled' => 'Shell-plugin er ikke aktiveret. Aktivér det via config.yml.'
|
||||
);
|
||||
];
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
* @link https://www.phptesting.org/
|
||||
*/
|
||||
|
||||
$strings = array(
|
||||
$strings = [
|
||||
'language_name' => 'Deutsch',
|
||||
'language' => 'Sprache',
|
||||
|
||||
|
|
@ -430,4 +430,4 @@ generiert. Um es zu verwenden, fügen Sie einfach den folgenden Public Key im Ab
|
|||
'php_unit' => 'PHP Unit',
|
||||
'php_cpd' => 'PHP Copy/Paste Detector',
|
||||
'php_docblock_checker' => 'PHP Docblock Checker',
|
||||
);
|
||||
];
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
* @link https://www.phptesting.org/
|
||||
*/
|
||||
|
||||
$strings = array(
|
||||
$strings = [
|
||||
'language_name' => 'Ελληνικά',
|
||||
'language' => 'Γλώσσα',
|
||||
|
||||
|
|
@ -396,4 +396,4 @@ Services</a> του Bitbucket αποθετηρίου σας.',
|
|||
'property_file_missing' => 'Καθορισμένο αρχείο ιδιοκτησίας δεν υπάρχει.',
|
||||
'could_not_process_report' => 'Δεν ήταν δυνατή η επεξεργασία της έκθεσης που δημιουργείται από αυτό το εργαλείο.',
|
||||
'shell_not_enabled' => 'Το πρόσθετο για το κέλυφος δεν είναι ενεργοποιημένο. Παρακαλούμε ενεργοποιήστε το μέσω του αρχείου config.yml.'
|
||||
);
|
||||
];
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
* @link https://www.phptesting.org/
|
||||
*/
|
||||
|
||||
$strings = array(
|
||||
$strings =[
|
||||
'language_name' => 'English',
|
||||
'language' => 'Language',
|
||||
|
||||
|
|
@ -451,5 +451,4 @@ PHPCI',
|
|||
'php_docblock_checker' => 'PHP Docblock Checker',
|
||||
'behat' => 'Behat',
|
||||
'technical_debt' => 'Technical Debt',
|
||||
|
||||
);
|
||||
];
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
* @link https://www.phptesting.org/
|
||||
*/
|
||||
|
||||
$strings = array(
|
||||
$strings = [
|
||||
'language_name' => 'Español',
|
||||
'language' => 'Lenguaje',
|
||||
|
||||
|
|
@ -384,4 +384,4 @@ PHPCI',
|
|||
'property_file_missing' => 'El archivo de propiedades especificado no existe.',
|
||||
'could_not_process_report' => 'Imposible procesar el reporte generado por la herramienta.',
|
||||
'shell_not_enabled' => 'El plugin shell no está habilitado. Por favor, habilitalo desde config.yml.'
|
||||
);
|
||||
];
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
* @link https://www.phptesting.org/
|
||||
*/
|
||||
|
||||
$strings = array(
|
||||
$strings = [
|
||||
'language_name' => 'Français',
|
||||
'language' => 'Langue',
|
||||
|
||||
|
|
@ -407,4 +407,4 @@ PHPCI',
|
|||
'property_file_missing' => 'Le fichier de propriété spécifié n\'existe pas.',
|
||||
'could_not_process_report' => 'Impossible de traiter le rapport généré par cet outil.',
|
||||
'shell_not_enabled' => 'Le plugn shell n\'est pas activé. Merci de l\'activer via le fichier config.yml.'
|
||||
);
|
||||
];
|
||||
|
|
|
|||
|
|
@ -7,8 +7,7 @@
|
|||
* @link https://www.phptesting.org/
|
||||
*/
|
||||
|
||||
$strings = array(
|
||||
|
||||
$strings = [
|
||||
'language_name' => 'Italiano',
|
||||
'language' => 'Lingua',
|
||||
|
||||
|
|
@ -398,4 +397,4 @@ PHPCI',
|
|||
'property_file_missing' => 'Il file di proprietà specificato non esiste.',
|
||||
'could_not_process_report' => 'Non è possibile processare il report generato da questo tool.',
|
||||
'shell_not_enabled' => 'Il plugin shell non è attivato. Per favore attivalo tramite config.yml.'
|
||||
);
|
||||
];
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
* @link https://www.phptesting.org/
|
||||
*/
|
||||
|
||||
$strings = array(
|
||||
$strings = [
|
||||
'language_name' => 'Nederlands',
|
||||
'language' => 'Taal',
|
||||
|
||||
|
|
@ -396,4 +396,4 @@ Gelieve de fouten na te kijken vooraleer verder te gaan.',
|
|||
'property_file_missing' => 'Opgegeven bestand bestaat niet',
|
||||
'could_not_process_report' => 'Het is niet mogelijk om het gegenereerde rapport van deze tool te verwerken.',
|
||||
'shell_not_enabled' => 'De shell plugin is niet ingeschakeld, schakel deze a.u.b. in via het config.yml bestand.'
|
||||
);
|
||||
];
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
* @link https://www.phptesting.org/
|
||||
*/
|
||||
|
||||
$strings = array(
|
||||
$strings = [
|
||||
'language_name' => 'Polski',
|
||||
'language' => 'Język',
|
||||
|
||||
|
|
@ -397,4 +397,4 @@ Przejrzyj powyższą listę błędów przed kontynuowaniem.',
|
|||
'property_file_missing' => 'Podany plik właściwości nie istnieje.',
|
||||
'could_not_process_report' => 'Nie udało się przetworzyć raportu wygenerowanego przez to narzędzie.',
|
||||
'shell_not_enabled' => 'Plugin powłoki jest nieaktywny. Aktywuj go poprzez config.yml.'
|
||||
);
|
||||
];
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
* @link https://www.phptesting.org/
|
||||
*/
|
||||
|
||||
$strings = array(
|
||||
$strings = [
|
||||
'language_name' => 'Pусский',
|
||||
'language' => 'язык',
|
||||
|
||||
|
|
@ -419,4 +419,4 @@ PHPCI',
|
|||
'property_file_missing' => 'Указанного файла сборки не существует.',
|
||||
'could_not_process_report' => 'Невозможно обработать отчет этой утилиты.',
|
||||
'shell_not_enabled' => 'Плагин shell не включен. Пожалуйста, включите его в файле config.yml.'
|
||||
);
|
||||
];
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
* @link https://www.phptesting.org/
|
||||
*/
|
||||
|
||||
$strings = array(
|
||||
$strings = [
|
||||
'language_name' => 'Українська',
|
||||
'language' => 'Мова',
|
||||
|
||||
|
|
@ -396,4 +396,4 @@ PHPCI',
|
|||
'property_file_missing' => 'Вказаний файл властивості не існує.',
|
||||
'could_not_process_report' => 'Неможливо обробити звіт, згенерований цією утилітою.',
|
||||
'shell_not_enabled' => 'Плагін shell не увімкнений. Будь ласка, увімкніть його через config.yml.'
|
||||
);
|
||||
];
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class BuildLogger implements LoggerAwareInterface
|
|||
* @param string $level
|
||||
* @param mixed[] $context
|
||||
*/
|
||||
public function log($message, $level = LogLevel::INFO, $context = array())
|
||||
public function log($message, $level = LogLevel::INFO, $context = [])
|
||||
{
|
||||
// Skip if no logger has been loaded.
|
||||
if (!$this->logger) {
|
||||
|
|
@ -55,7 +55,7 @@ class BuildLogger implements LoggerAwareInterface
|
|||
}
|
||||
|
||||
if (!is_array($message)) {
|
||||
$message = array($message);
|
||||
$message = [$message];
|
||||
}
|
||||
|
||||
// The build is added to the context so the logger can use
|
||||
|
|
@ -79,18 +79,18 @@ class BuildLogger implements LoggerAwareInterface
|
|||
/**
|
||||
* Add a failure-coloured message to the log.
|
||||
* @param string $message
|
||||
* @param \Exception $exception The exception that caused the error.
|
||||
* @param \Exception $exception The exception that caused the error.
|
||||
*/
|
||||
public function logFailure($message, \Exception $exception = null)
|
||||
{
|
||||
$context = array();
|
||||
|
||||
$context = [];
|
||||
|
||||
// The psr3 log interface stipulates that exceptions should be passed
|
||||
// as the exception key in the context array.
|
||||
if ($exception) {
|
||||
$context['exception'] = $exception;
|
||||
}
|
||||
|
||||
|
||||
$this->log(
|
||||
"\033[0;31m" . $message . "\033[0m",
|
||||
LogLevel::ERROR,
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class Handler
|
|||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $levels = array(
|
||||
protected $levels = [
|
||||
E_WARNING => 'Warning',
|
||||
E_NOTICE => 'Notice',
|
||||
E_USER_ERROR => 'User Error',
|
||||
|
|
@ -30,7 +30,7 @@ class Handler
|
|||
E_RECOVERABLE_ERROR => 'Catchable Fatal Error',
|
||||
E_DEPRECATED => 'Deprecated',
|
||||
E_USER_DEPRECATED => 'User Deprecated',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* @var LoggerInterface
|
||||
|
|
@ -53,10 +53,10 @@ class Handler
|
|||
{
|
||||
$handler = new static($logger);
|
||||
|
||||
set_error_handler(array($handler, 'handleError'));
|
||||
register_shutdown_function(array($handler, 'handleFatalError'));
|
||||
set_error_handler([$handler, 'handleError']);
|
||||
register_shutdown_function([$handler, 'handleFatalError']);
|
||||
|
||||
set_exception_handler(array($handler, 'handleException'));
|
||||
set_exception_handler([$handler, 'handleException']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -147,7 +147,7 @@ class Handler
|
|||
$exception->getLine()
|
||||
);
|
||||
|
||||
$this->logger->error($message, array('exception' => $exception));
|
||||
$this->logger->error($message, ['exception' => $exception]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class LoggerConfig
|
|||
{
|
||||
const KEY_ALWAYS_LOADED = "_";
|
||||
private $config;
|
||||
private $cache = array();
|
||||
private $cache = [];
|
||||
|
||||
/**
|
||||
* The filepath is expected to return an array which will be
|
||||
|
|
@ -34,7 +34,7 @@ class LoggerConfig
|
|||
if (file_exists($filePath)) {
|
||||
$configArray = require($filePath);
|
||||
} else {
|
||||
$configArray = array();
|
||||
$configArray = [];
|
||||
}
|
||||
return new self($configArray);
|
||||
}
|
||||
|
|
@ -45,7 +45,7 @@ class LoggerConfig
|
|||
* array of LogHandlers.
|
||||
* @param array $configArray
|
||||
*/
|
||||
public function __construct(array $configArray = array())
|
||||
public function __construct(array $configArray = [])
|
||||
{
|
||||
$this->config = $configArray;
|
||||
}
|
||||
|
|
@ -81,7 +81,7 @@ class LoggerConfig
|
|||
*/
|
||||
protected function getHandlers($key)
|
||||
{
|
||||
$handlers = array();
|
||||
$handlers = [];
|
||||
|
||||
// They key is expected to either be an array or
|
||||
// a callable function that returns an array
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class InitialMigration extends AbstractMigration
|
|||
$build = $this->table('build');
|
||||
|
||||
if (!$build->hasForeignKey('project_id')) {
|
||||
$build->addForeignKey('project_id', 'project', 'id', array('delete'=> 'CASCADE', 'update' => 'CASCADE'));
|
||||
$build->addForeignKey('project_id', 'project', 'id', ['delete'=> 'CASCADE', 'update' => 'CASCADE']);
|
||||
}
|
||||
|
||||
$build->save();
|
||||
|
|
@ -30,11 +30,11 @@ class InitialMigration extends AbstractMigration
|
|||
$buildMeta = $this->table('build_meta');
|
||||
|
||||
if (!$buildMeta->hasForeignKey('build_id')) {
|
||||
$buildMeta->addForeignKey('build_id', 'build', 'id', array('delete'=> 'CASCADE', 'update' => 'CASCADE'));
|
||||
$buildMeta->addForeignKey('build_id', 'build', 'id', ['delete'=> 'CASCADE', 'update' => 'CASCADE']);
|
||||
}
|
||||
|
||||
if (!$buildMeta->hasForeignKey('project_id')) {
|
||||
$buildMeta->addForeignKey('project_id', 'project', 'id', array('delete'=> 'CASCADE', 'update' => 'CASCADE'));
|
||||
$buildMeta->addForeignKey('project_id', 'project', 'id', ['delete'=> 'CASCADE', 'update' => 'CASCADE']);
|
||||
}
|
||||
|
||||
$buildMeta->save();
|
||||
|
|
@ -61,11 +61,11 @@ class InitialMigration extends AbstractMigration
|
|||
}
|
||||
|
||||
if (!$table->hasColumn('commit_id')) {
|
||||
$table->addColumn('commit_id', 'string', array('limit' => 50));
|
||||
$table->addColumn('commit_id', 'string', ['limit' => 50]);
|
||||
}
|
||||
|
||||
if (!$table->hasColumn('status')) {
|
||||
$table->addColumn('status', 'integer', array('limit' => 4));
|
||||
$table->addColumn('status', 'integer', ['limit' => 4]);
|
||||
}
|
||||
|
||||
if (!$table->hasColumn('log')) {
|
||||
|
|
@ -73,7 +73,7 @@ class InitialMigration extends AbstractMigration
|
|||
}
|
||||
|
||||
if (!$table->hasColumn('branch')) {
|
||||
$table->addColumn('branch', 'string', array('limit' => 50));
|
||||
$table->addColumn('branch', 'string', ['limit' => 50]);
|
||||
}
|
||||
|
||||
if (!$table->hasColumn('created')) {
|
||||
|
|
@ -89,7 +89,7 @@ class InitialMigration extends AbstractMigration
|
|||
}
|
||||
|
||||
if (!$table->hasColumn('committer_email')) {
|
||||
$table->addColumn('committer_email', 'string', array('limit' => 250));
|
||||
$table->addColumn('committer_email', 'string', ['limit' => 250]);
|
||||
}
|
||||
|
||||
if (!$table->hasColumn('commit_message')) {
|
||||
|
|
@ -104,12 +104,12 @@ class InitialMigration extends AbstractMigration
|
|||
$table->removeColumn('plugins');
|
||||
}
|
||||
|
||||
if (!$table->hasIndex(array('project_id'))) {
|
||||
$table->addIndex(array('project_id'));
|
||||
if (!$table->hasIndex(['project_id'])) {
|
||||
$table->addIndex(['project_id']);
|
||||
}
|
||||
|
||||
if (!$table->hasIndex(array('status'))) {
|
||||
$table->addIndex(array('status'));
|
||||
if (!$table->hasIndex(['status'])) {
|
||||
$table->addIndex(['status']);
|
||||
}
|
||||
|
||||
$table->save();
|
||||
|
|
@ -132,15 +132,15 @@ class InitialMigration extends AbstractMigration
|
|||
}
|
||||
|
||||
if (!$table->hasColumn('meta_key')) {
|
||||
$table->addColumn('meta_key', 'string', array('limit' => 250));
|
||||
$table->addColumn('meta_key', 'string', ['limit' => 250]);
|
||||
}
|
||||
|
||||
if (!$table->hasColumn('meta_value')) {
|
||||
$table->addColumn('meta_value', 'text');
|
||||
}
|
||||
|
||||
if (!$table->hasIndex(array('build_id', 'meta_key'))) {
|
||||
$table->addIndex(array('build_id', 'meta_key'));
|
||||
if (!$table->hasIndex(['build_id', 'meta_key'])) {
|
||||
$table->addIndex(['build_id', 'meta_key']);
|
||||
}
|
||||
|
||||
$table->save();
|
||||
|
|
@ -155,11 +155,11 @@ class InitialMigration extends AbstractMigration
|
|||
}
|
||||
|
||||
if (!$table->hasColumn('title')) {
|
||||
$table->addColumn('title', 'string', array('limit' => 250));
|
||||
$table->addColumn('title', 'string', ['limit' => 250]);
|
||||
}
|
||||
|
||||
if (!$table->hasColumn('reference')) {
|
||||
$table->addColumn('reference', 'string', array('limit' => 250));
|
||||
$table->addColumn('reference', 'string', ['limit' => 250]);
|
||||
}
|
||||
|
||||
if (!$table->hasColumn('git_key')) {
|
||||
|
|
@ -171,15 +171,15 @@ class InitialMigration extends AbstractMigration
|
|||
}
|
||||
|
||||
if (!$table->hasColumn('type')) {
|
||||
$table->addColumn('type', 'string', array('limit' => 50));
|
||||
$table->addColumn('type', 'string', ['limit' => 50]);
|
||||
}
|
||||
|
||||
if (!$table->hasColumn('access_information')) {
|
||||
$table->addColumn('access_information', 'string', array('limit' => 250));
|
||||
$table->addColumn('access_information', 'string', ['limit' => 250]);
|
||||
}
|
||||
|
||||
if (!$table->hasColumn('last_commit')) {
|
||||
$table->addColumn('last_commit', 'string', array('limit' => 250));
|
||||
$table->addColumn('last_commit', 'string', ['limit' => 250]);
|
||||
}
|
||||
|
||||
if (!$table->hasColumn('build_config')) {
|
||||
|
|
@ -194,8 +194,8 @@ class InitialMigration extends AbstractMigration
|
|||
$table->removeColumn('token');
|
||||
}
|
||||
|
||||
if (!$table->hasIndex(array('title'))) {
|
||||
$table->addIndex(array('title'));
|
||||
if (!$table->hasIndex(['title'])) {
|
||||
$table->addIndex(['title']);
|
||||
}
|
||||
|
||||
$table->save();
|
||||
|
|
@ -210,23 +210,23 @@ class InitialMigration extends AbstractMigration
|
|||
}
|
||||
|
||||
if (!$table->hasColumn('email')) {
|
||||
$table->addColumn('email', 'string', array('limit' => 250));
|
||||
$table->addColumn('email', 'string', ['limit' => 250]);
|
||||
}
|
||||
|
||||
if (!$table->hasColumn('hash')) {
|
||||
$table->addColumn('hash', 'string', array('limit' => 250));
|
||||
$table->addColumn('hash', 'string', ['limit' => 250]);
|
||||
}
|
||||
|
||||
if (!$table->hasColumn('name')) {
|
||||
$table->addColumn('name', 'string', array('limit' => 250));
|
||||
$table->addColumn('name', 'string', ['limit' => 250]);
|
||||
}
|
||||
|
||||
if (!$table->hasColumn('is_admin')) {
|
||||
$table->addColumn('is_admin', 'integer');
|
||||
}
|
||||
|
||||
if (!$table->hasIndex(array('email'))) {
|
||||
$table->addIndex(array('email'));
|
||||
if (!$table->hasIndex(['email'])) {
|
||||
$table->addIndex(['email']);
|
||||
}
|
||||
|
||||
$table->save();
|
||||
|
|
|
|||
|
|
@ -23,10 +23,10 @@ class ChooseBranch extends AbstractMigration
|
|||
public function up()
|
||||
{
|
||||
$project = $this->table('project');
|
||||
$project->addColumn('branch', 'string', array(
|
||||
$project->addColumn('branch', 'string', [
|
||||
'after' => 'reference',
|
||||
'limit' => 250
|
||||
))->save();
|
||||
])->save();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -17,41 +17,41 @@ class FixDatabaseColumns extends AbstractMigration
|
|||
}
|
||||
|
||||
$build = $this->table('build');
|
||||
$build->changeColumn('project_id', 'integer', array('null' => false));
|
||||
$build->changeColumn('commit_id', 'string', array('limit' => 50, 'null' => false));
|
||||
$build->changeColumn('status', 'integer', array('null' => false));
|
||||
$build->changeColumn('log', 'text', array('null' => true));
|
||||
$build->changeColumn('branch', 'string', array('limit' => 50, 'null' => false, 'default' => 'master'));
|
||||
$build->changeColumn('created', 'datetime', array('null' => true));
|
||||
$build->changeColumn('started', 'datetime', array('null' => true));
|
||||
$build->changeColumn('finished', 'datetime', array('null' => true));
|
||||
$build->changeColumn('committer_email', 'string', array('limit' => 512, 'null' => true));
|
||||
$build->changeColumn('commit_message', 'text', array('null' => true));
|
||||
$build->changeColumn('extra', 'text', array('null' => true));
|
||||
$build->changeColumn('project_id', 'integer', ['null' => false]);
|
||||
$build->changeColumn('commit_id', 'string', ['limit' => 50, 'null' => false]);
|
||||
$build->changeColumn('status', 'integer', ['null' => false]);
|
||||
$build->changeColumn('log', 'text', ['null' => true, 'default' => '']);
|
||||
$build->changeColumn('branch', 'string', ['limit' => 50, 'null' => false, 'default' => 'master']);
|
||||
$build->changeColumn('created', 'datetime', ['null' => true]);
|
||||
$build->changeColumn('started', 'datetime', ['null' => true]);
|
||||
$build->changeColumn('finished', 'datetime', ['null' => true]);
|
||||
$build->changeColumn('committer_email', 'string', ['limit' => 512, 'null' => true]);
|
||||
$build->changeColumn('commit_message', 'text', ['null' => true]);
|
||||
$build->changeColumn('extra', 'text', ['null' => true]);
|
||||
|
||||
$buildMeta = $this->table('build_meta');
|
||||
$buildMeta->changeColumn('project_id', 'integer', array('null' => false));
|
||||
$buildMeta->changeColumn('build_id', 'integer', array('null' => false));
|
||||
$buildMeta->changeColumn('meta_key', 'string', array('limit' => 250, 'null' => false));
|
||||
$buildMeta->changeColumn('meta_value', 'text', array('null' => false));
|
||||
$buildMeta->changeColumn('project_id', 'integer', ['null' => false]);
|
||||
$buildMeta->changeColumn('build_id', 'integer', ['null' => false]);
|
||||
$buildMeta->changeColumn('meta_key', 'string', ['limit' => 250, 'null' => false]);
|
||||
$buildMeta->changeColumn('meta_value', 'text', ['null' => false]);
|
||||
|
||||
$project = $this->table('project');
|
||||
$project->changeColumn('title', 'string', array('limit' => 250, 'null' => false));
|
||||
$project->changeColumn('reference', 'string', array('limit' => 250, 'null' => false));
|
||||
$project->changeColumn('branch', 'string', array('limit' => 50, 'null' => false, 'default' => 'master'));
|
||||
$project->changeColumn('ssh_private_key', 'text', array('null' => true, 'default' => null));
|
||||
$project->changeColumn('ssh_public_key', 'text', array('null' => true, 'default' => null));
|
||||
$project->changeColumn('type', 'string', array('limit' => 50, 'null' => false));
|
||||
$project->changeColumn('access_information', 'string', array('limit' => 250, 'null' => true, 'default' => null));
|
||||
$project->changeColumn('last_commit', 'string', array('limit' => 250, 'null' => true, 'default' => null));
|
||||
$project->changeColumn('ssh_public_key', 'text', array('null' => true, 'default' => null));
|
||||
$project->changeColumn('allow_public_status', 'integer', array('null' => false, 'default' => 0));
|
||||
$project->changeColumn('title', 'string', ['limit' => 250, 'null' => false]);
|
||||
$project->changeColumn('reference', 'string', ['limit' => 250, 'null' => false]);
|
||||
$project->changeColumn('branch', 'string', ['limit' => 50, 'null' => false, 'default' => 'master']);
|
||||
$project->changeColumn('ssh_private_key', 'text', ['null' => true, 'default' => null]);
|
||||
$project->changeColumn('ssh_public_key', 'text', ['null' => true, 'default' => null]);
|
||||
$project->changeColumn('type', 'string', ['limit' => 50, 'null' => false]);
|
||||
$project->changeColumn('access_information', 'string', ['limit' => 250, 'null' => true, 'default' => null]);
|
||||
$project->changeColumn('last_commit', 'string', ['limit' => 250, 'null' => true, 'default' => null]);
|
||||
$project->changeColumn('ssh_public_key', 'text', ['null' => true, 'default' => null]);
|
||||
$project->changeColumn('allow_public_status', 'integer', ['null' => false, 'default' => 0]);
|
||||
|
||||
$user = $this->table('user');
|
||||
$user->changeColumn('email', 'string', array('limit' => 250, 'null' => false));
|
||||
$user->changeColumn('hash', 'string', array('limit' => 250, 'null' => false));
|
||||
$user->changeColumn('is_admin', 'integer', array('null' => false, 'default' => 0));
|
||||
$user->changeColumn('name', 'string', array('limit' => 250, 'null' => false));
|
||||
$user->changeColumn('email', 'string', ['limit' => 250, 'null' => false]);
|
||||
$user->changeColumn('hash', 'string', ['limit' => 250, 'null' => false]);
|
||||
$user->changeColumn('is_admin', 'integer', ['null' => false, 'default' => 0]);
|
||||
$user->changeColumn('name', 'string', ['limit' => 250, 'null' => false]);
|
||||
|
||||
if ($dbAdapter instanceof \Phinx\Db\Adapter\PdoAdapter) {
|
||||
$pdo = $dbAdapter->getConnection();
|
||||
|
|
|
|||
|
|
@ -12,16 +12,17 @@ class FixColumnTypes extends AbstractMigration
|
|||
{
|
||||
// Update the build log column to MEDIUMTEXT:
|
||||
$build = $this->table('build');
|
||||
$build->changeColumn('log', 'text', array(
|
||||
'null' => true,
|
||||
'limit' => MysqlAdapter::TEXT_MEDIUM,
|
||||
));
|
||||
$build->changeColumn('log', 'text', [
|
||||
'null' => true,
|
||||
'default' => '',
|
||||
'limit' => MysqlAdapter::TEXT_MEDIUM,
|
||||
]);
|
||||
|
||||
// Update the build meta value column to MEDIUMTEXT:
|
||||
$buildMeta = $this->table('build_meta');
|
||||
$buildMeta->changeColumn('meta_value', 'text', array(
|
||||
'null' => false,
|
||||
$buildMeta->changeColumn('meta_value', 'text', [
|
||||
'null' => false,
|
||||
'limit' => MysqlAdapter::TEXT_MEDIUM,
|
||||
));
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ class UniqueEmailAndNameUserFields extends AbstractMigration
|
|||
{
|
||||
$user_table = $this->table('user');
|
||||
$user_table
|
||||
->addIndex('email', array('unique' => true))
|
||||
->addIndex('name', array('unique' => true))
|
||||
->addIndex('email', ['unique' => true])
|
||||
->addIndex('name', ['unique' => true])
|
||||
->save();
|
||||
}
|
||||
|
||||
|
|
@ -23,8 +23,8 @@ class UniqueEmailAndNameUserFields extends AbstractMigration
|
|||
{
|
||||
$user_table = $this->table('user');
|
||||
$user_table
|
||||
->removeIndex('email', array('unique' => true))
|
||||
->removeIndex('name', array('unique' => true))
|
||||
->removeIndex('email', ['unique' => true])
|
||||
->removeIndex('name', ['unique' => true])
|
||||
->save();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class AddProjectGroups extends AbstractMigration
|
|||
public function change()
|
||||
{
|
||||
$table = $this->table('project_group');
|
||||
$table->addColumn('title', 'string', array('limit' => 100, 'null' => false));
|
||||
$table->addColumn('title', 'string', ['limit' => 100, 'null' => false]);
|
||||
$table->save();
|
||||
|
||||
$group = new \PHPCI\Model\ProjectGroup();
|
||||
|
|
@ -17,13 +17,13 @@ class AddProjectGroups extends AbstractMigration
|
|||
$group = \b8\Store\Factory::getStore('ProjectGroup')->save($group);
|
||||
|
||||
$table = $this->table('project');
|
||||
$table->addColumn('group_id', 'integer', array(
|
||||
'signed' => true,
|
||||
'null' => false,
|
||||
$table->addColumn('group_id', 'integer', [
|
||||
'signed' => true,
|
||||
'null' => false,
|
||||
'default' => $group->getId(),
|
||||
));
|
||||
]);
|
||||
|
||||
$table->addForeignKey('group_id', 'project_group', 'id', array('delete'=> 'RESTRICT', 'update' => 'CASCADE'));
|
||||
$table->addForeignKey('group_id', 'project_group', 'id', ['delete'=> 'RESTRICT', 'update' => 'CASCADE']);
|
||||
$table->save();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,12 +29,12 @@ class RemoveUniqueNameIndex extends AbstractMigration
|
|||
{
|
||||
$user = $this->table('user');
|
||||
|
||||
if ($user->hasIndex('name', array('unique' => true))) {
|
||||
$user->removeIndex('name', array('unique' => true));
|
||||
if ($user->hasIndex('name', ['unique' => true])) {
|
||||
$user->removeIndex('name', ['unique' => true]);
|
||||
$user->save();
|
||||
}
|
||||
|
||||
$user->addIndex('name', array('unique' => false));
|
||||
$user->addIndex('name', ['unique' => false]);
|
||||
$user->save();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,16 +8,16 @@ class ErrorsTable extends AbstractMigration
|
|||
public function change()
|
||||
{
|
||||
$table = $this->table('build_error');
|
||||
$table->addColumn('build_id', 'integer', array('signed' => true));
|
||||
$table->addColumn('plugin', 'string', array('limit' => 100));
|
||||
$table->addColumn('file', 'string', array('limit' => 250, 'null' => true));
|
||||
$table->addColumn('line_start', 'integer', array('signed' => false, 'null' => true));
|
||||
$table->addColumn('line_end', 'integer', array('signed' => false, 'null' => true));
|
||||
$table->addColumn('severity', 'integer', array('signed' => false, 'limit' => MysqlAdapter::INT_TINY));
|
||||
$table->addColumn('message', 'string', array('limit' => 250));
|
||||
$table->addColumn('build_id', 'integer', ['signed' => true]);
|
||||
$table->addColumn('plugin', 'string', ['limit' => 100]);
|
||||
$table->addColumn('file', 'string', ['limit' => 250, 'null' => true]);
|
||||
$table->addColumn('line_start', 'integer', ['signed' => false, 'null' => true]);
|
||||
$table->addColumn('line_end', 'integer', ['signed' => false, 'null' => true]);
|
||||
$table->addColumn('severity', 'integer', ['signed' => false, 'limit' => MysqlAdapter::INT_TINY]);
|
||||
$table->addColumn('message', 'string', ['limit' => 250]);
|
||||
$table->addColumn('created_date', 'datetime');
|
||||
$table->addIndex(array('build_id', 'created_date'), array('unique' => false));
|
||||
$table->addForeignKey('build_id', 'build', 'id', array('delete'=> 'CASCADE', 'update' => 'CASCADE'));
|
||||
$table->addIndex(['build_id', 'created_date'], ['unique' => false]);
|
||||
$table->addForeignKey('build_id', 'build', 'id', ['delete'=> 'CASCADE', 'update' => 'CASCADE']);
|
||||
$table->save();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -138,13 +138,13 @@ class Build extends BuildBase
|
|||
$pluginDir = PHPCI_DIR . 'PHPCI/Plugin/';
|
||||
$dir = new \DirectoryIterator($pluginDir);
|
||||
|
||||
$config = array(
|
||||
'build_settings' => array(
|
||||
'ignore' => array(
|
||||
$config = [
|
||||
'build_settings' => [
|
||||
'ignore' => [
|
||||
'vendor',
|
||||
)
|
||||
)
|
||||
);
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
foreach ($dir as $item) {
|
||||
if ($item->isDot()) {
|
||||
|
|
@ -167,11 +167,11 @@ class Build extends BuildBase
|
|||
continue;
|
||||
}
|
||||
|
||||
foreach (array('setup', 'test', 'complete', 'success', 'failure') as $stage) {
|
||||
foreach (['setup', 'test', 'complete', 'success', 'failure'] as $stage) {
|
||||
if ($className::canExecute($stage, $builder, $this)) {
|
||||
$config[$stage][$className] = array(
|
||||
$config[$stage][$className] = [
|
||||
'zero_config' => true
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,14 +30,14 @@ class Project extends ProjectBase
|
|||
*/
|
||||
public function getLatestBuild($branch = 'master', $status = null)
|
||||
{
|
||||
$criteria = array('branch' => $branch, 'project_id' => $this->getId());
|
||||
$criteria = ['branch' => $branch, 'project_id' => $this->getId()];
|
||||
|
||||
if (isset($status)) {
|
||||
$criteria['status'] = $status;
|
||||
}
|
||||
|
||||
$order = array('id' => 'DESC');
|
||||
$builds = Store\Factory::getStore('Build')->getWhere($criteria, 1, 0, array(), $order);
|
||||
$order = ['id' => 'DESC'];
|
||||
$builds = Store\Factory::getStore('Build')->getWhere($criteria, 1, 0, [], $order);
|
||||
|
||||
if (is_array($builds['items']) && count($builds['items'])) {
|
||||
$latest = array_shift($builds['items']);
|
||||
|
|
@ -57,10 +57,9 @@ class Project extends ProjectBase
|
|||
*/
|
||||
public function getPreviousBuild($branch = 'master')
|
||||
{
|
||||
$criteria = array('branch' => $branch, 'project_id' => $this->getId());
|
||||
|
||||
$order = array('id' => 'DESC');
|
||||
$builds = Store\Factory::getStore('Build')->getWhere($criteria, 1, 1, array(), $order);
|
||||
$criteria = ['branch' => $branch, 'project_id' => $this->getId()];
|
||||
$order = ['id' => 'DESC'];
|
||||
$builds = Store\Factory::getStore('Build')->getWhere($criteria, 1, 1, [], $order);
|
||||
|
||||
if (is_array($builds['items']) && count($builds['items'])) {
|
||||
$previous = array_shift($builds['items']);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue