Skip to content

Commit f61d205

Browse files
authored
Merge pull request #60 from mmoll/minor_fixes
minor optimizations
2 parents f60bda1 + 91e5dfa commit f61d205

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

MO4/Sniffs/Arrays/ArrayDoubleArrowAlignmentSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public function process(File $phpcsFile, $stackPtr)
121121

122122
$j = ($i - 1);
123123
while (($j >= 0) && ($tokens[$j]['line'] === $current['line'])) {
124-
if ((in_array($tokens[$j]['code'], PHP_CodeSniffer_Tokens::$emptyTokens)) === false) {
124+
if (in_array($tokens[$j]['code'], PHP_CodeSniffer_Tokens::$emptyTokens, true) === false) {
125125
$hasKeyInLine = true;
126126
}
127127

MO4/Sniffs/Commenting/PropertyCommentSniff.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ class PropertyCommentSniff extends AbstractScopeSniff
5353

5454
/**
5555
* Construct PropertyCommentSniff
56+
*
57+
* @throws \PHP_CodeSniffer\Exceptions\RuntimeException
5658
*/
5759
public function __construct()
5860
{
@@ -153,9 +155,9 @@ protected function processTokenWithinScope(
153155
$this->myTokenTypes,
154156
$commentEnd
155157
);
156-
if ($tokens[$commentStart]['line'] === $tokens[$commentEnd]['line']
158+
if ($firstTokenOnLine !== false
159+
&& $tokens[$commentStart]['line'] === $tokens[$commentEnd]['line']
157160
&& $tokens[$stackPtr]['line'] > $tokens[$commentEnd]['line']
158-
&& $firstTokenOnLine !== false
159161
) {
160162
return;
161163
}

MO4/Sniffs/Formatting/AlphabeticalUseStatementsSniff.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class AlphabeticalUseStatementsSniff extends UseDeclarationSniff
9494
*/
9595
public function register()
9696
{
97-
if (in_array($this->order, $this->supportedOrderingMethods) === false) {
97+
if (in_array($this->order, $this->supportedOrderingMethods, true) === false) {
9898
$error = sprintf(
9999
"'%s' is not a valid order function for %s! Pick one of: %s",
100100
$this->order,
@@ -360,15 +360,15 @@ private function findNewDestination(
360360
*/
361361
private function compareString($a, $b)
362362
{
363-
if ('dictionary' === $this->order) {
364-
return $this->dictionaryCompare($a, $b);
365-
} else if ('string' === $this->order) {
363+
switch ($this->order) {
364+
case 'string':
366365
return strcmp($a, $b);
367-
} else if ('string-locale' === $this->order) {
366+
case 'string-locale':
368367
return strcoll($a, $b);
369-
} else if ('string-case-insensitive' === $this->order) {
368+
case 'string-case-insensitive':
370369
return strcasecmp($a, $b);
371-
} else {
370+
default:
371+
// Default is 'dictionary'.
372372
return $this->dictionaryCompare($a, $b);
373373
}
374374

MO4/Sniffs/Formatting/UnnecessaryNamespaceUsageSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function process(File $phpcsFile, $stackPtr)
103103

104104
if ($tokens[$nsSep]['code'] === T_NS_SEPARATOR) {
105105
if ($tokens[($nsSep - 1)]['code'] === T_STRING) {
106-
$nsSep -= 1;
106+
--$nsSep;
107107
}
108108

109109
$className = $phpcsFile->getTokensAsString(
@@ -124,7 +124,7 @@ public function process(File $phpcsFile, $stackPtr)
124124
// Doc comment block.
125125
foreach ($tokens[$nsSep]['comment_tags'] as $tag) {
126126
$content = $tokens[$tag]['content'];
127-
if ((array_key_exists($content, $docCommentTags)) === false) {
127+
if (array_key_exists($content, $docCommentTags) === false) {
128128
continue;
129129
}
130130

0 commit comments

Comments
 (0)