Skip to content

Commit 215e6ab

Browse files
Merge branch '5.0'
* 5.0: [DI] Service locators can't be decorated [HttpClient] force HTTP/1.1 when NTLM auth is used [Validation][FrameworkBundle] Allow EnableAutoMapping to work without auto-mapping namespaces [Console][SymfonyQuestionHelper] Handle multibytes question choices keys and custom prompt [DI] fix auto-binding service providers to their service subscribers [Mailer] fixed undefined index when sending mail
2 parents b2ca71e + ff51ce5 commit 215e6ab

File tree

5 files changed

+11
-14
lines changed

5 files changed

+11
-14
lines changed

CHANGELOG.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,20 @@ CHANGELOG
2121
4.4.0
2222
-----
2323

24-
* added `EnableAutoMapping` and `DisableAutoMapping` constraints to enable or disable auto mapping for class or a property
24+
* [BC BREAK] using null as `$classValidatorRegexp` value in `PropertyInfoLoader::__construct` will not enable auto-mapping for all classes anymore, use `'{.*}'` instead.
25+
* added `EnableAutoMapping` and `DisableAutoMapping` constraints to enable or disable auto mapping for class or a property
2526
* using anything else than a `string` as the code of a `ConstraintViolation` is deprecated, a `string` type-hint will
2627
be added to the constructor of the `ConstraintViolation` class and to the `ConstraintViolationBuilder::setCode()`
2728
method in 5.0
2829
* deprecated passing an `ExpressionLanguage` instance as the second argument of `ExpressionValidator::__construct()`. Pass it as the first argument instead.
29-
* added the `compared_value_path` parameter in violations when using any
30+
* added the `compared_value_path` parameter in violations when using any
3031
comparison constraint with the `propertyPath` option.
3132
* added support for checking an array of types in `TypeValidator`
3233
* added a new `allowEmptyString` option to the `Length` constraint to allow rejecting empty strings when `min` is set, by setting it to `false`.
3334
* Added new `minPropertyPath` and `maxPropertyPath` options
3435
to `Range` constraint in order to get the value to compare
3536
from an array or object
36-
* added the `min_limit_path` and `max_limit_path` parameters in violations when using
37+
* added the `min_limit_path` and `max_limit_path` parameters in violations when using
3738
`Range` constraint with respectively the `minPropertyPath` and
3839
`maxPropertyPath` options
3940
* added a new `notInRangeMessage` option to the `Range` constraint that will

DependencyInjection/AddAutoMappingConfigurationPass.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,8 @@ public function process(ContainerBuilder $container)
5959
$validatorBuilder = $container->getDefinition($this->validatorBuilderService);
6060
foreach ($container->findTaggedServiceIds($this->tag) as $id => $tags) {
6161
$regexp = $this->getRegexp(array_merge($globalNamespaces, $servicesToNamespaces[$id] ?? []));
62-
if (null === $regexp) {
63-
$container->removeDefinition($id);
64-
continue;
65-
}
66-
67-
$container->getDefinition($id)->setArgument('$classValidatorRegexp', $regexp);
6862
$validatorBuilder->addMethodCall('addLoader', [new Reference($id)]);
63+
$container->getDefinition($id)->setArgument('$classValidatorRegexp', $regexp);
6964
}
7065

7166
$container->getParameterBag()->remove('validator.auto_mapping');

Mapping/Loader/AutoMappingTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ private function isAutoMappingEnabledForClass(ClassMetadata $metadata, string $c
2929
}
3030

3131
// Fallback on the config
32-
return null === $classValidatorRegexp || preg_match($classValidatorRegexp, $metadata->getClassName());
32+
return null !== $classValidatorRegexp && preg_match($classValidatorRegexp, $metadata->getClassName());
3333
}
3434
}

Tests/DependencyInjection/AddAutoMappingConfigurationPassTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,6 @@ public function testDoNotMapAllClassesWhenConfigIsEmpty()
8181

8282
(new AddAutoMappingConfigurationPass())->process($container);
8383

84-
$this->assertFalse($container->hasDefinition('loader'));
84+
$this->assertNull($container->getDefinition('loader')->getArguments()['$classValidatorRegexp'] ?? null);
8585
}
8686
}

Tests/Mapping/Loader/PropertyInfoLoaderTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function testLoadClassMetadata()
8686
))
8787
;
8888

89-
$propertyInfoLoader = new PropertyInfoLoader($propertyInfoStub, $propertyInfoStub, $propertyInfoStub);
89+
$propertyInfoLoader = new PropertyInfoLoader($propertyInfoStub, $propertyInfoStub, $propertyInfoStub, '{.*}');
9090

9191
$validator = Validation::createValidatorBuilder()
9292
->enableAnnotationMapping()
@@ -197,7 +197,8 @@ public function testClassValidator(bool $expected, string $classValidatorRegexp
197197
public function regexpProvider()
198198
{
199199
return [
200-
[true, null],
200+
[false, null],
201+
[true, '{.*}'],
201202
[true, '{^'.preg_quote(PropertyInfoLoaderEntity::class).'$|^'.preg_quote(Entity::class).'$}'],
202203
[false, '{^'.preg_quote(Entity::class).'$}'],
203204
];
@@ -217,7 +218,7 @@ public function testClassNoAutoMapping()
217218
[new Type(Type::BUILTIN_TYPE_BOOL)]
218219
);
219220

220-
$propertyInfoLoader = new PropertyInfoLoader($propertyInfoStub, $propertyInfoStub, $propertyInfoStub);
221+
$propertyInfoLoader = new PropertyInfoLoader($propertyInfoStub, $propertyInfoStub, $propertyInfoStub, '{.*}');
221222
$validator = Validation::createValidatorBuilder()
222223
->enableAnnotationMapping()
223224
->addLoader($propertyInfoLoader)

0 commit comments

Comments
 (0)