diff --git a/src/Spout/Autoloader/Psr4Autoloader.php b/src/Spout/Autoloader/Psr4Autoloader.php index 1699293..37b6d4a 100644 --- a/src/Spout/Autoloader/Psr4Autoloader.php +++ b/src/Spout/Autoloader/Psr4Autoloader.php @@ -23,7 +23,7 @@ class Psr4Autoloader */ public function register() { - spl_autoload_register([$this, 'loadClass']); + \spl_autoload_register([$this, 'loadClass']); } /** @@ -40,10 +40,10 @@ class Psr4Autoloader public function addNamespace($prefix, $baseDir, $prepend = false) { // normalize namespace prefix - $prefix = trim($prefix, '\\') . '\\'; + $prefix = \trim($prefix, '\\') . '\\'; // normalize the base directory with a trailing separator - $baseDir = rtrim($baseDir, DIRECTORY_SEPARATOR) . '/'; + $baseDir = \rtrim($baseDir, DIRECTORY_SEPARATOR) . '/'; // initialize the namespace prefix array if (isset($this->prefixes[$prefix]) === false) { @@ -52,9 +52,9 @@ class Psr4Autoloader // retain the base directory for the namespace prefix if ($prepend) { - array_unshift($this->prefixes[$prefix], $baseDir); + \array_unshift($this->prefixes[$prefix], $baseDir); } else { - array_push($this->prefixes[$prefix], $baseDir); + \array_push($this->prefixes[$prefix], $baseDir); } } @@ -72,12 +72,12 @@ class Psr4Autoloader // work backwards through the namespace names of the fully-qualified // class name to find a mapped file name - while (($pos = strrpos($prefix, '\\')) !== false) { + while (($pos = \strrpos($prefix, '\\')) !== false) { // retain the trailing namespace separator in the prefix - $prefix = substr($class, 0, $pos + 1); + $prefix = \substr($class, 0, $pos + 1); // the rest is the relative class name - $relativeClass = substr($class, $pos + 1); + $relativeClass = \substr($class, $pos + 1); // try to load a mapped file for the prefix and relative class $mappedFile = $this->loadMappedFile($prefix, $relativeClass); @@ -87,7 +87,7 @@ class Psr4Autoloader // remove the trailing namespace separator for the next iteration // of strrpos() - $prefix = rtrim($prefix, '\\'); + $prefix = \rtrim($prefix, '\\'); } // never found a mapped file @@ -115,7 +115,7 @@ class Psr4Autoloader // replace namespace separators with directory separators // in the relative class name, append with .php $file = $baseDir - . str_replace('\\', '/', $relativeClass) + . \str_replace('\\', '/', $relativeClass) . '.php'; // if the mapped file exists, require it @@ -137,7 +137,7 @@ class Psr4Autoloader */ protected function requireFile($file) { - if (file_exists($file)) { + if (\file_exists($file)) { require $file; return true; diff --git a/src/Spout/Autoloader/autoload.php b/src/Spout/Autoloader/autoload.php index e08ee34..44468a7 100644 --- a/src/Spout/Autoloader/autoload.php +++ b/src/Spout/Autoloader/autoload.php @@ -8,7 +8,7 @@ require_once 'Psr4Autoloader.php'; * @var string * Full path to "src/Spout" which is what we want "Box\Spout" to map to. */ -$srcBaseDirectory = dirname(dirname(__FILE__)); +$srcBaseDirectory = \dirname(\dirname(__FILE__)); $loader = new Psr4Autoloader(); $loader->register(); diff --git a/src/Spout/Common/Entity/Row.php b/src/Spout/Common/Entity/Row.php index c54cbc0..0cc49c7 100644 --- a/src/Spout/Common/Entity/Row.php +++ b/src/Spout/Common/Entity/Row.php @@ -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); } diff --git a/src/Spout/Common/Entity/Style/BorderPart.php b/src/Spout/Common/Entity/Style/BorderPart.php index 4dcfd82..c087484 100644 --- a/src/Spout/Common/Entity/Style/BorderPart.php +++ b/src/Spout/Common/Entity/Style/BorderPart.php @@ -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; diff --git a/src/Spout/Common/Entity/Style/Color.php b/src/Spout/Common/Entity/Style/Color.php index ce903e5..f2a4731 100644 --- a/src/Spout/Common/Entity/Style/Color.php +++ b/src/Spout/Common/Entity/Style/Color.php @@ -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); } /** diff --git a/src/Spout/Common/Helper/CellTypeHelper.php b/src/Spout/Common/Helper/CellTypeHelper.php index 03d26a3..97d2e8d 100644 --- a/src/Spout/Common/Helper/CellTypeHelper.php +++ b/src/Spout/Common/Helper/CellTypeHelper.php @@ -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'; } /** diff --git a/src/Spout/Common/Helper/EncodingHelper.php b/src/Spout/Common/Helper/EncodingHelper.php index 9064274..62ddf60 100644 --- a/src/Spout/Common/Helper/EncodingHelper.php +++ b/src/Spout/Common/Helper/EncodingHelper.php @@ -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); } diff --git a/src/Spout/Common/Helper/Escaper/ODS.php b/src/Spout/Common/Helper/Escaper/ODS.php index 5420836..b7e6eb1 100644 --- a/src/Spout/Common/Helper/Escaper/ODS.php +++ b/src/Spout/Common/Helper/Escaper/ODS.php @@ -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; diff --git a/src/Spout/Common/Helper/Escaper/XLSX.php b/src/Spout/Common/Helper/Escaper/XLSX.php index d72caa8..daef46e 100644 --- a/src/Spout/Common/Helper/Escaper/XLSX.php +++ b/src/Spout/Common/Helper/Escaper/XLSX.php @@ -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("/(?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); } } diff --git a/src/Spout/Common/Helper/FileSystemHelper.php b/src/Spout/Common/Helper/FileSystemHelper.php index b1bff8f..4d5d223 100644 --- a/src/Spout/Common/Helper/FileSystemHelper.php +++ b/src/Spout/Common/Helper/FileSystemHelper.php @@ -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}"); } diff --git a/src/Spout/Common/Helper/GlobalFunctionsHelper.php b/src/Spout/Common/Helper/GlobalFunctionsHelper.php index db33c57..5deb8d9 100644 --- a/src/Spout/Common/Helper/GlobalFunctionsHelper.php +++ b/src/Spout/Common/Helper/GlobalFunctionsHelper.php @@ -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); } } diff --git a/src/Spout/Common/Helper/StringHelper.php b/src/Spout/Common/Helper/StringHelper.php index c698815..0906132 100644 --- a/src/Spout/Common/Helper/StringHelper.php +++ b/src/Spout/Common/Helper/StringHelper.php @@ -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; } diff --git a/src/Spout/Common/Manager/OptionsManagerAbstract.php b/src/Spout/Common/Manager/OptionsManagerAbstract.php index 20eb14e..5670b95 100644 --- a/src/Spout/Common/Manager/OptionsManagerAbstract.php +++ b/src/Spout/Common/Manager/OptionsManagerAbstract.php @@ -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; } } diff --git a/src/Spout/Reader/CSV/Creator/InternalEntityFactory.php b/src/Spout/Reader/CSV/Creator/InternalEntityFactory.php index cdb4197..65cf3eb 100644 --- a/src/Spout/Reader/CSV/Creator/InternalEntityFactory.php +++ b/src/Spout/Reader/CSV/Creator/InternalEntityFactory.php @@ -89,7 +89,7 @@ class InternalEntityFactory implements InternalEntityFactoryInterface */ public function createRowFromArray(array $cellValues = []) { - $cells = array_map(function ($cellValue) { + $cells = \array_map(function ($cellValue) { return $this->createCell($cellValue); }, $cellValues); diff --git a/src/Spout/Reader/CSV/Reader.php b/src/Spout/Reader/CSV/Reader.php index 77249c1..ca61ef2 100644 --- a/src/Spout/Reader/CSV/Reader.php +++ b/src/Spout/Reader/CSV/Reader.php @@ -84,8 +84,8 @@ class Reader extends ReaderAbstract */ protected function openReader($filePath) { - $this->originalAutoDetectLineEndings = ini_get('auto_detect_line_endings'); - ini_set('auto_detect_line_endings', '1'); + $this->originalAutoDetectLineEndings = \ini_get('auto_detect_line_endings'); + \ini_set('auto_detect_line_endings', '1'); $this->filePointer = $this->globalFunctionsHelper->fopen($filePath, 'r'); if (!$this->filePointer) { @@ -123,6 +123,6 @@ class Reader extends ReaderAbstract $this->globalFunctionsHelper->fclose($this->filePointer); } - ini_set('auto_detect_line_endings', $this->originalAutoDetectLineEndings); + \ini_set('auto_detect_line_endings', $this->originalAutoDetectLineEndings); } } diff --git a/src/Spout/Reader/CSV/RowIterator.php b/src/Spout/Reader/CSV/RowIterator.php index bec3072..78e6650 100644 --- a/src/Spout/Reader/CSV/RowIterator.php +++ b/src/Spout/Reader/CSV/RowIterator.php @@ -147,7 +147,7 @@ class RowIterator implements IteratorInterface if ($rowData !== false) { // str_replace will replace NULL values by empty strings - $rowDataBufferAsArray = str_replace(null, null, $rowData); + $rowDataBufferAsArray = \str_replace(null, null, $rowData); $this->rowBuffer = $this->entityFactory->createRowFromArray($rowDataBufferAsArray); $this->numReadRows++; } else { @@ -193,13 +193,13 @@ class RowIterator implements IteratorInterface case EncodingHelper::ENCODING_UTF16_LE: case EncodingHelper::ENCODING_UTF32_LE: // remove whitespace from the beginning of a string as fgetcsv() add extra whitespace when it try to explode non UTF-8 data - $cellValue = ltrim($cellValue); + $cellValue = \ltrim($cellValue); break; case EncodingHelper::ENCODING_UTF16_BE: case EncodingHelper::ENCODING_UTF32_BE: // remove whitespace from the end of a string as fgetcsv() add extra whitespace when it try to explode non UTF-8 data - $cellValue = rtrim($cellValue); + $cellValue = \rtrim($cellValue); break; } @@ -215,7 +215,7 @@ class RowIterator implements IteratorInterface */ protected function isEmptyLine($lineData) { - return (is_array($lineData) && count($lineData) === 1 && $lineData[0] === null); + return (\is_array($lineData) && \count($lineData) === 1 && $lineData[0] === null); } /** diff --git a/src/Spout/Reader/Common/Creator/ReaderFactory.php b/src/Spout/Reader/Common/Creator/ReaderFactory.php index 245a42a..6b10175 100644 --- a/src/Spout/Reader/Common/Creator/ReaderFactory.php +++ b/src/Spout/Reader/Common/Creator/ReaderFactory.php @@ -37,7 +37,7 @@ class ReaderFactory */ public static function createFromFile(string $path) { - $extension = strtolower(pathinfo($path, PATHINFO_EXTENSION)); + $extension = \strtolower(\pathinfo($path, PATHINFO_EXTENSION)); return self::createFromType($extension); } diff --git a/src/Spout/Reader/Common/XMLProcessor.php b/src/Spout/Reader/Common/XMLProcessor.php index 3b2d848..05ee970 100644 --- a/src/Spout/Reader/Common/XMLProcessor.php +++ b/src/Spout/Reader/Common/XMLProcessor.php @@ -73,7 +73,7 @@ class XMLProcessor { $callbackObject = $callback[0]; $callbackMethodName = $callback[1]; - $reflectionMethod = new \ReflectionMethod(get_class($callbackObject), $callbackMethodName); + $reflectionMethod = new \ReflectionMethod(\get_class($callbackObject), $callbackMethodName); $reflectionMethod->setAccessible(true); return [ diff --git a/src/Spout/Reader/ODS/Helper/CellValueFormatter.php b/src/Spout/Reader/ODS/Helper/CellValueFormatter.php index 0fb0ac6..168770f 100644 --- a/src/Spout/Reader/ODS/Helper/CellValueFormatter.php +++ b/src/Spout/Reader/ODS/Helper/CellValueFormatter.php @@ -108,7 +108,7 @@ class CellValueFormatter $pNodeValues[] = $this->extractTextValueFromNode($pNode); } - $escapedCellValue = implode("\n", $pNodeValues); + $escapedCellValue = \implode("\n", $pNodeValues); $cellValue = $this->escaper->unescape($escapedCellValue); return $cellValue; @@ -167,7 +167,7 @@ class CellValueFormatter $countAttribute = $node->getAttribute(self::XML_ATTRIBUTE_C); // only defined for "" $numWhitespaces = (!empty($countAttribute)) ? (int) $countAttribute : 1; - return str_repeat(self::$WHITESPACE_XML_NODES[$node->nodeName], $numWhitespaces); + return \str_repeat(self::$WHITESPACE_XML_NODES[$node->nodeName], $numWhitespaces); } /** diff --git a/src/Spout/Reader/ReaderAbstract.php b/src/Spout/Reader/ReaderAbstract.php index dea234e..39b333d 100644 --- a/src/Spout/Reader/ReaderAbstract.php +++ b/src/Spout/Reader/ReaderAbstract.php @@ -145,7 +145,7 @@ abstract class ReaderAbstract implements ReaderInterface } // Need to use realpath to fix "Can't open file" on some Windows setup - return realpath($filePath); + return \realpath($filePath); } /** @@ -158,7 +158,7 @@ abstract class ReaderAbstract implements ReaderInterface protected function getStreamWrapperScheme($filePath) { $streamScheme = null; - if (preg_match('/^(\w+):\/\//', $filePath, $matches)) { + if (\preg_match('/^(\w+):\/\//', $filePath, $matches)) { $streamScheme = $matches[1]; } @@ -190,7 +190,7 @@ abstract class ReaderAbstract implements ReaderInterface $streamScheme = $this->getStreamWrapperScheme($filePath); return ($streamScheme !== null) ? - in_array($streamScheme, $this->globalFunctionsHelper->stream_get_wrappers()) : + \in_array($streamScheme, $this->globalFunctionsHelper->stream_get_wrappers()) : true; } diff --git a/src/Spout/Reader/Wrapper/XMLInternalErrorsHelper.php b/src/Spout/Reader/Wrapper/XMLInternalErrorsHelper.php index 7047a94..ecf0dbd 100644 --- a/src/Spout/Reader/Wrapper/XMLInternalErrorsHelper.php +++ b/src/Spout/Reader/Wrapper/XMLInternalErrorsHelper.php @@ -20,8 +20,8 @@ trait XMLInternalErrorsHelper */ protected function useXMLInternalErrors() { - libxml_clear_errors(); - $this->initialUseInternalErrorsValue = libxml_use_internal_errors(true); + \libxml_clear_errors(); + $this->initialUseInternalErrorsValue = \libxml_use_internal_errors(true); } /** @@ -48,7 +48,7 @@ trait XMLInternalErrorsHelper */ private function hasXMLErrorOccured() { - return (libxml_get_last_error() !== false); + return (\libxml_get_last_error() !== false); } /** @@ -60,10 +60,10 @@ trait XMLInternalErrorsHelper private function getLastXMLErrorMessage() { $errorMessage = null; - $error = libxml_get_last_error(); + $error = \libxml_get_last_error(); if ($error !== false) { - $errorMessage = trim($error->message); + $errorMessage = \trim($error->message); } return $errorMessage; @@ -74,6 +74,6 @@ trait XMLInternalErrorsHelper */ protected function resetXMLInternalErrorsSetting() { - libxml_use_internal_errors($this->initialUseInternalErrorsValue); + \libxml_use_internal_errors($this->initialUseInternalErrorsValue); } } diff --git a/src/Spout/Reader/Wrapper/XMLReader.php b/src/Spout/Reader/Wrapper/XMLReader.php index bdbaf4d..6f85f32 100644 --- a/src/Spout/Reader/Wrapper/XMLReader.php +++ b/src/Spout/Reader/Wrapper/XMLReader.php @@ -46,9 +46,9 @@ class XMLReader extends \XMLReader public function getRealPathURIForFileInZip($zipFilePath, $fileInsideZipPath) { // The file path should not start with a '/', otherwise it won't be found - $fileInsideZipPathWithoutLeadingSlash = ltrim($fileInsideZipPath, '/'); + $fileInsideZipPathWithoutLeadingSlash = \ltrim($fileInsideZipPath, '/'); - return (self::ZIP_WRAPPER . realpath($zipFilePath) . '#' . $fileInsideZipPathWithoutLeadingSlash); + return (self::ZIP_WRAPPER . \realpath($zipFilePath) . '#' . $fileInsideZipPathWithoutLeadingSlash); } /** @@ -62,7 +62,7 @@ class XMLReader extends \XMLReader $doesFileExists = false; $pattern = '/zip:\/\/([^#]+)#(.*)/'; - if (preg_match($pattern, $zipStreamURI, $matches)) { + if (\preg_match($pattern, $zipStreamURI, $matches)) { $zipFilePath = $matches[1]; $innerFilePath = $matches[2]; @@ -158,7 +158,7 @@ class XMLReader extends \XMLReader // In some cases, the node has a prefix (for instance, "" can also be ""). // So if the given node name does not have a prefix, we need to look at the unprefixed name ("localName"). // @see https://github.com/box/spout/issues/233 - $hasPrefix = (strpos($nodeName, ':') !== false); + $hasPrefix = (\strpos($nodeName, ':') !== false); $currentNodeName = ($hasPrefix) ? $this->name : $this->localName; return ($this->nodeType === $nodeType && $currentNodeName === $nodeName); diff --git a/src/Spout/Reader/XLSX/Helper/CellHelper.php b/src/Spout/Reader/XLSX/Helper/CellHelper.php index 27b5abf..d970189 100644 --- a/src/Spout/Reader/XLSX/Helper/CellHelper.php +++ b/src/Spout/Reader/XLSX/Helper/CellHelper.php @@ -37,7 +37,7 @@ class CellHelper $columnIndex = 0; // Remove row information - $columnLetters = preg_replace('/\d/', '', $cellIndex); + $columnLetters = \preg_replace('/\d/', '', $cellIndex); // strlen() is super slow too... Using isset() is way faster and not too unreadable, // since we checked before that there are between 1 and 3 letters. @@ -75,6 +75,6 @@ class CellHelper */ protected static function isValidCellIndex($cellIndex) { - return (preg_match('/^[A-Z]{1,3}\d+$/', $cellIndex) === 1); + return (\preg_match('/^[A-Z]{1,3}\d+$/', $cellIndex) === 1); } } diff --git a/src/Spout/Reader/XLSX/Helper/CellValueFormatter.php b/src/Spout/Reader/XLSX/Helper/CellValueFormatter.php index fba36b1..169c395 100644 --- a/src/Spout/Reader/XLSX/Helper/CellValueFormatter.php +++ b/src/Spout/Reader/XLSX/Helper/CellValueFormatter.php @@ -163,7 +163,7 @@ class CellValueFormatter */ protected function formatStrCellValue($nodeValue) { - $escapedCellValue = trim($nodeValue); + $escapedCellValue = \trim($nodeValue); $cellValue = $this->escaper->unescape($escapedCellValue); return $cellValue; @@ -248,8 +248,8 @@ class CellValueFormatter $baseDate = $this->shouldUse1904Dates ? '1904-01-01' : '1899-12-30'; $daysSinceBaseDate = (int) $nodeValue; - $timeRemainder = fmod($nodeValue, 1); - $secondsRemainder = round($timeRemainder * self::NUM_SECONDS_IN_ONE_DAY, 0); + $timeRemainder = \fmod($nodeValue, 1); + $secondsRemainder = \round($timeRemainder * self::NUM_SECONDS_IN_ONE_DAY, 0); $dateObj = \DateTime::createFromFormat('|Y-m-d', $baseDate); $dateObj->modify('+' . $daysSinceBaseDate . 'days'); diff --git a/src/Spout/Reader/XLSX/Helper/DateFormatHelper.php b/src/Spout/Reader/XLSX/Helper/DateFormatHelper.php index 1618af7..4435788 100644 --- a/src/Spout/Reader/XLSX/Helper/DateFormatHelper.php +++ b/src/Spout/Reader/XLSX/Helper/DateFormatHelper.php @@ -62,13 +62,13 @@ class DateFormatHelper // Remove brackets potentially present at the beginning of the format string // and text portion of the format at the end of it (starting with ";") // See §18.8.31 of ECMA-376 for more detail. - $dateFormat = preg_replace('/^(?:\[\$[^\]]+?\])?([^;]*).*/', '$1', $excelDateFormat); + $dateFormat = \preg_replace('/^(?:\[\$[^\]]+?\])?([^;]*).*/', '$1', $excelDateFormat); // Double quotes are used to escape characters that must not be interpreted. // For instance, ["Day " dd] should result in "Day 13" and we should not try to interpret "D", "a", "y" // By exploding the format string using double quote as a delimiter, we can get all parts // that must be transformed (even indexes) and all parts that must not be (odd indexes). - $dateFormatParts = explode('"', $dateFormat); + $dateFormatParts = \explode('"', $dateFormat); foreach ($dateFormatParts as $partIndex => $dateFormatPart) { // do not look at odd indexes @@ -77,19 +77,19 @@ class DateFormatHelper } // Make sure all characters are lowercase, as the mapping table is using lowercase characters - $transformedPart = strtolower($dateFormatPart); + $transformedPart = \strtolower($dateFormatPart); // Remove escapes related to non-format characters - $transformedPart = str_replace('\\', '', $transformedPart); + $transformedPart = \str_replace('\\', '', $transformedPart); // Apply general transformation first... - $transformedPart = strtr($transformedPart, self::$excelDateFormatToPHPDateFormatMapping[self::KEY_GENERAL]); + $transformedPart = \strtr($transformedPart, self::$excelDateFormatToPHPDateFormatMapping[self::KEY_GENERAL]); // ... then apply hour transformation, for 12-hour or 24-hour format if (self::has12HourFormatMarker($dateFormatPart)) { - $transformedPart = strtr($transformedPart, self::$excelDateFormatToPHPDateFormatMapping[self::KEY_HOUR_12]); + $transformedPart = \strtr($transformedPart, self::$excelDateFormatToPHPDateFormatMapping[self::KEY_HOUR_12]); } else { - $transformedPart = strtr($transformedPart, self::$excelDateFormatToPHPDateFormatMapping[self::KEY_HOUR_24]); + $transformedPart = \strtr($transformedPart, self::$excelDateFormatToPHPDateFormatMapping[self::KEY_HOUR_24]); } // overwrite the parts array with the new transformed part @@ -97,16 +97,16 @@ class DateFormatHelper } // Merge all transformed parts back together - $phpDateFormat = implode('"', $dateFormatParts); + $phpDateFormat = \implode('"', $dateFormatParts); // Finally, to have the date format compatible with the DateTime::format() function, we need to escape // all characters that are inside double quotes (and double quotes must be removed). // For instance, ["Day " dd] should become [\D\a\y\ dd] - $phpDateFormat = preg_replace_callback('/"(.+?)"/', function ($matches) { + $phpDateFormat = \preg_replace_callback('/"(.+?)"/', function ($matches) { $stringToEscape = $matches[1]; - $letters = preg_split('//u', $stringToEscape, -1, PREG_SPLIT_NO_EMPTY); + $letters = \preg_split('//u', $stringToEscape, -1, PREG_SPLIT_NO_EMPTY); - return '\\' . implode('\\', $letters); + return '\\' . \implode('\\', $letters); }, $phpDateFormat); return $phpDateFormat; @@ -118,6 +118,6 @@ class DateFormatHelper */ private static function has12HourFormatMarker($excelDateFormat) { - return (stripos($excelDateFormat, 'am/pm') !== false); + return (\stripos($excelDateFormat, 'am/pm') !== false); } } diff --git a/src/Spout/Reader/XLSX/Manager/OptionsManager.php b/src/Spout/Reader/XLSX/Manager/OptionsManager.php index 253e009..25fcc5c 100644 --- a/src/Spout/Reader/XLSX/Manager/OptionsManager.php +++ b/src/Spout/Reader/XLSX/Manager/OptionsManager.php @@ -29,7 +29,7 @@ class OptionsManager extends OptionsManagerAbstract */ protected function setDefaultOptions() { - $this->setOption(Options::TEMP_FOLDER, sys_get_temp_dir()); + $this->setOption(Options::TEMP_FOLDER, \sys_get_temp_dir()); $this->setOption(Options::SHOULD_FORMAT_DATES, false); $this->setOption(Options::SHOULD_PRESERVE_EMPTY_ROWS, false); $this->setOption(Options::SHOULD_USE_1904_DATES, false); diff --git a/src/Spout/Reader/XLSX/Manager/SharedStringsCaching/CachingStrategyFactory.php b/src/Spout/Reader/XLSX/Manager/SharedStringsCaching/CachingStrategyFactory.php index bc7ee9c..1c00a52 100644 --- a/src/Spout/Reader/XLSX/Manager/SharedStringsCaching/CachingStrategyFactory.php +++ b/src/Spout/Reader/XLSX/Manager/SharedStringsCaching/CachingStrategyFactory.php @@ -103,14 +103,14 @@ class CachingStrategyFactory protected function getMemoryLimitInKB() { $memoryLimitFormatted = $this->getMemoryLimitFromIni(); - $memoryLimitFormatted = strtolower(trim($memoryLimitFormatted)); + $memoryLimitFormatted = \strtolower(\trim($memoryLimitFormatted)); // No memory limit if ($memoryLimitFormatted === '-1') { return -1; } - if (preg_match('/(\d+)([bkmgt])b?/', $memoryLimitFormatted, $matches)) { + if (\preg_match('/(\d+)([bkmgt])b?/', $memoryLimitFormatted, $matches)) { $amount = (int) ($matches[1]); $unit = $matches[2]; @@ -133,6 +133,6 @@ class CachingStrategyFactory */ protected function getMemoryLimitFromIni() { - return ini_get('memory_limit'); + return \ini_get('memory_limit'); } } diff --git a/src/Spout/Reader/XLSX/Manager/SharedStringsCaching/FileBasedStrategy.php b/src/Spout/Reader/XLSX/Manager/SharedStringsCaching/FileBasedStrategy.php index c8ded70..0e743b4 100644 --- a/src/Spout/Reader/XLSX/Manager/SharedStringsCaching/FileBasedStrategy.php +++ b/src/Spout/Reader/XLSX/Manager/SharedStringsCaching/FileBasedStrategy.php @@ -55,7 +55,7 @@ class FileBasedStrategy implements CachingStrategyInterface public function __construct($tempFolder, $maxNumStringsPerTempFile, $helperFactory) { $this->fileSystemHelper = $helperFactory->createFileSystemHelper($tempFolder); - $this->tempFolder = $this->fileSystemHelper->createFolder($tempFolder, uniqid('sharedstrings')); + $this->tempFolder = $this->fileSystemHelper->createFolder($tempFolder, \uniqid('sharedstrings')); $this->maxNumStringsPerTempFile = $maxNumStringsPerTempFile; @@ -135,7 +135,7 @@ class FileBasedStrategy implements CachingStrategyInterface // free memory unset($this->inMemoryTempFileContents); - $this->inMemoryTempFileContents = explode(PHP_EOL, $this->globalFunctionsHelper->file_get_contents($tempFilePath)); + $this->inMemoryTempFileContents = \explode(PHP_EOL, $this->globalFunctionsHelper->file_get_contents($tempFilePath)); $this->inMemoryTempFilePath = $tempFilePath; } @@ -151,7 +151,7 @@ class FileBasedStrategy implements CachingStrategyInterface throw new SharedStringNotFoundException("Shared string not found for index: $sharedStringIndex"); } - return rtrim($sharedString, PHP_EOL); + return \rtrim($sharedString, PHP_EOL); } /** @@ -162,7 +162,7 @@ class FileBasedStrategy implements CachingStrategyInterface */ private function escapeLineFeed($unescapedString) { - return str_replace("\n", self::ESCAPED_LINE_FEED_CHARACTER, $unescapedString); + return \str_replace("\n", self::ESCAPED_LINE_FEED_CHARACTER, $unescapedString); } /** @@ -173,7 +173,7 @@ class FileBasedStrategy implements CachingStrategyInterface */ private function unescapeLineFeed($escapedString) { - return str_replace(self::ESCAPED_LINE_FEED_CHARACTER, "\n", $escapedString); + return \str_replace(self::ESCAPED_LINE_FEED_CHARACTER, "\n", $escapedString); } /** diff --git a/src/Spout/Reader/XLSX/Manager/SharedStringsManager.php b/src/Spout/Reader/XLSX/Manager/SharedStringsManager.php index 18d4681..caaeed7 100644 --- a/src/Spout/Reader/XLSX/Manager/SharedStringsManager.php +++ b/src/Spout/Reader/XLSX/Manager/SharedStringsManager.php @@ -190,7 +190,7 @@ class SharedStringsManager $textNodeValue = $textNode->nodeValue; $shouldPreserveWhitespace = $this->shouldPreserveWhitespace($textNode); - $sharedStringValue .= ($shouldPreserveWhitespace) ? $textNodeValue : trim($textNodeValue); + $sharedStringValue .= ($shouldPreserveWhitespace) ? $textNodeValue : \trim($textNodeValue); } } diff --git a/src/Spout/Reader/XLSX/Manager/SheetManager.php b/src/Spout/Reader/XLSX/Manager/SheetManager.php index 42f287d..e7b41e0 100644 --- a/src/Spout/Reader/XLSX/Manager/SheetManager.php +++ b/src/Spout/Reader/XLSX/Manager/SheetManager.php @@ -116,7 +116,7 @@ class SheetManager { // Using "filter_var($x, FILTER_VALIDATE_BOOLEAN)" here because the value of the "date1904" attribute // may be the string "false", that is not mapped to the boolean "false" by default... - $shouldUse1904Dates = filter_var($xmlReader->getAttribute(self::XML_ATTRIBUTE_DATE_1904), FILTER_VALIDATE_BOOLEAN); + $shouldUse1904Dates = \filter_var($xmlReader->getAttribute(self::XML_ATTRIBUTE_DATE_1904), FILTER_VALIDATE_BOOLEAN); $this->optionsManager->setOption(Options::SHOULD_USE_1904_DATES, $shouldUse1904Dates); return XMLProcessor::PROCESSING_CONTINUE; @@ -211,7 +211,7 @@ class SheetManager $sheetDataXMLFilePath = $xmlReader->getAttribute(self::XML_ATTRIBUTE_TARGET); // sometimes, the sheet data file path already contains "/xl/"... - if (strpos($sheetDataXMLFilePath, '/xl/') !== 0) { + if (\strpos($sheetDataXMLFilePath, '/xl/') !== 0) { $sheetDataXMLFilePath = '/xl/' . $sheetDataXMLFilePath; break; } diff --git a/src/Spout/Reader/XLSX/Manager/StyleManager.php b/src/Spout/Reader/XLSX/Manager/StyleManager.php index 193324d..d5db0d5 100644 --- a/src/Spout/Reader/XLSX/Manager/StyleManager.php +++ b/src/Spout/Reader/XLSX/Manager/StyleManager.php @@ -78,7 +78,7 @@ class StyleManager { $this->filePath = $filePath; $this->entityFactory = $entityFactory; - $this->builtinNumFmtIdIndicatingDates = array_keys(self::$builtinNumFmtIdToNumFormatMapping); + $this->builtinNumFmtIdIndicatingDates = \array_keys(self::$builtinNumFmtIdToNumFormatMapping); $this->hasStylesXMLFile = $workbookRelationshipsManager->hasStylesXMLFile(); if ($this->hasStylesXMLFile) { $this->stylesXMLFilePath = $workbookRelationshipsManager->getStylesXMLFilePath(); @@ -273,7 +273,7 @@ class StyleManager */ protected function isNumFmtIdBuiltInDateFormat($numFmtId) { - return in_array($numFmtId, $this->builtinNumFmtIdIndicatingDates); + return \in_array($numFmtId, $this->builtinNumFmtIdIndicatingDates); } /** @@ -283,7 +283,7 @@ class StyleManager protected function isFormatCodeCustomDateFormat($formatCode) { // if no associated format code or if using the default "General" format - if ($formatCode === null || strcasecmp($formatCode, self::NUMBER_FORMAT_GENERAL) === 0) { + if ($formatCode === null || \strcasecmp($formatCode, self::NUMBER_FORMAT_GENERAL) === 0) { return false; } @@ -298,7 +298,7 @@ class StyleManager { // Remove extra formatting (what's between [ ], the brackets should not be preceded by a "\") $pattern = '((?getAttribute(self::XML_ATTRIBUTE_REF); // returns 'A1:M13' for instance (or 'A1' for empty sheet) - if (preg_match('/[A-Z]+\d+:([A-Z]+\d+)/', $dimensionRef, $matches)) { + if (\preg_match('/[A-Z]+\d+:([A-Z]+\d+)/', $dimensionRef, $matches)) { $this->numColumns = CellHelper::getColumnIndexFromCellIndex($matches[1]) + 1; } @@ -257,11 +257,11 @@ class RowIterator implements IteratorInterface $numberOfColumnsForRow = $this->numColumns; $spans = $xmlReader->getAttribute(self::XML_ATTRIBUTE_SPANS); // returns '1:5' for instance if ($spans) { - list(, $numberOfColumnsForRow) = explode(':', $spans); + list(, $numberOfColumnsForRow) = \explode(':', $spans); $numberOfColumnsForRow = (int) $numberOfColumnsForRow; } - $cells = array_fill(0, $numberOfColumnsForRow, $this->entityFactory->createCell('')); + $cells = \array_fill(0, $numberOfColumnsForRow, $this->entityFactory->createCell('')); $this->currentlyProcessedRow->setCells($cells); return XMLProcessor::PROCESSING_CONTINUE; diff --git a/src/Spout/Reader/XLSX/SheetIterator.php b/src/Spout/Reader/XLSX/SheetIterator.php index d9ed17c..81f481c 100644 --- a/src/Spout/Reader/XLSX/SheetIterator.php +++ b/src/Spout/Reader/XLSX/SheetIterator.php @@ -27,7 +27,7 @@ class SheetIterator implements IteratorInterface // Fetch all available sheets $this->sheets = $sheetManager->getSheets(); - if (count($this->sheets) === 0) { + if (\count($this->sheets) === 0) { throw new NoSheetsFoundException('The file must contain at least one sheet.'); } } @@ -51,7 +51,7 @@ class SheetIterator implements IteratorInterface */ public function valid() { - return ($this->currentSheetIndex < count($this->sheets)); + return ($this->currentSheetIndex < \count($this->sheets)); } /** diff --git a/src/Spout/Writer/Common/Creator/WriterEntityFactory.php b/src/Spout/Writer/Common/Creator/WriterEntityFactory.php index 3acbed9..8e43c31 100644 --- a/src/Spout/Writer/Common/Creator/WriterEntityFactory.php +++ b/src/Spout/Writer/Common/Creator/WriterEntityFactory.php @@ -98,7 +98,7 @@ class WriterEntityFactory */ public static function createRowFromArray(array $cellValues = [], Style $rowStyle = null) { - $cells = array_map(function ($cellValue) { + $cells = \array_map(function ($cellValue) { return new Cell($cellValue); }, $cellValues); diff --git a/src/Spout/Writer/Common/Creator/WriterFactory.php b/src/Spout/Writer/Common/Creator/WriterFactory.php index e504587..96a8eb0 100644 --- a/src/Spout/Writer/Common/Creator/WriterFactory.php +++ b/src/Spout/Writer/Common/Creator/WriterFactory.php @@ -35,7 +35,7 @@ class WriterFactory */ public static function createFromFile(string $path) { - $extension = strtolower(pathinfo($path, PATHINFO_EXTENSION)); + $extension = \strtolower(\pathinfo($path, PATHINFO_EXTENSION)); return self::createFromType($extension); } diff --git a/src/Spout/Writer/Common/Entity/Workbook.php b/src/Spout/Writer/Common/Entity/Workbook.php index 782310b..dd18219 100644 --- a/src/Spout/Writer/Common/Entity/Workbook.php +++ b/src/Spout/Writer/Common/Entity/Workbook.php @@ -19,7 +19,7 @@ class Workbook */ public function __construct() { - $this->internalId = uniqid(); + $this->internalId = \uniqid(); } /** diff --git a/src/Spout/Writer/Common/Helper/CellHelper.php b/src/Spout/Writer/Common/Helper/CellHelper.php index 87623d8..afe3c71 100644 --- a/src/Spout/Writer/Common/Helper/CellHelper.php +++ b/src/Spout/Writer/Common/Helper/CellHelper.php @@ -28,11 +28,11 @@ class CellHelper // Using isset here because it is way faster than array_key_exists... if (!isset(self::$columnIndexToColumnLettersCache[$originalColumnIndex])) { $columnLetters = ''; - $capitalAAsciiValue = ord('A'); + $capitalAAsciiValue = \ord('A'); do { $modulus = $columnIndexZeroBased % 26; - $columnLetters = chr($capitalAAsciiValue + $modulus) . $columnLetters; + $columnLetters = \chr($capitalAAsciiValue + $modulus) . $columnLetters; // substracting 1 because it's zero-based $columnIndexZeroBased = (int) ($columnIndexZeroBased / 26) - 1; diff --git a/src/Spout/Writer/Common/Helper/ZipHelper.php b/src/Spout/Writer/Common/Helper/ZipHelper.php index b8fcd6c..7a250c8 100644 --- a/src/Spout/Writer/Common/Helper/ZipHelper.php +++ b/src/Spout/Writer/Common/Helper/ZipHelper.php @@ -135,7 +135,7 @@ class ZipHelper public static function canChooseCompressionMethod() { // setCompressionName() is a PHP7+ method... - return (method_exists(new \ZipArchive(), 'setCompressionName')); + return (\method_exists(new \ZipArchive(), 'setCompressionName')); } /** @@ -151,7 +151,7 @@ class ZipHelper foreach ($itemIterator as $itemInfo) { $itemRealPath = $this->getNormalizedRealPath($itemInfo->getPathname()); - $itemLocalPath = str_replace($folderRealPath, '', $itemRealPath); + $itemLocalPath = \str_replace($folderRealPath, '', $itemRealPath); if ($itemInfo->isFile() && !$this->shouldSkipFile($zip, $itemLocalPath, $existingFileMode)) { $zip->addFile($itemRealPath, $itemLocalPath); @@ -181,9 +181,9 @@ class ZipHelper */ protected function getNormalizedRealPath($path) { - $realPath = realpath($path); + $realPath = \realpath($path); - return str_replace(DIRECTORY_SEPARATOR, '/', $realPath); + return \str_replace(DIRECTORY_SEPARATOR, '/', $realPath); } /** @@ -210,8 +210,8 @@ class ZipHelper */ protected function copyZipToStream($zipFilePath, $pointer) { - $zipFilePointer = fopen($zipFilePath, 'r'); - stream_copy_to_stream($zipFilePointer, $pointer); - fclose($zipFilePointer); + $zipFilePointer = \fopen($zipFilePath, 'r'); + \stream_copy_to_stream($zipFilePointer, $pointer); + \fclose($zipFilePointer); } } diff --git a/src/Spout/Writer/Common/Manager/SheetManager.php b/src/Spout/Writer/Common/Manager/SheetManager.php index 708137c..d1d4e6a 100644 --- a/src/Spout/Writer/Common/Manager/SheetManager.php +++ b/src/Spout/Writer/Common/Manager/SheetManager.php @@ -45,8 +45,8 @@ class SheetManager */ public function throwIfNameIsInvalid($name, Sheet $sheet) { - if (!is_string($name)) { - $actualType = gettype($name); + if (!\is_string($name)) { + $actualType = \gettype($name); $errorMessage = "The sheet's name is invalid. It must be a string ($actualType given)."; throw new InvalidSheetNameException($errorMessage); } @@ -74,9 +74,9 @@ class SheetManager } } - if (count($failedRequirements) !== 0) { + if (\count($failedRequirements) !== 0) { $errorMessage = "The sheet's name (\"$name\") is invalid. It did not respect these rules:\n - "; - $errorMessage .= implode("\n - ", $failedRequirements); + $errorMessage .= \implode("\n - ", $failedRequirements); throw new InvalidSheetNameException($errorMessage); } } @@ -90,7 +90,7 @@ class SheetManager */ private function doesContainInvalidCharacters($name) { - return (str_replace(self::$INVALID_CHARACTERS_IN_SHEET_NAME, '', $name) !== $name); + return (\str_replace(self::$INVALID_CHARACTERS_IN_SHEET_NAME, '', $name) !== $name); } /** diff --git a/src/Spout/Writer/Common/Manager/Style/StyleManager.php b/src/Spout/Writer/Common/Manager/Style/StyleManager.php index 36abdc3..77eec73 100644 --- a/src/Spout/Writer/Common/Manager/Style/StyleManager.php +++ b/src/Spout/Writer/Common/Manager/Style/StyleManager.php @@ -80,7 +80,7 @@ class StyleManager implements StyleManagerInterface return $cellStyle; } - if ($cell->isString() && strpos($cell->getValue(), "\n") !== false) { + if ($cell->isString() && \strpos($cell->getValue(), "\n") !== false) { $cellStyle->setShouldWrapText(); } diff --git a/src/Spout/Writer/Common/Manager/Style/StyleRegistry.php b/src/Spout/Writer/Common/Manager/Style/StyleRegistry.php index fc978e7..d9e315f 100644 --- a/src/Spout/Writer/Common/Manager/Style/StyleRegistry.php +++ b/src/Spout/Writer/Common/Manager/Style/StyleRegistry.php @@ -37,7 +37,7 @@ class StyleRegistry $serializedStyle = $this->serialize($style); if (!$this->hasStyleAlreadyBeenRegistered($style)) { - $nextStyleId = count($this->serializedStyleToStyleIdMappingTable); + $nextStyleId = \count($this->serializedStyleToStyleIdMappingTable); $style->setId($nextStyleId); $this->serializedStyleToStyleIdMappingTable[$serializedStyle] = $nextStyleId; @@ -79,7 +79,7 @@ class StyleRegistry */ public function getRegisteredStyles() { - return array_values($this->styleIdToStyleMappingTable); + return \array_values($this->styleIdToStyleMappingTable); } /** @@ -105,7 +105,7 @@ class StyleRegistry $currentId = $style->getId(); $style->setId(0); - $serializedStyle = serialize($style); + $serializedStyle = \serialize($style); $style->setId($currentId); diff --git a/src/Spout/Writer/Common/Manager/WorkbookManagerAbstract.php b/src/Spout/Writer/Common/Manager/WorkbookManagerAbstract.php index 7be5c6e..b513555 100644 --- a/src/Spout/Writer/Common/Manager/WorkbookManagerAbstract.php +++ b/src/Spout/Writer/Common/Manager/WorkbookManagerAbstract.php @@ -124,7 +124,7 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface { $worksheets = $this->getWorksheets(); - $newSheetIndex = count($worksheets); + $newSheetIndex = \count($worksheets); $sheetManager = $this->managerFactory->createSheetManager(); $sheet = $this->entityFactory->createSheet($newSheetIndex, $this->workbook->getInternalId(), $sheetManager); @@ -260,7 +260,7 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface // update max num columns for the worksheet $currentMaxNumColumns = $worksheet->getMaxNumColumns(); $cellsCount = $row->getNumCells(); - $worksheet->setMaxNumColumns(max($currentMaxNumColumns, $cellsCount)); + $worksheet->setMaxNumColumns(\max($currentMaxNumColumns, $cellsCount)); } /** diff --git a/src/Spout/Writer/Exception/Border/InvalidNameException.php b/src/Spout/Writer/Exception/Border/InvalidNameException.php index 8bedc38..c975d4f 100644 --- a/src/Spout/Writer/Exception/Border/InvalidNameException.php +++ b/src/Spout/Writer/Exception/Border/InvalidNameException.php @@ -11,6 +11,6 @@ class InvalidNameException extends WriterException { $msg = '%s is not a valid name identifier for a border. Valid identifiers are: %s.'; - parent::__construct(sprintf($msg, $name, implode(',', BorderPart::getAllowedNames()))); + parent::__construct(\sprintf($msg, $name, \implode(',', BorderPart::getAllowedNames()))); } } diff --git a/src/Spout/Writer/Exception/Border/InvalidStyleException.php b/src/Spout/Writer/Exception/Border/InvalidStyleException.php index e4bb145..2d1d78c 100644 --- a/src/Spout/Writer/Exception/Border/InvalidStyleException.php +++ b/src/Spout/Writer/Exception/Border/InvalidStyleException.php @@ -11,6 +11,6 @@ class InvalidStyleException extends WriterException { $msg = '%s is not a valid style identifier for a border. Valid identifiers are: %s.'; - parent::__construct(sprintf($msg, $name, implode(',', BorderPart::getAllowedStyles()))); + parent::__construct(\sprintf($msg, $name, \implode(',', BorderPart::getAllowedStyles()))); } } diff --git a/src/Spout/Writer/Exception/Border/InvalidWidthException.php b/src/Spout/Writer/Exception/Border/InvalidWidthException.php index f38d898..790ddc2 100644 --- a/src/Spout/Writer/Exception/Border/InvalidWidthException.php +++ b/src/Spout/Writer/Exception/Border/InvalidWidthException.php @@ -11,6 +11,6 @@ class InvalidWidthException extends WriterException { $msg = '%s is not a valid width identifier for a border. Valid identifiers are: %s.'; - parent::__construct(sprintf($msg, $name, implode(',', BorderPart::getAllowedWidths()))); + parent::__construct(\sprintf($msg, $name, \implode(',', BorderPart::getAllowedWidths()))); } } diff --git a/src/Spout/Writer/ODS/Helper/BorderHelper.php b/src/Spout/Writer/ODS/Helper/BorderHelper.php index a53f63c..34886ac 100644 --- a/src/Spout/Writer/ODS/Helper/BorderHelper.php +++ b/src/Spout/Writer/ODS/Helper/BorderHelper.php @@ -53,14 +53,14 @@ class BorderHelper $definition = 'fo:border-%s="%s"'; if ($borderPart->getStyle() === Border::STYLE_NONE) { - $borderPartDefinition = sprintf($definition, $borderPart->getName(), 'none'); + $borderPartDefinition = \sprintf($definition, $borderPart->getName(), 'none'); } else { $attributes = [ self::$widthMap[$borderPart->getWidth()], self::$styleMap[$borderPart->getStyle()], '#' . $borderPart->getColor(), ]; - $borderPartDefinition = sprintf($definition, $borderPart->getName(), implode(' ', $attributes)); + $borderPartDefinition = \sprintf($definition, $borderPart->getName(), \implode(' ', $attributes)); } return $borderPartDefinition; diff --git a/src/Spout/Writer/ODS/Helper/FileSystemHelper.php b/src/Spout/Writer/ODS/Helper/FileSystemHelper.php index d0e2e05..5598bb4 100644 --- a/src/Spout/Writer/ODS/Helper/FileSystemHelper.php +++ b/src/Spout/Writer/ODS/Helper/FileSystemHelper.php @@ -89,7 +89,7 @@ class FileSystemHelper extends \Box\Spout\Common\Helper\FileSystemHelper impleme */ protected function createRootFolder() { - $this->rootFolder = $this->createFolder($this->baseFolderRealPath, uniqid('ods')); + $this->rootFolder = $this->createFolder($this->baseFolderRealPath, \uniqid('ods')); return $this; } @@ -210,22 +210,22 @@ EOD; // Append sheets content to "content.xml" $contentXmlFilePath = $this->rootFolder . '/' . self::CONTENT_XML_FILE_NAME; - $contentXmlHandle = fopen($contentXmlFilePath, 'a'); + $contentXmlHandle = \fopen($contentXmlFilePath, 'a'); foreach ($worksheets as $worksheet) { // write the "" node, with the final sheet's name - fwrite($contentXmlHandle, $worksheetManager->getTableElementStartAsString($worksheet)); + \fwrite($contentXmlHandle, $worksheetManager->getTableElementStartAsString($worksheet)); $worksheetFilePath = $worksheet->getFilePath(); $this->copyFileContentsToTarget($worksheetFilePath, $contentXmlHandle); - fwrite($contentXmlHandle, ''); + \fwrite($contentXmlHandle, ''); } $contentXmlFileContents = ''; - fwrite($contentXmlHandle, $contentXmlFileContents); - fclose($contentXmlHandle); + \fwrite($contentXmlHandle, $contentXmlFileContents); + \fclose($contentXmlHandle); return $this; } @@ -241,9 +241,9 @@ EOD; */ protected function copyFileContentsToTarget($sourceFilePath, $targetResource) { - $sourceHandle = fopen($sourceFilePath, 'r'); - stream_copy_to_stream($sourceHandle, $targetResource); - fclose($sourceHandle); + $sourceHandle = \fopen($sourceFilePath, 'r'); + \stream_copy_to_stream($sourceHandle, $targetResource); + \fclose($sourceHandle); } /** diff --git a/src/Spout/Writer/ODS/Manager/OptionsManager.php b/src/Spout/Writer/ODS/Manager/OptionsManager.php index 4d29928..a6fb564 100644 --- a/src/Spout/Writer/ODS/Manager/OptionsManager.php +++ b/src/Spout/Writer/ODS/Manager/OptionsManager.php @@ -42,7 +42,7 @@ class OptionsManager extends OptionsManagerAbstract */ protected function setDefaultOptions() { - $this->setOption(Options::TEMP_FOLDER, sys_get_temp_dir()); + $this->setOption(Options::TEMP_FOLDER, \sys_get_temp_dir()); $this->setOption(Options::DEFAULT_ROW_STYLE, $this->styleBuilder->build()); $this->setOption(Options::SHOULD_CREATE_NEW_SHEETS_AUTOMATICALLY, true); } diff --git a/src/Spout/Writer/ODS/Manager/Style/StyleManager.php b/src/Spout/Writer/ODS/Manager/Style/StyleManager.php index 4e163eb..34f75c7 100644 --- a/src/Spout/Writer/ODS/Manager/Style/StyleManager.php +++ b/src/Spout/Writer/ODS/Manager/Style/StyleManager.php @@ -295,7 +295,7 @@ EOD; */ private function getCellAlignmentSectionContent($style) { - return sprintf( + return \sprintf( ' fo:text-align="%s" ', $this->transformCellAlignment($style->getCellAlignment()) ); @@ -364,11 +364,11 @@ EOD; */ private function getBorderXMLContent($style) { - $borders = array_map(function (BorderPart $borderPart) { + $borders = \array_map(function (BorderPart $borderPart) { return BorderHelper::serializeBorderPart($borderPart); }, $style->getBorder()->getParts()); - return sprintf(' %s ', implode(' ', $borders)); + return \sprintf(' %s ', \implode(' ', $borders)); } /** @@ -379,6 +379,6 @@ EOD; */ private function getBackgroundColorXMLContent($style) { - return sprintf(' fo:background-color="#%s" ', $style->getBackgroundColor()); + return \sprintf(' fo:background-color="#%s" ', $style->getBackgroundColor()); } } diff --git a/src/Spout/Writer/ODS/Manager/Style/StyleRegistry.php b/src/Spout/Writer/ODS/Manager/Style/StyleRegistry.php index bc9dccc..6c580d4 100644 --- a/src/Spout/Writer/ODS/Manager/Style/StyleRegistry.php +++ b/src/Spout/Writer/ODS/Manager/Style/StyleRegistry.php @@ -33,6 +33,6 @@ class StyleRegistry extends \Box\Spout\Writer\Common\Manager\Style\StyleRegistry */ public function getUsedFonts() { - return array_keys($this->usedFontsSet); + return \array_keys($this->usedFontsSet); } } diff --git a/src/Spout/Writer/ODS/Manager/WorkbookManager.php b/src/Spout/Writer/ODS/Manager/WorkbookManager.php index 367c281..77c5f90 100644 --- a/src/Spout/Writer/ODS/Manager/WorkbookManager.php +++ b/src/Spout/Writer/ODS/Manager/WorkbookManager.php @@ -56,7 +56,7 @@ class WorkbookManager extends WorkbookManagerAbstract protected function writeAllFilesToDiskAndZipThem($finalFilePointer) { $worksheets = $this->getWorksheets(); - $numWorksheets = count($worksheets); + $numWorksheets = \count($worksheets); $this->fileSystemHelper ->createContentFile($this->worksheetManager, $this->styleManager, $worksheets) diff --git a/src/Spout/Writer/ODS/Manager/WorksheetManager.php b/src/Spout/Writer/ODS/Manager/WorksheetManager.php index 6d76fa0..6392259 100644 --- a/src/Spout/Writer/ODS/Manager/WorksheetManager.php +++ b/src/Spout/Writer/ODS/Manager/WorksheetManager.php @@ -61,7 +61,7 @@ class WorksheetManager implements WorksheetManagerInterface */ public function startSheet(Worksheet $worksheet) { - $sheetFilePointer = fopen($worksheet->getFilePath(), 'w'); + $sheetFilePointer = \fopen($worksheet->getFilePath(), 'w'); $this->throwIfSheetFilePointerIsNotAvailable($sheetFilePointer); $worksheet->setFilePointer($sheetFilePointer); @@ -134,7 +134,7 @@ class WorksheetManager implements WorksheetManagerInterface $data .= ''; - $wasWriteSuccessful = fwrite($worksheet->getFilePointer(), $data); + $wasWriteSuccessful = \fwrite($worksheet->getFilePointer(), $data); if ($wasWriteSuccessful === false) { throw new IOException("Unable to write data in {$worksheet->getFilePath()}"); } @@ -190,7 +190,7 @@ class WorksheetManager implements WorksheetManagerInterface if ($cell->isString()) { $data .= ' office:value-type="string" calcext:value-type="string">'; - $cellValueLines = explode("\n", $cell->getValue()); + $cellValueLines = \explode("\n", $cell->getValue()); foreach ($cellValueLines as $cellValueLine) { $data .= '' . $this->stringsEscaper->escape($cellValueLine) . ''; } @@ -207,7 +207,7 @@ class WorksheetManager implements WorksheetManagerInterface } elseif ($cell->isEmpty()) { $data .= '/>'; } else { - throw new InvalidArgumentException('Trying to add a value with an unsupported type: ' . gettype($cell->getValue())); + throw new InvalidArgumentException('Trying to add a value with an unsupported type: ' . \gettype($cell->getValue())); } return $data; @@ -223,10 +223,10 @@ class WorksheetManager implements WorksheetManagerInterface { $worksheetFilePointer = $worksheet->getFilePointer(); - if (!is_resource($worksheetFilePointer)) { + if (!\is_resource($worksheetFilePointer)) { return; } - fclose($worksheetFilePointer); + \fclose($worksheetFilePointer); } } diff --git a/src/Spout/Writer/WriterAbstract.php b/src/Spout/Writer/WriterAbstract.php index 4bcc407..d96a628 100644 --- a/src/Spout/Writer/WriterAbstract.php +++ b/src/Spout/Writer/WriterAbstract.php @@ -223,7 +223,7 @@ abstract class WriterAbstract implements WriterInterface $this->closeWriter(); - if (is_resource($this->filePointer)) { + if (\is_resource($this->filePointer)) { $this->globalFunctionsHelper->fclose($this->filePointer); } @@ -243,7 +243,7 @@ abstract class WriterAbstract implements WriterInterface // remove output file if it was created if ($this->globalFunctionsHelper->file_exists($this->outputFilePath)) { - $outputFolderPath = dirname($this->outputFilePath); + $outputFolderPath = \dirname($this->outputFilePath); $fileSystemHelper = $this->helperFactory->createFileSystemHelper($outputFolderPath); $fileSystemHelper->deleteFile($this->outputFilePath); } diff --git a/src/Spout/Writer/XLSX/Helper/BorderHelper.php b/src/Spout/Writer/XLSX/Helper/BorderHelper.php index 1c773fd..ed202cb 100644 --- a/src/Spout/Writer/XLSX/Helper/BorderHelper.php +++ b/src/Spout/Writer/XLSX/Helper/BorderHelper.php @@ -43,8 +43,8 @@ class BorderHelper { $borderStyle = self::getBorderStyle($borderPart); - $colorEl = $borderPart->getColor() ? sprintf('', $borderPart->getColor()) : ''; - $partEl = sprintf( + $colorEl = $borderPart->getColor() ? \sprintf('', $borderPart->getColor()) : ''; + $partEl = \sprintf( '<%s style="%s">%s', $borderPart->getName(), $borderStyle, diff --git a/src/Spout/Writer/XLSX/Helper/FileSystemHelper.php b/src/Spout/Writer/XLSX/Helper/FileSystemHelper.php index 8997b98..0a19d9e 100644 --- a/src/Spout/Writer/XLSX/Helper/FileSystemHelper.php +++ b/src/Spout/Writer/XLSX/Helper/FileSystemHelper.php @@ -112,7 +112,7 @@ class FileSystemHelper extends \Box\Spout\Common\Helper\FileSystemHelper impleme */ private function createRootFolder() { - $this->rootFolder = $this->createFolder($this->baseFolderRealPath, uniqid('xlsx', true)); + $this->rootFolder = $this->createFolder($this->baseFolderRealPath, \uniqid('xlsx', true)); return $this; } diff --git a/src/Spout/Writer/XLSX/Manager/OptionsManager.php b/src/Spout/Writer/XLSX/Manager/OptionsManager.php index 53718bc..d3b5cd4 100644 --- a/src/Spout/Writer/XLSX/Manager/OptionsManager.php +++ b/src/Spout/Writer/XLSX/Manager/OptionsManager.php @@ -52,7 +52,7 @@ class OptionsManager extends OptionsManagerAbstract ->setFontName(self::DEFAULT_FONT_NAME) ->build(); - $this->setOption(Options::TEMP_FOLDER, sys_get_temp_dir()); + $this->setOption(Options::TEMP_FOLDER, \sys_get_temp_dir()); $this->setOption(Options::DEFAULT_ROW_STYLE, $defaultRowStyle); $this->setOption(Options::SHOULD_CREATE_NEW_SHEETS_AUTOMATICALLY, true); $this->setOption(Options::SHOULD_USE_INLINE_STRINGS, true); diff --git a/src/Spout/Writer/XLSX/Manager/SharedStringsManager.php b/src/Spout/Writer/XLSX/Manager/SharedStringsManager.php index 2a60c3c..b0a5b48 100644 --- a/src/Spout/Writer/XLSX/Manager/SharedStringsManager.php +++ b/src/Spout/Writer/XLSX/Manager/SharedStringsManager.php @@ -40,13 +40,13 @@ EOD; public function __construct($xlFolder, $stringsEscaper) { $sharedStringsFilePath = $xlFolder . '/' . self::SHARED_STRINGS_FILE_NAME; - $this->sharedStringsFilePointer = fopen($sharedStringsFilePath, 'w'); + $this->sharedStringsFilePointer = \fopen($sharedStringsFilePath, 'w'); $this->throwIfSharedStringsFilePointerIsNotAvailable(); // the headers is split into different parts so that we can fseek and put in the correct count and uniqueCount later $header = self::SHARED_STRINGS_XML_FILE_FIRST_PART_HEADER . ' ' . self::DEFAULT_STRINGS_COUNT_PART . '>'; - fwrite($this->sharedStringsFilePointer, $header); + \fwrite($this->sharedStringsFilePointer, $header); $this->stringsEscaper = $stringsEscaper; } @@ -73,7 +73,7 @@ EOD; */ public function writeString($string) { - fwrite($this->sharedStringsFilePointer, '' . $this->stringsEscaper->escape($string) . ''); + \fwrite($this->sharedStringsFilePointer, '' . $this->stringsEscaper->escape($string) . ''); $this->numSharedStrings++; // Shared string ID is zero-based @@ -87,20 +87,20 @@ EOD; */ public function close() { - if (!is_resource($this->sharedStringsFilePointer)) { + if (!\is_resource($this->sharedStringsFilePointer)) { return; } - fwrite($this->sharedStringsFilePointer, ''); + \fwrite($this->sharedStringsFilePointer, ''); // Replace the default strings count with the actual number of shared strings in the file header - $firstPartHeaderLength = strlen(self::SHARED_STRINGS_XML_FILE_FIRST_PART_HEADER); - $defaultStringsCountPartLength = strlen(self::DEFAULT_STRINGS_COUNT_PART); + $firstPartHeaderLength = \strlen(self::SHARED_STRINGS_XML_FILE_FIRST_PART_HEADER); + $defaultStringsCountPartLength = \strlen(self::DEFAULT_STRINGS_COUNT_PART); // Adding 1 to take into account the space between the last xml attribute and "count" - fseek($this->sharedStringsFilePointer, $firstPartHeaderLength + 1); - fwrite($this->sharedStringsFilePointer, sprintf("%-{$defaultStringsCountPartLength}s", 'count="' . $this->numSharedStrings . '" uniqueCount="' . $this->numSharedStrings . '"')); + \fseek($this->sharedStringsFilePointer, $firstPartHeaderLength + 1); + \fwrite($this->sharedStringsFilePointer, \sprintf("%-{$defaultStringsCountPartLength}s", 'count="' . $this->numSharedStrings . '" uniqueCount="' . $this->numSharedStrings . '"')); - fclose($this->sharedStringsFilePointer); + \fclose($this->sharedStringsFilePointer); } } diff --git a/src/Spout/Writer/XLSX/Manager/Style/StyleManager.php b/src/Spout/Writer/XLSX/Manager/Style/StyleManager.php index 5eaa606..f0ca9d9 100644 --- a/src/Spout/Writer/XLSX/Manager/Style/StyleManager.php +++ b/src/Spout/Writer/XLSX/Manager/Style/StyleManager.php @@ -88,8 +88,8 @@ EOD; $format = $style->getFormat(); $tags[] = ''; } - $content = ''; - $content .= implode('', $tags); + $content = ''; + $content .= \implode('', $tags); $content .= ''; return $content; @@ -104,7 +104,7 @@ EOD; { $registeredStyles = $this->styleRegistry->getRegisteredStyles(); - $content = ''; + $content = ''; /** @var Style $style */ foreach ($registeredStyles as $style) { @@ -145,8 +145,8 @@ EOD; $registeredFills = $this->styleRegistry->getRegisteredFills(); // Excel reserves two default fills - $fillsCount = count($registeredFills) + 2; - $content = sprintf('', $fillsCount); + $fillsCount = \count($registeredFills) + 2; + $content = \sprintf('', $fillsCount); $content .= ''; $content .= ''; @@ -157,7 +157,7 @@ EOD; $style = $this->styleRegistry->getStyleFromStyleId($styleId); $backgroundColor = $style->getBackgroundColor(); - $content .= sprintf( + $content .= \sprintf( '', $backgroundColor ); @@ -178,7 +178,7 @@ EOD; $registeredBorders = $this->styleRegistry->getRegisteredBorders(); // There is one default border with index 0 - $borderCount = count($registeredBorders) + 1; + $borderCount = \count($registeredBorders) + 1; $content = ''; @@ -233,7 +233,7 @@ EOD; { $registeredStyles = $this->styleRegistry->getRegisteredStyles(); - $content = ''; + $content = ''; foreach ($registeredStyles as $style) { $styleId = $style->getId(); @@ -247,13 +247,13 @@ EOD; $content .= ' applyFont="1"'; } - $content .= sprintf(' applyBorder="%d"', $style->shouldApplyBorder() ? 1 : 0); + $content .= \sprintf(' applyBorder="%d"', $style->shouldApplyBorder() ? 1 : 0); if ($style->shouldApplyCellAlignment() || $style->shouldWrapText()) { $content .= ' applyAlignment="1">'; $content .= 'shouldApplyCellAlignment()) { - $content .= sprintf(' horizontal="%s"', $style->getCellAlignment()); + $content .= \sprintf(' horizontal="%s"', $style->getCellAlignment()); } if ($style->shouldWrapText()) { $content .= ' wrapText="1"'; diff --git a/src/Spout/Writer/XLSX/Manager/Style/StyleRegistry.php b/src/Spout/Writer/XLSX/Manager/Style/StyleRegistry.php index f3882ac..ace607c 100644 --- a/src/Spout/Writer/XLSX/Manager/Style/StyleRegistry.php +++ b/src/Spout/Writer/XLSX/Manager/Style/StyleRegistry.php @@ -221,7 +221,7 @@ class StyleRegistry extends \Box\Spout\Writer\Common\Manager\Style\StyleRegistry if ($style->shouldApplyBorder()) { $border = $style->getBorder(); - $serializedBorder = serialize($border); + $serializedBorder = \serialize($border); $isBorderAlreadyRegistered = isset($this->registeredBorders[$serializedBorder]); @@ -231,7 +231,7 @@ class StyleRegistry extends \Box\Spout\Writer\Common\Manager\Style\StyleRegistry $this->styleIdToBorderMappingTable[$styleId] = $registeredBorderId; } else { $this->registeredBorders[$serializedBorder] = $styleId; - $this->styleIdToBorderMappingTable[$styleId] = count($this->registeredBorders); + $this->styleIdToBorderMappingTable[$styleId] = \count($this->registeredBorders); } } else { // If no border should be applied - the mapping is the default border: 0 diff --git a/src/Spout/Writer/XLSX/Manager/WorkbookManager.php b/src/Spout/Writer/XLSX/Manager/WorkbookManager.php index 944516b..708208b 100644 --- a/src/Spout/Writer/XLSX/Manager/WorkbookManager.php +++ b/src/Spout/Writer/XLSX/Manager/WorkbookManager.php @@ -44,7 +44,7 @@ class WorkbookManager extends WorkbookManagerAbstract { $worksheetFilesFolder = $this->fileSystemHelper->getXlWorksheetsFolder(); - return $worksheetFilesFolder . '/' . strtolower($sheet->getName()) . '.xml'; + return $worksheetFilesFolder . '/' . \strtolower($sheet->getName()) . '.xml'; } /** diff --git a/src/Spout/Writer/XLSX/Manager/WorksheetManager.php b/src/Spout/Writer/XLSX/Manager/WorksheetManager.php index e02e9e6..d4e65e2 100644 --- a/src/Spout/Writer/XLSX/Manager/WorksheetManager.php +++ b/src/Spout/Writer/XLSX/Manager/WorksheetManager.php @@ -107,13 +107,13 @@ EOD; */ public function startSheet(Worksheet $worksheet) { - $sheetFilePointer = fopen($worksheet->getFilePath(), 'w'); + $sheetFilePointer = \fopen($worksheet->getFilePath(), 'w'); $this->throwIfSheetFilePointerIsNotAvailable($sheetFilePointer); $worksheet->setFilePointer($sheetFilePointer); - fwrite($sheetFilePointer, self::SHEET_XML_FILE_HEADER); - fwrite($sheetFilePointer, ''); + \fwrite($sheetFilePointer, self::SHEET_XML_FILE_HEADER); + \fwrite($sheetFilePointer, ''); } /** @@ -165,7 +165,7 @@ EOD; $rowXML .= ''; - $wasWriteSuccessful = fwrite($worksheet->getFilePointer(), $rowXML); + $wasWriteSuccessful = \fwrite($worksheet->getFilePointer(), $rowXML); if ($wasWriteSuccessful === false) { throw new IOException("Unable to write data in {$worksheet->getFilePath()}"); } @@ -227,7 +227,7 @@ EOD; $cellXML = ''; } } else { - throw new InvalidArgumentException('Trying to add a value with an unsupported type: ' . gettype($cell->getValue())); + throw new InvalidArgumentException('Trying to add a value with an unsupported type: ' . \gettype($cell->getValue())); } return $cellXML; @@ -263,12 +263,12 @@ EOD; { $worksheetFilePointer = $worksheet->getFilePointer(); - if (!is_resource($worksheetFilePointer)) { + if (!\is_resource($worksheetFilePointer)) { return; } - fwrite($worksheetFilePointer, ''); - fwrite($worksheetFilePointer, ''); - fclose($worksheetFilePointer); + \fwrite($worksheetFilePointer, ''); + \fwrite($worksheetFilePointer, ''); + \fclose($worksheetFilePointer); } }