Skip to content

Commit c9171c0

Browse files
mmollxalopp
authored andcommitted
prefer builtin-functions for performance
refs GH-80
1 parent b231537 commit c9171c0

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

MO4/Sniffs/Arrays/ArrayDoubleArrowAlignmentSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function process(File $phpcsFile, $stackPtr)
8484
$previous = $tokens[($i - 1)];
8585

8686
// Skip nested arrays.
87-
if (in_array($current['code'], $this->arrayTokens, true) === true) {
87+
if (\in_array($current['code'], $this->arrayTokens, true) === true) {
8888
if ($current['code'] === T_ARRAY) {
8989
$i = ($current['parenthesis_closer'] + 1);
9090
} else {
@@ -114,7 +114,7 @@ public function process(File $phpcsFile, $stackPtr)
114114

115115
$j = ($i - 1);
116116
while (($j >= 0) && ($tokens[$j]['line'] === $current['line'])) {
117-
if (in_array($tokens[$j]['code'], PHP_CodeSniffer_Tokens::$emptyTokens, true) === false) {
117+
if (\in_array($tokens[$j]['code'], PHP_CodeSniffer_Tokens::$emptyTokens, true) === false) {
118118
$hasKeyInLine = true;
119119
}
120120

MO4/Sniffs/Formatting/AlphabeticalUseStatementsSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class AlphabeticalUseStatementsSniff extends UseDeclarationSniff
8888
*/
8989
public function process(File $phpcsFile, $stackPtr)
9090
{
91-
if (in_array($this->order, $this->supportedOrderingMethods, true) === false) {
91+
if (\in_array($this->order, $this->supportedOrderingMethods, true) === false) {
9292
$error = sprintf(
9393
"'%s' is not a valid order function for %s! Pick one of: %s",
9494
$this->order,
@@ -369,7 +369,7 @@ private function compareString($a, $b)
369369
*/
370370
private function dictionaryCompare($a, $b)
371371
{
372-
$min = min(strlen($a), strlen($b));
372+
$min = min(\strlen($a), \strlen($b));
373373

374374
for ($i = 0; $i < $min; $i++) {
375375
if ($a[$i] === $b[$i]) {

MO4/Sniffs/Formatting/UnnecessaryNamespaceUsageSniff.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public function process(File $phpcsFile, $stackPtr)
150150
-1,
151151
PREG_SPLIT_NO_EMPTY
152152
);
153-
$docLineTokens = array_slice(
153+
$docLineTokens = \array_slice(
154154
$docLineTokens,
155155
0,
156156
$docCommentTags[$content]
@@ -163,7 +163,7 @@ public function process(File $phpcsFile, $stackPtr)
163163
PREG_SPLIT_NO_EMPTY
164164
);
165165
foreach ($typeTokens as $typeToken) {
166-
if (true === in_array($typeToken, $useStatements, true)) {
166+
if (true === \in_array($typeToken, $useStatements, true)) {
167167
continue;
168168
}
169169

@@ -365,7 +365,7 @@ private function checkShorthandPossible(
365365

366366
$replaceClassName = true;
367367
} else if ($namespace !== "" && strpos($fullClassName, $namespace) === 0) {
368-
$replacement = substr($fullClassName, strlen($namespace));
368+
$replacement = substr($fullClassName, \strlen($namespace));
369369

370370
$data = [
371371
$className,

MO4/Sniffs/Strings/VariableInDoubleQuotedStringSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public function process(File $phpcsFile, $stackPtr)
130130
private function surroundVariableWithBraces($content, $pos, $var)
131131
{
132132
$before = substr($content, 0, $pos);
133-
$after = substr($content, ($pos + strlen($var)));
133+
$after = substr($content, ($pos + \strlen($var)));
134134

135135
return $before.'{'.$var.'}'.$after;
136136

0 commit comments

Comments
 (0)