Skip to content

Commit

Permalink
Merge pull request #400 from perftools/cs-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc authored Dec 23, 2020
2 parents 15062c2 + fb74ebd commit e729eaf
Show file tree
Hide file tree
Showing 30 changed files with 223 additions and 223 deletions.
2 changes: 1 addition & 1 deletion .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ $config = require __DIR__ . '/vendor/glen/php-cs-fixer-config/phpcs.php';
$rules = $config->getRuleBuilder();
$finder = $config->getFinder();

$rules['void_return'] = false;
$rules['list_syntax'] = ['syntax' => 'short'];

return $config;

Expand Down
2 changes: 1 addition & 1 deletion install.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* - Downloads composer.
* - Installs dependencies.
*/
function out($out)
function out($out): void
{
if (is_string($out)) {
echo $out . "\n";
Expand Down
2 changes: 1 addition & 1 deletion src/AbstractController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function __construct(App $app)
$this->app = $app;
}

protected function render(string $template, array $data = [])
protected function render(string $template, array $data = []): void
{
/** @var Response $response */
$response = $this->app->response;
Expand Down
2 changes: 1 addition & 1 deletion src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Config
* Load a config file, it will replace
* all the currently loaded configuration.
*/
public static function load($file)
public static function load($file): void
{
$config = include $file;
self::$config = array_merge(self::$config, $config);
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/CustomController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public function __construct(App $app, SearcherInterface $searcher)
$this->searcher = $searcher;
}

public function get()
public function get(): void
{
$this->render('custom/create.twig');
}

public function help(Request $request)
public function help(Request $request): void
{
if ($request->get('id')) {
$res = $this->searcher->get($request->get('id'));
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/ImportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct(App $app, SaverInterface $saver, $token)
$this->token = $token;
}

public function import(Request $request, Response $response)
public function import(Request $request, Response $response): void
{
try {
$id = $this->runImport($request);
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/MetricsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(App $app, SearcherInterface $searcher)
$this->searcher = $searcher;
}

public function metrics(Response $response)
public function metrics(Response $response): void
{
$stats = $this->searcher->stats();

Expand Down
28 changes: 14 additions & 14 deletions src/Controller/RunController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class RunController extends AbstractController
/**
* HTTP GET attribute name for comma separated filters
*/
const FILTER_ARGUMENT_NAME = 'filter';
private const FILTER_ARGUMENT_NAME = 'filter';

/**
* @var SearcherInterface
Expand All @@ -28,7 +28,7 @@ public function __construct(App $app, SearcherInterface $searcher)
$this->searcher = $searcher;
}

public function index(Request $request, Response $response)
public function index(Request $request, Response $response): void
{
// The list changes whenever new profiles are recorded.
// Generally avoid caching, but allow re-use in browser's bfcache
Expand Down Expand Up @@ -82,7 +82,7 @@ public function index(Request $request, Response $response)
]);
}

public function view(Request $request, Response $response)
public function view(Request $request, Response $response): void
{
// Permalink views to a specific run are meant to be public and immutable.
// But limit the cache to only a short period of time (enough to allow
Expand Down Expand Up @@ -145,7 +145,7 @@ protected function getFilters()
return $filters;
}

public function deleteForm(Request $request)
public function deleteForm(Request $request): void
{
$id = $request->get('id');
if (!is_string($id) || !strlen($id)) {
Expand All @@ -161,7 +161,7 @@ public function deleteForm(Request $request)
]);
}

public function deleteSubmit(Request $request)
public function deleteSubmit(Request $request): void
{
$id = $request->post('id');
// Don't call profilers->delete() unless $id is set,
Expand All @@ -180,12 +180,12 @@ public function deleteSubmit(Request $request)
$this->app->redirect($this->app->urlFor('home'));
}

public function deleteAllForm()
public function deleteAllForm(): void
{
$this->render('runs/delete-all-form.twig');
}

public function deleteAllSubmit()
public function deleteAllSubmit(): void
{
// Delete all profile runs.
$this->searcher->truncate();
Expand All @@ -195,7 +195,7 @@ public function deleteAllSubmit()
$this->app->redirect($this->app->urlFor('home'));
}

public function url(Request $request)
public function url(Request $request): void
{
$pagination = [
'sort' => $request->get('sort'),
Expand Down Expand Up @@ -247,7 +247,7 @@ public function url(Request $request)
]);
}

public function compare(Request $request)
public function compare(Request $request): void
{
$baseRun = $headRun = $candidates = $comparison = null;
$paging = [];
Expand Down Expand Up @@ -300,14 +300,14 @@ public function compare(Request $request)
]);
}

public function symbol(Request $request)
public function symbol(Request $request): void
{
$id = $request->get('id');
$symbol = $request->get('symbol');

$profile = $this->searcher->get($id);
$profile->calculateSelf();
list($parents, $current, $children) = $profile->getRelatives($symbol);
[$parents, $current, $children] = $profile->getRelatives($symbol);

$this->render('runs/symbol.twig', [
'symbol' => $symbol,
Expand All @@ -319,7 +319,7 @@ public function symbol(Request $request)
]);
}

public function symbolShort(Request $request)
public function symbolShort(Request $request): void
{
$id = $request->get('id');
$threshold = $request->get('threshold');
Expand All @@ -328,7 +328,7 @@ public function symbolShort(Request $request)

$profile = $this->searcher->get($id);
$profile->calculateSelf();
list($parents, $current, $children) = $profile->getRelatives($symbol, $metric, $threshold);
[$parents, $current, $children] = $profile->getRelatives($symbol, $metric, $threshold);

$this->render('runs/symbol-short.twig', [
'symbol' => $symbol,
Expand All @@ -340,7 +340,7 @@ public function symbolShort(Request $request)
]);
}

public function callgraph(Request $request)
public function callgraph(Request $request): void
{
$profile = $this->searcher->get($request->get('id'));

Expand Down
4 changes: 2 additions & 2 deletions src/Controller/WatchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ public function __construct(App $app, SearcherInterface $searcher)
$this->searcher = $searcher;
}

public function get()
public function get(): void
{
$watched = $this->searcher->getAllWatches();

$this->render('watch/list.twig', ['watched' => $watched]);
}

public function post(Request $request)
public function post(Request $request): void
{
$saved = false;
foreach ((array)$request->post('watch') as $data) {
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/WaterfallController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct(App $app, SearcherInterface $searcher)
$this->searcher = $searcher;
}

public function index()
public function index(): void
{
$request = $this->app->request();
$search = [];
Expand Down Expand Up @@ -55,7 +55,7 @@ public function index()
]);
}

public function query(Request $request, Response $response)
public function query(Request $request, Response $response): void
{
$search = [];
$keys = ['remote_addr', 'request_start', 'request_end'];
Expand Down
6 changes: 3 additions & 3 deletions src/Db/PdoRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function findByUrl(string $url, string $direction, int $skip, int $perPag
}
}

public function deleteById(string $id)
public function deleteById(string $id): void
{
$stmt = $this->pdo->prepare(sprintf('
DELETE FROM %s
Expand Down Expand Up @@ -166,7 +166,7 @@ public function getStatistics()
return $row ?: null;
}

public function initSchema()
public function initSchema(): void
{
$this->pdo->exec(sprintf('
CREATE TABLE IF NOT EXISTS %s (
Expand All @@ -189,7 +189,7 @@ public function initSchema()
', $this->table));
}

public function saveProfile(array $data)
public function saveProfile(array $data): void
{
$stmt = $this->pdo->prepare(sprintf('
INSERT INTO %s (
Expand Down
4 changes: 2 additions & 2 deletions src/Options/OptionsConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function offsetGet($offset)
return $this->options[$offset];
}

public function offsetSet($offset, $value)
public function offsetSet($offset, $value): void
{
if (null === $offset) {
$this->options[] = $value;
Expand All @@ -44,7 +44,7 @@ public function offsetSet($offset, $value)
}
}

public function offsetUnset($offset)
public function offsetUnset($offset): void
{
unset($this->options[$offset]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Options/SearchOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class SearchOptions extends OptionsConfigurator
* - conditions: an array of criteria to match
* - projection: an array or bool
*/
protected function configureOptions(OptionsResolver $resolver)
protected function configureOptions(OptionsResolver $resolver): void
{
// NOTE: the null values is trickery to set default values via null value
$defaults = [
Expand Down
Loading

0 comments on commit e729eaf

Please sign in to comment.