Skip to content

Commit

Permalink
Psalm lvl 1 (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
xepozz committed Jan 12, 2024
1 parent 39f6c34 commit ed919f4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<psalm
errorLevel="2"
errorLevel="1"
findUnusedBaselineEntry="true"
findUnusedCode="false"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Expand Down
15 changes: 12 additions & 3 deletions src/FileRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
$possibleEntrypoints = $this->parseRequestPath($request);

foreach ($possibleEntrypoints as $possibleEntrypoint) {
if (!is_array($possibleEntrypoint)) {
continue;
}
/**
* @psalm-var class-string $controllerClass
* @psalm-var string|null $possibleAction
Expand All @@ -96,7 +99,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
continue;
}

/** @psalm-suppress InvalidPropertyFetch */
/** @psalm-suppress InvalidPropertyFetch, MixedArrayAccess */
$action = $possibleAction ?? ($controllerClass::$actions ?? [

Check warning on line 103 in src/FileRouter.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.2-ubuntu-latest

Escaped Mutant for Mutator "ArrayItemRemoval": --- Original +++ New @@ @@ continue; } /** @psalm-suppress InvalidPropertyFetch, MixedArrayAccess */ - $action = $possibleAction ?? ($controllerClass::$actions ?? ['HEAD' => 'head', 'OPTIONS' => 'options', 'GET' => 'index', 'POST' => 'create', 'PUT' => 'update', 'PATCH' => 'patch', 'DELETE' => 'delete'])[$request->getMethod()] ?? null; + $action = $possibleAction ?? ($controllerClass::$actions ?? ['OPTIONS' => 'options', 'GET' => 'index', 'POST' => 'create', 'PUT' => 'update', 'PATCH' => 'patch', 'DELETE' => 'delete'])[$request->getMethod()] ?? null; if (!is_string($action)) { continue; }
'HEAD' => 'head',
'OPTIONS' => 'options',
Expand All @@ -107,18 +110,24 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
'DELETE' => 'delete',
])[$request->getMethod()] ?? null;

if ($action === null) {
if (!is_string($action)) {
continue;

Check warning on line 114 in src/FileRouter.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.2-ubuntu-latest

Escaped Mutant for Mutator "Continue_": --- Original +++ New @@ @@ /** @psalm-suppress InvalidPropertyFetch, MixedArrayAccess */ $action = $possibleAction ?? ($controllerClass::$actions ?? ['HEAD' => 'head', 'OPTIONS' => 'options', 'GET' => 'index', 'POST' => 'create', 'PUT' => 'update', 'PATCH' => 'patch', 'DELETE' => 'delete'])[$request->getMethod()] ?? null; if (!is_string($action)) { - continue; + break; } if (!method_exists($controllerClass, $action)) { continue;
}

if (!method_exists($controllerClass, $action)) {
continue;
}

/** @psalm-suppress InvalidPropertyFetch */
/** @psalm-suppress InvalidPropertyFetch, MixedArrayAccess */
$middlewares = $controllerClass::$middlewares[$action] ?? [];

if (!is_array($middlewares)) {
$middlewares = [];
}

$middlewares[] = [$controllerClass, $action];

/** @psalm-suppress MixedArgumentTypeCoercion */
$middlewareDispatcher = $this->middlewareDispatcher->withMiddlewares($middlewares);

return $middlewareDispatcher->dispatch($request, $handler);
Expand Down

0 comments on commit ed919f4

Please sign in to comment.