Skip to content

Commit

Permalink
Changed private static array-properties to const
Browse files Browse the repository at this point in the history
  • Loading branch information
simonberger committed Jan 24, 2021
1 parent 6a34516 commit adbefb0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions Encoder/QpEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class QpEncoder implements EncoderInterface
/**
* Pre-computed QP for HUGE optimization.
*/
private static $qpMap = [
private const QP_MAP = [
0 => '=00', 1 => '=01', 2 => '=02', 3 => '=03', 4 => '=04',
5 => '=05', 6 => '=06', 7 => '=07', 8 => '=08', 9 => '=09',
10 => '=0A', 11 => '=0B', 12 => '=0C', 13 => '=0D', 14 => '=0E',
Expand Down Expand Up @@ -170,7 +170,7 @@ private function encodeByteSequence(array $bytes, int &$size): string
$ret .= $this->safeMap[$b];
++$size;
} else {
$ret .= self::$qpMap[$b];
$ret .= self::QP_MAP[$b];
$size += 3;
}
}
Expand All @@ -187,7 +187,7 @@ private function standardize(string $string): string
switch ($end = \ord(substr($string, -1))) {
case 0x09:
case 0x20:
$string = substr_replace($string, self::$qpMap[$end], -1);
$string = substr_replace($string, self::QP_MAP[$end], -1);
}

return $string;
Expand Down
6 changes: 3 additions & 3 deletions Header/Headers.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
final class Headers
{
private static $uniqueHeaders = [
private const UNIQUE_HEADERS = [
'date', 'from', 'sender', 'reply-to', 'to', 'cc', 'bcc',
'message-id', 'in-reply-to', 'references', 'subject',
];
Expand Down Expand Up @@ -153,7 +153,7 @@ public function add(HeaderInterface $header): self
throw new LogicException(sprintf('The "%s" header must be an instance of "%s" (got "%s").', $header->getName(), $map[$name], \get_class($header)));
}

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

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

public static function isUniqueHeader(string $name): bool
{
return \in_array($name, self::$uniqueHeaders, true);
return \in_array($name, self::UNIQUE_HEADERS, true);
}

public function toString(): string
Expand Down
8 changes: 4 additions & 4 deletions MimeTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function getExtensions(string $mimeType): array
$extensions = $this->extensions[$mimeType] ?? $this->extensions[$lcMimeType = strtolower($mimeType)] ?? null;
}

return $extensions ?? self::$map[$mimeType] ?? self::$map[$lcMimeType ?? strtolower($mimeType)] ?? [];
return $extensions ?? self::MAP[$mimeType] ?? self::MAP[$lcMimeType ?? strtolower($mimeType)] ?? [];
}

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

return $mimeTypes ?? self::$reverseMap[$ext] ?? self::$reverseMap[$lcExt ?? strtolower($ext)] ?? [];
return $mimeTypes ?? self::REVERSE_MAP[$ext] ?? self::REVERSE_MAP[$lcExt ?? strtolower($ext)] ?? [];
}

/**
Expand Down Expand Up @@ -150,7 +150,7 @@ public function guessMimeType(string $path): ?string
*
* @see Resources/bin/update_mime_types.php
*/
private static $map = [
private const MAP = [
'application/acrobat' => ['pdf'],
'application/andrew-inset' => ['ez'],
'application/annodex' => ['anx'],
Expand Down Expand Up @@ -1611,7 +1611,7 @@ public function guessMimeType(string $path): ?string
'zz-application/zz-winassoc-xls' => ['xls', 'xlc', 'xll', 'xlm', 'xlw', 'xla', 'xlt', 'xld'],
];

private static $reverseMap = [
private const REVERSE_MAP = [
'32x' => ['application/x-genesis-32x-rom'],
'3dml' => ['text/vnd.in3d.3dml'],
'3ds' => ['image/x-3ds'],
Expand Down

0 comments on commit adbefb0

Please sign in to comment.