Skip to content

Commit 625ff8c

Browse files
committed
Fix unset proprty values on request
1 parent 1707fe5 commit 625ff8c

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

sample/src/Routes/Path/Subpath/GetPathSubpath.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function execute(GetRequest $r, int $pathVar2): GetResponse
2121

2222
class GetRequest extends AbstractRequest
2323
{
24-
public ?int $someVar; // TODO: This does not work becuase property is not intialized
24+
public ?int $someVar;
2525
public string $someMessage = 'Has a default value';
2626
}
2727

src/Model/Request/AbstractRequest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ public function __construct(
1919
foreach ($paramTypes as $paramType) {
2020
if ($paramType->type === InputParamType::Query) {
2121
$queryParamValue = $this->request->query[$paramType->name] ?? null;
22-
if (isset($queryParamValue)) {
22+
if (isset($queryParamValue) || !isset($this->{$paramType->propertyName})) {
2323
$this->{$paramType->propertyName} = $queryParamValue;
2424
}
2525
} elseif ($paramType->type === InputParamType::Json) {
2626
$jsonParamValue = $this->request->json[$paramType->name] ?? null;
27-
if (isset($jsonParamValue)) {
27+
if (isset($jsonParamValue) || !isset($this->{$paramType->propertyName})) {
2828
$this->{$paramType->propertyName} = $jsonParamValue;
2929
}
3030
} elseif ($paramType->type === InputParamType::Input) {
3131
$inputParamValue = $this->request->input[$paramType->name] ?? null;
32-
if (isset($inputParamValue)) {
32+
if (isset($inputParamValue) || !isset($this->{$paramType->propertyName})) {
3333
$this->{$paramType->propertyName} = $inputParamValue;
3434
}
3535
}

0 commit comments

Comments
 (0)