Skip to content

Commit

Permalink
Implement use of the new Collections::$ternaryOperators() token array
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfnl committed May 10, 2024
1 parent b0c51c1 commit 1510a86
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions PHPCSUtils/AbstractSniffs/AbstractArrayDeclarationSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ abstract class AbstractArrayDeclarationSniff implements Sniff
\T_DNUMBER => \T_DNUMBER,
\T_CONSTANT_ENCAPSED_STRING => \T_CONSTANT_ENCAPSED_STRING,
\T_STRING_CONCAT => \T_STRING_CONCAT,
\T_INLINE_THEN => \T_INLINE_THEN,
\T_INLINE_ELSE => \T_INLINE_ELSE,
\T_BOOLEAN_NOT => \T_BOOLEAN_NOT,
];

Expand All @@ -143,6 +141,7 @@ final public function __construct()
$this->acceptedTokens += Tokens::$castTokens;
$this->acceptedTokens += Tokens::$bracketTokens;
$this->acceptedTokens += Tokens::$heredocTokens;
$this->acceptedTokens += Collections::ternaryOperators();
}

/**
Expand Down
3 changes: 1 addition & 2 deletions PHPCSUtils/Utils/Operators.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ final class Operators
\T_OPEN_SHORT_ARRAY => true,
\T_OPEN_CURLY_BRACKET => true,
\T_COLON => true,
\T_INLINE_THEN => true,
\T_INLINE_ELSE => true,
\T_CASE => true,
\T_FN_ARROW => true,
\T_MATCH_ARROW => true,
Expand Down Expand Up @@ -206,6 +204,7 @@ public static function isUnaryPlusMinus(File $phpcsFile, $stackPtr)
|| isset(Tokens::$booleanOperators[$tokens[$prev]['code']]) === true
|| isset(Tokens::$assignmentTokens[$tokens[$prev]['code']]) === true
|| isset(Tokens::$castTokens[$tokens[$prev]['code']]) === true
|| isset(Collections::ternaryOperators()[$tokens[$prev]['code']]) === true
|| isset(self::$extraUnaryIndicators[$tokens[$prev]['code']]) === true
) {
return true;
Expand Down

0 comments on commit 1510a86

Please sign in to comment.