Skip to content

Commit

Permalink
[!]: "php": ">=7.0" v2
Browse files Browse the repository at this point in the history
  • Loading branch information
voku committed Dec 9, 2017
1 parent 9813676 commit 3dac0f3
Show file tree
Hide file tree
Showing 53 changed files with 239 additions and 223 deletions.
10 changes: 4 additions & 6 deletions lib/classes/Swift/ByteStream/ArrayByteStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function __construct($stack = null)
{
if (is_array($stack)) {
$this->_array = $stack;
$this->_arraySize = count($stack);
$this->_arraySize = \count($stack);
} elseif (is_string($stack)) {
$this->write($stack);
} else {
Expand All @@ -72,7 +72,7 @@ public function __construct($stack = null)
*
* @param int $length
*
* @return string
* @return string|false
*/
public function read($length)
{
Expand Down Expand Up @@ -100,12 +100,12 @@ public function read($length)
*/
public function write($bytes)
{
$to_add = str_split($bytes);
$to_add = \str_split($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 Expand Up @@ -154,8 +154,6 @@ public function unbind(Swift_InputByteStream $is)
* Move the internal read pointer to $byteOffset in the stream.
*
* @param int $byteOffset
*
* @return bool
*/
public function setReadPointer($byteOffset)
{
Expand Down
16 changes: 7 additions & 9 deletions lib/classes/Swift/ByteStream/FileByteStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ class Swift_ByteStream_FileByteStream extends Swift_ByteStream_AbstractFilterabl
/**
* A lazy-loaded resource handle for reading the file
*
* @var resource
* @var null|resource
*/
private $_reader;

/**
* A lazy-loaded resource handle for writing the file
*
* @var resource
* @var null|resource
*/
private $_writer;

Expand Down Expand Up @@ -81,7 +81,7 @@ public function __construct($path, $writable = false)
if (strpos($path, '?') !== false) {
$parameter = parse_url($path, PHP_URL_QUERY);

$this->_path = str_replace('?' . $parameter, '', $path);
$this->_path = \str_replace('?' . $parameter, '', $path);
} else {
$this->_path = $path;
}
Expand Down Expand Up @@ -161,12 +161,10 @@ public function read($length)
* Move the internal read pointer to $byteOffset in the stream.
*
* @param int $byteOffset
*
* @return bool
*/
public function setReadPointer($byteOffset)
{
if (isset($this->_reader)) {
if (null !== $this->_reader) {
$this->_seekReadStreamToPosition($byteOffset);
}
$this->_offset = $byteOffset;
Expand Down Expand Up @@ -198,7 +196,7 @@ protected function _flush()
*/
private function _getReadHandle()
{
if (!isset($this->_reader)) {
if (null === $this->_reader) {

$opts = array(
'ssl' => array(
Expand Down Expand Up @@ -229,7 +227,7 @@ private function _getReadHandle()
/** Get the resource for writing */
private function _getWriteHandle()
{
if (!isset($this->_writer)) {
if (null === $this->_writer) {
/** @noinspection PhpUsageOfSilenceOperatorInspection */
$pointer = @fopen($this->_path, $this->_mode);

Expand All @@ -246,7 +244,7 @@ private function _getWriteHandle()
/** Force a reload of the resource for reading */
private function _resetReadHandle()
{
if (isset($this->_reader)) {
if (null !== $this->_reader) {
fclose($this->_reader);
$this->_reader = null;
}
Expand Down
3 changes: 2 additions & 1 deletion lib/classes/Swift/ByteStream/TemporaryFileByteStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public function getContent()
public function __destruct()
{
if (file_exists($this->getPath())) {
@unlink($this->getPath());
/** @noinspection PhpUsageOfSilenceOperatorInspection */
@unlink($this->getPath());
}
}
}
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): int
{
$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
6 changes: 3 additions & 3 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): int
{
$strlen = strlen($string);
$strlen = \strlen($string);
$ignoredChars = '';
for ($i = 0; $i < $strlen; ++$i) {
if ($string[$i] > "\x07F") {
Expand Down Expand Up @@ -66,11 +66,11 @@ public function validateByteSequence($bytes, $size): int
{
$byte = reset($bytes);
if (
1 === count($bytes)
&&
$byte >= 0x00
&&
$byte <= 0x7F
&&
1 === \count($bytes)
) {
return 0;
}
Expand Down
8 changes: 4 additions & 4 deletions lib/classes/Swift/CharacterReader/Utf8Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ class Swift_CharacterReader_Utf8Reader implements Swift_CharacterReader
*/
public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars): int
{
if (!isset($currentMap['i']) || !isset($currentMap['p'])) {
if (!isset($currentMap['i'], $currentMap['p'])) {
$currentMap['p'] = $currentMap['i'] = array();
}

$strlen = strlen($string);
$charPos = count($currentMap['p']);
$strlen = \strlen($string);
$charPos = \count($currentMap['p']);
$foundChars = 0;
$invalid = false;

Expand All @@ -112,7 +112,7 @@ public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredC
}

if (($i + $size) > $strlen) {
$ignoredChars = substr($string, $i);
$ignoredChars = \substr($string, $i);
break;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/classes/Swift/CharacterStream/ArrayCharacterStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ public function importByteStream(Swift_OutputByteStream $os)
while (false !== $bytes = $os->read($startLength)) {

$c = array();
$len = strlen($bytes);
$len = \strlen($bytes);
for ($i = 0; $i < $len; ++$i) {
$c[] = self::$_byteMap[$bytes[$i]];
}

$size = count($c);
$size = \count($c);
$need = $this->_charReader->validateByteSequence($c, $size);

if (
Expand Down
12 changes: 6 additions & 6 deletions lib/classes/Swift/CharacterStream/NgCharacterStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public function read($length)
switch ($this->_mapType) {
case Swift_CharacterReader::MAP_TYPE_FIXED_LEN:
$len = $length * $this->_map;
$ret = substr($this->_datas, $this->_currentPos * $this->_map, $len);
$ret = \substr($this->_datas, $this->_currentPos * $this->_map, $len);
$this->_currentPos += $length;
break;

Expand Down Expand Up @@ -203,14 +203,14 @@ public function read($length)
$to = $start;
for (; $this->_currentPos < $end; ++$this->_currentPos) {
if (isset($this->_map['i'], $this->_map['i'][$this->_currentPos])) {
$ret .= substr($this->_datas, $start, $to - $start) . '?';
$ret .= \substr($this->_datas, $start, $to - $start) . '?';
$start = $this->_map['p'][$this->_currentPos];
} else {
$to = $this->_map['p'][$this->_currentPos];
}
}

$ret .= substr($this->_datas, $start, $to - $start);
$ret .= \substr($this->_datas, $start, $to - $start);
break;
}

Expand Down Expand Up @@ -271,16 +271,16 @@ public function write($chars)
$ignored = '';
$this->_datas .= $chars;
$this->_charCount += $this->_charReader->getCharPositions(
substr($this->_datas, $this->_datasSize),
\substr($this->_datas, $this->_datasSize),
$this->_datasSize,
$this->_map,
$ignored
);

if ($ignored !== false) {
$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/Encoder/QpEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder
/**
* A filter used if input should be canonicalized.
*
* @var Swift_StreamFilter
* @var null|Swift_StreamFilter
*/
protected $_filter;

Expand Down Expand Up @@ -191,7 +191,7 @@ public function encodeString(string $string, int $firstLineOffset = 0, int $maxL

while (false !== $bytes = $this->_nextSequence()) {
// if we're filtering the input
if (isset($this->_filter)) {
if (null !== $this->_filter) {
// if we can't filter because we need more bytes
while ($this->_filter->shouldBuffer($bytes)) {
// then collect bytes into the buffer
Expand Down
6 changes: 3 additions & 3 deletions lib/classes/Swift/Encoder/Rfc2231Encoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ public function encodeString(string $string, int $firstLineOffset = 0, int $maxL
$thisLineLength = $maxLineLength - $firstLineOffset;

while (false !== $char = $this->_charStream->read(4)) {
$encodedChar = rawurlencode($char);
$encodedChar = \rawurlencode($char);
if (
$currentLine !== ''
&&
strlen($currentLine . $encodedChar) > $thisLineLength
\strlen($currentLine . $encodedChar) > $thisLineLength
) {
$lines[] = '';
$currentLine = &$lines[$lineCount++];
Expand All @@ -72,7 +72,7 @@ public function encodeString(string $string, int $firstLineOffset = 0, int $maxL
$currentLine .= $encodedChar;
}

return implode("\r\n", $lines);
return \implode("\r\n", $lines);
}

/**
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 @@ -209,7 +209,7 @@ protected function getRandomString($count = null)
// This string MUST stay FS safe, avoid special chars.
$base = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-';
$ret = '';
$strlen = strlen($base) - 1;
$strlen = \strlen($base) - 1;
for ($i = 0; $i < $count; ++$i) {
$ret .= $base[\random_int(0, $strlen - 1)];
}
Expand Down
9 changes: 6 additions & 3 deletions lib/classes/Swift/KeyCache/ArrayKeyCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function getInputByteStream($nsKey, $itemKey, Swift_InputByteStream $writ
$is->setKeyCache($this);
$is->setNsKey($nsKey);
$is->setItemKey($itemKey);
if (isset($writeThrough)) {
if (null !== $writeThrough) {
$is->setWriteThroughStream($writeThrough);
}

Expand All @@ -141,9 +141,12 @@ public function getInputByteStream($nsKey, $itemKey, Swift_InputByteStream $writ
public function getString($nsKey, $itemKey)
{
$this->_prepareCache($nsKey);
if ($this->hasKey($nsKey, $itemKey)) {
return $this->_contents[$nsKey][$itemKey];

if (!$this->hasKey($nsKey, $itemKey)) {
return '';
}

return $this->_contents[$nsKey][$itemKey];
}

/**
Expand Down
31 changes: 17 additions & 14 deletions lib/classes/Swift/KeyCache/DiskKeyCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,25 +181,28 @@ public function getInputByteStream($nsKey, $itemKey, Swift_InputByteStream $writ
public function getString($nsKey, $itemKey)
{
$this->_prepareCache($nsKey);
if ($this->hasKey($nsKey, $itemKey)) {
$fp = $this->_getHandle($nsKey, $itemKey, self::POSITION_START);
if ($this->_quotes) {
ini_set('magic_quotes_runtime', 0);
}

$str = '';
while (!feof($fp) && false !== $bytes = fread($fp, 8192)) {
$str .= $bytes;
}
if (!$this->hasKey($nsKey, $itemKey)) {
return '';
}

if ($this->_quotes) {
ini_set('magic_quotes_runtime', 1);
}
$fp = $this->_getHandle($nsKey, $itemKey, self::POSITION_START);
if ($this->_quotes) {
ini_set('magic_quotes_runtime', 0);
}

$this->_freeHandle($nsKey, $itemKey);
$str = '';
while (!feof($fp) && false !== $bytes = fread($fp, 8192)) {
$str .= $bytes;
}

return $str;
if ($this->_quotes) {
ini_set('magic_quotes_runtime', 1);
}

$this->_freeHandle($nsKey, $itemKey);

return $str;
}

/**
Expand Down
5 changes: 3 additions & 2 deletions lib/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class Swift_KeyCache_SimpleKeyCacheInputStream implements Swift_KeyCache_KeyCach

/**
* A stream to write through on each write()
*
* @var null|Swift_InputByteStream
*/
private $_writeThrough = null;
Expand Down Expand Up @@ -77,11 +78,11 @@ public function write($bytes, Swift_InputByteStream $is = null)
Swift_KeyCache::MODE_APPEND
);

if (isset($is)) {
if (null !== $is) {
$is->write($bytes);
}

if (isset($this->_writeThrough)) {
if (null !== $this->_writeThrough) {
$this->_writeThrough->write($bytes);
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/classes/Swift/Mime/Attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ public function setFile(Swift_FileStream $file, $contentType = null)
*/
private function getFileExtension($str)
{
$extension = substr($str, strrpos($str, '.') + 1);
$extension = \substr($str, strrpos($str, '.') + 1);
if (strpos($extension, '?') !== false) {
$extension = preg_replace("/(\?.*)/", '', $extension);
$extension = \preg_replace("/(\?.*)/", '', $extension);
}
$extension = Swift::strtolowerWithStaticCache($extension);

Expand Down
Loading

0 comments on commit 3dac0f3

Please sign in to comment.