Skip to content

Commit

Permalink
Feat: Add OctalNotationFixer for explicit octal notation using 0o in …
Browse files Browse the repository at this point in the history
…PHP 8.1+ (part of #94)
  • Loading branch information
OndraM committed May 10, 2024
1 parent f77ef49 commit 71791d0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions tests/Integration/Fixtures/NewPhpFeatures.correct.php.inc
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,10 @@ class NewPhpFeatures
string $foo,
string $bar,
): void {}

public function php81features(): void
{
// OctalNotationFixer
$numberInOctalNotation = 0o0123;
}
}
6 changes: 6 additions & 0 deletions tests/Integration/Fixtures/NewPhpFeatures.wrong.php.inc
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,10 @@ class NewPhpFeatures
#[ParamAttribute] #[AnotherAttribute('foo')] string $foo,
string $bar,
): void {}

public function php81features(): void
{
// OctalNotationFixer
$numberInOctalNotation = 0123;
}
}

0 comments on commit 71791d0

Please sign in to comment.