Skip to content

Commit

Permalink
Optimize boolean conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoll committed Jan 26, 2025
1 parent 39b264f commit c811a43
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions MO4/Sniffs/Arrays/ArrayDoubleArrowAlignmentSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function process(File $phpcsFile, $stackPtr): void
$previous = $tokens[($i - 1)];

// Skip nested arrays.
if (true === \in_array($current['code'], $this->arrayTokens, true)) {
if (\in_array($current['code'], $this->arrayTokens, true)) {
$i = T_ARRAY === $current['code'] ? ($current['parenthesis_closer'] + 1) : ($current['bracket_closer'] + 1);

continue;
Expand Down Expand Up @@ -147,7 +147,7 @@ public function process(File $phpcsFile, $stackPtr): void
$j = ($i - 1);

while (($j >= 0) && ($tokens[$j]['line'] === $current['line'])) {
if (false === \in_array($tokens[$j]['code'], PHP_CodeSniffer_Tokens::$emptyTokens, true)) {
if (!\in_array($tokens[$j]['code'], PHP_CodeSniffer_Tokens::$emptyTokens, true)) {
$hasKeyInLine = true;
}

Expand Down
2 changes: 1 addition & 1 deletion MO4/Sniffs/Formatting/AlphabeticalUseStatementsSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class AlphabeticalUseStatementsSniff extends UseDeclarationSniff
*/
public function process(File $phpcsFile, $stackPtr): void
{
if (false === \in_array($this->order, self::SUPPORTED_ORDERING_METHODS, true)) {
if (!\in_array($this->order, self::SUPPORTED_ORDERING_METHODS, true)) {
$error = \sprintf(
"'%s' is not a valid order function for %s! Pick one of: %s",
$this->order,
Expand Down
6 changes: 3 additions & 3 deletions MO4/Sniffs/Formatting/UnnecessaryNamespaceUsageSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function process(File $phpcsFile, $stackPtr): void
foreach ($tokens[$nsSep]['comment_tags'] as $tag) {
$content = $tokens[$tag]['content'];

if (false === \array_key_exists($content, $docCommentTags)) {
if (!\array_key_exists($content, $docCommentTags)) {
continue;
}

Expand Down Expand Up @@ -181,7 +181,7 @@ public function process(File $phpcsFile, $stackPtr): void
// phpcs:enable

foreach ($typeTokens as $typeToken) {
if (true === \in_array($typeToken, $useStatements, true)) {
if (\in_array($typeToken, $useStatements, true)) {
continue;
}

Expand Down Expand Up @@ -343,7 +343,7 @@ private function checkShorthandPossible(File $phpcsFile, array $useStatements, s

$fullClassName = $this->getFullyQualifiedClassName($className);

if (true === \array_key_exists($fullClassName, $useStatements)) {
if (\array_key_exists($fullClassName, $useStatements)) {
$replacement = $useStatements[$fullClassName];

$data = [
Expand Down

0 comments on commit c811a43

Please sign in to comment.