Skip to content

Commit 186eb93

Browse files
bug symfony#61766 Fix ord()-related PHP 8.5 deprecations (nicolas-grekas)
This PR was merged into the 6.4 branch. Discussion ---------- Fix ord()-related PHP 8.5 deprecations | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | - | License | MIT The remaining deprecations will be fixed by doctrine/orm#12160 Commits ------- 5314fd5 Fix ord()-related PHP 8.5 deprecations
2 parents cae30bb + 5314fd5 commit 186eb93

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/Symfony/Component/HttpFoundation/BinaryFileResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public function setContentDisposition(string $disposition, string $filename = ''
163163
for ($i = 0, $filenameLength = mb_strlen($filename, $encoding); $i < $filenameLength; ++$i) {
164164
$char = mb_substr($filename, $i, 1, $encoding);
165165

166-
if ('%' === $char || \ord($char) < 32 || \ord($char) > 126) {
166+
if ('%' === $char || \ord($char[0]) < 32 || \ord($char[0]) > 126) {
167167
$filenameFallback .= '_';
168168
} else {
169169
$filenameFallback .= $char;

src/Symfony/Component/Mime/Encoder/QpContentEncoder.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ private function standardize(string $string): string
4646
// transform =0D=0A to CRLF
4747
$string = str_replace(["\t=0D=0A", ' =0D=0A', '=0D=0A'], ["=09\r\n", "=20\r\n", "\r\n"], $string);
4848

49-
return match (\ord(substr($string, -1))) {
50-
0x09 => substr_replace($string, '=09', -1),
51-
0x20 => substr_replace($string, '=20', -1),
49+
return match ($string[-1] ?? '') {
50+
"\x09" => substr_replace($string, '=09', -1),
51+
"\x20" => substr_replace($string, '=20', -1),
5252
default => $string,
5353
};
5454
}

src/Symfony/Component/Mime/Encoder/QpEncoder.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,9 @@ private function standardize(string $string): string
183183
{
184184
$string = str_replace(["\t=0D=0A", ' =0D=0A', '=0D=0A'], ["=09\r\n", "=20\r\n", "\r\n"], $string);
185185

186-
return match ($end = \ord(substr($string, -1))) {
187-
0x09,
188-
0x20 => substr_replace($string, self::QP_MAP[$end], -1),
186+
return match ($end = ($string[-1] ?? '')) {
187+
"\x09",
188+
"\x20" => substr_replace($string, self::QP_MAP[\ord($end)], -1),
189189
default => $string,
190190
};
191191
}

0 commit comments

Comments
 (0)