Browse Source

Follow newest CS

Dariusz Ruminski 7 years ago
parent
commit
8bebec4323

+ 1 - 1
src/AbstractPhpdocTypesFixer.php

@@ -130,7 +130,7 @@ abstract class AbstractPhpdocTypesFixer extends AbstractFixer
      */
     private function normalizeType($type)
     {
-        if (substr($type, -2) === '[]') {
+        if ('[]' === substr($type, -2)) {
             return $this->normalize(substr($type, 0, -2)).'[]';
         }
 

+ 3 - 3
src/ConfigInterface.php

@@ -37,7 +37,7 @@ interface ConfigInterface
     /**
      * Returns files to scan.
      *
-     * @return iterable|\Traversable|string[]
+     * @return iterable|string[]|\Traversable
      */
     public function getFinder();
 
@@ -107,7 +107,7 @@ interface ConfigInterface
      *
      * Name of custom fixer should follow `VendorName/rule_name` convention.
      *
-     * @param iterable|\Traversable|FixerInterface[] $fixers
+     * @param FixerInterface[]|iterable|\Traversable $fixers
      */
     public function registerCustomFixers($fixers);
 
@@ -121,7 +121,7 @@ interface ConfigInterface
     public function setCacheFile($cacheFile);
 
     /**
-     * @param iterable|\Traversable|string[] $finder
+     * @param iterable|string[]|\Traversable $finder
      *
      * @return self
      */

+ 1 - 1
src/Console/ConfigurationResolver.php

@@ -611,7 +611,7 @@ final class ConfigurationResolver
 
         $rules = trim($this->options['rules']);
 
-        if ($rules[0] === '{') {
+        if ('{' === $rules[0]) {
             $rules = json_decode($rules, true);
             if (JSON_ERROR_NONE !== json_last_error()) {
                 throw new InvalidConfigurationException(sprintf('Invalid JSON rules input: %s.', json_last_error_msg()));

+ 3 - 3
src/Error/ErrorsManager.php

@@ -36,7 +36,7 @@ final class ErrorsManager
     public function getInvalidErrors()
     {
         return array_filter($this->errors, function (Error $error) {
-            return $error->getType() === Error::TYPE_INVALID;
+            return Error::TYPE_INVALID === $error->getType();
         });
     }
 
@@ -48,7 +48,7 @@ final class ErrorsManager
     public function getExceptionErrors()
     {
         return array_filter($this->errors, function (Error $error) {
-            return $error->getType() === Error::TYPE_EXCEPTION;
+            return Error::TYPE_EXCEPTION === $error->getType();
         });
     }
 
@@ -60,7 +60,7 @@ final class ErrorsManager
     public function getLintErrors()
     {
         return array_filter($this->errors, function (Error $error) {
-            return $error->getType() === Error::TYPE_LINT;
+            return Error::TYPE_LINT === $error->getType();
         });
     }
 

+ 7 - 7
src/Fixer/Basic/BracesFixer.php

@@ -756,18 +756,18 @@ class Foo
 
     private function getControlContinuationTokensForOpeningToken($openingTokenKind)
     {
-        if ($openingTokenKind === T_IF) {
+        if (T_IF === $openingTokenKind) {
             return array(
                 T_ELSE,
                 T_ELSEIF,
             );
         }
 
-        if ($openingTokenKind === T_DO) {
+        if (T_DO === $openingTokenKind) {
             return array(T_WHILE);
         }
 
-        if ($openingTokenKind === T_TRY) {
+        if (T_TRY === $openingTokenKind) {
             $tokens = array(T_CATCH);
             if (defined('T_FINALLY')) {
                 $tokens[] = T_FINALLY;
@@ -781,11 +781,11 @@ class Foo
 
     private function getFinalControlContinuationTokensForOpeningToken($openingTokenKind)
     {
-        if ($openingTokenKind === T_IF) {
+        if (T_IF === $openingTokenKind) {
             return array(T_ELSE);
         }
 
-        if ($openingTokenKind === T_TRY && defined('T_FINALLY')) {
+        if (T_TRY === $openingTokenKind && defined('T_FINALLY')) {
             return array(T_FINALLY);
         }
 
@@ -849,7 +849,7 @@ class Foo
             $previousToken = $tokens[$nextTokenIndex - 1];
             // do not indent inline comments used to comment out unused code
             if (
-                (0 === strpos($nextToken->getContent(), '//'.$this->whitespacesConfig->getIndent()) || $nextToken->getContent() === '//')
+                (0 === strpos($nextToken->getContent(), '//'.$this->whitespacesConfig->getIndent()) || '//' === $nextToken->getContent())
                 && $previousToken->isWhitespace() && 1 === preg_match('/\R$/', $previousToken->getContent())
             ) {
                 return;
@@ -946,7 +946,7 @@ class Foo
      * @param int    $index
      * @param bool   $after
      *
-     * @return int|null
+     * @return null|int
      */
     private function getSiblingContinuousSingleLineComment(Tokens $tokens, $index, $after)
     {

+ 1 - 1
src/Fixer/ClassNotation/NoPhp4ConstructorFixer.php

@@ -374,7 +374,7 @@ class Foo
         } else {
             // find method body start and the end of the function definition
             $bodyStart = $tokens->getNextTokenOfKind($function[2], array('{'));
-            $funcEnd = $bodyStart !== null ? $tokens->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $bodyStart) : null;
+            $funcEnd = null !== $bodyStart ? $tokens->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $bodyStart) : null;
         }
 
         return array(

+ 1 - 1
src/Fixer/ClassNotation/OrderedClassElementsFixer.php

@@ -319,7 +319,7 @@ array('order' => array('method_private', 'method_public'))
      * @param Tokens $tokens
      * @param int    $index
      *
-     * @return string|array type or array of type and name
+     * @return array|string type or array of type and name
      */
     private function detectElementType(Tokens $tokens, $index)
     {

+ 6 - 6
src/Fixer/ClassNotation/VisibilityRequiredFixer.php

@@ -185,7 +185,7 @@ class Sample
      * @param Tokens $tokens Tokens collection
      * @param int    $index  token index
      *
-     * @return array<string, Token|null> map of grabbed attributes, key is attribute name and value is array of index and clone of Token
+     * @return array<string, null|Token> map of grabbed attributes, key is attribute name and value is array of index and clone of Token
      */
     private function grabAttribsBeforeMethodToken(Tokens $tokens, $index)
     {
@@ -218,7 +218,7 @@ class Sample
      *
      * @param Tokens                    $tokens      Tokens collection
      * @param int                       $memberIndex token index
-     * @param array<string, Token|null> $attribs     map of grabbed attributes, key is attribute name and value is array of index and clone of Token
+     * @param array<string, null|Token> $attribs     map of grabbed attributes, key is attribute name and value is array of index and clone of Token
      */
     private function overrideAttribs(Tokens $tokens, $memberIndex, array $attribs)
     {
@@ -253,7 +253,7 @@ class Sample
      * @param Tokens $tokens Tokens collection
      * @param int    $index  token index
      *
-     * @return array<string, Token|null> map of grabbed attributes, key is attribute name and value is array of index and clone of Token
+     * @return array<string, null|Token> map of grabbed attributes, key is attribute name and value is array of index and clone of Token
      */
     private function grabAttribsBeforePropertyToken(Tokens $tokens, $index)
     {
@@ -281,10 +281,10 @@ class Sample
      *
      * @param Tokens                    $tokens          Tokens collection
      * @param int                       $index           token index
-     * @param array<int, string|null>   $tokenAttribsMap token to attribute name map
-     * @param array<string, Token|null> $attribs         array of token attributes
+     * @param array<int, null|string>   $tokenAttribsMap token to attribute name map
+     * @param array<string, null|Token> $attribs         array of token attributes
      *
-     * @return array<string, Token|null> map of grabbed attributes, key is attribute name and value is array of index and clone of Token
+     * @return array<string, null|Token> map of grabbed attributes, key is attribute name and value is array of index and clone of Token
      */
     private function grabAttribsBeforeToken(Tokens $tokens, $index, array $tokenAttribsMap, array $attribs)
     {

+ 2 - 1
src/Fixer/ControlStructure/NoUselessElseFixer.php

@@ -263,7 +263,8 @@ final class NoUselessElseFixer extends AbstractFixer
 
             if ($token->equals(';', '}')) {
                 return false;
-            } elseif ($token->equals('{')) {
+            }
+            if ($token->equals('{')) {
                 $index = $tokens->getPrevMeaningfulToken($index);
 
                 // OK if belongs to: for, do, while, foreach

+ 1 - 1
src/Fixer/FunctionNotation/NativeFunctionInvocationFixer.php

@@ -153,7 +153,7 @@ function baz($options)
             ->setAllowedTypes(array('array'))
             ->setAllowedValues(array(function ($value) {
                 foreach ($value as $functionName) {
-                    if (!\is_string($functionName) || \trim($functionName) === '' || \trim($functionName) !== $functionName) {
+                    if (!\is_string($functionName) || '' === \trim($functionName) || \trim($functionName) !== $functionName) {
                         throw new InvalidOptionsException(\sprintf(
                             'Each element must be a non-empty, trimmed string, got "%s" instead.',
                             \is_object($functionName) ? \get_class($functionName) : \gettype($functionName)

Some files were not shown because too many files changed in this diff