Skip to content

Commit beb4cb6

Browse files
committed
Fix phan errors
1 parent a9741c7 commit beb4cb6

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/Model/Request/RequestParser.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,18 @@ private static function getConstructorArgument(
4444
}
4545

4646
if (!empty($propertyType->subProperties)) {
47-
$content = match ($propertyType->type) {
47+
$content = (match ($propertyType->type) {
4848
InputParamType::Query => $request->query,
4949
InputParamType::Json => $cacheJsonContent,
5050
InputParamType::Input => $request->input,
51-
};
51+
})[$propertyType->name] ?? null;
52+
53+
if (!is_array($content)) {
54+
return $propertyType->defaultValue;
55+
}
5256

5357
$subItemConstructorArgs = array_map(
54-
fn (RequestProperty $subProperty) => self::getSubObjectConstructorArguments($subProperty, $content[$propertyType->name] ?? []),
58+
fn (RequestProperty $subProperty) => self::getSubObjectConstructorArguments($subProperty, $content),
5559
$propertyType->subProperties,
5660
);
5761

src/Router.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use PhpApi\Enum\RouterExceptions;
99
use PhpApi\Interface\IRequestMiddleware;
1010
use PhpApi\Interface\IResponseMiddleware;
11-
use PhpApi\Model\Request\AbstractRequest;
1211
use PhpApi\Model\Request\RequestParser;
1312
use PhpApi\Model\Response\AbstractResponse;
1413
use PhpApi\Model\RouterOptions;

0 commit comments

Comments
 (0)