Fixed some static analysis issues

This commit is contained in:
Chris Kankiewicz
2019-11-28 22:42:20 -07:00
parent 8dd0a9b542
commit 4a816d01a6
8 changed files with 563 additions and 10 deletions

View File

@@ -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,

View File

@@ -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];
})

View File

@@ -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}";

View File

@@ -1,11 +1,12 @@
<?php
use Symfony\Component\Finder\SplFileInfo;
use Twig\TwigFunction;
return [
/** Theme specific Twig functions */
'functions' => [
new TwigFunction('icon', function ($file) {
new TwigFunction('icon', function (SplFileInfo $file) {
$icons = require __DIR__ . '/icons.php';
$icon = $file->isDir() ? 'fas fa-folder'

View File

@@ -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',

View File

@@ -62,7 +62,7 @@
</ul>
</div>
<footer class="">
<footer>
<div class="container border-t-2 border-gray-800 text-center mx-auto px-4 py-8">
Powered by <a href="https://www.directorylister.com" class="underline">Directory Lister</a>
</div>

View File

@@ -24,7 +24,8 @@
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.3",
"phpunit/phpunit": "^7.0 || ^8.0",
"psy/psysh": "^0.9.9"
"psy/psysh": "^0.9.9",
"vimeo/psalm": "^3.6"
},
"autoload": {
"psr-4": {

553
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "5003b90640a509723c3c5392fb26754a",
"content-hash": "3f8b853962638f4e1d58e70a684b6393",
"packages": [
{
"name": "fig/http-message-util",
@@ -1746,6 +1746,142 @@
}
],
"packages-dev": [
{
"name": "amphp/amp",
"version": "v2.4.0",
"source": {
"type": "git",
"url": "https://github.com/amphp/amp.git",
"reference": "13930a582947831bb66ff1aeac28672fd91c38ea"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/amphp/amp/zipball/13930a582947831bb66ff1aeac28672fd91c38ea",
"reference": "13930a582947831bb66ff1aeac28672fd91c38ea",
"shasum": ""
},
"require": {
"php": ">=7"
},
"require-dev": {
"amphp/php-cs-fixer-config": "dev-master",
"amphp/phpunit-util": "^1",
"ext-json": "*",
"phpstan/phpstan": "^0.8.5",
"phpunit/phpunit": "^6.0.9 | ^7",
"react/promise": "^2"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Amp\\": "lib"
},
"files": [
"lib/functions.php",
"lib/Internal/functions.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Daniel Lowrey",
"email": "rdlowrey@php.net"
},
{
"name": "Aaron Piotrowski",
"email": "aaron@trowski.com"
},
{
"name": "Bob Weinand",
"email": "bobwei9@hotmail.com"
},
{
"name": "Niklas Keller",
"email": "me@kelunik.com"
}
],
"description": "A non-blocking concurrency framework for PHP applications.",
"homepage": "http://amphp.org/amp",
"keywords": [
"async",
"asynchronous",
"awaitable",
"concurrency",
"event",
"event-loop",
"future",
"non-blocking",
"promise"
],
"time": "2019-11-11T19:32:05+00:00"
},
{
"name": "amphp/byte-stream",
"version": "v1.7.1",
"source": {
"type": "git",
"url": "https://github.com/amphp/byte-stream.git",
"reference": "9d8205686a004948475dc43f8a88d2fa5e75a113"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/amphp/byte-stream/zipball/9d8205686a004948475dc43f8a88d2fa5e75a113",
"reference": "9d8205686a004948475dc43f8a88d2fa5e75a113",
"shasum": ""
},
"require": {
"amphp/amp": "^2"
},
"require-dev": {
"amphp/php-cs-fixer-config": "dev-master",
"amphp/phpunit-util": "^1",
"friendsofphp/php-cs-fixer": "^2.3",
"infection/infection": "^0.9.3",
"phpunit/phpunit": "^6"
},
"type": "library",
"autoload": {
"psr-4": {
"Amp\\ByteStream\\": "lib"
},
"files": [
"lib/functions.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Aaron Piotrowski",
"email": "aaron@trowski.com"
},
{
"name": "Niklas Keller",
"email": "me@kelunik.com"
}
],
"description": "A stream abstraction to make working with non-blocking I/O simple.",
"homepage": "http://amphp.org/byte-stream",
"keywords": [
"amp",
"amphp",
"async",
"io",
"non-blocking",
"stream"
],
"time": "2019-10-27T14:33:41+00:00"
},
{
"name": "composer/semver",
"version": "1.5.0",
@@ -2071,6 +2207,94 @@
],
"time": "2019-10-30T14:39:59+00:00"
},
{
"name": "felixfbecker/advanced-json-rpc",
"version": "v3.0.4",
"source": {
"type": "git",
"url": "https://github.com/felixfbecker/php-advanced-json-rpc.git",
"reference": "23366dd0cab0a0f3fd3016bf3c0b36dec74348e7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/felixfbecker/php-advanced-json-rpc/zipball/23366dd0cab0a0f3fd3016bf3c0b36dec74348e7",
"reference": "23366dd0cab0a0f3fd3016bf3c0b36dec74348e7",
"shasum": ""
},
"require": {
"netresearch/jsonmapper": "^1.0",
"php": ">=7.0",
"phpdocumentor/reflection-docblock": "^4.0.0"
},
"require-dev": {
"phpunit/phpunit": "^6.0.0"
},
"type": "library",
"autoload": {
"psr-4": {
"AdvancedJsonRpc\\": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"ISC"
],
"authors": [
{
"name": "Felix Becker",
"email": "felix.b@outlook.com"
}
],
"description": "A more advanced JSONRPC implementation",
"time": "2019-09-12T22:41:08+00:00"
},
{
"name": "felixfbecker/language-server-protocol",
"version": "v1.4.0",
"source": {
"type": "git",
"url": "https://github.com/felixfbecker/php-language-server-protocol.git",
"reference": "378801f6139bb74ac215d81cca1272af61df9a9f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/felixfbecker/php-language-server-protocol/zipball/378801f6139bb74ac215d81cca1272af61df9a9f",
"reference": "378801f6139bb74ac215d81cca1272af61df9a9f",
"shasum": ""
},
"require": {
"php": "^7.0"
},
"require-dev": {
"phpstan/phpstan": "*",
"phpunit/phpunit": "^6.3",
"squizlabs/php_codesniffer": "^3.1"
},
"type": "library",
"autoload": {
"psr-4": {
"LanguageServerProtocol\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"ISC"
],
"authors": [
{
"name": "Felix Becker",
"email": "felix.b@outlook.com"
}
],
"description": "PHP classes for the Language Server Protocol",
"keywords": [
"language",
"microsoft",
"php",
"server"
],
"time": "2019-06-23T21:03:50+00:00"
},
{
"name": "friendsofphp/php-cs-fixer",
"version": "v2.16.0",
@@ -2296,6 +2520,152 @@
],
"time": "2019-08-09T12:45:53+00:00"
},
{
"name": "netresearch/jsonmapper",
"version": "v1.6.0",
"source": {
"type": "git",
"url": "https://github.com/cweiske/jsonmapper.git",
"reference": "0d4d1b48d682a93b6bfedf60b88c7750e9cb0b06"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/cweiske/jsonmapper/zipball/0d4d1b48d682a93b6bfedf60b88c7750e9cb0b06",
"reference": "0d4d1b48d682a93b6bfedf60b88c7750e9cb0b06",
"shasum": ""
},
"require": {
"ext-json": "*",
"ext-pcre": "*",
"ext-reflection": "*",
"ext-spl": "*",
"php": ">=5.6"
},
"require-dev": {
"phpunit/phpunit": "~4.8.35 || ~5.7 || ~6.4",
"squizlabs/php_codesniffer": "~1.5"
},
"type": "library",
"autoload": {
"psr-0": {
"JsonMapper": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"OSL-3.0"
],
"authors": [
{
"name": "Christian Weiske",
"email": "cweiske@cweiske.de",
"homepage": "http://github.com/cweiske/jsonmapper/",
"role": "Developer"
}
],
"description": "Map nested JSON structures onto PHP classes",
"time": "2019-08-15T19:41:25+00:00"
},
{
"name": "ocramius/package-versions",
"version": "1.5.1",
"source": {
"type": "git",
"url": "https://github.com/Ocramius/PackageVersions.git",
"reference": "1d32342b8c1eb27353c8887c366147b4c2da673c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Ocramius/PackageVersions/zipball/1d32342b8c1eb27353c8887c366147b4c2da673c",
"reference": "1d32342b8c1eb27353c8887c366147b4c2da673c",
"shasum": ""
},
"require": {
"composer-plugin-api": "^1.0.0",
"php": "^7.3.0"
},
"require-dev": {
"composer/composer": "^1.8.6",
"doctrine/coding-standard": "^6.0.0",
"ext-zip": "*",
"infection/infection": "^0.13.4",
"phpunit/phpunit": "^8.2.5",
"vimeo/psalm": "^3.4.9"
},
"type": "composer-plugin",
"extra": {
"class": "PackageVersions\\Installer",
"branch-alias": {
"dev-master": "1.6.x-dev"
}
},
"autoload": {
"psr-4": {
"PackageVersions\\": "src/PackageVersions"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Marco Pivetta",
"email": "ocramius@gmail.com"
}
],
"description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)",
"time": "2019-07-17T15:49:50+00:00"
},
{
"name": "openlss/lib-array2xml",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/nullivex/lib-array2xml.git",
"reference": "a91f18a8dfc69ffabe5f9b068bc39bb202c81d90"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nullivex/lib-array2xml/zipball/a91f18a8dfc69ffabe5f9b068bc39bb202c81d90",
"reference": "a91f18a8dfc69ffabe5f9b068bc39bb202c81d90",
"shasum": ""
},
"require": {
"php": ">=5.3.2"
},
"type": "library",
"autoload": {
"psr-0": {
"LSS": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "Bryan Tong",
"email": "bryan@nullivex.com",
"homepage": "https://www.nullivex.com"
},
{
"name": "Tony Butler",
"email": "spudz76@gmail.com",
"homepage": "https://www.nullivex.com"
}
],
"description": "Array2XML conversion library credit to lalit.org",
"homepage": "https://www.nullivex.com",
"keywords": [
"array",
"array conversion",
"xml",
"xml conversion"
],
"time": "2019-03-29T20:06:56+00:00"
},
{
"name": "paragonie/random_compat",
"version": "v9.99.99",
@@ -4399,6 +4769,94 @@
"description": "A small library for converting tokenized PHP source code into XML and potentially other formats",
"time": "2019-06-13T22:48:21+00:00"
},
{
"name": "vimeo/psalm",
"version": "3.6.4",
"source": {
"type": "git",
"url": "https://github.com/vimeo/psalm.git",
"reference": "3e98c800ec72e06eed7546956823ff395fc30c75"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/vimeo/psalm/zipball/3e98c800ec72e06eed7546956823ff395fc30c75",
"reference": "3e98c800ec72e06eed7546956823ff395fc30c75",
"shasum": ""
},
"require": {
"amphp/amp": "^2.1",
"amphp/byte-stream": "^1.5",
"composer/xdebug-handler": "^1.1",
"felixfbecker/advanced-json-rpc": "^3.0.3",
"felixfbecker/language-server-protocol": "^1.4",
"netresearch/jsonmapper": "^1.0",
"nikic/php-parser": "^4.2",
"ocramius/package-versions": "^1.2",
"openlss/lib-array2xml": "^1.0",
"php": "^7.1.3",
"sebastian/diff": "^3.0",
"symfony/console": "^3.3||^4.0",
"webmozart/glob": "^4.1",
"webmozart/path-util": "^2.3"
},
"provide": {
"psalm/psalm": "self.version"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.2",
"ext-curl": "*",
"friendsofphp/php-cs-fixer": "^2.15",
"phpmyadmin/sql-parser": "^5.0",
"phpunit/phpunit": "^7.5 || ^8.0",
"psalm/plugin-phpunit": "^0.6",
"slevomat/coding-standard": "^5.0",
"squizlabs/php_codesniffer": "3.4.0",
"symfony/process": "^4.3"
},
"suggest": {
"ext-igbinary": "^2.0.5"
},
"bin": [
"psalm",
"psalter",
"psalm-language-server",
"psalm-plugin",
"psalm-refactor"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.x-dev",
"dev-2.x": "2.x-dev",
"dev-1.x": "1.x-dev"
}
},
"autoload": {
"psr-4": {
"Psalm\\Plugin\\": "src/Psalm/Plugin",
"Psalm\\": "src/Psalm"
},
"files": [
"src/functions.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Matthew Brown"
}
],
"description": "A static analysis tool for finding errors in PHP applications",
"keywords": [
"code",
"inspection",
"php"
],
"time": "2019-11-06T18:13:02+00:00"
},
{
"name": "webmozart/assert",
"version": "1.5.0",
@@ -4448,6 +4906,99 @@
"validate"
],
"time": "2019-08-24T08:43:50+00:00"
},
{
"name": "webmozart/glob",
"version": "4.1.0",
"source": {
"type": "git",
"url": "https://github.com/webmozart/glob.git",
"reference": "3cbf63d4973cf9d780b93d2da8eec7e4a9e63bbe"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/webmozart/glob/zipball/3cbf63d4973cf9d780b93d2da8eec7e4a9e63bbe",
"reference": "3cbf63d4973cf9d780b93d2da8eec7e4a9e63bbe",
"shasum": ""
},
"require": {
"php": "^5.3.3|^7.0",
"webmozart/path-util": "^2.2"
},
"require-dev": {
"phpunit/phpunit": "^4.6",
"sebastian/version": "^1.0.1",
"symfony/filesystem": "^2.5"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.1-dev"
}
},
"autoload": {
"psr-4": {
"Webmozart\\Glob\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Bernhard Schussek",
"email": "bschussek@gmail.com"
}
],
"description": "A PHP implementation of Ant's glob.",
"time": "2015-12-29T11:14:33+00:00"
},
{
"name": "webmozart/path-util",
"version": "2.3.0",
"source": {
"type": "git",
"url": "https://github.com/webmozart/path-util.git",
"reference": "d939f7edc24c9a1bb9c0dee5cb05d8e859490725"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/webmozart/path-util/zipball/d939f7edc24c9a1bb9c0dee5cb05d8e859490725",
"reference": "d939f7edc24c9a1bb9c0dee5cb05d8e859490725",
"shasum": ""
},
"require": {
"php": ">=5.3.3",
"webmozart/assert": "~1.0"
},
"require-dev": {
"phpunit/phpunit": "^4.6",
"sebastian/version": "^1.0.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.3-dev"
}
},
"autoload": {
"psr-4": {
"Webmozart\\PathUtil\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Bernhard Schussek",
"email": "bschussek@gmail.com"
}
],
"description": "A robust cross-platform utility for normalizing, comparing and modifying file paths.",
"time": "2015-12-17T08:42:14+00:00"
}
],
"aliases": [],