Skip to content

Commit 78a9619

Browse files
authored
WebSocketHandeShakeException is deprecated, please use WebSocketHandShakeException instead. (#6621)
1 parent eab3c53 commit 78a9619

File tree

5 files changed

+35
-8
lines changed

5 files changed

+35
-8
lines changed

src/ConfigProvider.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212

1313
namespace Hyperf\WebSocketServer;
1414

15+
use Hyperf\WebSocketServer\Exception\WebSocketHandShakeException;
16+
17+
// Will remove at v3.2
18+
class_alias(WebSocketHandShakeException::class, 'Hyperf\WebSocketServer\Exception\WebSocketHandeShakeException');
19+
1520
class ConfigProvider
1621
{
1722
public function __invoke(): array

src/CoreMiddleware.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Hyperf\HttpMessage\Base\Response;
1717
use Hyperf\HttpServer\CoreMiddleware as HttpCoreMiddleware;
1818
use Hyperf\HttpServer\Router\Dispatched;
19-
use Hyperf\WebSocketServer\Exception\WebSocketHandeShakeException;
19+
use Hyperf\WebSocketServer\Exception\WebSocketHandShakeException;
2020
use Psr\Http\Message\ResponseInterface;
2121
use Psr\Http\Message\ServerRequestInterface;
2222

@@ -31,7 +31,7 @@ protected function handleFound(Dispatched $dispatched, ServerRequestInterface $r
3131
{
3232
[$controller] = $this->prepareHandler($dispatched->handler->callback);
3333
if (! $this->container->has($controller)) {
34-
throw new WebSocketHandeShakeException('Router not exist.');
34+
throw new WebSocketHandShakeException('Router not exist.');
3535
}
3636

3737
/** @var Response $response */
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
/**
5+
* This file is part of Hyperf.
6+
*
7+
* @link https://www.hyperf.io
8+
* @document https://hyperf.wiki
9+
* @contact group@hyperf.io
10+
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
11+
*/
12+
13+
namespace Hyperf\WebSocketServer\Exception;
14+
15+
use Hyperf\HttpMessage\Exception\BadRequestHttpException;
16+
17+
class WebSocketHandShakeException extends BadRequestHttpException
18+
{
19+
}

src/Exception/WebSocketHandeShakeException.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@
1212

1313
namespace Hyperf\WebSocketServer\Exception;
1414

15-
use Hyperf\HttpMessage\Exception\BadRequestHttpException;
16-
17-
class WebSocketHandeShakeException extends BadRequestHttpException
18-
{
15+
if (! class_exists('Hyperf\WebSocketServer\Exception\WebSocketHandeShakeException', false)) {
16+
/**
17+
* @deprecated since v3.1, will remove at v3.2. Please use Hyperf\WebSocketServer\Exception\WebSocketHandShakeException instead.
18+
*/
19+
class WebSocketHandeShakeException extends WebSocketHandShakeException
20+
{
21+
}
1922
}

src/Server.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
use Hyperf\WebSocketServer\Collector\FdCollector;
4343
use Hyperf\WebSocketServer\Context as WsContext;
4444
use Hyperf\WebSocketServer\Exception\Handler\WebSocketExceptionHandler;
45-
use Hyperf\WebSocketServer\Exception\WebSocketHandeShakeException;
45+
use Hyperf\WebSocketServer\Exception\WebSocketHandShakeException;
4646
use Psr\Container\ContainerInterface;
4747
use Psr\Http\Message\ResponseInterface;
4848
use Psr\Http\Message\ServerRequestInterface;
@@ -130,7 +130,7 @@ public function onHandShake($request, $response): void
130130

131131
$key = $psr7Request->getHeaderLine(Security::SEC_WEBSOCKET_KEY);
132132
if ($security->isInvalidSecurityKey($key)) {
133-
throw new WebSocketHandeShakeException('sec-websocket-key is invalid!');
133+
throw new WebSocketHandShakeException('sec-websocket-key is invalid!');
134134
}
135135

136136
$psr7Request = $this->coreMiddleware->dispatch($psr7Request);

0 commit comments

Comments
 (0)