Skip to content
This repository was archived by the owner on May 26, 2022. It is now read-only.

Commit eb88bb4

Browse files
drowe-wayfairadrilo
authored andcommitted
Automated native_function_invocation fixes
1 parent 94b6541 commit eb88bb4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+237
-237
lines changed

src/Spout/Autoloader/Psr4Autoloader.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Psr4Autoloader
2323
*/
2424
public function register()
2525
{
26-
spl_autoload_register([$this, 'loadClass']);
26+
\spl_autoload_register([$this, 'loadClass']);
2727
}
2828

2929
/**
@@ -40,10 +40,10 @@ public function register()
4040
public function addNamespace($prefix, $baseDir, $prepend = false)
4141
{
4242
// normalize namespace prefix
43-
$prefix = trim($prefix, '\\') . '\\';
43+
$prefix = \trim($prefix, '\\') . '\\';
4444

4545
// normalize the base directory with a trailing separator
46-
$baseDir = rtrim($baseDir, DIRECTORY_SEPARATOR) . '/';
46+
$baseDir = \rtrim($baseDir, DIRECTORY_SEPARATOR) . '/';
4747

4848
// initialize the namespace prefix array
4949
if (isset($this->prefixes[$prefix]) === false) {
@@ -52,9 +52,9 @@ public function addNamespace($prefix, $baseDir, $prepend = false)
5252

5353
// retain the base directory for the namespace prefix
5454
if ($prepend) {
55-
array_unshift($this->prefixes[$prefix], $baseDir);
55+
\array_unshift($this->prefixes[$prefix], $baseDir);
5656
} else {
57-
array_push($this->prefixes[$prefix], $baseDir);
57+
\array_push($this->prefixes[$prefix], $baseDir);
5858
}
5959
}
6060

@@ -72,12 +72,12 @@ public function loadClass($class)
7272

7373
// work backwards through the namespace names of the fully-qualified
7474
// class name to find a mapped file name
75-
while (($pos = strrpos($prefix, '\\')) !== false) {
75+
while (($pos = \strrpos($prefix, '\\')) !== false) {
7676
// retain the trailing namespace separator in the prefix
77-
$prefix = substr($class, 0, $pos + 1);
77+
$prefix = \substr($class, 0, $pos + 1);
7878

7979
// the rest is the relative class name
80-
$relativeClass = substr($class, $pos + 1);
80+
$relativeClass = \substr($class, $pos + 1);
8181

8282
// try to load a mapped file for the prefix and relative class
8383
$mappedFile = $this->loadMappedFile($prefix, $relativeClass);
@@ -87,7 +87,7 @@ public function loadClass($class)
8787

8888
// remove the trailing namespace separator for the next iteration
8989
// of strrpos()
90-
$prefix = rtrim($prefix, '\\');
90+
$prefix = \rtrim($prefix, '\\');
9191
}
9292

9393
// never found a mapped file
@@ -115,7 +115,7 @@ protected function loadMappedFile($prefix, $relativeClass)
115115
// replace namespace separators with directory separators
116116
// in the relative class name, append with .php
117117
$file = $baseDir
118-
. str_replace('\\', '/', $relativeClass)
118+
. \str_replace('\\', '/', $relativeClass)
119119
. '.php';
120120

121121
// if the mapped file exists, require it
@@ -137,7 +137,7 @@ protected function loadMappedFile($prefix, $relativeClass)
137137
*/
138138
protected function requireFile($file)
139139
{
140-
if (file_exists($file)) {
140+
if (\file_exists($file)) {
141141
require $file;
142142

143143
return true;

src/Spout/Autoloader/autoload.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @var string
99
* Full path to "src/Spout" which is what we want "Box\Spout" to map to.
1010
*/
11-
$srcBaseDirectory = dirname(dirname(__FILE__));
11+
$srcBaseDirectory = \dirname(\dirname(__FILE__));
1212

1313
$loader = new Psr4Autoloader();
1414
$loader->register();

src/Spout/Common/Entity/Row.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function getNumCells()
9595
return 0;
9696
}
9797

98-
return max(array_keys($this->cells)) + 1;
98+
return \max(\array_keys($this->cells)) + 1;
9999
}
100100

101101
/**
@@ -122,7 +122,7 @@ public function setStyle($style)
122122
*/
123123
public function toArray()
124124
{
125-
return array_map(function (Cell $cell) {
125+
return \array_map(function (Cell $cell) {
126126
return $cell->getValue();
127127
}, $this->cells);
128128
}

src/Spout/Common/Entity/Style/BorderPart.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function getName()
9393
*/
9494
public function setName($name)
9595
{
96-
if (!in_array($name, self::$allowedNames)) {
96+
if (!\in_array($name, self::$allowedNames)) {
9797
throw new InvalidNameException($name);
9898
}
9999
$this->name = $name;
@@ -114,7 +114,7 @@ public function getStyle()
114114
*/
115115
public function setStyle($style)
116116
{
117-
if (!in_array($style, self::$allowedStyles)) {
117+
if (!\in_array($style, self::$allowedStyles)) {
118118
throw new InvalidStyleException($style);
119119
}
120120
$this->style = $style;
@@ -152,7 +152,7 @@ public function getWidth()
152152
*/
153153
public function setWidth($width)
154154
{
155-
if (!in_array($width, self::$allowedWidths)) {
155+
if (!\in_array($width, self::$allowedWidths)) {
156156
throw new InvalidWidthException($width);
157157
}
158158
$this->width = $width;

src/Spout/Common/Entity/Style/Color.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public static function rgb($red, $green, $blue)
3838
self::throwIfInvalidColorComponentValue($green);
3939
self::throwIfInvalidColorComponentValue($blue);
4040

41-
return strtoupper(
41+
return \strtoupper(
4242
self::convertColorComponentToHex($red) .
4343
self::convertColorComponentToHex($green) .
4444
self::convertColorComponentToHex($blue)
@@ -54,7 +54,7 @@ public static function rgb($red, $green, $blue)
5454
*/
5555
protected static function throwIfInvalidColorComponentValue($colorComponent)
5656
{
57-
if (!is_int($colorComponent) || $colorComponent < 0 || $colorComponent > 255) {
57+
if (!\is_int($colorComponent) || $colorComponent < 0 || $colorComponent > 255) {
5858
throw new InvalidColorException("The RGB components must be between 0 and 255. Received: $colorComponent");
5959
}
6060
}
@@ -67,7 +67,7 @@ protected static function throwIfInvalidColorComponentValue($colorComponent)
6767
*/
6868
protected static function convertColorComponentToHex($colorComponent)
6969
{
70-
return str_pad(dechex($colorComponent), 2, '0', STR_PAD_LEFT);
70+
return \str_pad(\dechex($colorComponent), 2, '0', STR_PAD_LEFT);
7171
}
7272

7373
/**

src/Spout/Common/Helper/CellTypeHelper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public static function isEmpty($value)
2323
*/
2424
public static function isNonEmptyString($value)
2525
{
26-
return (gettype($value) === 'string' && $value !== '');
26+
return (\gettype($value) === 'string' && $value !== '');
2727
}
2828

2929
/**
@@ -35,7 +35,7 @@ public static function isNonEmptyString($value)
3535
*/
3636
public static function isNumeric($value)
3737
{
38-
$valueType = gettype($value);
38+
$valueType = \gettype($value);
3939

4040
return ($valueType === 'integer' || $valueType === 'double');
4141
}
@@ -49,7 +49,7 @@ public static function isNumeric($value)
4949
*/
5050
public static function isBoolean($value)
5151
{
52-
return gettype($value) === 'boolean';
52+
return \gettype($value) === 'boolean';
5353
}
5454

5555
/**

src/Spout/Common/Helper/EncodingHelper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function getBytesOffsetToSkipBOM($filePointer, $encoding)
6161
$bomUsed = $this->supportedEncodingsWithBom[$encoding];
6262

6363
// we skip the N first bytes
64-
$byteOffsetToSkipBom = strlen($bomUsed);
64+
$byteOffsetToSkipBom = \strlen($bomUsed);
6565
}
6666

6767
return $byteOffsetToSkipBom;
@@ -80,9 +80,9 @@ protected function hasBOM($filePointer, $encoding)
8080

8181
$this->globalFunctionsHelper->rewind($filePointer);
8282

83-
if (array_key_exists($encoding, $this->supportedEncodingsWithBom)) {
83+
if (\array_key_exists($encoding, $this->supportedEncodingsWithBom)) {
8484
$potentialBom = $this->supportedEncodingsWithBom[$encoding];
85-
$numBytesInBom = strlen($potentialBom);
85+
$numBytesInBom = \strlen($potentialBom);
8686

8787
$hasBOM = ($this->globalFunctionsHelper->fgets($filePointer, $numBytesInBom + 1) === $potentialBom);
8888
}

src/Spout/Common/Helper/Escaper/ODS.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ public function escape($string)
1818
{
1919
// @NOTE: Using ENT_QUOTES as XML entities ('<', '>', '&') as well as
2020
// single/double quotes (for XML attributes) need to be encoded.
21-
if (defined('ENT_DISALLOWED')) {
21+
if (\defined('ENT_DISALLOWED')) {
2222
// 'ENT_DISALLOWED' ensures that invalid characters in the given document type are replaced.
2323
// Otherwise control characters like a vertical tab "\v" will make the XML document unreadable by the XML processor
2424
// @link https://github.com/box/spout/issues/329
25-
$replacedString = htmlspecialchars($string, ENT_QUOTES | ENT_DISALLOWED, 'UTF-8');
25+
$replacedString = \htmlspecialchars($string, ENT_QUOTES | ENT_DISALLOWED, 'UTF-8');
2626
} else {
2727
// We are on hhvm or any other engine that does not support ENT_DISALLOWED.
28-
$escapedString = htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
28+
$escapedString = \htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
2929

3030
// control characters values are from 0 to 1F (hex values) in the ASCII table
3131
// some characters should not be escaped though: "\t", "\r" and "\n".
@@ -34,7 +34,7 @@ public function escape($string)
3434
'\x0B-\x0C' .
3535
// skipping "\r" (0xD)
3636
'\x0E-\x1F]';
37-
$replacedString = preg_replace("/$regexPattern/", '', $escapedString);
37+
$replacedString = \preg_replace("/$regexPattern/", '', $escapedString);
3838
}
3939

4040
return $replacedString;

src/Spout/Common/Helper/Escaper/XLSX.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ protected function initIfNeeded()
2828
if (!$this->isAlreadyInitialized) {
2929
$this->escapableControlCharactersPattern = $this->getEscapableControlCharactersPattern();
3030
$this->controlCharactersEscapingMap = $this->getControlCharactersEscapingMap();
31-
$this->controlCharactersEscapingReverseMap = array_flip($this->controlCharactersEscapingMap);
31+
$this->controlCharactersEscapingReverseMap = \array_flip($this->controlCharactersEscapingMap);
3232

3333
$this->isAlreadyInitialized = true;
3434
}
@@ -47,7 +47,7 @@ public function escape($string)
4747
$escapedString = $this->escapeControlCharacters($string);
4848
// @NOTE: Using ENT_QUOTES as XML entities ('<', '>', '&') as well as
4949
// single/double quotes (for XML attributes) need to be encoded.
50-
$escapedString = htmlspecialchars($escapedString, ENT_QUOTES, 'UTF-8');
50+
$escapedString = \htmlspecialchars($escapedString, ENT_QUOTES, 'UTF-8');
5151

5252
return $escapedString;
5353
}
@@ -103,10 +103,10 @@ protected function getControlCharactersEscapingMap()
103103

104104
// control characters values are from 0 to 1F (hex values) in the ASCII table
105105
for ($charValue = 0x00; $charValue <= 0x1F; $charValue++) {
106-
$character = chr($charValue);
107-
if (preg_match("/{$this->escapableControlCharactersPattern}/", $character)) {
108-
$charHexValue = dechex($charValue);
109-
$escapedChar = '_x' . sprintf('%04s', strtoupper($charHexValue)) . '_';
106+
$character = \chr($charValue);
107+
if (\preg_match("/{$this->escapableControlCharactersPattern}/", $character)) {
108+
$charHexValue = \dechex($charValue);
109+
$escapedChar = '_x' . \sprintf('%04s', \strtoupper($charHexValue)) . '_';
110110
$controlCharactersEscapingMap[$escapedChar] = $character;
111111
}
112112
}
@@ -132,11 +132,11 @@ protected function escapeControlCharacters($string)
132132
$escapedString = $this->escapeEscapeCharacter($string);
133133

134134
// if no control characters
135-
if (!preg_match("/{$this->escapableControlCharactersPattern}/", $escapedString)) {
135+
if (!\preg_match("/{$this->escapableControlCharactersPattern}/", $escapedString)) {
136136
return $escapedString;
137137
}
138138

139-
return preg_replace_callback("/({$this->escapableControlCharactersPattern})/", function ($matches) {
139+
return \preg_replace_callback("/({$this->escapableControlCharactersPattern})/", function ($matches) {
140140
return $this->controlCharactersEscapingReverseMap[$matches[0]];
141141
}, $escapedString);
142142
}
@@ -149,7 +149,7 @@ protected function escapeControlCharacters($string)
149149
*/
150150
protected function escapeEscapeCharacter($string)
151151
{
152-
return preg_replace('/_(x[\dA-F]{4})_/', '_x005F_$1_', $string);
152+
return \preg_replace('/_(x[\dA-F]{4})_/', '_x005F_$1_', $string);
153153
}
154154

155155
/**
@@ -171,7 +171,7 @@ protected function unescapeControlCharacters($string)
171171

172172
foreach ($this->controlCharactersEscapingMap as $escapedCharValue => $charValue) {
173173
// only unescape characters that don't contain the escaped escape character for now
174-
$unescapedString = preg_replace("/(?<!_x005F)($escapedCharValue)/", $charValue, $unescapedString);
174+
$unescapedString = \preg_replace("/(?<!_x005F)($escapedCharValue)/", $charValue, $unescapedString);
175175
}
176176

177177
return $this->unescapeEscapeCharacter($unescapedString);
@@ -185,6 +185,6 @@ protected function unescapeControlCharacters($string)
185185
*/
186186
protected function unescapeEscapeCharacter($string)
187187
{
188-
return preg_replace('/_x005F(_x[\dA-F]{4}_)/', '$1', $string);
188+
return \preg_replace('/_x005F(_x[\dA-F]{4}_)/', '$1', $string);
189189
}
190190
}

src/Spout/Common/Helper/FileSystemHelper.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class FileSystemHelper implements FileSystemHelperInterface
1919
*/
2020
public function __construct($baseFolderPath)
2121
{
22-
$this->baseFolderRealPath = realpath($baseFolderPath);
22+
$this->baseFolderRealPath = \realpath($baseFolderPath);
2323
}
2424

2525
/**
@@ -36,7 +36,7 @@ public function createFolder($parentFolderPath, $folderName)
3636

3737
$folderPath = $parentFolderPath . '/' . $folderName;
3838

39-
$wasCreationSuccessful = mkdir($folderPath, 0777, true);
39+
$wasCreationSuccessful = \mkdir($folderPath, 0777, true);
4040
if (!$wasCreationSuccessful) {
4141
throw new IOException("Unable to create folder: $folderPath");
4242
}
@@ -60,7 +60,7 @@ public function createFileWithContents($parentFolderPath, $fileName, $fileConten
6060

6161
$filePath = $parentFolderPath . '/' . $fileName;
6262

63-
$wasCreationSuccessful = file_put_contents($filePath, $fileContents);
63+
$wasCreationSuccessful = \file_put_contents($filePath, $fileContents);
6464
if ($wasCreationSuccessful === false) {
6565
throw new IOException("Unable to create file: $filePath");
6666
}
@@ -79,8 +79,8 @@ public function deleteFile($filePath)
7979
{
8080
$this->throwIfOperationNotInBaseFolder($filePath);
8181

82-
if (file_exists($filePath) && is_file($filePath)) {
83-
unlink($filePath);
82+
if (\file_exists($filePath) && \is_file($filePath)) {
83+
\unlink($filePath);
8484
}
8585
}
8686

@@ -102,13 +102,13 @@ public function deleteFolderRecursively($folderPath)
102102

103103
foreach ($itemIterator as $item) {
104104
if ($item->isDir()) {
105-
rmdir($item->getPathname());
105+
\rmdir($item->getPathname());
106106
} else {
107-
unlink($item->getPathname());
107+
\unlink($item->getPathname());
108108
}
109109
}
110110

111-
rmdir($folderPath);
111+
\rmdir($folderPath);
112112
}
113113

114114
/**
@@ -122,8 +122,8 @@ public function deleteFolderRecursively($folderPath)
122122
*/
123123
protected function throwIfOperationNotInBaseFolder($operationFolderPath)
124124
{
125-
$operationFolderRealPath = realpath($operationFolderPath);
126-
$isInBaseFolder = (strpos($operationFolderRealPath, $this->baseFolderRealPath) === 0);
125+
$operationFolderRealPath = \realpath($operationFolderPath);
126+
$isInBaseFolder = (\strpos($operationFolderRealPath, $this->baseFolderRealPath) === 0);
127127
if (!$isInBaseFolder) {
128128
throw new IOException("Cannot perform I/O operation outside of the base folder: {$this->baseFolderRealPath}");
129129
}

0 commit comments

Comments
 (0)