Skip to content

Commit 71929ca

Browse files
committed
类型转换
1 parent d068fa1 commit 71929ca

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Utils/Binary.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,11 @@ public function __construct(mixed $payload = null)
117117
$this->bytes = [];
118118
break;
119119
case is_numeric($payload):
120-
$this->bytes = [(int)$payload];
120+
$byte = (int)$payload;
121+
if ($byte < 0 || $byte > 255) {
122+
throw new InvalidArgumentException("Payload numeric '$payload' is invalid", ExceptionCode::ERROR_TYPE);
123+
}
124+
$this->bytes = [];
121125
break;
122126
case is_string($payload):
123127
$this->bytes = static::StringToBytes($payload);

0 commit comments

Comments
 (0)