Skip to content

Commit

Permalink
Merge pull request #221 from kbond/php-cs-fixer
Browse files Browse the repository at this point in the history
Add php-cs-fixer and configure travis to check code quality
  • Loading branch information
kbond authored Nov 27, 2019
2 parents 91c7032 + c1a496d commit 4fa1d2b
Show file tree
Hide file tree
Showing 56 changed files with 332 additions and 407 deletions.
13 changes: 13 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

$finder = PhpCsFixer\Finder::create()
->exclude('vendor')
->exclude('Tests/app/var')
->in(__DIR__)
;

return PhpCsFixer\Config::create()
->setRules(['@Symfony' => true])
->setFinder($finder)
->setUsingCache(false)
;
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
include:
# Tests the lowest set of dependencies
- php: 7.1
env: LOWEST
install:
- travis_retry composer update -n --prefer-lowest --prefer-stable --prefer-dist

Expand All @@ -53,5 +54,10 @@ jobs:
- composer require --dev symfony/mailer --no-update
- travis_retry composer update -n --prefer-dist --prefer-stable

- stage: Code Quality
php: 7.3
script:
- ./vendor/bin/php-cs-fixer fix -v --dry-run

notifications:
slack: liip:3QOs1QKt3aCFxpJvRzpJCbVZ
2 changes: 1 addition & 1 deletion Check/CustomErrorPages.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function check()
// we suppose pages has been customized if the exception controller is not the default one,
// so we don't look for template file in this case.
if ($values['exception_controller']->getDefaultValue() == $this->exceptionController) {
$missingTemplate = array();
$missingTemplate = [];

foreach ($this->errorCodes as $errorCode) {
$template = sprintf('%s/Resources/TwigBundle/views/Exception/error%d.html.twig', $this->kernelRootDir, $errorCode);
Expand Down
4 changes: 2 additions & 2 deletions Check/DoctrineDbalCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
*/
class DoctrineDbalCollection implements CheckCollectionInterface
{
private $checks = array();
private $checks = [];

public function __construct(ConnectionRegistry $manager, $connections)
{
if (!is_array($connections)) {
$connections = array($connections);
$connections = [$connections];
}

foreach ($connections as $connection) {
Expand Down
12 changes: 6 additions & 6 deletions Check/DoctrineMigrationsCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@
use ZendDiagnostics\Check\DoctrineMigration as ZendDoctrineMigration;

/**
* Class DoctrineMigrationsCollection
* Class DoctrineMigrationsCollection.
*/
class DoctrineMigrationsCollection implements CheckCollectionInterface
{
/**
* DI Container
* DI Container.
*
* @var ContainerInterface
*/
private $container;

/**
* Available checks
* Available checks.
*
* @var CheckInterface[]
*/
private $checks;

/**
* Migrations configuration service ids
* Migrations configuration service ids.
*
* @var string[]
*/
Expand All @@ -44,7 +44,7 @@ public function __construct(
ContainerInterface $container,
array $migrations
) {
$this->container = $container;
$this->container = $container;
$this->migrations = $migrations;
}

Expand All @@ -53,7 +53,7 @@ public function __construct(
*/
public function getChecks()
{
if ($this->checks === null) {
if (null === $this->checks) {
$this->checks = [];
foreach ($this->migrations as $key => $migration) {
$check = new ZendDoctrineMigration($this->container->get($migration));
Expand Down
4 changes: 2 additions & 2 deletions Check/DoctrineMongoDbCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
*/
class DoctrineMongoDbCollection implements CheckCollectionInterface
{
private $checks = array();
private $checks = [];

public function __construct(ConnectionRegistry $manager, $connections)
{
if (!is_array($connections)) {
$connections = array($connections);
$connections = [$connections];
}

foreach ($connections as $connection) {
Expand Down
2 changes: 1 addition & 1 deletion Check/ExpressionCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
class ExpressionCollection implements CheckCollectionInterface
{
private $checks = array();
private $checks = [];

public function __construct(array $configs)
{
Expand Down
2 changes: 1 addition & 1 deletion Check/GuzzleHttpServiceCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
class GuzzleHttpServiceCollection implements CheckCollectionInterface
{
private $checks = array();
private $checks = [];

public function __construct(array $configs)
{
Expand Down
2 changes: 1 addition & 1 deletion Check/HttpServiceCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
class HttpServiceCollection implements CheckCollectionInterface
{
private $checks = array();
private $checks = [];

public function __construct(array $configs)
{
Expand Down
2 changes: 1 addition & 1 deletion Check/MemcacheCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
class MemcacheCollection implements CheckCollectionInterface
{
private $checks = array();
private $checks = [];

public function __construct(array $configs)
{
Expand Down
2 changes: 1 addition & 1 deletion Check/MemcachedCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
class MemcachedCollection implements CheckCollectionInterface
{
private $checks = array();
private $checks = [];

public function __construct(array $configs)
{
Expand Down
2 changes: 1 addition & 1 deletion Check/PdoConnectionCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class PdoConnectionCollection implements CheckCollectionInterface
{
private $checks = array();
private $checks = [];

public function __construct(array $connections)
{
Expand Down
5 changes: 1 addition & 4 deletions Check/PhpFlagsCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ class PhpFlagsCollection implements CheckCollectionInterface
/**
* @var array
*/
private $checks = array();
private $checks = [];

/**
* @param array $configs
*/
public function __construct(array $configs)
{
foreach ($configs as $setting => $value) {
Expand Down
5 changes: 1 addition & 4 deletions Check/PhpVersionCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ class PhpVersionCollection implements CheckCollectionInterface
/**
* @var array
*/
private $checks = array();
private $checks = [];

/**
* @param array $configs
*/
public function __construct(array $configs)
{
foreach ($configs as $version => $comparisonOperator) {
Expand Down
4 changes: 2 additions & 2 deletions Check/ProcessRunningCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
*/
class ProcessRunningCollection implements CheckCollectionInterface
{
private $checks = array();
private $checks = [];

public function __construct($processes)
{
if (!is_array($processes)) {
$processes = array($processes);
$processes = [$processes];
}

foreach ($processes as $process) {
Expand Down
2 changes: 1 addition & 1 deletion Check/RabbitMQCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
class RabbitMQCollection implements CheckCollectionInterface
{
private $checks = array();
private $checks = [];

public function __construct(array $configs)
{
Expand Down
8 changes: 4 additions & 4 deletions Check/SymfonyVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ function ($value) use ($branch) {
*/
private function getResponseAndDecode($url)
{
$opts = array(
'http' => array(
$opts = [
'http' => [
'method' => 'GET',
'header' => "User-Agent: LiipMonitorBundle\r\n",
),
);
],
];

$array = json_decode(file_get_contents($url, false, stream_context_create($opts)), true);

Expand Down
9 changes: 3 additions & 6 deletions Command/HealthCheckCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
use Liip\MonitorBundle\Helper\RawConsoleReporter;
use Liip\MonitorBundle\Helper\RunnerManager;
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\Input\InputArgument;

class HealthCheckCommand extends Command
{
Expand All @@ -29,7 +29,7 @@ public function __construct(ConsoleReporter $reporter, RawConsoleReporter $rawRe
protected function configure()
{
$this
->setName('monitor:health')
->setName('monitor:health')
->setDescription('Runs Health Checks')
->addArgument(
'checkName',
Expand All @@ -54,16 +54,13 @@ protected function configure()
}

/**
* @param InputInterface $input
* @param OutputInterface $output
*
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$failureCount = 0;

$groups = $input->getOption('group') ?: array(null);
$groups = $input->getOption('group') ?: [null];
$allGroups = $input->getOption('all');
$checkName = $input->getArgument('checkName');
$nagios = $input->getOption('nagios');
Expand Down
14 changes: 0 additions & 14 deletions Command/ListChecksCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;

class ListChecksCommand extends Command
{
Expand Down Expand Up @@ -68,9 +67,6 @@ protected function listChecks(InputInterface $input, OutputInterface $output)
$this->doListChecks($output, $runner);
}

/**
* @param OutputInterface $output
*/
protected function listAllChecks(OutputInterface $output)
{
foreach ($this->runnerManager->getRunners() as $group => $runner) {
Expand All @@ -80,9 +76,6 @@ protected function listAllChecks(OutputInterface $output)
}
}

/**
* @param OutputInterface $output
*/
protected function listReporters(OutputInterface $output)
{
$reporters = $this->runner->getAdditionalReporters();
Expand All @@ -95,20 +88,13 @@ protected function listReporters(OutputInterface $output)
}
}

/**
* @param OutputInterface $output
*/
protected function listGroups(OutputInterface $output)
{
foreach ($this->runnerManager->getGroups() as $group) {
$output->writeln($group);
}
}

/**
* @param OutputInterface $output
* @param Runner $runner
*/
private function doListChecks(OutputInterface $output, Runner $runner)
{
$checks = $runner->getChecks();
Expand Down
Loading

0 comments on commit 4fa1d2b

Please sign in to comment.