|
19 | 19 | use Docker\Endpoint\SystemEvents; |
20 | 20 | use Docker\Exception\BadRequestException; |
21 | 21 | use Docker\Http\InteractiveHttpClient; |
| 22 | +use Docker\Stream\AttachWebsocketStream; |
| 23 | +use Docker\Stream\BuildStream; |
| 24 | +use Docker\Stream\CreateImageStream; |
| 25 | +use Docker\Stream\DockerRawStream; |
| 26 | +use Docker\Stream\EventStream; |
22 | 27 | use Docker\Stream\InteractiveExecStream; |
| 28 | +use Docker\Stream\PushStream; |
23 | 29 | use Docker\Stream\SocketReadStream; |
24 | 30 | use Http\Client\Socket\Stream as SocketStream; |
| 31 | +use Psr\Http\Message\ResponseInterface; |
25 | 32 |
|
26 | 33 | /** |
27 | 34 | * Docker\Docker. |
@@ -32,6 +39,8 @@ class Docker extends Client |
32 | 39 |
|
33 | 40 | /** |
34 | 41 | * {@inheritdoc} |
| 42 | + * |
| 43 | + * @return ($fetch is 'object' ? DockerRawStream|null : ResponseInterface) |
35 | 44 | */ |
36 | 45 | public function containerAttach(string $id, array $queryParameters = [], string $fetch = self::FETCH_OBJECT, array $accept = []) |
37 | 46 | { |
@@ -40,6 +49,8 @@ public function containerAttach(string $id, array $queryParameters = [], string |
40 | 49 |
|
41 | 50 | /** |
42 | 51 | * {@inheritdoc} |
| 52 | + * |
| 53 | + * @return ($fetch is 'object' ? AttachWebsocketStream|null : ResponseInterface) |
43 | 54 | */ |
44 | 55 | public function containerAttachWebsocket(string $id, array $queryParameters = [], string $fetch = self::FETCH_OBJECT, array $accept = []) |
45 | 56 | { |
@@ -48,6 +59,8 @@ public function containerAttachWebsocket(string $id, array $queryParameters = [] |
48 | 59 |
|
49 | 60 | /** |
50 | 61 | * {@inheritdoc} |
| 62 | + * |
| 63 | + * @return ($fetch is 'object' ? DockerRawStream|null : ResponseInterface) |
51 | 64 | */ |
52 | 65 | public function containerLogs(string $id, array $queryParameters = [], string $fetch = self::FETCH_OBJECT, array $accept = []) |
53 | 66 | { |
@@ -61,6 +74,8 @@ public function containerLogs(string $id, array $queryParameters = [], string $f |
61 | 74 |
|
62 | 75 | /** |
63 | 76 | * {@inheritdoc} |
| 77 | + * |
| 78 | + * @return ($fetch is 'object' ? DockerRawStream|null : ResponseInterface) |
64 | 79 | */ |
65 | 80 | public function execStart(string $id, ?ExecIdStartPostBody $requestBody = null, string $fetch = self::FETCH_OBJECT, array $accept = []) |
66 | 81 | { |
@@ -96,7 +111,7 @@ public function execStartInteractive(string $id, ?ExecIdStartPostBody $requestBo |
96 | 111 | || !preg_match('/(?:^|,)\s*upgrade\s*(?:,|$)/i', $response->getHeaderLine('Connection')) |
97 | 112 | || $response->hasHeader('Transfer-Encoding') |
98 | 113 | || $response->hasHeader('Content-Encoding') |
99 | | - || !\in_array($mediaType, [\Docker\Stream\DockerRawStream::HEADER, \Docker\Stream\DockerRawStream::MULTIPLEXED_HEADER], true) |
| 114 | + || !\in_array($mediaType, [DockerRawStream::HEADER, DockerRawStream::MULTIPLEXED_HEADER], true) |
100 | 115 | || (!$stream instanceof SocketReadStream && !$stream instanceof SocketStream)) { |
101 | 116 | $stream->close(); |
102 | 117 | throw new \RuntimeException('Docker did not provide a supported interactive exec upgrade (HTTP '.$response->getStatusCode().').'); |
@@ -115,6 +130,8 @@ public function execStartInteractive(string $id, ?ExecIdStartPostBody $requestBo |
115 | 130 |
|
116 | 131 | /** |
117 | 132 | * {@inheritdoc} |
| 133 | + * |
| 134 | + * @return ($fetch is 'object' ? BuildStream|null : ResponseInterface) |
118 | 135 | */ |
119 | 136 | public function imageBuild($requestBody = null, array $queryParameters = [], array $headerParameters = [], string $fetch = self::FETCH_OBJECT) |
120 | 137 | { |
@@ -123,12 +140,19 @@ public function imageBuild($requestBody = null, array $queryParameters = [], arr |
123 | 140 |
|
124 | 141 | /** |
125 | 142 | * {@inheritdoc} |
| 143 | + * |
| 144 | + * @return ($fetch is 'object' ? CreateImageStream|null : ResponseInterface) |
126 | 145 | */ |
127 | 146 | public function imageCreate(?string $requestBody = null, array $queryParameters = [], array $headerParameters = [], string $fetch = self::FETCH_OBJECT) |
128 | 147 | { |
129 | 148 | return $this->executeEndpoint(new ImageCreate($requestBody, $queryParameters, $headerParameters), $fetch); |
130 | 149 | } |
131 | 150 |
|
| 151 | + /** |
| 152 | + * {@inheritdoc} |
| 153 | + * |
| 154 | + * @return ($fetch is 'object' ? PushStream|null : ResponseInterface) |
| 155 | + */ |
132 | 156 | public function imagePush(string $name, array $queryParameters = [], array $headerParameters = [], string $fetch = self::FETCH_OBJECT, array $accept = []) |
133 | 157 | { |
134 | 158 | if (isset($headerParameters['X-Registry-Auth']) && $headerParameters['X-Registry-Auth'] instanceof AuthConfig) { |
@@ -140,6 +164,8 @@ public function imagePush(string $name, array $queryParameters = [], array $head |
140 | 164 |
|
141 | 165 | /** |
142 | 166 | * {@inheritdoc} |
| 167 | + * |
| 168 | + * @return ($fetch is 'object' ? EventStream|null : ResponseInterface) |
143 | 169 | */ |
144 | 170 | public function systemEvents(array $queryParameters = [], string $fetch = self::FETCH_OBJECT) |
145 | 171 | { |
|