From 4a816d01a65374f0dcd91a76111f28ded40739c6 Mon Sep 17 00:00:00 2001 From: Chris Kankiewicz Date: Thu, 28 Nov 2019 22:42:20 -0700 Subject: [PATCH] Fixed some static analysis issues --- .php_cs.dist | 1 + app/Bootstrap/ViewComposer.php | 6 +- app/Controllers/DirectoryController.php | 4 +- app/themes/default/config.php | 3 +- app/themes/default/icons.php | 1 - app/themes/default/index.twig | 2 +- composer.json | 3 +- composer.lock | 553 +++++++++++++++++++++++- 8 files changed, 563 insertions(+), 10 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index 415321f..2c724a9 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -19,6 +19,7 @@ return PhpCsFixer\Config::create()->setRules([ 'linebreak_after_opening_tag' => true, 'new_with_braces' => false, 'no_multiline_whitespace_before_semicolons' => true, + 'no_superfluous_phpdoc_tags' => false, 'no_useless_else' => true, 'no_useless_return' => true, 'not_operator_with_successor_space' => true, diff --git a/app/Bootstrap/ViewComposer.php b/app/Bootstrap/ViewComposer.php index 0c23e51..6258d04 100644 --- a/app/Bootstrap/ViewComposer.php +++ b/app/Bootstrap/ViewComposer.php @@ -38,15 +38,15 @@ class ViewComposer ); $this->twig->getEnvironment()->addFunction( - new TwigFunction('asset', function ($path) { + new TwigFunction('asset', function (string $path) { return "/app/themes/{$this->config->get('theme', 'defualt')}/{$path}"; }) ); $this->twig->getEnvironment()->addFunction( - new TwigFunction('sizeForHumans', function ($bytes) { + new TwigFunction('sizeForHumans', function (int $bytes) { $sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; - $factor = floor((strlen($bytes) - 1) / 3); + $factor = (int) floor((strlen($bytes) - 1) / 3); return sprintf('%.2f', $bytes / pow(1024, $factor)) . $sizes[$factor]; }) diff --git a/app/Controllers/DirectoryController.php b/app/Controllers/DirectoryController.php index d9e9591..10223eb 100644 --- a/app/Controllers/DirectoryController.php +++ b/app/Controllers/DirectoryController.php @@ -36,7 +36,7 @@ class DirectoryController * @param \Slim\Psr7\Response $response * @param string $path * - * @return \Slim\Psr7\Response + * @return \Psr\Http\Message\ResponseInterface */ public function __invoke(Request $request, Response $response, string $path = '.') { @@ -64,7 +64,7 @@ class DirectoryController { $breadcrumbs = Collection::make(array_filter(explode('/', $path))); - return $breadcrumbs->filter(function ($crumb) { + return $breadcrumbs->filter(function (string $crumb) { return $crumb !== '.'; })->reduce(function (array $carry, string $crumb) { $carry[$crumb] = end($carry) . "/{$crumb}"; diff --git a/app/themes/default/config.php b/app/themes/default/config.php index 041a58c..98f2fb6 100644 --- a/app/themes/default/config.php +++ b/app/themes/default/config.php @@ -1,11 +1,12 @@ [ - new TwigFunction('icon', function ($file) { + new TwigFunction('icon', function (SplFileInfo $file) { $icons = require __DIR__ . '/icons.php'; $icon = $file->isDir() ? 'fas fa-folder' diff --git a/app/themes/default/icons.php b/app/themes/default/icons.php index 1a6d371..eb2ec6e 100644 --- a/app/themes/default/icons.php +++ b/app/themes/default/icons.php @@ -84,7 +84,6 @@ return [ // Executables 'app' => 'fas fa-window', - 'bat' => 'fas fa-window', 'com' => 'fas fa-window', 'exe' => 'fas fa-window', 'jar' => 'fas fa-window', diff --git a/app/themes/default/index.twig b/app/themes/default/index.twig index a95c51f..1d0612e 100644 --- a/app/themes/default/index.twig +++ b/app/themes/default/index.twig @@ -62,7 +62,7 @@ -