Lots of cleanup.

This commit is contained in:
Dan Cryer 2015-02-12 14:11:58 +00:00
parent 5ca9d4606e
commit c20ca7c8ff
30 changed files with 27 additions and 60 deletions

View file

@ -6,4 +6,4 @@ Redistribution and use in source and binary forms, with or without modification,
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View file

@ -14,7 +14,6 @@ use b8\Exception\HttpException;
use b8\Http\Response;
use b8\Http\Response\RedirectResponse;
use b8\View;
use PHPCI\Model\Build;
/**
* PHPCI Front Controller
@ -58,7 +57,7 @@ class Application extends b8\Application
$routeHandler = function (&$route, Response &$response) use (&$request, $validateSession, $skipAuth) {
$skipValidation = in_array($route['controller'], array('session', 'webhook', 'build-status'));
if (!$skipValidation && !$validateSession() && !$skipAuth()) {
if (!$skipValidation && !$validateSession() && (!is_callable($skipAuth) || !$skipAuth())) {
if ($request->isAjax()) {
$response->setResponseCode(401);
$response->setContent('');

View file

@ -12,12 +12,9 @@ namespace PHPCI\Command;
use PHPCI\Helper\Lang;
use PHPCI\Service\UserService;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use b8\Store\Factory;
use PHPCI\Builder;
/**
* Create admin command - creates an admin user
@ -77,7 +74,7 @@ class CreateAdminCommand extends Command
if (!$emptyOk && empty($rtn)) {
$rtn = $this->ask($question, $emptyOk, $validationFilter);
} elseif ($validationFilter != null && ! empty($rtn)) {
} elseif (!is_null($validationFilter) && ! empty($rtn)) {
if (! $this -> controlFormat($rtn, $validationFilter, $statusMessage)) {
print $statusMessage;
$rtn = $this->ask($question, $emptyOk, $validationFilter);

View file

@ -12,13 +12,8 @@ namespace PHPCI\Command;
use Monolog\Logger;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use b8\Store\Factory;
use PHPCI\Builder;
use PHPCI\BuildFactory;
/**
* Daemon that loops and call the run-command.

View file

@ -12,9 +12,7 @@ namespace PHPCI\Command;
use Monolog\Logger;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
/**
@ -76,7 +74,7 @@ class DaemoniseCommand extends Command
$this->sleep = 0;
$runner = new RunCommand($this->logger);
$runner->setMaxBuilds(1);
$runner->setIsDaemon(true);
$runner->setDaemon(true);
$emptyInput = new ArgvInput(array());

View file

@ -10,9 +10,7 @@
namespace PHPCI\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use b8\Database;
use b8\Database\CodeGenerator;

View file

@ -17,11 +17,9 @@ use b8\Database;
use b8\Store\Factory;
use PHPCI\Helper\Lang;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Helper\DialogHelper;
use PHPCI\Service\UserService;
/**
@ -298,6 +296,8 @@ class InstallCommand extends Command
)
);
unset($pdo);
return true;
} catch (Exception $ex) {

View file

@ -14,9 +14,7 @@ use b8\HttpClient;
use Monolog\Logger;
use PHPCI\Helper\Lang;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Yaml\Parser;
use PHPCI\Model\Build;

View file

@ -15,11 +15,8 @@ use PHPCI\Helper\Lang;
use PHPCI\Logging\BuildDBLogHandler;
use PHPCI\Logging\LoggedBuildContextTidier;
use PHPCI\Logging\OutputLogHandler;
use Psr\Log\LoggerAwareInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use b8\Store\Factory;
use PHPCI\Builder;
@ -143,7 +140,7 @@ class RunCommand extends Command
$this->maxBuilds = (int)$numBuilds;
}
public function setIsDaemon($fromDaemon)
public function setDaemon($fromDaemon)
{
$this->isFromDaemon = (bool)$fromDaemon;
}

View file

@ -12,10 +12,7 @@ namespace PHPCI\Command;
use Monolog\Logger;
use PHPCI\Helper\Lang;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
/**

View file

@ -11,7 +11,6 @@ namespace PHPCI\Controller;
use b8;
use PHPCI\Helper\Lang;
use PHPCI\Model\Build;
use PHPCI\Plugin\Util\ComposerPluginInformation;
use PHPCI\Plugin\Util\FilesPluginInformation;
use PHPCI\Plugin\Util\PluginInformationCollection;

View file

@ -10,17 +10,14 @@
namespace PHPCI\Controller;
use b8;
use b8\Controller;
use b8\Form;
use b8\Exception\HttpException\ForbiddenException;
use b8\Exception\HttpException\NotFoundException;
use b8\Store;
use PHPCI;
use PHPCI\BuildFactory;
use PHPCI\Helper\Github;
use PHPCI\Helper\Lang;
use PHPCI\Helper\SshKey;
use PHPCI\Model\Build;
use PHPCI\Model\Project;
use PHPCI\Service\BuildService;
use PHPCI\Service\ProjectService;
@ -30,7 +27,7 @@ use PHPCI\Service\ProjectService;
* @package PHPCI
* @subpackage Web
*/
class ProjectController extends \PHPCI\Controller
class ProjectController extends Controller
{
/**
* @var \PHPCI\Store\ProjectStore

View file

@ -14,7 +14,6 @@ use b8\Form;
use b8\HttpClient;
use PHPCI\Controller;
use PHPCI\Helper\Lang;
use PHPCI\Model\Build;
use Symfony\Component\Yaml\Dumper;
use Symfony\Component\Yaml\Parser;

View file

@ -10,12 +10,10 @@
namespace PHPCI\Controller;
use b8;
use b8\Exception\HttpException\ForbiddenException;
use b8\Exception\HttpException\NotFoundException;
use b8\Form;
use PHPCI\Controller;
use PHPCI\Helper\Lang;
use PHPCI\Model\User;
use PHPCI\Service\UserService;
/**

View file

@ -12,7 +12,6 @@ namespace PHPCI\Controller;
use b8;
use b8\Store;
use PHPCI\BuildFactory;
use PHPCI\Model\Build;
use PHPCI\Service\BuildService;
/**

View file

@ -90,7 +90,7 @@ class Email
* @param bool $isHtml
* @return $this
*/
public function setIsHtml($isHtml = false)
public function setHtml($isHtml = false)
{
$this->isHtml = $isHtml;

View file

@ -23,4 +23,4 @@ class ChangeBuildKeysMigration extends AbstractMigration
$project->renameColumn('ssh_private_key', 'git_key');
$project->renameColumn('ssh_public_key', 'public_key');
}
}
}

View file

@ -37,4 +37,4 @@ class ChooseBranch extends AbstractMigration
$project = $this->table('project');
$project->removeColumn('branch')->save();
}
}
}

View file

@ -25,4 +25,4 @@ class FixColumnTypes extends AbstractMigration
'limit' => MysqlAdapter::TEXT_MEDIUM,
));
}
}
}

View file

@ -9,8 +9,6 @@
namespace PHPCI;
use PHPCI\Model\Build;
/**
* PHPCI Plugin Interface - Used by all build plugins.
* @author Dan Cryer <dan@block8.co.uk>

View file

@ -148,7 +148,6 @@ class Campfire implements \PHPCI\Plugin
return json_decode($output);
}
// Simple 200 OK response (such as for joining a room)
// TODO: check for other result codes here
return true;
}
}

View file

@ -74,7 +74,7 @@ class CopyBuild implements \PHPCI\Plugin
*/
protected function wipeExistingDirectory()
{
if ($this->wipe == true && $this->directory != '/' && is_dir($this->directory)) {
if ($this->wipe === true && $this->directory != '/' && is_dir($this->directory)) {
$cmd = 'rm -Rf "%s*"';
$success = $this->phpci->executeCommand($cmd, $this->directory);

View file

@ -21,11 +21,9 @@ use PHPCI\Model\Build;
*/
class HipchatNotify implements \PHPCI\Plugin
{
private $authToken;
private $userAgent;
private $cookie;
private $color;
private $notify;
protected $authToken;
protected $color;
protected $notify;
/**
* Set up the plugin, configure options, etc.

View file

@ -2,6 +2,8 @@
namespace PHPCI\Plugin\Util;
use PHPCI\Plugin;
/**
* Class ComposerPluginInformation
* @package PHPCI\Plugin\Util
@ -63,7 +65,7 @@ class ComposerPluginInformation implements InstalledPluginInformation
public function getPluginClasses()
{
return array_map(
function ($plugin) {
function (Plugin $plugin) {
return $plugin->class;
},
$this->getInstalledPlugins()

View file

@ -2,6 +2,8 @@
namespace PHPCI\Plugin\Util;
use PHPCI\Plugin;
/**
* Class FilesPluginInformation
* @package PHPCI\Plugin\Util
@ -66,7 +68,7 @@ class FilesPluginInformation implements InstalledPluginInformation
public function getPluginClasses()
{
return array_map(
function ($plugin) {
function (Plugin $plugin) {
return $plugin->class;
},
$this->getInstalledPlugins()
@ -114,8 +116,6 @@ class FilesPluginInformation implements InstalledPluginInformation
*/
protected function getFullClassFromFile(\SplFileInfo $fileInfo)
{
//TODO: Something less horrible than a regular expression
// on the contents of a file
$contents = file_get_contents($fileInfo->getRealPath());
$matches = array();

View file

@ -10,7 +10,6 @@
namespace PHPCI\Store;
use b8\Database;
use PHPCI\BuildFactory;
use PHPCI\Model\Build;
use PHPCI\Store\Base\BuildStoreBase;

View file

@ -1,2 +1,2 @@
*
!.gitignore
!.gitignore

2
daemon/.gitignore vendored
View file

@ -1,2 +1,2 @@
*
!.gitignore
!.gitignore

View file

@ -13,4 +13,4 @@ return array(
new \Monolog\Handler\RotatingFileHandler(__DIR__ . DIRECTORY_SEPARATOR . 'everything',3, \Monolog\Logger::DEBUG),
);
},
);
);

View file

@ -19,4 +19,4 @@ return function (PHPCI\Plugin\Util\Factory $factory) {
// The resource will only be given when the type hint is:
PHPCI\Plugin\Util\Factory::TYPE_ARRAY
);
};
};