Skip to content

Commit

Permalink
chore: use numeric_literal_separator for project (PHP-CS-Fixer#7713)
Browse files Browse the repository at this point in the history
  • Loading branch information
keradus authored Jan 12, 2024
1 parent 4c66916 commit 0428582
Show file tree
Hide file tree
Showing 18 changed files with 69 additions and 65 deletions.
4 changes: 4 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
'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)
;
4 changes: 2 additions & 2 deletions src/Console/Report/FixReport/JsonReporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ public function generate(ReportSummary $reportSummary): string
$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);
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Report/FixReport/JunitReporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function generate(ReportSummary $reportSummary): string
'time',
sprintf(
'%.3f',
$reportSummary->getTime() / 1000
$reportSummary->getTime() / 1_000
)
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Console/Report/FixReport/TextReporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ private function getFooter(int $time, int $identifiedFiles, int $files, int $mem
$identifiedFiles,
$files,
$isDryRun ? 'files that can be fixed' : 'files',
$time / 1000,
$memory / 1024 / 1024
$time / 1_000,
$memory / 1_024 / 1_024
);
}
}
4 changes: 2 additions & 2 deletions src/Console/Report/FixReport/XmlReporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private function createDiffElement(\DOMDocument $dom, string $diff): \DOMElement

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');
Expand All @@ -112,7 +112,7 @@ private function createTimeElement(float $time, \DOMDocument $dom): \DOMElement

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);
Expand Down
78 changes: 39 additions & 39 deletions src/Tokenizer/CT.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,45 +19,45 @@
*/
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() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function testDefaults(): void
public function testConstructorSetsValues(): void
{
$message = 'I cannot do that, Dave.';
$code = 9000;
$code = 9_000;
$previous = new \RuntimeException();

$exception = new InvalidConfigurationException(
Expand Down
8 changes: 4 additions & 4 deletions tests/Console/Report/FixReport/AbstractReporterTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ class Foo
],
],
10,
1234,
2621440, // 2.5 * 1024 * 1024
1_234,
2_621_440, // 2.5 * 1024 * 1024
false,
false,
false
Expand All @@ -193,8 +193,8 @@ class Foo
],
],
10,
1234,
2621440, // 2.5 * 1024 * 1024
1_234,
2_621_440, // 2.5 * 1024 * 1024
true,
true,
true
Expand Down
2 changes: 1 addition & 1 deletion tests/Console/Report/FixReport/ReportSummaryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function testReportSummary(): void
];
$filesCount = 10;
$time = time();
$memory = 123456789;
$memory = 123_456_789;
$addAppliedFixers = true;
$isDryRun = true;
$isDecoratedOutput = false;
Expand Down
2 changes: 1 addition & 1 deletion tests/DocBlock/TypeExpressionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ private function clearPcreRegexCache(): void
// 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.'/', '');
}
}
Expand Down
6 changes: 3 additions & 3 deletions tests/Doctrine/Annotation/TokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public static function provideIsTypeReturnsTrueCases(): iterable
42,
[
42,
9001,
9_001,
],
];
}
Expand All @@ -112,13 +112,13 @@ public static function provideIsTypeReturnsFalseCases(): iterable
{
yield 'different-value' => [
42,
9001,
9_001,
];

yield 'array-without-value' => [
42,
[
9001,
9_001,
],
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function testInvalidConfiguration(): void
'#^\[return_type_declaration\] Invalid configuration: The option "s" does not exist\. (Known|Defined) options are: "space_before"\.$#'
);

$this->fixer->configure(['s' => 9000]);
$this->fixer->configure(['s' => 9_000]);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixer/Phpdoc/NoSuperfluousPhpdocTagsFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1442,7 +1442,7 @@ public function doFoo(int $bar, string $baz): bool {}
* "Sponsored" by https://github.com/PrestaShop/PrestaShop/blob/1.6.1.24/tools/tcpdf/tcpdf.php (search for "Get page dimensions from format name")
* @see
* @param $number - it can be:
* '.implode("\n * ", range(1, 1000)).'
* '.implode("\n * ", range(1, 1_000)).'
*/
function display($number) {}
',
Expand Down
4 changes: 2 additions & 2 deletions tests/FixerDefinition/VersionSpecificationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ public function testIsSatisfiedByReturnsFalse(?int $minimum, ?int $maximum, int

public static function provideIsSatisfiedByReturnsFalseCases(): iterable
{
yield 'version-greater-than-maximum' => [null, 1000, 1001];
yield 'version-greater-than-maximum' => [null, 1_000, 1_001];

yield 'version-less-than-minimum' => [2000, null, 1999];
yield 'version-less-than-minimum' => [2_000, null, 1_999];
}
}
2 changes: 1 addition & 1 deletion tests/Linter/LintingExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function testIsRuntimeException(): void
public function testConstructorSetsValues(): void
{
$message = 'Cannot lint this, sorry!';
$code = 9001;
$code = 9_001;
$previous = new \RuntimeException();

$exception = new LintingException(
Expand Down
2 changes: 1 addition & 1 deletion tests/Linter/UnavailableLinterExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function testIsRuntimeException(): void
public function testConstructorSetsValues(): void
{
$message = 'Never heard of that one, sorry!';
$code = 9001;
$code = 9_001;
$previous = new \RuntimeException();

$exception = new UnavailableLinterException(
Expand Down
4 changes: 2 additions & 2 deletions tests/Tokenizer/Analyzer/BlocksAnalyzerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ public static function provideNonBlocksCases(): iterable

yield ['<?php foo(1);', 2, null];

yield ['<?php foo(1);', 1000, 4];
yield ['<?php foo(1);', 1_000, 4];

yield ['<?php foo(1);', 2, 1000];
yield ['<?php foo(1);', 2, 1_000];

yield ['<?php foo(1);', 1, 4];

Expand Down
2 changes: 1 addition & 1 deletion tests/Tokenizer/CTTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function testGetNameNotExists(): void
*/
public function testConstants(string $name, int $value): void
{
self::assertGreaterThan(10000, $value);
self::assertGreaterThan(10_000, $value);
self::assertFalse(\defined($name), 'The CT name must not use native T_* name.');
}

Expand Down

0 comments on commit 0428582

Please sign in to comment.