Skip to content

Commit a3ef378

Browse files
Merge branch '4.4' into 5.1
* 4.4: Changed private static array-properties to const
2 parents f05d505 + adbefb0 commit a3ef378

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

Encoder/QpEncoder.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class QpEncoder implements EncoderInterface
2121
/**
2222
* Pre-computed QP for HUGE optimization.
2323
*/
24-
private static $qpMap = [
24+
private const QP_MAP = [
2525
0 => '=00', 1 => '=01', 2 => '=02', 3 => '=03', 4 => '=04',
2626
5 => '=05', 6 => '=06', 7 => '=07', 8 => '=08', 9 => '=09',
2727
10 => '=0A', 11 => '=0B', 12 => '=0C', 13 => '=0D', 14 => '=0E',
@@ -170,7 +170,7 @@ private function encodeByteSequence(array $bytes, int &$size): string
170170
$ret .= $this->safeMap[$b];
171171
++$size;
172172
} else {
173-
$ret .= self::$qpMap[$b];
173+
$ret .= self::QP_MAP[$b];
174174
$size += 3;
175175
}
176176
}
@@ -187,7 +187,7 @@ private function standardize(string $string): string
187187
switch ($end = \ord(substr($string, -1))) {
188188
case 0x09:
189189
case 0x20:
190-
$string = substr_replace($string, self::$qpMap[$end], -1);
190+
$string = substr_replace($string, self::QP_MAP[$end], -1);
191191
}
192192

193193
return $string;

Header/Headers.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*/
2222
final class Headers
2323
{
24-
private static $uniqueHeaders = [
24+
private const UNIQUE_HEADERS = [
2525
'date', 'from', 'sender', 'reply-to', 'to', 'cc', 'bcc',
2626
'message-id', 'in-reply-to', 'references', 'subject',
2727
];
@@ -153,7 +153,7 @@ public function add(HeaderInterface $header): self
153153
throw new LogicException(sprintf('The "%s" header must be an instance of "%s" (got "%s").', $header->getName(), $map[$name], get_debug_type($header)));
154154
}
155155

156-
if (\in_array($name, self::$uniqueHeaders, true) && isset($this->headers[$name]) && \count($this->headers[$name]) > 0) {
156+
if (\in_array($name, self::UNIQUE_HEADERS, true) && isset($this->headers[$name]) && \count($this->headers[$name]) > 0) {
157157
throw new LogicException(sprintf('Impossible to set header "%s" as it\'s already defined and must be unique.', $header->getName()));
158158
}
159159

@@ -201,7 +201,7 @@ public function remove(string $name): void
201201

202202
public static function isUniqueHeader(string $name): bool
203203
{
204-
return \in_array($name, self::$uniqueHeaders, true);
204+
return \in_array($name, self::UNIQUE_HEADERS, true);
205205
}
206206

207207
public function toString(): string

MimeTypes.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function getExtensions(string $mimeType): array
8787
$extensions = $this->extensions[$mimeType] ?? $this->extensions[$lcMimeType = strtolower($mimeType)] ?? null;
8888
}
8989

90-
return $extensions ?? self::$map[$mimeType] ?? self::$map[$lcMimeType ?? strtolower($mimeType)] ?? [];
90+
return $extensions ?? self::MAP[$mimeType] ?? self::MAP[$lcMimeType ?? strtolower($mimeType)] ?? [];
9191
}
9292

9393
/**
@@ -99,7 +99,7 @@ public function getMimeTypes(string $ext): array
9999
$mimeTypes = $this->mimeTypes[$ext] ?? $this->mimeTypes[$lcExt = strtolower($ext)] ?? null;
100100
}
101101

102-
return $mimeTypes ?? self::$reverseMap[$ext] ?? self::$reverseMap[$lcExt ?? strtolower($ext)] ?? [];
102+
return $mimeTypes ?? self::REVERSE_MAP[$ext] ?? self::REVERSE_MAP[$lcExt ?? strtolower($ext)] ?? [];
103103
}
104104

105105
/**
@@ -150,7 +150,7 @@ public function guessMimeType(string $path): ?string
150150
*
151151
* @see Resources/bin/update_mime_types.php
152152
*/
153-
private static $map = [
153+
private const MAP = [
154154
'application/acrobat' => ['pdf'],
155155
'application/andrew-inset' => ['ez'],
156156
'application/annodex' => ['anx'],
@@ -1612,7 +1612,7 @@ public function guessMimeType(string $path): ?string
16121612
'zz-application/zz-winassoc-xls' => ['xls', 'xlc', 'xll', 'xlm', 'xlw', 'xla', 'xlt', 'xld'],
16131613
];
16141614

1615-
private static $reverseMap = [
1615+
private const REVERSE_MAP = [
16161616
'32x' => ['application/x-genesis-32x-rom'],
16171617
'3dml' => ['text/vnd.in3d.3dml'],
16181618
'3ds' => ['image/x-3ds'],

0 commit comments

Comments
 (0)