Browse Source

chore: use numeric_literal_separator for project (#7713)

Dariusz Rumiński 1 year ago
parent
commit
04285823e0

+ 4 - 0
.php-cs-fixer.dist.php

@@ -44,6 +44,10 @@ return (new Config())
         'header_comment' => ['header' => $header],
         'modernize_strpos' => true, // needs PHP 8+ or polyfill
         'no_useless_concat_operator' => false, // TODO switch back on when the `src/Console/Application.php` no longer needs the concat
+        'numeric_literal_separator' => [
+            'override_existing' => false,
+            'strategy' => 'use_separator',
+        ],
     ])
     ->setFinder($finder)
 ;

+ 2 - 2
src/Console/Report/FixReport/JsonReporter.php

@@ -49,9 +49,9 @@ final class JsonReporter implements ReporterInterface
         $json = [
             'files' => $jsonFiles,
             'time' => [
-                'total' => round($reportSummary->getTime() / 1000, 3),
+                'total' => round($reportSummary->getTime() / 1_000, 3),
             ],
-            'memory' => round($reportSummary->getMemory() / 1024 / 1024, 3),
+            'memory' => round($reportSummary->getMemory() / 1_024 / 1_024, 3),
         ];
 
         $json = json_encode($json, JSON_THROW_ON_ERROR);

+ 1 - 1
src/Console/Report/FixReport/JunitReporter.php

@@ -53,7 +53,7 @@ final class JunitReporter implements ReporterInterface
                 'time',
                 sprintf(
                     '%.3f',
-                    $reportSummary->getTime() / 1000
+                    $reportSummary->getTime() / 1_000
                 )
             );
         }

+ 2 - 2
src/Console/Report/FixReport/TextReporter.php

@@ -95,8 +95,8 @@ final class TextReporter implements ReporterInterface
             $identifiedFiles,
             $files,
             $isDryRun ? 'files that can be fixed' : 'files',
-            $time / 1000,
-            $memory / 1024 / 1024
+            $time / 1_000,
+            $memory / 1_024 / 1_024
         );
     }
 }

+ 2 - 2
src/Console/Report/FixReport/XmlReporter.php

@@ -99,7 +99,7 @@ final class XmlReporter implements ReporterInterface
 
     private function createTimeElement(float $time, \DOMDocument $dom): \DOMElement
     {
-        $time = round($time / 1000, 3);
+        $time = round($time / 1_000, 3);
 
         $timeXML = $dom->createElement('time');
         $timeXML->setAttribute('unit', 's');
@@ -112,7 +112,7 @@ final class XmlReporter implements ReporterInterface
 
     private function createMemoryElement(float $memory, \DOMDocument $dom): \DOMElement
     {
-        $memory = round($memory / 1024 / 1024, 3);
+        $memory = round($memory / 1_024 / 1_024, 3);
 
         $memoryXML = $dom->createElement('memory');
         $memoryXML->setAttribute('value', (string) $memory);

+ 39 - 39
src/Tokenizer/CT.php

@@ -19,45 +19,45 @@ namespace PhpCsFixer\Tokenizer;
  */
 final class CT
 {
-    public const T_ARRAY_INDEX_CURLY_BRACE_CLOSE = 10001;
-    public const T_ARRAY_INDEX_CURLY_BRACE_OPEN = 10002;
-    public const T_ARRAY_SQUARE_BRACE_CLOSE = 10003;
-    public const T_ARRAY_SQUARE_BRACE_OPEN = 10004;
-    public const T_ARRAY_TYPEHINT = 10005;
-    public const T_BRACE_CLASS_INSTANTIATION_CLOSE = 10006;
-    public const T_BRACE_CLASS_INSTANTIATION_OPEN = 10007;
-    public const T_CLASS_CONSTANT = 10008;
-    public const T_CONST_IMPORT = 10009;
-    public const T_CURLY_CLOSE = 10010;
-    public const T_DESTRUCTURING_SQUARE_BRACE_CLOSE = 10011;
-    public const T_DESTRUCTURING_SQUARE_BRACE_OPEN = 10012;
-    public const T_DOLLAR_CLOSE_CURLY_BRACES = 10013;
-    public const T_DYNAMIC_PROP_BRACE_CLOSE = 10014;
-    public const T_DYNAMIC_PROP_BRACE_OPEN = 10015;
-    public const T_DYNAMIC_VAR_BRACE_CLOSE = 10016;
-    public const T_DYNAMIC_VAR_BRACE_OPEN = 10017;
-    public const T_FUNCTION_IMPORT = 10018;
-    public const T_GROUP_IMPORT_BRACE_CLOSE = 10019;
-    public const T_GROUP_IMPORT_BRACE_OPEN = 10020;
-    public const T_NAMESPACE_OPERATOR = 10021;
-    public const T_NULLABLE_TYPE = 10022;
-    public const T_RETURN_REF = 10023;
-    public const T_TYPE_ALTERNATION = 10024;
-    public const T_TYPE_COLON = 10025;
-    public const T_USE_LAMBDA = 10026;
-    public const T_USE_TRAIT = 10027;
-    public const T_CONSTRUCTOR_PROPERTY_PROMOTION_PUBLIC = 10028;
-    public const T_CONSTRUCTOR_PROPERTY_PROMOTION_PROTECTED = 10029;
-    public const T_CONSTRUCTOR_PROPERTY_PROMOTION_PRIVATE = 10030;
-    public const T_ATTRIBUTE_CLOSE = 10031;
-    public const T_NAMED_ARGUMENT_NAME = 10032;
-    public const T_NAMED_ARGUMENT_COLON = 10033;
-    public const T_FIRST_CLASS_CALLABLE = 10034;
-    public const T_TYPE_INTERSECTION = 10035;
-    public const T_DISJUNCTIVE_NORMAL_FORM_TYPE_PARENTHESIS_OPEN = 10036;
-    public const T_DISJUNCTIVE_NORMAL_FORM_TYPE_PARENTHESIS_CLOSE = 10037;
-    public const T_DYNAMIC_CLASS_CONSTANT_FETCH_CURLY_BRACE_OPEN = 10038;
-    public const T_DYNAMIC_CLASS_CONSTANT_FETCH_CURLY_BRACE_CLOSE = 10039;
+    public const T_ARRAY_INDEX_CURLY_BRACE_CLOSE = 10_001;
+    public const T_ARRAY_INDEX_CURLY_BRACE_OPEN = 10_002;
+    public const T_ARRAY_SQUARE_BRACE_CLOSE = 10_003;
+    public const T_ARRAY_SQUARE_BRACE_OPEN = 10_004;
+    public const T_ARRAY_TYPEHINT = 10_005;
+    public const T_BRACE_CLASS_INSTANTIATION_CLOSE = 10_006;
+    public const T_BRACE_CLASS_INSTANTIATION_OPEN = 10_007;
+    public const T_CLASS_CONSTANT = 10_008;
+    public const T_CONST_IMPORT = 10_009;
+    public const T_CURLY_CLOSE = 10_010;
+    public const T_DESTRUCTURING_SQUARE_BRACE_CLOSE = 10_011;
+    public const T_DESTRUCTURING_SQUARE_BRACE_OPEN = 10_012;
+    public const T_DOLLAR_CLOSE_CURLY_BRACES = 10_013;
+    public const T_DYNAMIC_PROP_BRACE_CLOSE = 10_014;
+    public const T_DYNAMIC_PROP_BRACE_OPEN = 10_015;
+    public const T_DYNAMIC_VAR_BRACE_CLOSE = 10_016;
+    public const T_DYNAMIC_VAR_BRACE_OPEN = 10_017;
+    public const T_FUNCTION_IMPORT = 10_018;
+    public const T_GROUP_IMPORT_BRACE_CLOSE = 10_019;
+    public const T_GROUP_IMPORT_BRACE_OPEN = 10_020;
+    public const T_NAMESPACE_OPERATOR = 10_021;
+    public const T_NULLABLE_TYPE = 10_022;
+    public const T_RETURN_REF = 10_023;
+    public const T_TYPE_ALTERNATION = 10_024;
+    public const T_TYPE_COLON = 10_025;
+    public const T_USE_LAMBDA = 10_026;
+    public const T_USE_TRAIT = 10_027;
+    public const T_CONSTRUCTOR_PROPERTY_PROMOTION_PUBLIC = 10_028;
+    public const T_CONSTRUCTOR_PROPERTY_PROMOTION_PROTECTED = 10_029;
+    public const T_CONSTRUCTOR_PROPERTY_PROMOTION_PRIVATE = 10_030;
+    public const T_ATTRIBUTE_CLOSE = 10_031;
+    public const T_NAMED_ARGUMENT_NAME = 10_032;
+    public const T_NAMED_ARGUMENT_COLON = 10_033;
+    public const T_FIRST_CLASS_CALLABLE = 10_034;
+    public const T_TYPE_INTERSECTION = 10_035;
+    public const T_DISJUNCTIVE_NORMAL_FORM_TYPE_PARENTHESIS_OPEN = 10_036;
+    public const T_DISJUNCTIVE_NORMAL_FORM_TYPE_PARENTHESIS_CLOSE = 10_037;
+    public const T_DYNAMIC_CLASS_CONSTANT_FETCH_CURLY_BRACE_OPEN = 10_038;
+    public const T_DYNAMIC_CLASS_CONSTANT_FETCH_CURLY_BRACE_CLOSE = 10_039;
 
     private function __construct() {}
 

+ 1 - 1
tests/ConfigurationException/InvalidConfigurationExceptionTest.php

@@ -48,7 +48,7 @@ final class InvalidConfigurationExceptionTest extends TestCase
     public function testConstructorSetsValues(): void
     {
         $message = 'I cannot do that, Dave.';
-        $code = 9000;
+        $code = 9_000;
         $previous = new \RuntimeException();
 
         $exception = new InvalidConfigurationException(

+ 4 - 4
tests/Console/Report/FixReport/AbstractReporterTestCase.php

@@ -171,8 +171,8 @@ abstract class AbstractReporterTestCase extends TestCase
                     ],
                 ],
                 10,
-                1234,
-                2621440, // 2.5 * 1024 * 1024
+                1_234,
+                2_621_440, // 2.5 * 1024 * 1024
                 false,
                 false,
                 false
@@ -193,8 +193,8 @@ abstract class AbstractReporterTestCase extends TestCase
                     ],
                 ],
                 10,
-                1234,
-                2621440, // 2.5 * 1024 * 1024
+                1_234,
+                2_621_440, // 2.5 * 1024 * 1024
                 true,
                 true,
                 true

+ 1 - 1
tests/Console/Report/FixReport/ReportSummaryTest.php

@@ -34,7 +34,7 @@ final class ReportSummaryTest extends TestCase
         ];
         $filesCount = 10;
         $time = time();
-        $memory = 123456789;
+        $memory = 123_456_789;
         $addAppliedFixers = true;
         $isDryRun = true;
         $isDecoratedOutput = false;

+ 1 - 1
tests/DocBlock/TypeExpressionTest.php

@@ -894,7 +894,7 @@ final class TypeExpressionTest extends TestCase
         // on https://www.php.net/manual/en/intro.pcre.php there are 4096 cache slots
         // pruned in FIFO fashion, so to clear the cache, replace all existing
         // cache slots with dummy regexes
-        for ($i = 0; $i < 4096; ++$i) {
+        for ($i = 0; $i < 4_096; ++$i) {
             preg_match('/^'.$i.'/', '');
         }
     }

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