Skip to content

Commit

Permalink
Feat: Add NullableTypeDeclarationFixer to standardize nullable declar…
Browse files Browse the repository at this point in the history
…ation using `?` (part of #94)
  • Loading branch information
OndraM committed May 9, 2024
1 parent 35130c6 commit 6a20107
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
use PhpCsFixer\Fixer\Import\OrderedImportsFixer;
use PhpCsFixer\Fixer\LanguageConstruct\DeclareEqualNormalizeFixer;
use PhpCsFixer\Fixer\LanguageConstruct\IsNullFixer;
use PhpCsFixer\Fixer\LanguageConstruct\NullableTypeDeclarationFixer;
use PhpCsFixer\Fixer\LanguageConstruct\SingleSpaceAroundConstructFixer;
use PhpCsFixer\Fixer\ListNotation\ListSyntaxFixer;
use PhpCsFixer\Fixer\NamespaceNotation\BlankLinesBeforeNamespaceFixer;
Expand Down Expand Up @@ -310,6 +311,8 @@
DeclareEqualNormalizeFixer::class,
// Replaces `is_null($var)` expression with `null === $var`
IsNullFixer::class,
// Nullable single type declaration should be standardised using question mark syntax.
NullableTypeDeclarationFixer::class,
// Ensures a single space around language constructs.
SingleSpaceAroundConstructFixer::class,
// Namespace must not contain spacing, comments or PHPDoc.
Expand Down
3 changes: 3 additions & 0 deletions tests/Integration/Fixtures/Basic.correct.php.inc
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,7 @@ class Basic extends AbstractBasic implements InterfaceFromThisNamespace // Fully
2,
);
}

// NullableTypeDeclarationFixer
public function withParameters(?string $nullableValue): void {}
}
4 changes: 4 additions & 0 deletions tests/Integration/Fixtures/Basic.wrong.php.inc
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,8 @@ but should be heredoc instead';
2
);
}

// NullableTypeDeclarationFixer
public function withParameters(null|string $nullableValue): void
{}
}

0 comments on commit 6a20107

Please sign in to comment.