Skip to content
This repository has been archived by the owner on Nov 17, 2021. It is now read-only.

Commit

Permalink
Fix CS
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Sep 29, 2020
1 parent e5148f4 commit 4af8d50
Show file tree
Hide file tree
Showing 93 changed files with 292 additions and 287 deletions.
9 changes: 7 additions & 2 deletions .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@ return PhpCsFixer\Config::create()
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
'@PHPUnit75Migration:risky' => true,
'php_unit_dedicate_assert' => ['target' => '5.6'],
'array_syntax' => ['syntax' => 'short'],
'php_unit_fqcn_annotation' => true,
'no_unreachable_default_argument_value' => false,
'braces' => ['allow_single_line_closure' => true],
'heredoc_to_nowdoc' => false,
'phpdoc_annotation_without_dot' => false,
'ternary_to_null_coalescing' => true,
'ordered_imports' => true,
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'all'],
'fopen_flags' => false,
])
->setRiskyAllowed(true)
->setFinder(PhpCsFixer\Finder::create()->in(__DIR__))
Expand Down
2 changes: 1 addition & 1 deletion lib/classes/Swift.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static function autoload($class)
if (self::$inits && !self::$initialized) {
self::$initialized = true;
foreach (self::$inits as $init) {
call_user_func($init);
\call_user_func($init);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/classes/Swift/AddressEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ interface Swift_AddressEncoder
/**
* Encodes an email address.
*
* @throws Swift_AddressEncoderException If the email cannot be represented in
* the encoding implemented by this class.
* @throws Swift_AddressEncoderException if the email cannot be represented in
* the encoding implemented by this class
*/
public function encodeString(string $address): string;
}
2 changes: 1 addition & 1 deletion lib/classes/Swift/Attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Swift_Attachment extends Swift_Mime_Attachment
*/
public function __construct($data = null, $filename = null, $contentType = null)
{
call_user_func_array(
\call_user_func_array(
[$this, 'Swift_Mime_Attachment::__construct'],
Swift_DependencyContainer::getInstance()
->createDependenciesFor('mime.attachment')
Expand Down
8 changes: 4 additions & 4 deletions lib/classes/Swift/ByteStream/ArrayByteStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ class Swift_ByteStream_ArrayByteStream implements Swift_InputByteStream, Swift_O
*/
public function __construct($stack = null)
{
if (is_array($stack)) {
if (\is_array($stack)) {
$this->array = $stack;
$this->arraySize = count($stack);
} elseif (is_string($stack)) {
$this->arraySize = \count($stack);
} elseif (\is_string($stack)) {
$this->write($stack);
} else {
$this->array = [];
Expand Down Expand Up @@ -102,7 +102,7 @@ public function write($bytes)
foreach ($to_add as $value) {
$this->array[] = $value;
}
$this->arraySize = count($this->array);
$this->arraySize = \count($this->array);

foreach ($this->mirrors as $stream) {
$stream->write($bytes);
Expand Down
2 changes: 1 addition & 1 deletion lib/classes/Swift/ByteStream/FileByteStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ private function copyReadStream()
{
if ($tmpFile = fopen('php://temp/maxmemory:4096', 'w+b')) {
/* We have opened a php:// Stream Should work without problem */
} elseif (function_exists('sys_get_temp_dir') && is_writable(sys_get_temp_dir()) && ($tmpFile = tmpfile())) {
} elseif (\function_exists('sys_get_temp_dir') && is_writable(sys_get_temp_dir()) && ($tmpFile = tmpfile())) {
/* We have opened a tmpfile */
} else {
throw new Swift_IoException('Unable to copy the file to make it seekable, sys_temp_dir is not writable, php://memory not available');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct($width)
*/
public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars)
{
$strlen = strlen($string);
$strlen = \strlen($string);
// % and / are CPU intensive, so, maybe find a better way
$ignored = $strlen % $this->width;
$ignoredChars = $ignored ? substr($string, -$ignored) : '';
Expand Down
4 changes: 2 additions & 2 deletions lib/classes/Swift/CharacterReader/UsAsciiReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Swift_CharacterReader_UsAsciiReader implements Swift_CharacterReader
*/
public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars)
{
$strlen = strlen($string);
$strlen = \strlen($string);
$ignoredChars = '';
for ($i = 0; $i < $strlen; ++$i) {
if ($string[$i] > "\x07F") {
Expand Down Expand Up @@ -65,7 +65,7 @@ public function getMapType()
public function validateByteSequence($bytes, $size)
{
$byte = reset($bytes);
if (1 == count($bytes) && $byte >= 0x00 && $byte <= 0x7F) {
if (1 == \count($bytes) && $byte >= 0x00 && $byte <= 0x7F) {
return 0;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/classes/Swift/CharacterReader/Utf8Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredC
$currentMap['p'] = $currentMap['i'] = [];
}

$strlen = strlen($string);
$charPos = count($currentMap['p']);
$strlen = \strlen($string);
$charPos = \count($currentMap['p']);
$foundChars = 0;
$invalid = false;
for ($i = 0; $i < $strlen; ++$i) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __wakeup()

public function init()
{
if (count(self::$map) > 0) {
if (\count(self::$map) > 0) {
return;
}

Expand Down Expand Up @@ -107,7 +107,7 @@ public function getReaderFor($charset)
foreach (self::$map as $pattern => $spec) {
$re = '/^'.$pattern.'$/D';
if (preg_match($re, $charset)) {
if (!array_key_exists($pattern, self::$loaded)) {
if (!\array_key_exists($pattern, self::$loaded)) {
$reflector = new ReflectionClass($spec['class']);
if ($reflector->getConstructor()) {
$reader = $reflector->newInstanceArgs($spec['constructor']);
Expand Down
14 changes: 7 additions & 7 deletions lib/classes/Swift/CharacterStream/ArrayCharacterStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ public function importByteStream(Swift_OutputByteStream $os)
$startLength = $this->charReader->getInitialByteSize();
while (false !== $bytes = $os->read($startLength)) {
$c = [];
for ($i = 0, $len = strlen($bytes); $i < $len; ++$i) {
for ($i = 0, $len = \strlen($bytes); $i < $len; ++$i) {
$c[] = self::$byteMap[$bytes[$i]];
}
$size = count($c);
$size = \count($c);
$need = $this->charReader
->validateByteSequence($c, $size);
if ($need > 0 &&
false !== $bytes = $os->read($need)) {
for ($i = 0, $len = strlen($bytes); $i < $len; ++$i) {
for ($i = 0, $len = \strlen($bytes); $i < $len; ++$i) {
$c[] = self::$byteMap[$bytes[$i]];
}
}
Expand Down Expand Up @@ -204,7 +204,7 @@ public function write($chars)
$new = $this->reloadBuffer($fp, 100);
if ($new) {
$buffer = array_merge($buf, $new);
$buf_len = count($buffer);
$buf_len = \count($buffer);
$buf_pos = 0;
} else {
$has_datas = false;
Expand All @@ -224,7 +224,7 @@ public function write($chars)

if ($new) {
$buffer = array_merge($buffer, $new);
$buf_len = count($buffer);
$buf_len = \count($buffer);
}
}
for ($i = 0; $i < $need && isset($buffer[$buf_pos]); ++$i) {
Expand Down Expand Up @@ -268,7 +268,7 @@ private function reloadBuffer($fp, $len)
{
if (!feof($fp) && false !== ($bytes = fread($fp, $len))) {
$buf = [];
for ($i = 0, $len = strlen($bytes); $i < $len; ++$i) {
for ($i = 0, $len = \strlen($bytes); $i < $len; ++$i) {
$buf[] = self::$byteMap[$bytes[$i]];
}

Expand All @@ -283,7 +283,7 @@ private static function initializeMaps()
if (!isset(self::$charMap)) {
self::$charMap = [];
for ($byte = 0; $byte < 256; ++$byte) {
self::$charMap[$byte] = chr($byte);
self::$charMap[$byte] = \chr($byte);
}
self::$byteMap = array_flip(self::$charMap);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/classes/Swift/CharacterStream/NgCharacterStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,9 @@ public function write($chars)
$this->datas .= $chars;
$this->charCount += $this->charReader->getCharPositions(substr($this->datas, $this->datasSize), $this->datasSize, $this->map, $ignored);
if (false !== $ignored) {
$this->datasSize = strlen($this->datas) - strlen($ignored);
$this->datasSize = \strlen($this->datas) - \strlen($ignored);
} else {
$this->datasSize = strlen($this->datas);
$this->datasSize = \strlen($this->datas);
}
}
}
4 changes: 2 additions & 2 deletions lib/classes/Swift/DependencyContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function listItems()
*/
public function has($itemName)
{
return array_key_exists($itemName, $this->store)
return \array_key_exists($itemName, $this->store)
&& isset($this->store[$itemName]['lookupType']);
}

Expand Down Expand Up @@ -373,7 +373,7 @@ private function resolveArgs(array $args)
/** Resolve a single dependency with an collections */
private function lookupRecursive($item)
{
if (is_array($item)) {
if (\is_array($item)) {
$collection = [];
foreach ($item as $k => $v) {
$collection[$k] = $this->lookupRecursive($v);
Expand Down
2 changes: 1 addition & 1 deletion lib/classes/Swift/EmbeddedFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Swift_EmbeddedFile extends Swift_Mime_EmbeddedFile
*/
public function __construct($data = null, $filename = null, $contentType = null)
{
call_user_func_array(
\call_user_func_array(
[$this, 'Swift_Mime_EmbeddedFile::__construct'],
Swift_DependencyContainer::getInstance()
->createDependenciesFor('mime.embeddedfile')
Expand Down
4 changes: 2 additions & 2 deletions lib/classes/Swift/Encoder/QpEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ protected function initSafeMap()
{
foreach (array_merge(
[0x09, 0x20], range(0x21, 0x3C), range(0x3E, 0x7E)) as $byte) {
$this->safeMap[$byte] = chr($byte);
$this->safeMap[$byte] = \chr($byte);
}
}

Expand Down Expand Up @@ -281,7 +281,7 @@ protected function standardize($string)
$string = str_replace(["\t=0D=0A", ' =0D=0A', '=0D=0A'],
["=09\r\n", "=20\r\n", "\r\n"], $string
);
switch ($end = ord(substr($string, -1))) {
switch ($end = \ord(substr($string, -1))) {
case 0x09:
case 0x20:
$string = substr_replace($string, self::$qpMap[$end], -1);
Expand Down
4 changes: 2 additions & 2 deletions lib/classes/Swift/Encoder/Rfc2231Encoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0)

while (false !== $char = $this->charStream->read(4)) {
$encodedChar = rawurlencode($char);
if (0 != strlen($currentLine)
&& strlen($currentLine.$encodedChar) > $thisLineLength) {
if (0 != \strlen($currentLine)
&& \strlen($currentLine.$encodedChar) > $thisLineLength) {
$lines[] = '';
$currentLine = &$lines[$lineCount++];
$thisLineLength = $maxLineLength;
Expand Down
4 changes: 2 additions & 2 deletions lib/classes/Swift/Events/SimpleEventDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ public function dispatchEvent(Swift_Events_EventObject $evt, $target)
private function prepareBubbleQueue(Swift_Events_EventObject $evt)
{
$this->bubbleQueue = [];
$evtClass = get_class($evt);
$evtClass = \get_class($evt);
foreach ($this->listeners as $listener) {
if (array_key_exists($evtClass, $this->eventMap)
if (\array_key_exists($evtClass, $this->eventMap)
&& ($listener instanceof $this->eventMap[$evtClass])) {
$this->bubbleQueue[] = $listener;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/classes/Swift/FailoverTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Swift_FailoverTransport extends Swift_Transport_FailoverTransport
*/
public function __construct($transports = [])
{
call_user_func_array(
\call_user_func_array(
[$this, 'Swift_Transport_FailoverTransport::__construct'],
Swift_DependencyContainer::getInstance()
->createDependenciesFor('transport.failover')
Expand Down
2 changes: 1 addition & 1 deletion lib/classes/Swift/FileSpool.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ protected function getRandomString($count)
// This string MUST stay FS safe, avoid special chars
$base = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-';
$ret = '';
$strlen = strlen($base);
$strlen = \strlen($base);
for ($i = 0; $i < $count; ++$i) {
$ret .= $base[random_int(0, $strlen - 1)];
}
Expand Down
4 changes: 2 additions & 2 deletions lib/classes/Swift/KeyCache/ArrayKeyCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function hasKey($nsKey, $itemKey)
{
$this->prepareCache($nsKey);

return array_key_exists($itemKey, $this->contents[$nsKey]);
return \array_key_exists($itemKey, $this->contents[$nsKey]);
}

/**
Expand Down Expand Up @@ -190,7 +190,7 @@ public function clearAll($nsKey)
*/
private function prepareCache($nsKey)
{
if (!array_key_exists($nsKey, $this->contents)) {
if (!\array_key_exists($nsKey, $this->contents)) {
$this->contents[$nsKey] = [];
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/classes/Swift/KeyCache/DiskKeyCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public function clearKey($nsKey, $itemKey)
*/
public function clearAll($nsKey)
{
if (array_key_exists($nsKey, $this->keys)) {
if (\array_key_exists($nsKey, $this->keys)) {
foreach ($this->keys[$nsKey] as $itemKey => $null) {
$this->clearKey($nsKey, $itemKey);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/classes/Swift/LoadBalancedTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Swift_LoadBalancedTransport extends Swift_Transport_LoadBalancedTransport
*/
public function __construct($transports = [])
{
call_user_func_array(
\call_user_func_array(
[$this, 'Swift_Transport_LoadBalancedTransport::__construct'],
Swift_DependencyContainer::getInstance()
->createDependenciesFor('transport.loadbalanced')
Expand Down
4 changes: 2 additions & 2 deletions lib/classes/Swift/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Swift_Message extends Swift_Mime_SimpleMessage
*/
public function __construct($subject = null, $body = null, $contentType = null, $charset = null)
{
call_user_func_array(
\call_user_func_array(
[$this, 'Swift_Mime_SimpleMessage::__construct'],
Swift_DependencyContainer::getInstance()
->createDependenciesFor('mime.message')
Expand Down Expand Up @@ -212,7 +212,7 @@ protected function saveMessage()
$this->savedMessage = ['headers' => []];
$this->savedMessage['body'] = $this->getBody();
$this->savedMessage['children'] = $this->getChildren();
if (count($this->savedMessage['children']) > 0 && '' != $this->getBody()) {
if (\count($this->savedMessage['children']) > 0 && '' != $this->getBody()) {
$this->setChildren(array_merge([$this->becomeMimePart()], $this->savedMessage['children']));
$this->setBody('');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/classes/Swift/Mime/Attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function setFile(Swift_FileStream $file, $contentType = null)
if (!isset($contentType)) {
$extension = strtolower(substr($file->getPath(), strrpos($file->getPath(), '.') + 1));

if (array_key_exists($extension, $this->mimeTypes)) {
if (\array_key_exists($extension, $this->mimeTypes)) {
$this->setContentType($this->mimeTypes[$extension]);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStre
$streamTheseBytes = $base64ReadBufferRemainderBytes.$readBytes;
}
$base64ReadBufferRemainderBytes = null;
$bytesLength = strlen($streamTheseBytes);
$bytesLength = \strlen($streamTheseBytes);

if (0 === $bytesLength) { // no data left to encode
break;
Expand All @@ -66,15 +66,15 @@ public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStre
$encodedTransformed = '';
$thisMaxLineLength = $maxLineLength - $remainder - $firstLineOffset;

while ($thisMaxLineLength < strlen($encoded)) {
while ($thisMaxLineLength < \strlen($encoded)) {
$encodedTransformed .= substr($encoded, 0, $thisMaxLineLength)."\r\n";
$firstLineOffset = 0;
$encoded = substr($encoded, $thisMaxLineLength);
$thisMaxLineLength = $maxLineLength;
$remainder = 0;
}

if (0 < $remainingLength = strlen($encoded)) {
if (0 < $remainingLength = \strlen($encoded)) {
$remainder += $remainingLength;
$encodedTransformed .= $encoded;
$encoded = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ protected function standardize($string)
// transform =0D=0A to CRLF
$string = str_replace(["\t=0D=0A", ' =0D=0A', '=0D=0A'], ["=09\r\n", "=20\r\n", "\r\n"], $string);

switch (ord(substr($string, -1))) {
switch (\ord(substr($string, -1))) {
case 0x09:
$string = substr_replace($string, '=09', -1);
break;
Expand Down
Loading

0 comments on commit 4af8d50

Please sign in to comment.