Skip to content

Commit 7818761

Browse files
fix: proxy uncovered response methods in ResponsePlusProxy (#6165)
Co-authored-by: 李铭昕 <[email protected]>
1 parent 9709aad commit 7818761

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/Server/ResponsePlusProxy.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
*/
1212
namespace Hyperf\HttpMessage\Server;
1313

14+
use Hyperf\Coroutine\Exception\InvalidArgumentException;
1415
use Psr\Http\Message\ResponseInterface;
1516
use Psr\Http\Message\StreamInterface;
1617
use Stringable;
@@ -27,6 +28,24 @@ public function __toString(): string
2728
return $this->toString();
2829
}
2930

31+
public function __call(string $name, array $arguments)
32+
{
33+
if (str_starts_with($name, 'with')) {
34+
return new static($this->response->{$name}(...$arguments));
35+
}
36+
37+
if (str_starts_with($name, 'get')) {
38+
return $this->response->{$name}(...$arguments);
39+
}
40+
41+
if (str_starts_with($name, 'set')) {
42+
$this->response->{$name}(...$arguments);
43+
return $this;
44+
}
45+
46+
throw new InvalidArgumentException(sprintf('The method %s is not supported.', $name));
47+
}
48+
3049
public function getProtocolVersion(): string
3150
{
3251
return $this->response->getProtocolVersion();

0 commit comments

Comments
 (0)