Skip to content

Commit 0a396ae

Browse files
add generic types for dto and dtoOrFail
1 parent e669e85 commit 0a396ae

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Http/Response.php

+8-2
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,11 @@ public function collect(string|int|null $key = null): Collection
287287

288288
/**
289289
* Cast the response to a DTO.
290+
*
291+
* @template T of object
292+
* @return ($dto is class-string<T> ? T : object)
290293
*/
291-
public function dto(): mixed
294+
public function dto(?string $dto = null): mixed
292295
{
293296
$request = $this->pendingRequest->getRequest();
294297
$connector = $this->pendingRequest->getConnector();
@@ -304,8 +307,11 @@ public function dto(): mixed
304307

305308
/**
306309
* Convert the response into a DTO or throw a LogicException if the response failed
310+
*
311+
* @template T of object
312+
* @return ($dto is class-string<T> ? T : object)
307313
*/
308-
public function dtoOrFail(): mixed
314+
public function dtoOrFail(?string $dto = null): mixed
309315
{
310316
if ($this->failed()) {
311317
throw new LogicException('Unable to create data transfer object as the response has failed.', 0, $this->toException());

0 commit comments

Comments
 (0)