From 0283f14aa1fbd97796f753e8d6105c752546050f Mon Sep 17 00:00:00 2001 From: Chris Kankiewicz Date: Sat, 20 May 2023 20:48:36 -0700 Subject: [PATCH] Fixed static analysis errors --- app/src/HiddenFiles.php | 1 + app/src/Support/Str.php | 6 ++++- app/src/ViewFunctions/Asset.php | 7 +++++- app/src/ViewFunctions/Breadcrumbs.php | 6 ++++- phpstan-baseline.neon | 35 ++++++++++++--------------- 5 files changed, 32 insertions(+), 23 deletions(-) diff --git a/app/src/HiddenFiles.php b/app/src/HiddenFiles.php index 227ea4d..2ee1a65 100644 --- a/app/src/HiddenFiles.php +++ b/app/src/HiddenFiles.php @@ -5,6 +5,7 @@ namespace App; use BadMethodCallException; use Tightenco\Collect\Support\Collection; +/** @extends Collection */ class HiddenFiles extends Collection { protected function __construct($items = []) diff --git a/app/src/Support/Str.php b/app/src/Support/Str.php index 36024e1..1ba9cff 100644 --- a/app/src/Support/Str.php +++ b/app/src/Support/Str.php @@ -6,7 +6,11 @@ use Tightenco\Collect\Support\Collection; class Str { - /** Explode a string by a string into a collection. */ + /** + * Explode a string by a string into a collection. + * + * @return Collection + */ public static function explode(string $string, string $delimiter): Collection { return Collection::make(explode($delimiter, $string)); diff --git a/app/src/ViewFunctions/Asset.php b/app/src/ViewFunctions/Asset.php index 989080e..45eb126 100644 --- a/app/src/ViewFunctions/Asset.php +++ b/app/src/ViewFunctions/Asset.php @@ -21,13 +21,18 @@ class Asset extends ViewFunction $path = '/' . ltrim($path, '/'); if ($this->mixManifest()->has($path)) { + /** @var string $path */ $path = $this->mixManifest()->get($path); } return 'app/assets/' . ltrim($path, '/'); } - /** Return the mix manifest collection. */ + /** + * Return the mix manifest collection. + * + * @return Collection + */ protected function mixManifest(): Collection { $mixManifest = $this->config->get('asset_path') . '/mix-manifest.json'; diff --git a/app/src/ViewFunctions/Breadcrumbs.php b/app/src/ViewFunctions/Breadcrumbs.php index becf646..151f4f3 100644 --- a/app/src/ViewFunctions/Breadcrumbs.php +++ b/app/src/ViewFunctions/Breadcrumbs.php @@ -17,7 +17,11 @@ class Breadcrumbs extends ViewFunction ) { } - /** Build a collection of breadcrumbs for a given path. */ + /** + * Build a collection of breadcrumbs for a given path. + * + * @return Collection + */ public function __invoke(string $path): Collection { return Str::explode($path, $this->directorySeparator)->diffAssoc( diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 4e257eb..53d1e00 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,25 +1,5 @@ parameters: ignoreErrors: - - - message: "#^Parameter \\#1 \\$factory of function DI\\\\factory expects callable\\(\\)\\: mixed, 'App\\\\\\\\Factories\\\\\\\\CacheFactory' given\\.$#" - count: 1 - path: app/config/container.php - - - - message: "#^Parameter \\#1 \\$factory of function DI\\\\factory expects callable\\(\\)\\: mixed, 'App\\\\\\\\Factories\\\\\\\\FinderFactory' given\\.$#" - count: 1 - path: app/config/container.php - - - - message: "#^Parameter \\#1 \\$factory of function DI\\\\factory expects callable\\(\\)\\: mixed, 'App\\\\\\\\Factories\\\\\\\\TranslationFactory' given\\.$#" - count: 1 - path: app/config/container.php - - - - message: "#^Parameter \\#1 \\$factory of function DI\\\\factory expects callable\\(\\)\\: mixed, 'App\\\\\\\\Factories\\\\\\\\TwigFactory' given\\.$#" - count: 1 - path: app/config/container.php - - message: "#^Method App\\\\Controllers\\\\DirectoryController\\:\\:__invoke\\(\\) throws checked exception Twig\\\\Error\\\\LoaderError but it's missing from the PHPDoc @throws tag\\.$#" count: 2 @@ -50,6 +30,11 @@ parameters: count: 2 path: app/src/Controllers/SearchController.php + - + message: "#^Method App\\\\Controllers\\\\ZipController\\:\\:generateFileName\\(\\) should return string but returns string\\|null\\.$#" + count: 1 + path: app/src/Controllers/ZipController.php + - message: "#^Method App\\\\Exceptions\\\\ErrorHandler\\:\\:__invoke\\(\\) throws checked exception Twig\\\\Error\\\\LoaderError but it's missing from the PHPDoc @throws tag\\.$#" count: 1 @@ -80,6 +65,16 @@ parameters: count: 1 path: app/src/Support/Str.php + - + message: "#^Unable to resolve the template type TMakeKey in call to method static method Tightenco\\\\Collect\\\\Support\\\\Collection\\<\\(int\\|string\\),mixed\\>\\:\\:make\\(\\)$#" + count: 1 + path: app/src/ViewFunctions/Asset.php + + - + message: "#^Unable to resolve the template type TMakeValue in call to method static method Tightenco\\\\Collect\\\\Support\\\\Collection\\<\\(int\\|string\\),mixed\\>\\:\\:make\\(\\)$#" + count: 1 + path: app/src/ViewFunctions/Asset.php + - message: "#^Parameter \\#1 \\$separator of function explode expects non\\-empty\\-string, string given\\.$#" count: 1