Skip to content

Commit

Permalink
TASK: Support nullable parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
mficzel committed Apr 4, 2024
1 parent 2b7d449 commit fd048b9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
3 changes: 0 additions & 3 deletions Classes/Application/ParameterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ public static function resolveParameters(string $className, string $methodName,
if (!$type instanceof \ReflectionNamedType) {
throw new \DomainException('Can only resolve named parameters with single type', 1709721743);
}
if ($type->allowsNull()) {
throw new \DomainException('Nullable types are not supported yet', 1709721755);
}

$requestBodyAttribute = RequestBody::tryFromReflectionParameter($parameter);
if ($requestBodyAttribute) {
Expand Down
8 changes: 4 additions & 4 deletions Classes/Domain/Path/ParameterLocation.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ enum ParameterLocation: string implements \JsonSerializable
public function resolveParameterFromRequest(ActionRequest $request, string $parameterName): array|int|bool|string|float|null
{
return match ($this) {
ParameterLocation::LOCATION_PATH => $request->getArgument($parameterName),
ParameterLocation::LOCATION_QUERY => $request->getHttpRequest()->getQueryParams()[$parameterName],
ParameterLocation::LOCATION_HEADER => $request->getHttpRequest()->getHeader($parameterName),
ParameterLocation::LOCATION_COOKIE => $request->getHttpRequest()->getCookieParams()[$parameterName],
ParameterLocation::LOCATION_PATH => $request->hasArgument($parameterName) ? $request->getArgument($parameterName) : null,
ParameterLocation::LOCATION_QUERY => $request->getHttpRequest()->getQueryParams()[$parameterName] ?? null,
ParameterLocation::LOCATION_HEADER => $request->getHttpRequest()->hasHeader($parameterName) ? $request->getHttpRequest()->getHeader($parameterName) : null,
ParameterLocation::LOCATION_COOKIE => $request->getHttpRequest()->getCookieParams()[$parameterName] ?? null,
};
}

Expand Down

0 comments on commit fd048b9

Please sign in to comment.