Skip to content

Commit b836fd3

Browse files
authored
Ensure partial usage of Symfony validator assertions and Doctrine ORM attributes (see #21)
Description ----------- With my feature contributed in slevomat/coding-standard#1856 we can now make sure that some partial namespaces are not only allowed but enforced to be used the way we want them to 😎 This config now ensures this usage: ```php use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; #[ORM\Column(type: 'string')] #[Assert\NotNull] #[Assert\NotBlank] private string $myProperty = ''; ``` Commits ------- a2f8efa Ensure partial usage of Symfony validator assertions and Doctrine ORM…
1 parent 6e589ae commit b836fd3

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"require": {
1313
"php": "^8.1",
1414
"kubawerlos/php-cs-fixer-custom-fixers": "^3.14",
15-
"slevomat/coding-standard": "^8.0",
15+
"slevomat/coding-standard": "^8.30",
1616
"symplify/easy-coding-standard": "^13.0"
1717
},
1818
"require-dev": {

config/contao.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,18 @@
186186
->withConfiguredRule(PhpdocTypesFixer::class, ['groups' => ['simple', 'meta']])
187187
->withConfiguredRule(PhpUnitTestCaseStaticMethodCallsFixer::class, ['call_type' => 'this'])
188188
->withConfiguredRule(RandomApiMigrationFixer::class, ['replacements' => ['mt_rand' => 'random_int', 'rand' => 'random_int']])
189-
->withConfiguredRule(ReferenceUsedNamesOnlySniff::class, ['searchAnnotations' => true, 'allowFullyQualifiedNameForCollidingClasses' => true, 'allowFullyQualifiedGlobalClasses' => true, 'allowFullyQualifiedGlobalFunctions' => true, 'allowFullyQualifiedGlobalConstants' => true, 'allowPartialUses' => false])
189+
->withConfiguredRule(ReferenceUsedNamesOnlySniff::class, [
190+
'searchAnnotations' => true,
191+
'allowFullyQualifiedNameForCollidingClasses' => true,
192+
'allowFullyQualifiedGlobalClasses' => true,
193+
'allowFullyQualifiedGlobalFunctions' => true,
194+
'allowFullyQualifiedGlobalConstants' => true,
195+
'allowPartialUses' => false,
196+
'namespacesRequiredToUsePartially' => [
197+
'Doctrine\ORM\Mapping as ORM',
198+
'Symfony\Component\Validator\Constraints as Assert',
199+
],
200+
])
190201
->withConfiguredRule(StringImplicitBackslashesFixer::class, ['single_quoted' => 'ignore', 'double_quoted' => 'escape', 'heredoc' => 'escape'])
191202
->withConfiguredRule(TrailingCommaInMultilineFixer::class, ['elements' => ['arrays', 'arguments', 'match', 'parameters'], 'after_heredoc' => true])
192203
->withConfiguredRule(UnusedUsesSniff::class, ['searchAnnotations' => true])

0 commit comments

Comments
 (0)