Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/AnnotationGenerator/ConstraintAnnotationGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function generateFieldAnnotations(string $className, string $fieldName):
$asserts[] = '@Assert\Email';
}

if (empty($asserts)) {
if (!$asserts && $this->config['validator']['assertType']) {
$phpType = $this->toPhpType($field);
if (in_array($phpType, ['boolean', 'float', 'integer', 'string'], true)) {
$asserts[] = sprintf('@Assert\Type(type="%s")', $phpType);
Expand Down
7 changes: 7 additions & 0 deletions src/TypesGeneratorConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ function ($rdfa) {
->scalarNode('resolveTargetEntityConfigPath')->defaultNull()->info('The Resolve Target Entity Listener config file pass')->end()
->end()
->end()
->arrayNode('validator')
->addDefaultsIfNotSet()
->info('Symfony Validator Component')
->children()
->booleanNode('assertType')->defaultFalse()->info('Generate @Assert\Type annotation')->end()
->end()
->end()
->scalarNode('author')->defaultFalse()->info('The value of the phpDoc\'s @author annotation')->example('Kévin Dunglas <dunglas@gmail.com>')->end()
->enumNode('fieldVisibility')->values(['private', 'protected', 'public'])->defaultValue('private')->cannotBeEmpty()->info('Visibility of entities fields')->end()
->booleanNode('mutatorMethods')->defaultTrue()->info('Set this flag to false to not generate getter, setter, adder and remover methods')->end()
Expand Down
6 changes: 6 additions & 0 deletions tests/Command/DumpConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ interface: AppBundle\Model # Example: Acme\Model
# The Resolve Target Entity Listener config file pass
resolveTargetEntityConfigPath: null

# Symfony Validator Component
validator:

# Generate @Assert\Type annotation
assertType: false

# The value of the phpDoc's @author annotation
author: false # Example: Kévin Dunglas <dunglas@gmail.com>

Expand Down