Skip to content

Commit ef02a29

Browse files
authored
Adds a VarDumper ResultCaster (#214)
1 parent 6ff3253 commit ef02a29

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Result.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ class Result
3636
*/
3737
private $response;
3838

39+
/**
40+
* @var self[]
41+
*/
42+
private $prefetchResults = [];
43+
3944
/**
4045
* @var HttpClientInterface
4146
*/
@@ -59,6 +64,10 @@ public function __construct(ResponseInterface $response, HttpClientInterface $ht
5964

6065
public function __destruct()
6166
{
67+
while (!empty($this->prefetchResponses)) {
68+
array_shift($this->prefetchResponses)->cancel();
69+
}
70+
6271
if (false === $this->isResolved) {
6372
$this->resolve();
6473
}
@@ -139,6 +148,17 @@ final public function cancel(): void
139148
}
140149

141150
$this->response->cancel();
151+
unset($this->response);
152+
}
153+
154+
final protected function registerPrefetch(self $result): void
155+
{
156+
$this->prefetchResults[spl_object_hash($result)] = $result;
157+
}
158+
159+
final protected function unregisterPrefetch(self $result): void
160+
{
161+
unset($this->prefetchResults[spl_object_hash($result)]);
142162
}
143163

144164
final protected function initialize(): void

0 commit comments

Comments
 (0)