Skip to content

Commit c5e6bd9

Browse files
committedMay 10, 2024
Feat: Add OctalNotationFixer for explicit octal notation using 0o in PHP 8.1+ (part of #94)
1 parent f77ef49 commit c5e6bd9

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed
 

‎ecs.php

+3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
use PhpCsFixer\Fixer\AttributeNotation\AttributeEmptyParenthesesFixer;
4747
use PhpCsFixer\Fixer\Basic\BracesFixer;
4848
use PhpCsFixer\Fixer\Basic\NoTrailingCommaInSinglelineFixer;
49+
use PhpCsFixer\Fixer\Basic\OctalNotationFixer;
4950
use PhpCsFixer\Fixer\Basic\PsrAutoloadingFixer;
5051
use PhpCsFixer\Fixer\Basic\SingleLineEmptyBodyFixer;
5152
use PhpCsFixer\Fixer\Casing\ClassReferenceNameCasingFixer;
@@ -244,6 +245,8 @@
244245
SingleLineEmptyBodyFixer::class, // Defined in PER 2.0
245246
// Values separated by a comma on a single line should not have a trailing comma.
246247
NoTrailingCommaInSinglelineFixer::class,
248+
// Literal octal must be in 0o notation.
249+
OctalNotationFixer::class,
247250
// Arrays should be formatted like function/method arguments
248251
TrimArraySpacesFixer::class,
249252
// In array declaration, there MUST be a whitespace after each comma

‎tests/Integration/Fixtures/NewPhpFeatures.correct.php.inc

+6
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,10 @@ class NewPhpFeatures
4343
string $foo,
4444
string $bar,
4545
): void {}
46+
47+
public function php81features(): void
48+
{
49+
// OctalNotationFixer
50+
$numberInOctalNotation = 0o123;
51+
}
4652
}

‎tests/Integration/Fixtures/NewPhpFeatures.wrong.php.inc

+6
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,10 @@ class NewPhpFeatures
4444
#[ParamAttribute] #[AnotherAttribute('foo')] string $foo,
4545
string $bar,
4646
): void {}
47+
48+
public function php81features(): void
49+
{
50+
// OctalNotationFixer
51+
$numberInOctalNotation = 0123;
52+
}
4753
}

0 commit comments

Comments
 (0)