Browse Source

TokensAnalyzer.php - Fix T_ENCAPSED_AND_WHITESPACE handling in isBinaryOperator

SpacePossum 3 years ago
parent
commit
79f0872575

+ 1 - 1
src/AbstractPhpdocTypesFixer.php

@@ -66,7 +66,7 @@ abstract class AbstractPhpdocTypesFixer extends AbstractFixer
             $doc = new DocBlock($token->getContent());
             $annotations = $doc->getAnnotationsOfType($this->tags);
 
-            if (empty($annotations)) {
+            if (0 === \count($annotations)) {
                 continue;
             }
 

+ 2 - 4
src/Fixer/ClassNotation/NoPhp4ConstructorFixer.php

@@ -147,13 +147,11 @@ class Foo
         $php4 = $this->findFunction($tokens, $className, $classStart, $classEnd);
 
         if (null === $php4) {
-            // no PHP4-constructor!
-            return;
+            return; // no PHP4-constructor!
         }
 
         if (!empty($php4['modifiers'][T_ABSTRACT]) || !empty($php4['modifiers'][T_STATIC])) {
-            // PHP4 constructor can't be abstract or static
-            return;
+            return; // PHP4 constructor can't be abstract or static
         }
 
         $php5 = $this->findFunction($tokens, '__construct', $classStart, $classEnd);

+ 2 - 0
src/Fixer/Import/OrderedImportsFixer.php

@@ -477,6 +477,7 @@ use Bar;
         if (null !== $this->configuration['imports_order']) {
             // Grouping indexes by import type.
             $groupedByTypes = [];
+
             foreach ($indexes as $startIndex => $item) {
                 $groupedByTypes[$item['importType']][$startIndex] = $item;
             }
@@ -488,6 +489,7 @@ use Bar;
 
             // Ordering groups
             $sortedGroups = [];
+
             foreach ($this->configuration['imports_order'] as $type) {
                 if (isset($groupedByTypes[$type]) && !empty($groupedByTypes[$type])) {
                     foreach ($groupedByTypes[$type] as $startIndex => $item) {

+ 1 - 1
src/Fixer/PhpUnit/PhpUnitNamespacedFixer.php

@@ -216,8 +216,8 @@ final class MyTest extends \PHPUnit_Framework_TestCase
         }
 
         $parts = explode($delimiter, $string);
-
         $tokensArray = [];
+
         while (!empty($parts)) {
             $tokensArray[] = new Token([T_STRING, array_shift($parts)]);
             if (!empty($parts)) {

+ 5 - 2
src/Fixer/PhpUnit/PhpUnitSizeClassFixer.php

@@ -106,9 +106,11 @@ final class PhpUnitSizeClassFixer extends AbstractPhpUnitFixer implements Whites
     private function updateDocBlockIfNeeded(Tokens $tokens, int $docBlockIndex): void
     {
         $doc = new DocBlock($tokens[$docBlockIndex]->getContent());
-        if (!empty($this->filterDocBlock($doc))) {
+
+        if (0 !== \count($this->filterDocBlock($doc))) {
             return;
         }
+
         $doc = $this->makeDocBlockMultiLineIfNeeded($doc, $tokens, $docBlockIndex);
         $lines = $this->addSizeAnnotation($doc, $tokens, $docBlockIndex);
         $lines = implode('', $lines);
@@ -133,7 +135,8 @@ final class PhpUnitSizeClassFixer extends AbstractPhpUnitFixer implements Whites
     private function makeDocBlockMultiLineIfNeeded(DocBlock $doc, Tokens $tokens, int $docBlockIndex): DocBlock
     {
         $lines = $doc->getLines();
-        if (1 === \count($lines) && empty($this->filterDocBlock($doc))) {
+
+        if (1 === \count($lines) && 0 === \count($this->filterDocBlock($doc))) {
             $lines = $this->splitUpDocBlock($lines, $tokens, $docBlockIndex);
 
             return new DocBlock(implode('', $lines));

+ 1 - 1
src/Fixer/PhpUnit/PhpUnitTestAnnotationFixer.php

@@ -408,6 +408,6 @@ public function testItDoesSomething() {}}'.$this->whitespacesConfig->getLineEndi
 
     private function doesDocBlockContainTest(DocBlock $doc): bool
     {
-        return !empty($doc->getAnnotationsOfType('test'));
+        return 0 !== \count($doc->getAnnotationsOfType('test'));
     }
 }

+ 1 - 1
src/Fixer/PhpUnit/PhpUnitTestClassRequiresCoversFixer.php

@@ -86,7 +86,7 @@ final class MyTest extends \PHPUnit_Framework_TestCase
             $doc = new DocBlock($docContent);
 
             // skip if already has annotation
-            if (!empty($doc->getAnnotationsOfType([
+            if (0 !== \count($doc->getAnnotationsOfType([
                 'covers',
                 'coversDefaultClass',
                 'coversNothing',

+ 1 - 1
src/Fixer/Phpdoc/GeneralPhpdocAnnotationRemoveFixer.php

@@ -103,7 +103,7 @@ function foo() {}
             $annotations = $doc->getAnnotationsOfType($this->configuration['annotations']);
 
             // nothing to do if there are no annotations
-            if (empty($annotations)) {
+            if (0 === \count($annotations)) {
                 continue;
             }
 

+ 1 - 1
src/Fixer/Phpdoc/PhpdocAnnotationWithoutDotFixer.php

@@ -81,7 +81,7 @@ function foo ($bar) {}
             $doc = new DocBlock($token->getContent());
             $annotations = $doc->getAnnotations();
 
-            if (empty($annotations)) {
+            if (0 === \count($annotations)) {
                 continue;
             }
 

+ 1 - 1
src/Fixer/Phpdoc/PhpdocNoEmptyReturnFixer.php

@@ -88,7 +88,7 @@ function foo() {}
             $doc = new DocBlock($token->getContent());
             $annotations = $doc->getAnnotationsOfType('return');
 
-            if (empty($annotations)) {
+            if (0 === \count($annotations)) {
                 continue;
             }
 

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