From a6e76e2b7f93ef09816463a8c0e913a465f07a48 Mon Sep 17 00:00:00 2001 From: neznaika0 Date: Sun, 5 Jan 2025 18:39:38 +0300 Subject: [PATCH] refactor: Fix phpstan nullCoalesce --- system/HTTP/Files/UploadedFile.php | 2 +- system/Router/Router.php | 5 +++-- utils/phpstan-baseline/loader.neon | 1 - utils/phpstan-baseline/nullCoalesce.expr.neon | 13 ------------- 4 files changed, 4 insertions(+), 17 deletions(-) delete mode 100644 utils/phpstan-baseline/nullCoalesce.expr.neon diff --git a/system/HTTP/Files/UploadedFile.php b/system/HTTP/Files/UploadedFile.php index c17a9e5af8e5..b43923026021 100644 --- a/system/HTTP/Files/UploadedFile.php +++ b/system/HTTP/Files/UploadedFile.php @@ -325,7 +325,7 @@ public function guessExtension(): string */ public function getClientExtension(): string { - return pathinfo($this->originalName, PATHINFO_EXTENSION) ?? ''; + return pathinfo($this->originalName, PATHINFO_EXTENSION); } /** diff --git a/system/Router/Router.php b/system/Router/Router.php index 4e8c08852f79..14927ebfa603 100644 --- a/system/Router/Router.php +++ b/system/Router/Router.php @@ -51,7 +51,7 @@ class Router implements RouterInterface /** * A RouteCollection instance. * - * @var RouteCollectionInterface + * @var RouteCollection|RouteCollectionInterface */ protected $collection; @@ -144,6 +144,7 @@ class Router implements RouterInterface public function __construct(RouteCollectionInterface $routes, ?Request $request = null) { $config = config(App::class); + if (isset($config->permittedURIChars)) { $this->permittedURIChars = $config->permittedURIChars; } @@ -154,7 +155,7 @@ public function __construct(RouteCollectionInterface $routes, ?Request $request $this->controller = $this->collection->getDefaultController(); $this->method = $this->collection->getDefaultMethod(); - $this->collection->setHTTPVerb($request->getMethod() ?? $_SERVER['REQUEST_METHOD']); + $this->collection->setHTTPVerb($request->getMethod() === '' ? $_SERVER['REQUEST_METHOD'] : $request->getMethod()); $this->translateURIDashes = $this->collection->shouldTranslateURIDashes(); diff --git a/utils/phpstan-baseline/loader.neon b/utils/phpstan-baseline/loader.neon index 3fa0e75a7e12..5e6754f849f1 100644 --- a/utils/phpstan-baseline/loader.neon +++ b/utils/phpstan-baseline/loader.neon @@ -34,7 +34,6 @@ includes: - missingType.property.neon - missingType.return.neon - notIdentical.alwaysTrue.neon - - nullCoalesce.expr.neon - nullCoalesce.property.neon - nullCoalesce.variable.neon - offsetAccess.notFound.neon diff --git a/utils/phpstan-baseline/nullCoalesce.expr.neon b/utils/phpstan-baseline/nullCoalesce.expr.neon deleted file mode 100644 index bf8ffb4201b7..000000000000 --- a/utils/phpstan-baseline/nullCoalesce.expr.neon +++ /dev/null @@ -1,13 +0,0 @@ -# total 2 errors - -parameters: - ignoreErrors: - - - message: '#^Expression on left side of \?\? is not nullable\.$#' - count: 1 - path: ../../system/HTTP/Files/UploadedFile.php - - - - message: '#^Expression on left side of \?\? is not nullable\.$#' - count: 1 - path: ../../system/Router/Router.php