Browse Source

chore: cleanup tests that had `@requires PHP 7.4` ages ago (#8122)

Kuba Werłos 7 months ago
parent
commit
71187b8c2b

+ 1 - 1
phpstan.dist.neon

@@ -53,6 +53,6 @@ parameters:
         -
             message: '#^Method PhpCsFixer\\Tests\\.+::provide.+Cases\(\) return type has no value type specified in iterable type iterable\.$#'
             path: tests
-            count: 1013
+            count: 1009
     tipsOfTheDay: false
     tmpDir: dev-tools/phpstan/cache

+ 18 - 46
tests/Fixer/ControlStructure/YodaStyleFixerTest.php

@@ -877,6 +877,24 @@ switch ($a) {
             '<?php function test() {return yield from 1 === $a ? $c : $d;};',
             '<?php function test() {return yield from $a === 1 ? $c : $d;};',
         ];
+
+        yield [
+            '<?php if (1_000 === $b);',
+            '<?php if ($b === 1_000);',
+        ];
+
+        yield [
+            '<?php fn() => $c === array(1) ? $b : $d;',
+            null,
+            [
+                'less_and_greater' => false,
+            ],
+        ];
+
+        yield [
+            '<?php $a ??= 4 === $b ? 2 : 3;',
+            '<?php $a ??= $b === 4 ? 2 : 3;',
+        ];
     }
 
     /**
@@ -1089,52 +1107,6 @@ while (2 !== $b = array_pop($c));
         ];
     }
 
-    /**
-     * @dataProvider provideFixPhp74Cases
-     */
-    public function testFixPhp74(string $expected, ?string $input): void
-    {
-        $this->doTest($expected, $input);
-    }
-
-    public static function provideFixPhp74Cases(): iterable
-    {
-        yield [
-            '<?php if (1_000 === $b);',
-            '<?php if ($b === 1_000);',
-        ];
-    }
-
-    /**
-     * Test with the inverse config.
-     *
-     * @param _AutogeneratedInputConfiguration $configuration
-     *
-     * @dataProvider providePHP74CasesInverseCases
-     */
-    public function testPHP74CasesInverse(string $expected, ?string $input = null, array $configuration = []): void
-    {
-        $this->fixer->configure($configuration);
-
-        $this->doTest($expected, $input);
-    }
-
-    public static function providePHP74CasesInverseCases(): iterable
-    {
-        yield [
-            '<?php fn() => $c === array(1) ? $b : $d;',
-            null,
-            [
-                'less_and_greater' => false,
-            ],
-        ];
-
-        yield [
-            '<?php $a ??= 4 === $b ? 2 : 3;',
-            '<?php $a ??= $b === 4 ? 2 : 3;',
-        ];
-    }
-
     /**
      * @dataProvider provideFixPrePHP80Cases
      *

+ 18 - 33
tests/Fixer/Operator/BinaryOperatorSpacesFixerTest.php

@@ -560,6 +560,24 @@ $a = $ae?? $b;
             null,
             ['operators' => ['|' => BinaryOperatorSpacesFixer::NO_SPACE]],
         ];
+
+        yield [
+            '<?php
+                    $a = fn() => null;
+                    $b = fn() => null;
+                ',
+            '<?php
+                    $a = fn()    =>      null;
+                    $b = fn()      =>  null;
+                ',
+            ['operators' => ['=>' => BinaryOperatorSpacesFixer::ALIGN_SINGLE_SPACE_MINIMAL]],
+        ];
+
+        yield [
+            '<?php $a ??= 1;',
+            '<?php $a??=1;',
+            ['operators' => ['??=' => BinaryOperatorSpacesFixer::ALIGN_SINGLE_SPACE]],
+        ];
     }
 
     /**
@@ -3276,39 +3294,6 @@ function test()
         );
     }
 
-    /**
-     * @param _AutogeneratedInputConfiguration $configuration
-     *
-     * @dataProvider provideFixPhp74Cases
-     */
-    public function testFixPhp74(string $expected, ?string $input = null, array $configuration = []): void
-    {
-        $this->fixer->configure($configuration);
-
-        $this->doTest($expected, $input);
-    }
-
-    public static function provideFixPhp74Cases(): iterable
-    {
-        yield [
-            '<?php
-                    $a = fn() => null;
-                    $b = fn() => null;
-                ',
-            '<?php
-                    $a = fn()    =>      null;
-                    $b = fn()      =>  null;
-                ',
-            ['operators' => ['=>' => BinaryOperatorSpacesFixer::ALIGN_SINGLE_SPACE_MINIMAL]],
-        ];
-
-        yield [
-            '<?php $a ??= 1;',
-            '<?php $a??=1;',
-            ['operators' => ['??=' => BinaryOperatorSpacesFixer::ALIGN_SINGLE_SPACE]],
-        ];
-    }
-
     /**
      * @requires PHP 8.0
      */

+ 0 - 17
tests/Tokenizer/TokensAnalyzerTest.php

@@ -969,24 +969,7 @@ preg_replace_callback(
                         return [];
                     };',
         ];
-    }
-
-    /**
-     * @param array<int, bool> $expected
-     *
-     * @dataProvider provideIsLambda74Cases
-     */
-    public function testIsLambda74(array $expected, string $source): void
-    {
-        $tokensAnalyzer = new TokensAnalyzer(Tokens::fromCode($source));
 
-        foreach ($expected as $index => $expectedValue) {
-            self::assertSame($expectedValue, $tokensAnalyzer->isLambda($index));
-        }
-    }
-
-    public static function provideIsLambda74Cases(): iterable
-    {
         yield [
             [5 => true],
             '<?php $fn = fn() => [];',