Automated native_function_invocation fixes

This commit is contained in:
drowe authored and Adrien Loison committed 2019-11-18 12:17:27 +01:00
1 parent 94b654175c
commit eb88bb4c3a
62 files changed
+237 -237

No files matched your search

+2 -2
View File
@@ -95,7 +95,7 @@ class Row
return 0;
}
return max(array_keys($this->cells)) + 1;
return \max(\array_keys($this->cells)) + 1;
}
/**
@@ -122,7 +122,7 @@ class Row
*/
public function toArray()
{
return array_map(function (Cell $cell) {
return \array_map(function (Cell $cell) {
return $cell->getValue();
}, $this->cells);
}
+3 -3
View File
@@ -93,7 +93,7 @@ class BorderPart
*/
public function setName($name)
{
if (!in_array($name, self::$allowedNames)) {
if (!\in_array($name, self::$allowedNames)) {
throw new InvalidNameException($name);
}
$this->name = $name;
@@ -114,7 +114,7 @@ class BorderPart
*/
public function setStyle($style)
{
if (!in_array($style, self::$allowedStyles)) {
if (!\in_array($style, self::$allowedStyles)) {
throw new InvalidStyleException($style);
}
$this->style = $style;
@@ -152,7 +152,7 @@ class BorderPart
*/
public function setWidth($width)
{
if (!in_array($width, self::$allowedWidths)) {
if (!\in_array($width, self::$allowedWidths)) {
throw new InvalidWidthException($width);
}
$this->width = $width;
+3 -3
View File
@@ -38,7 +38,7 @@ abstract class Color
self::throwIfInvalidColorComponentValue($green);
self::throwIfInvalidColorComponentValue($blue);
return strtoupper(
return \strtoupper(
self::convertColorComponentToHex($red) .
self::convertColorComponentToHex($green) .
self::convertColorComponentToHex($blue)
@@ -54,7 +54,7 @@ abstract class Color
*/
protected static function throwIfInvalidColorComponentValue($colorComponent)
{
if (!is_int($colorComponent) || $colorComponent < 0 || $colorComponent > 255) {
if (!\is_int($colorComponent) || $colorComponent < 0 || $colorComponent > 255) {
throw new InvalidColorException("The RGB components must be between 0 and 255. Received: $colorComponent");
}
}
@@ -67,7 +67,7 @@ abstract class Color
*/
protected static function convertColorComponentToHex($colorComponent)
{
return str_pad(dechex($colorComponent), 2, '0', STR_PAD_LEFT);
return \str_pad(\dechex($colorComponent), 2, '0', STR_PAD_LEFT);
}
/**
+3 -3
View File
@@ -23,7 +23,7 @@ class CellTypeHelper
*/
public static function isNonEmptyString($value)
{
return (gettype($value) === 'string' && $value !== '');
return (\gettype($value) === 'string' && $value !== '');
}
/**
@@ -35,7 +35,7 @@ class CellTypeHelper
*/
public static function isNumeric($value)
{
$valueType = gettype($value);
$valueType = \gettype($value);
return ($valueType === 'integer' || $valueType === 'double');
}
@@ -49,7 +49,7 @@ class CellTypeHelper
*/
public static function isBoolean($value)
{
return gettype($value) === 'boolean';
return \gettype($value) === 'boolean';
}
/**
+3 -3
View File
@@ -61,7 +61,7 @@ class EncodingHelper
$bomUsed = $this->supportedEncodingsWithBom[$encoding];
// we skip the N first bytes
$byteOffsetToSkipBom = strlen($bomUsed);
$byteOffsetToSkipBom = \strlen($bomUsed);
}
return $byteOffsetToSkipBom;
@@ -80,9 +80,9 @@ class EncodingHelper
$this->globalFunctionsHelper->rewind($filePointer);
if (array_key_exists($encoding, $this->supportedEncodingsWithBom)) {
if (\array_key_exists($encoding, $this->supportedEncodingsWithBom)) {
$potentialBom = $this->supportedEncodingsWithBom[$encoding];
$numBytesInBom = strlen($potentialBom);
$numBytesInBom = \strlen($potentialBom);
$hasBOM = ($this->globalFunctionsHelper->fgets($filePointer, $numBytesInBom + 1) === $potentialBom);
}
+4 -4
View File
@@ -18,14 +18,14 @@ class ODS implements EscaperInterface
{
// @NOTE: Using ENT_QUOTES as XML entities ('<', '>', '&') as well as
// single/double quotes (for XML attributes) need to be encoded.
if (defined('ENT_DISALLOWED')) {
if (\defined('ENT_DISALLOWED')) {
// 'ENT_DISALLOWED' ensures that invalid characters in the given document type are replaced.
// Otherwise control characters like a vertical tab "\v" will make the XML document unreadable by the XML processor
// @link https://github.com/box/spout/issues/329
$replacedString = htmlspecialchars($string, ENT_QUOTES | ENT_DISALLOWED, 'UTF-8');
$replacedString = \htmlspecialchars($string, ENT_QUOTES | ENT_DISALLOWED, 'UTF-8');
} else {
// We are on hhvm or any other engine that does not support ENT_DISALLOWED.
$escapedString = htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
$escapedString = \htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
// control characters values are from 0 to 1F (hex values) in the ASCII table
// some characters should not be escaped though: "\t", "\r" and "\n".
@@ -34,7 +34,7 @@ class ODS implements EscaperInterface
'\x0B-\x0C' .
// skipping "\r" (0xD)
'\x0E-\x1F]';
$replacedString = preg_replace("/$regexPattern/", '�', $escapedString);
$replacedString = \preg_replace("/$regexPattern/", '�', $escapedString);
}
return $replacedString;
+11 -11
View File
@@ -28,7 +28,7 @@ class XLSX implements EscaperInterface
if (!$this->isAlreadyInitialized) {
$this->escapableControlCharactersPattern = $this->getEscapableControlCharactersPattern();
$this->controlCharactersEscapingMap = $this->getControlCharactersEscapingMap();
$this->controlCharactersEscapingReverseMap = array_flip($this->controlCharactersEscapingMap);
$this->controlCharactersEscapingReverseMap = \array_flip($this->controlCharactersEscapingMap);
$this->isAlreadyInitialized = true;
}
@@ -47,7 +47,7 @@ class XLSX implements EscaperInterface
$escapedString = $this->escapeControlCharacters($string);
// @NOTE: Using ENT_QUOTES as XML entities ('<', '>', '&') as well as
// single/double quotes (for XML attributes) need to be encoded.
$escapedString = htmlspecialchars($escapedString, ENT_QUOTES, 'UTF-8');
$escapedString = \htmlspecialchars($escapedString, ENT_QUOTES, 'UTF-8');
return $escapedString;
}
@@ -103,10 +103,10 @@ class XLSX implements EscaperInterface
// control characters values are from 0 to 1F (hex values) in the ASCII table
for ($charValue = 0x00; $charValue <= 0x1F; $charValue++) {
$character = chr($charValue);
if (preg_match("/{$this->escapableControlCharactersPattern}/", $character)) {
$charHexValue = dechex($charValue);
$escapedChar = '_x' . sprintf('%04s', strtoupper($charHexValue)) . '_';
$character = \chr($charValue);
if (\preg_match("/{$this->escapableControlCharactersPattern}/", $character)) {
$charHexValue = \dechex($charValue);
$escapedChar = '_x' . \sprintf('%04s', \strtoupper($charHexValue)) . '_';
$controlCharactersEscapingMap[$escapedChar] = $character;
}
}
@@ -132,11 +132,11 @@ class XLSX implements EscaperInterface
$escapedString = $this->escapeEscapeCharacter($string);
// if no control characters
if (!preg_match("/{$this->escapableControlCharactersPattern}/", $escapedString)) {
if (!\preg_match("/{$this->escapableControlCharactersPattern}/", $escapedString)) {
return $escapedString;
}
return preg_replace_callback("/({$this->escapableControlCharactersPattern})/", function ($matches) {
return \preg_replace_callback("/({$this->escapableControlCharactersPattern})/", function ($matches) {
return $this->controlCharactersEscapingReverseMap[$matches[0]];
}, $escapedString);
}
@@ -149,7 +149,7 @@ class XLSX implements EscaperInterface
*/
protected function escapeEscapeCharacter($string)
{
return preg_replace('/_(x[\dA-F]{4})_/', '_x005F_$1_', $string);
return \preg_replace('/_(x[\dA-F]{4})_/', '_x005F_$1_', $string);
}
/**
@@ -171,7 +171,7 @@ class XLSX implements EscaperInterface
foreach ($this->controlCharactersEscapingMap as $escapedCharValue => $charValue) {
// only unescape characters that don't contain the escaped escape character for now
$unescapedString = preg_replace("/(?<!_x005F)($escapedCharValue)/", $charValue, $unescapedString);
$unescapedString = \preg_replace("/(?<!_x005F)($escapedCharValue)/", $charValue, $unescapedString);
}
return $this->unescapeEscapeCharacter($unescapedString);
@@ -185,6 +185,6 @@ class XLSX implements EscaperInterface
*/
protected function unescapeEscapeCharacter($string)
{
return preg_replace('/_x005F(_x[\dA-F]{4}_)/', '$1', $string);
return \preg_replace('/_x005F(_x[\dA-F]{4}_)/', '$1', $string);
}
}
+10 -10
View File
@@ -19,7 +19,7 @@ class FileSystemHelper implements FileSystemHelperInterface
*/
public function __construct($baseFolderPath)
{
$this->baseFolderRealPath = realpath($baseFolderPath);
$this->baseFolderRealPath = \realpath($baseFolderPath);
}
/**
@@ -36,7 +36,7 @@ class FileSystemHelper implements FileSystemHelperInterface
$folderPath = $parentFolderPath . '/' . $folderName;
$wasCreationSuccessful = mkdir($folderPath, 0777, true);
$wasCreationSuccessful = \mkdir($folderPath, 0777, true);
if (!$wasCreationSuccessful) {
throw new IOException("Unable to create folder: $folderPath");
}
@@ -60,7 +60,7 @@ class FileSystemHelper implements FileSystemHelperInterface
$filePath = $parentFolderPath . '/' . $fileName;
$wasCreationSuccessful = file_put_contents($filePath, $fileContents);
$wasCreationSuccessful = \file_put_contents($filePath, $fileContents);
if ($wasCreationSuccessful === false) {
throw new IOException("Unable to create file: $filePath");
}
@@ -79,8 +79,8 @@ class FileSystemHelper implements FileSystemHelperInterface
{
$this->throwIfOperationNotInBaseFolder($filePath);
if (file_exists($filePath) && is_file($filePath)) {
unlink($filePath);
if (\file_exists($filePath) && \is_file($filePath)) {
\unlink($filePath);
}
}
@@ -102,13 +102,13 @@ class FileSystemHelper implements FileSystemHelperInterface
foreach ($itemIterator as $item) {
if ($item->isDir()) {
rmdir($item->getPathname());
\rmdir($item->getPathname());
} else {
unlink($item->getPathname());
\unlink($item->getPathname());
}
}
rmdir($folderPath);
\rmdir($folderPath);
}
/**
@@ -122,8 +122,8 @@ class FileSystemHelper implements FileSystemHelperInterface
*/
protected function throwIfOperationNotInBaseFolder($operationFolderPath)
{
$operationFolderRealPath = realpath($operationFolderPath);
$isInBaseFolder = (strpos($operationFolderRealPath, $this->baseFolderRealPath) === 0);
$operationFolderRealPath = \realpath($operationFolderPath);
$isInBaseFolder = (\strpos($operationFolderRealPath, $this->baseFolderRealPath) === 0);
if (!$isInBaseFolder) {
throw new IOException("Cannot perform I/O operation outside of the base folder: {$this->baseFolderRealPath}");
}
@@ -20,7 +20,7 @@ class GlobalFunctionsHelper
*/
public function fopen($fileName, $mode)
{
return fopen($fileName, $mode);
return \fopen($fileName, $mode);
}
/**
@@ -33,7 +33,7 @@ class GlobalFunctionsHelper
*/
public function fgets($handle, $length = null)
{
return fgets($handle, $length);
return \fgets($handle, $length);
}
/**
@@ -46,7 +46,7 @@ class GlobalFunctionsHelper
*/
public function fputs($handle, $string)
{
return fputs($handle, $string);
return \fputs($handle, $string);
}
/**
@@ -58,7 +58,7 @@ class GlobalFunctionsHelper
*/
public function fflush($handle)
{
return fflush($handle);
return \fflush($handle);
}
/**
@@ -71,7 +71,7 @@ class GlobalFunctionsHelper
*/
public function fseek($handle, $offset)
{
return fseek($handle, $offset);
return \fseek($handle, $offset);
}
/**
@@ -92,7 +92,7 @@ class GlobalFunctionsHelper
// @see http://tools.ietf.org/html/rfc4180
$escapeCharacter = PHP_VERSION_ID >= 70400 ? '' : "\0";
return fgetcsv($handle, $length, $delimiter, $enclosure, $escapeCharacter);
return \fgetcsv($handle, $length, $delimiter, $enclosure, $escapeCharacter);
}
/**
@@ -113,7 +113,7 @@ class GlobalFunctionsHelper
// @see http://tools.ietf.org/html/rfc4180
$escapeCharacter = PHP_VERSION_ID >= 70400 ? '' : "\0";
return fputcsv($handle, $fields, $delimiter, $enclosure, $escapeCharacter);
return \fputcsv($handle, $fields, $delimiter, $enclosure, $escapeCharacter);
}
/**
@@ -126,7 +126,7 @@ class GlobalFunctionsHelper
*/
public function fwrite($handle, $string)
{
return fwrite($handle, $string);
return \fwrite($handle, $string);
}
/**
@@ -138,7 +138,7 @@ class GlobalFunctionsHelper
*/
public function fclose($handle)
{
return fclose($handle);
return \fclose($handle);
}
/**
@@ -150,7 +150,7 @@ class GlobalFunctionsHelper
*/
public function rewind($handle)
{
return rewind($handle);
return \rewind($handle);
}
/**
@@ -162,7 +162,7 @@ class GlobalFunctionsHelper
*/
public function file_exists($fileName)
{
return file_exists($fileName);
return \file_exists($fileName);
}
/**
@@ -176,7 +176,7 @@ class GlobalFunctionsHelper
{
$realFilePath = $this->convertToUseRealPath($filePath);
return file_get_contents($realFilePath);
return \file_get_contents($realFilePath);
}
/**
@@ -191,13 +191,13 @@ class GlobalFunctionsHelper
$realFilePath = $filePath;
if ($this->isZipStream($filePath)) {
if (preg_match('/zip:\/\/(.*)#(.*)/', $filePath, $matches)) {
if (\preg_match('/zip:\/\/(.*)#(.*)/', $filePath, $matches)) {
$documentPath = $matches[1];
$documentInsideZipPath = $matches[2];
$realFilePath = 'zip://' . realpath($documentPath) . '#' . $documentInsideZipPath;
$realFilePath = 'zip://' . \realpath($documentPath) . '#' . $documentInsideZipPath;
}
} else {
$realFilePath = realpath($filePath);
$realFilePath = \realpath($filePath);
}
return $realFilePath;
@@ -211,7 +211,7 @@ class GlobalFunctionsHelper
*/
protected function isZipStream($path)
{
return (strpos($path, 'zip://') === 0);
return (\strpos($path, 'zip://') === 0);
}
/**
@@ -223,7 +223,7 @@ class GlobalFunctionsHelper
*/
public function feof($handle)
{
return feof($handle);
return \feof($handle);
}
/**
@@ -235,7 +235,7 @@ class GlobalFunctionsHelper
*/
public function is_readable($fileName)
{
return is_readable($fileName);
return \is_readable($fileName);
}
/**
@@ -248,7 +248,7 @@ class GlobalFunctionsHelper
*/
public function basename($path, $suffix = null)
{
return basename($path, $suffix);
return \basename($path, $suffix);
}
/**
@@ -260,7 +260,7 @@ class GlobalFunctionsHelper
*/
public function header($string)
{
header($string);
\header($string);
}
/**
@@ -271,8 +271,8 @@ class GlobalFunctionsHelper
*/
public function ob_end_clean()
{
if (ob_get_length() > 0) {
ob_end_clean();
if (\ob_get_length() > 0) {
\ob_end_clean();
}
}
@@ -287,7 +287,7 @@ class GlobalFunctionsHelper
*/
public function iconv($string, $sourceEncoding, $targetEncoding)
{
return iconv($sourceEncoding, $targetEncoding, $string);
return \iconv($sourceEncoding, $targetEncoding, $string);
}
/**
@@ -301,7 +301,7 @@ class GlobalFunctionsHelper
*/
public function mb_convert_encoding($string, $sourceEncoding, $targetEncoding)
{
return mb_convert_encoding($string, $targetEncoding, $sourceEncoding);
return \mb_convert_encoding($string, $targetEncoding, $sourceEncoding);
}
/**
@@ -312,7 +312,7 @@ class GlobalFunctionsHelper
*/
public function stream_get_wrappers()
{
return stream_get_wrappers();
return \stream_get_wrappers();
}
/**
@@ -324,6 +324,6 @@ class GlobalFunctionsHelper
*/
public function function_exists($functionName)
{
return function_exists($functionName);
return \function_exists($functionName);
}
}
+4 -4
View File
@@ -18,7 +18,7 @@ class StringHelper
*/
public function __construct()
{
$this->hasMbstringSupport = extension_loaded('mbstring');
$this->hasMbstringSupport = \extension_loaded('mbstring');
}
/**
@@ -32,7 +32,7 @@ class StringHelper
*/
public function getStringLength($string)
{
return $this->hasMbstringSupport ? mb_strlen($string) : strlen($string);
return $this->hasMbstringSupport ? \mb_strlen($string) : \strlen($string);
}
/**
@@ -47,7 +47,7 @@ class StringHelper
*/
public function getCharFirstOccurrencePosition($char, $string)
{
$position = $this->hasMbstringSupport ? mb_strpos($string, $char) : strpos($string, $char);
$position = $this->hasMbstringSupport ? \mb_strpos($string, $char) : \strpos($string, $char);
return ($position !== false) ? $position : -1;
}
@@ -64,7 +64,7 @@ class StringHelper
*/
public function getCharLastOccurrencePosition($char, $string)
{
$position = $this->hasMbstringSupport ? mb_strrpos($string, $char) : strrpos($string, $char);
$position = $this->hasMbstringSupport ? \mb_strrpos($string, $char) : \strrpos($string, $char);
return ($position !== false) ? $position : -1;
}
@@ -46,7 +46,7 @@ abstract class OptionsManagerAbstract implements OptionsManagerInterface
*/
public function setOption($optionName, $optionValue)
{
if (in_array($optionName, $this->supportedOptions)) {
if (\in_array($optionName, $this->supportedOptions)) {
$this->options[$optionName] = $optionValue;
}
}