Browse Source

DX: use numeric_literal_separator (#6766)

Dariusz Rumiński 2 years ago
parent
commit
fd5d09309d

+ 1 - 1
.php-cs-fixer.php-highest.php

@@ -12,7 +12,7 @@ declare(strict_types=1);
  * with this source code in the file LICENSE.
  */
 
-if (PHP_VERSION_ID < 80100 || PHP_VERSION_ID >= 80200) {
+if (PHP_VERSION_ID < 8_01_00 || PHP_VERSION_ID >= 8_02_00) {
     fwrite(STDERR, "PHP CS Fixer's config for PHP-HIGHEST can be executed only on highest supported PHP version - 8.1.*.\n");
     fwrite(STDERR, "Running it on lower PHP version would prevent calling migration rules.\n");
 

+ 1 - 1
.php-cs-fixer.php-lowest.php

@@ -12,7 +12,7 @@ declare(strict_types=1);
  * with this source code in the file LICENSE.
  */
 
-if (PHP_VERSION_ID < 70400 || PHP_VERSION_ID >= 70500) {
+if (PHP_VERSION_ID < 7_04_00 || PHP_VERSION_ID >= 7_05_00) {
     fwrite(STDERR, "PHP CS Fixer's config for PHP-LOWEST can be executed only on lowest supported PHP version - ~7.4.0.\n");
     fwrite(STDERR, "Running it on higher PHP version would falsy expect more changes, eg `mixed` type on PHP 8.\n");
 

+ 5 - 5
src/AbstractPhpdocToTypeDeclarationFixer.php

@@ -37,10 +37,10 @@ abstract class AbstractPhpdocToTypeDeclarationFixer extends AbstractFixer implem
      * @var array<string, int>
      */
     private array $versionSpecificTypes = [
-        'void' => 70100,
-        'iterable' => 70100,
-        'object' => 70200,
-        'mixed' => 80000,
+        'void' => 7_01_00,
+        'iterable' => 7_01_00,
+        'object' => 7_02_00,
+        'mixed' => 8_00_00,
     ];
 
     /**
@@ -186,7 +186,7 @@ abstract class AbstractPhpdocToTypeDeclarationFixer extends AbstractFixer implem
             return null;
         }
 
-        if ('static' === $commonType && (!$isReturnType || \PHP_VERSION_ID < 80000)) {
+        if ('static' === $commonType && (!$isReturnType || \PHP_VERSION_ID < 8_00_00)) {
             $commonType = 'self';
         }
 

+ 1 - 1
src/Fixer/ArrayNotation/NoWhitespaceBeforeCommaInArrayFixer.php

@@ -51,7 +51,7 @@ final class NoWhitespaceBeforeCommaInArrayFixer extends AbstractFixer implements
                             ];
 
                         PHP,
-                    new VersionSpecification(70300),
+                    new VersionSpecification(7_03_00),
                     ['after_heredoc' => true]
                 ),
             ]

+ 3 - 3
src/Fixer/Basic/CurlyBracesPositionFixer.php

@@ -78,7 +78,7 @@ $foo = new class
 {
 };
 ',
-                    new VersionSpecification(70000)
+                    new VersionSpecification(7_00_00)
                 ),
                 new CodeSample(
                     '<?php
@@ -116,7 +116,7 @@ class Foo
 $foo = new class {
 };
 ',
-                    new VersionSpecification(70000),
+                    new VersionSpecification(7_00_00),
                     ['anonymous_classes_opening_brace' => self::NEXT_LINE_UNLESS_NEWLINE_AT_SIGNATURE_END]
                 ),
                 new VersionSpecificCodeSample(
@@ -124,7 +124,7 @@ $foo = new class {
 $foo = new class { };
 $bar = new class { private $baz; };
 ',
-                    new VersionSpecification(70000),
+                    new VersionSpecification(7_00_00),
                     ['allow_single_line_empty_anonymous_classes' => true]
                 ),
                 new CodeSample(

+ 2 - 2
src/Fixer/Basic/OctalNotationFixer.php

@@ -35,7 +35,7 @@ final class OctalNotationFixer extends AbstractFixer
             [
                 new VersionSpecificCodeSample(
                     "<?php \$foo = 0123;\n",
-                    new VersionSpecification(80100)
+                    new VersionSpecification(8_01_00)
                 ),
             ]
         );
@@ -46,7 +46,7 @@ final class OctalNotationFixer extends AbstractFixer
      */
     public function isCandidate(Tokens $tokens): bool
     {
-        return \PHP_VERSION_ID >= 80100 && $tokens->isTokenKindFound(T_LNUMBER);
+        return \PHP_VERSION_ID >= 8_01_00 && $tokens->isTokenKindFound(T_LNUMBER);
     }
 
     /**

+ 4 - 4
src/Fixer/Casing/NativeFunctionTypeDeclarationCasingFixer.php

@@ -72,18 +72,18 @@ final class NativeFunctionTypeDeclarationCasingFixer extends AbstractFixer
             'void' => true,
         ];
 
-        if (\PHP_VERSION_ID >= 80000) {
+        if (\PHP_VERSION_ID >= 8_00_00) {
             $this->hints['false'] = true;
             $this->hints['mixed'] = true;
             $this->hints['null'] = true;
             $this->hints['static'] = true;
         }
 
-        if (\PHP_VERSION_ID >= 80100) {
+        if (\PHP_VERSION_ID >= 8_01_00) {
             $this->hints['never'] = true;
         }
 
-        if (\PHP_VERSION_ID >= 80200) {
+        if (\PHP_VERSION_ID >= 8_02_00) {
             $this->hints['true'] = true;
         }
 
@@ -107,7 +107,7 @@ final class NativeFunctionTypeDeclarationCasingFixer extends AbstractFixer
                 ),
                 new VersionSpecificCodeSample(
                     "<?php\nfunction Foo(Object \$a)\n{\n    return 'hi!';\n}\n",
-                    new VersionSpecification(70200)
+                    new VersionSpecification(7_02_00)
                 ),
             ]
         );

+ 2 - 2
src/Fixer/CastNotation/LowercaseCastFixer.php

@@ -48,7 +48,7 @@ final class LowercaseCastFixer extends AbstractFixer
     $a = (UNset) $b;
     $a = (Binary) $b;
 ',
-                    new VersionSpecification(null, 70399)
+                    new VersionSpecification(null, 7_03_99)
                 ),
                 new VersionSpecificCodeSample(
                     '<?php
@@ -65,7 +65,7 @@ final class LowercaseCastFixer extends AbstractFixer
     $a = (UNset) $b;
     $a = (Binary) $b;
 ',
-                    new VersionSpecification(70400)
+                    new VersionSpecification(7_04_00)
                 ),
             ]
         );

+ 2 - 2
src/Fixer/CastNotation/ShortScalarCastFixer.php

@@ -34,11 +34,11 @@ final class ShortScalarCastFixer extends AbstractFixer
             [
                 new VersionSpecificCodeSample(
                     "<?php\n\$a = (boolean) \$b;\n\$a = (integer) \$b;\n\$a = (double) \$b;\n\$a = (real) \$b;\n\n\$a = (binary) \$b;\n",
-                    new VersionSpecification(null, 70399)
+                    new VersionSpecification(null, 7_03_99)
                 ),
                 new VersionSpecificCodeSample(
                     "<?php\n\$a = (boolean) \$b;\n\$a = (integer) \$b;\n\$a = (double) \$b;\n\n\$a = (binary) \$b;\n",
-                    new VersionSpecification(70400)
+                    new VersionSpecification(7_04_00)
                 ),
             ]
         );

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

@@ -146,7 +146,7 @@ class Sample
     public $e;
 }
 ',
-                    new VersionSpecification(80000),
+                    new VersionSpecification(8_00_00),
                     ['elements' => ['property' => self::SPACING_ONLY_IF_META]]
                 ),
             ]

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