From 71791d090b2fa55ef5dd8415e2429b21d95dbda4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Machulda?= Date: Fri, 10 May 2024 12:15:04 +0200 Subject: [PATCH] Feat: Add OctalNotationFixer for explicit octal notation using 0o in PHP 8.1+ (part of #94) --- ecs.php | 3 +++ tests/Integration/Fixtures/NewPhpFeatures.correct.php.inc | 6 ++++++ tests/Integration/Fixtures/NewPhpFeatures.wrong.php.inc | 6 ++++++ 3 files changed, 15 insertions(+) diff --git a/ecs.php b/ecs.php index b7b4732..29d907f 100644 --- a/ecs.php +++ b/ecs.php @@ -46,6 +46,7 @@ use PhpCsFixer\Fixer\AttributeNotation\AttributeEmptyParenthesesFixer; use PhpCsFixer\Fixer\Basic\BracesFixer; use PhpCsFixer\Fixer\Basic\NoTrailingCommaInSinglelineFixer; +use PhpCsFixer\Fixer\Basic\OctalNotationFixer; use PhpCsFixer\Fixer\Basic\PsrAutoloadingFixer; use PhpCsFixer\Fixer\Basic\SingleLineEmptyBodyFixer; use PhpCsFixer\Fixer\Casing\ClassReferenceNameCasingFixer; @@ -244,6 +245,8 @@ SingleLineEmptyBodyFixer::class, // Defined in PER 2.0 // Values separated by a comma on a single line should not have a trailing comma. NoTrailingCommaInSinglelineFixer::class, + // Literal octal must be in 0o notation. + OctalNotationFixer::class, // Arrays should be formatted like function/method arguments TrimArraySpacesFixer::class, // In array declaration, there MUST be a whitespace after each comma diff --git a/tests/Integration/Fixtures/NewPhpFeatures.correct.php.inc b/tests/Integration/Fixtures/NewPhpFeatures.correct.php.inc index bff038b..e823f58 100644 --- a/tests/Integration/Fixtures/NewPhpFeatures.correct.php.inc +++ b/tests/Integration/Fixtures/NewPhpFeatures.correct.php.inc @@ -43,4 +43,10 @@ class NewPhpFeatures string $foo, string $bar, ): void {} + + public function php81features(): void + { + // OctalNotationFixer + $numberInOctalNotation = 0o0123; + } } diff --git a/tests/Integration/Fixtures/NewPhpFeatures.wrong.php.inc b/tests/Integration/Fixtures/NewPhpFeatures.wrong.php.inc index 5629c7a..a73ba14 100644 --- a/tests/Integration/Fixtures/NewPhpFeatures.wrong.php.inc +++ b/tests/Integration/Fixtures/NewPhpFeatures.wrong.php.inc @@ -44,4 +44,10 @@ class NewPhpFeatures #[ParamAttribute] #[AnotherAttribute('foo')] string $foo, string $bar, ): void {} + + public function php81features(): void + { + // OctalNotationFixer + $numberInOctalNotation = 0123; + } }