File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -137,8 +137,12 @@ private static function renderEscapeSequences(string $body): string
137137 */
138138 private static function renderHexadecimalSequences (string $ body ): string
139139 {
140- return @\preg_replace_callback (self ::HEX_SEQUENCE_PATTERN , static fn (array $ matches ): string
141- => \chr ((int ) \hexdec ($ matches [1 ])), $ body ) ?? $ body ;
140+ $ callback = static fn (array $ matches ): string
141+ // @phpstan-ignore-next-line : A hexdec returns int<0, 255>
142+ => \chr ((int ) \hexdec ($ matches [1 ]));
143+
144+ return @\preg_replace_callback (self ::HEX_SEQUENCE_PATTERN , $ callback , $ body )
145+ ?? $ body ;
142146 }
143147
144148 /**
@@ -150,6 +154,7 @@ private static function renderHexadecimalSequences(string $body): string
150154 private static function renderUtfSequences (string $ body ): string
151155 {
152156 return @\preg_replace_callback (self ::UTF_SEQUENCE_PATTERN , static function (array $ matches ): string {
157+ /** @var int<0, 1114112> $code */
153158 $ code = (int ) \hexdec ($ matches [1 ]);
154159
155160 // @phpstan-ignore-next-line : PHPStan false-positive mb_chr evaluation
@@ -158,6 +163,7 @@ private static function renderUtfSequences(string $body): string
158163 }
159164
160165 if (0x80 > $ code %= 0x200000 ) {
166+ // @phpstan-ignore-next-line : Code is valid
161167 return \chr ($ code );
162168 }
163169
You can’t perform that action at this time.
0 commit comments