Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup php-cs-fixer config #347

Merged
merged 2 commits into from
Oct 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

/** @var ED\CS\Config\ED $config */
$config = require __DIR__ . '/vendor/glen/php-cs-fixer-config/phpcs.php';

$rules = $config->getRuleBuilder();
$finder = $config->getFinder();

return $config;

// vim:ft=php
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"twig/twig": "~1.17"
},
"require-dev": {
"glen/php-cs-fixer-config": "^0.3.0",
"phpunit/phpunit": "^5.7.27 | ^6.5.13"
},
"scripts": {
Expand Down
45 changes: 44 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions external/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,16 @@

if (!isset($options['f'])) {
throw new InvalidArgumentException('You should define a file to be loaded');
} else {
$file = $options['f'];
}
$file = $options['f'];

if (!is_readable($file)) {
throw new InvalidArgumentException($file.' isn\'t readable');
throw new InvalidArgumentException($file . ' isn\'t readable');
}

$fp = fopen($file, 'r');
if (!$fp) {
throw new RuntimeException('Can\'t open '.$file);
throw new RuntimeException('Can\'t open ' . $file);
}

$container = ServiceContainer::instance();
Expand Down
6 changes: 3 additions & 3 deletions install.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ function runProcess($cmd, $input = null)
* Composer setup.
*/
if (!file_exists(__DIR__ . '/composer.phar')) {
out("Downloading composer.");
out('Downloading composer.');
$cmd = "php -r \"eval('?>'.file_get_contents('https://getcomposer.org/installer'));\"";
$output = runProcess($cmd);
out($output);
} else {
out("Composer already installed.");
out('Composer already installed.');
}

if (!file_exists(__DIR__ . '/composer.phar')) {
Expand All @@ -74,7 +74,7 @@ function runProcess($cmd, $input = null)
exit(9);
}

out("Installing dependencies.");
out('Installing dependencies.');
$cmd = 'php ' . __DIR__ . '/composer.phar install --prefer-dist';
$output = runProcess($cmd);
out($output);
Expand Down
7 changes: 1 addition & 6 deletions src/Xhgui/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ class Config
/**
* Load a config file, it will replace
* all the currently loaded configuration.
*
* @return void
*/
public static function load($file)
{
Expand All @@ -25,7 +23,7 @@ public static function load($file)
* Read a config value.
*
* @param string $name The name of the config variable
* @return mixed The value or null.
* @return mixed the value or null
*/
public static function read($name)
{
Expand All @@ -51,7 +49,6 @@ public static function all()
*
* @param string $name The name of the config variable
* @param mixed $value The value of the config variable
* @return void
*/
public static function write($name, $value)
{
Expand All @@ -60,8 +57,6 @@ public static function write($name, $value)

/**
* Clear out the data stored in the config class.
*
* @return void
*/
public static function clear()
{
Expand Down
5 changes: 3 additions & 2 deletions src/Xhgui/Controller/ImportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
use InvalidArgumentException;
use Slim\Http\Request;
use Slim\Http\Response;
use XHGui\Saver\SaverInterface;
use XHGui\AbstractController;
use Slim\Slim as App;
use XHGui\AbstractController;
use XHGui\Saver\SaverInterface;

class ImportController extends AbstractController
{
Expand Down Expand Up @@ -53,6 +53,7 @@ private function runImport(Request $request): string
}

$data = json_decode($request->getBody(), true);

return $this->saver->save($data);
}
}
4 changes: 2 additions & 2 deletions src/Xhgui/Controller/MetricsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace XHGui\Controller;

use Slim\Http\Response;
use XHGui\Searcher\SearcherInterface;
use XHGui\AbstractController;
use Slim\Slim as App;
use XHGui\AbstractController;
use XHGui\Searcher\SearcherInterface;

class MetricsController extends AbstractController
{
Expand Down
4 changes: 2 additions & 2 deletions src/Xhgui/Controller/RunController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
use Exception;
use Slim\Http\Request;
use Slim\Http\Response;
use XHGui\Searcher\SearcherInterface;
use XHGui\AbstractController;
use Slim\Slim as App;
use XHGui\AbstractController;
use XHGui\Searcher\SearcherInterface;

class RunController extends AbstractController
{
Expand Down
4 changes: 2 additions & 2 deletions src/Xhgui/Controller/WatchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace XHGui\Controller;

use Slim\Http\Request;
use XHGui\Searcher\SearcherInterface;
use XHGui\AbstractController;
use Slim\Slim as App;
use XHGui\AbstractController;
use XHGui\Searcher\SearcherInterface;

class WatchController extends AbstractController
{
Expand Down
4 changes: 2 additions & 2 deletions src/Xhgui/Controller/WaterfallController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

use Slim\Http\Request;
use Slim\Http\Response;
use XHGui\Searcher\SearcherInterface;
use Slim\Slim as App;
use XHGui\AbstractController;
use XHGui\Profile;
use Slim\Slim as App;
use XHGui\Searcher\SearcherInterface;

class WaterfallController extends AbstractController
{
Expand Down
8 changes: 4 additions & 4 deletions src/Xhgui/Db/Mapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function convert($options)
*/
protected function _conditions($search)
{
if (!empty($search['limit_custom']) && $search['limit_custom'][0] === "P") {
if (!empty($search['limit_custom']) && $search['limit_custom'][0] === 'P') {
$search['limit'] = $search['limit_custom'];
}
$hasLimit = (!empty($search['limit']) && $search['limit'] != -1);
Expand Down Expand Up @@ -75,7 +75,7 @@ protected function _conditions($search)
$conditions['meta.SERVER.HTTP_COOKIE'] = (string)$search['cookie'];
}

if ($hasLimit && $search['limit'][0] === "P") {
if ($hasLimit && $search['limit'][0] === 'P') {
$date = new DateTime();
try {
$date->sub(new DateInterval($search['limit']));
Expand Down Expand Up @@ -129,8 +129,8 @@ protected function _direction($options)
*
* Whitelists to valid known keys.
*
* @param array $options Pagination options including the sort key.
* @return array Sort field & direction.
* @param array $options pagination options including the sort key
* @return array sort field & direction
*/
protected function _sort($options)
{
Expand Down
Loading