8000 Merge branch '6.4' into 7.0 · symfony/symfony@52e98e2 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 52e98e2

Browse files
committed
Merge branch '6.4' into 7.0
* 6.4: [FrameworkBundle][Validator] Deprecate annotation occurrences
2 parents f1c8b07 + f354c1e commit 52e98e2

File tree

90 files changed

+285
-176
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+285
-176
lines changed

src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
1616
use Symfony\Component\Validator\Mapping\ClassMetadata;
17-
use Symfony\Component\Validator\Mapping\Loader\AnnotationLoader;
17+
use Symfony\Component\Validator\Mapping\Loader\AttributeLoader;
1818

1919
class UniqueEntityTest extends TestCase
2020
{
2121
public function testAttributeWithDefaultProperty()
2222
{
2323
$metadata = new ClassMetadata(UniqueEntityDummyOne::class);
24-
$loader = new AnnotationLoader();
24+
$loader = new AttributeLoader();
2525
self::assertTrue($loader->loadClassMetadata($metadata));
2626

2727
/** @var UniqueEntity $constraint */
@@ -35,7 +35,7 @@ public function testAttributeWithDefaultProperty()
3535
public function testAttributeWithCustomizedService()
3636
{
3737
$metadata = new ClassMetadata(UniqueEntityDummyTwo::class);
38-
$loader = new AnnotationLoader();
38+
$loader = new AttributeLoader();
3939
self::assertTrue($loader->loadClassMetadata($metadata));
4040

4141
/** @var UniqueEntity $constraint */
@@ -50,7 +50,7 @@ public function testAttributeWithCustomizedService()
5050
public function testAttributeWithGroupsAndPaylod()
5151
{
5252
$metadata = new ClassMetadata(UniqueEntityDummyThree::class);
53-
$loader = new AnnotationLoader();
53+
$loader = new AttributeLoader();
5454
self::assertTrue($loader->loadClassMetadata($metadata));
5555

5656
/** @var UniqueEntity $constraint */

src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class DoctrineLoaderTest extends TestCase
3939
public function testLoadClassMetadata()
4040
{
4141
$validator = Validation::createValidatorBuilder()
42-
->enableAnnotationMapping(true)
42+
->enableAttributeMapping()
4343
->addLoader(new DoctrineLoader(DoctrineTestHelper::createTestEntityManager(), '{^Symfony\\\\Bridge\\\\Doctrine\\\\Tests\\\\Fixtures\\\\DoctrineLoader}'))
4444
->getValidator()
4545
;
@@ -142,7 +142,7 @@ public function testExtractEnum()
142142
{
143143
$validator = Validation::createValidatorBuilder()
144144
->addMethodMapping('loadValidatorMetadata')
145-
->enableAnnotationMapping(true)
145+
->enableAttributeMapping()
146146
->addLoader(new DoctrineLoader(DoctrineTestHelper::createTestEntityManager(), '{^Symfony\\\\Bridge\\\\Doctrine\\\\Tests\\\\Fixtures\\\\DoctrineLoader}'))
147147
->getValidator()
148148
;
@@ -159,7 +159,7 @@ public function testExtractEnum()
159159
public function testFieldMappingsConfiguration()
160160
{
161161
$validator = Validation::createValidatorBuilder()
162-
->enableAnnotationMapping(true)
162+
->enableAttributeMapping()
163163
->addXmlMappings([__DIR__.'/../Resources/validator/BaseUser.xml'])
164164
->addLoader(
165165
new DoctrineLoader(
@@ -200,7 +200,7 @@ public static function regexpProvider(): array
200200
public function testClassNoAutoMapping()
201201
{
202202
$validator = Validation::createValidatorBuilder()
203-
->enableAnnotationMapping(true)
203+
->enableAttributeMapping()
204204
->addLoader(new DoctrineLoader(DoctrineTestHelper::createTestEntityManager(), ' 10000 {.*}'))
205205
->getValidator();
206206

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ CHANGELOG
3636
* Deprecate not setting the `framework.uid.default_uuid_version` config option; it will default to `7` in 7.0
3737
* Deprecate not setting the `framework.uid.time_based_uuid_version` config option; it will default to `7` in 7.0
3838
* Deprecate not setting the `framework.validation.email_validation_mode` config option; it will default to `html5` in 7.0
39+
* Deprecate `framework.validation.enable_annotations`, use `framework.validation.enable_attributes` instead
40+
* Deprecate `framework.serializer.enable_annotations`, use `framework.serializer.enable_attributes` instead
3941

4042
6.3
4143
---

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,16 @@ private function addValidationSection(ArrayNodeDefinition $rootNode, callable $e
10231023
trigger_deprecation('symfony/framework-bundle', '6.4', 'Not setting the "framework.validation.email_validation_mode" config option is deprecated. It will default to "html5" in 7.0.');
10241024
}
10251025

1026+
if (isset($v['enable_annotations'])) {
1027+
trigger_deprecation('symfony/framework-bundle', '6.4', 'Option "enable_annotations" at "framework.validation" is deprecated. Use the "enable_attributes" option instead.');
1028+
1029+
if (!isset($v['enable_attributes'])) {
1030+
$v['enable_attributes'] = $v['enable_annotations'];
1031+
} else {
1032+
throw new LogicException('The "enable_annotations" and "enable_attributes" options at path "framework.validation" must not be both set. Only the "enable_attributes" option must be used.');
1033+
}
1034+
}
1035+
10261036
return $v;
10271037
})
10281038
->end()
@@ -1032,7 +1042,8 @@ private function addValidationSection(ArrayNodeDefinition $rootNode, callable $e
10321042
->{$enableIfStandalone('symfony/validator', Validation::class)}()
10331043
->children()
10341044
->scalarNode('cache')->end()
1035-
->booleanNode('enable_annotations' 10000 ;)->{!class_exists(FullStack::class) ? 'defaultTrue' : 'defaultFalse'}()->end()
1045+
->booleanNode('enable_annotations')->end()
1046+
->booleanNode('enable_attributes')->{!class_exists(FullStack::class) ? 'defaultTrue' : 'defaultFalse'}()->end()
10361047
->arrayNode('static_method')
10371048
->defaultValue(['loadValidatorMetadata'])
10381049
->prototype('scalar')->end()
@@ -1132,10 +1143,25 @@ private function addSerializerSection(ArrayNodeDefinition $rootNode, callable $e
11321143
$rootNode
11331144
->children()
11341145
->arrayNode('serializer')
1146+
->validate()
1147+
->always(function ($v) {
1148+
if (isset($v['enable_annotations'])) {
1149+
trigger_deprecation('symfony/framework-bundle', '6.4', 'Option "enable_annotations" at "framework.serializer" is deprecated. Use the "enable_attributes" option instead.');
1150+
1151+
if (!isset($v['enable_attributes'])) {
1152+
$v['enable_attributes'] = $v['enable_annotations'];
1153+
} else {
1154+
throw new LogicException('The "enable_annotations" and "enable_attributes" options at path "framework.serializer" must not be both set. Only the "enable_attributes" option must be used.');
1155+
}
1156+
}
1157+
1158+
return $v;
1159+
})->end()
11351160
->info('serializer configuration')
11361161
->{$enableIfStandalone('symfony/serializer', Serializer::class)}()
11371162
->children()
1138-
->booleanNode('enable_annotations')->{!class_exists(FullStack::class) ? 'defaultTrue' : 'defaultFalse'}()->end()
1163+
->booleanNode('enable_annotations')->end()
1164+
->booleanNode('enable_attributes')->{!class_exists(FullStack::class) ? 'defaultTrue' : 'defaultFalse'}()->end()
11391165
->scalarNode('name_converter')->end()
11401166
->scalarNode('circular_reference_handler')->end()
11411167
->scalarNode('max_depth_handler')->end()

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,8 +1636,8 @@ private function registerValidationConfiguration(array $config, ContainerBuilder
16361636
$definition = $container->findDefinition('validator.email');
16371637
$definition->replaceArgument(0, $config['email_validation_mode']);
16381638

1639-
if (\array_key_exists('enable_annotations', $config) && $config['enable_annotations']) {
1640-
$validatorBuilder->addMethodCall('enableAnnotationMapping');
1639+
if (\array_key_exists('enable_attributes', $config) && $config['enable_attributes']) {
1640+
$validatorBuilder->addMethodCall('enableAttributeMapping');
16411641
}
16421642

16431643
if (\array_key_exists('static_method', $config) && $config['static_method']) {
@@ -1854,7 +1854,7 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
18541854
}
18551855

18561856
$serializerLoaders = [];
1857-
if (isset($config['enable_annotations']) && $config['enable_annotations']) {
1857+
if (isset($config['enable_attributes']) && $config['enable_attributes']) {
18581858
if ($container->getParameter('kernel.debug')) {
18591859
$container->removeDefinition('serializer.mapping.cache_class_metadata_factory');
18601860
}

src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@
267267
<xsd:attribute name="enabled" type="xsd:boolean" />
268268
<xsd:attribute name="cache" type="xsd:string" />
269269
<xsd:attribute name="enable-annotations" type="xsd:boolean" />
270+
<xsd:attribute name="enable-attributes" type="xsd:boolean" />
270271
<xsd:attribute name="static-method" type="xsd:boolean" />
271272
<xsd:attribute name="translation-domain" type="xsd:string" />
272273
<xsd:attribute name="strict-email" type="xsd:boolean" />
@@ -320,6 +321,7 @@
320321
</xsd:choice>
321322
<xsd:attribute name="enabled" type="xsd:boolean" />
322323
<xsd:attribute name="enable-annotations" type="xsd:boolean" />
324+
<xsd:attribute name="enable-attributes" type="xsd:boolean" />
323325
<xsd:attribute name="name-converter" type="xsd:string" />
324326
<xsd:attribute name="circular-reference-handler" type="xsd:string" />
325327
<xsd:attribute name="max-depth-handler" type="xsd:string" />

src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/ValidatorCacheWarmerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function testWarmUp()
2626
$validatorBuilder->addXmlMapping(__DIR__.'/../Fixtures/Validation/Resources/person.xml');
2727
$validatorBuilder->addYamlMapping(__DIR__.'/../Fixtures/Validation/Resources/author.yml');
2828
$validatorBuilder->addMethodMapping('loadValidatorMetadata');
29-
$validatorBuilder->enableAnnotationMapping();
29+
$validatorBuilder->enableAttributeMapping();
3030

3131
$file = sys_get_temp_dir().'/cache-validator.php';
3232
@unlink($file);
@@ -46,7 +46,7 @@ public function testWarmUpWithAnnotations()
4646
{
4747
$validatorBuilder = new ValidatorBuilder();
4848
$validatorBuilder->addYamlMapping(__DIR__.'/../Fixtures/Validation/Resources/categories.yml');
49-
$validatorBuilder->enableAnnotationMapping();
49+
$validatorBuilder->enableAttributeMapping();
5050 B41A

5151
$file = sys_get_temp_dir().'/cache-validator-with-annotations.php';
5252
@unlink($file);

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ protected static function getBundleDefaultConfig()
591591
],
592592
'validation' => [
593593
'enabled' => !class_exists(FullStack::class),
594-
'enable_annotations' => !class_exists(FullStack::class),
594+
'enable_attributes' => !class_exists(FullStack::class),
595595
'static_method' => ['loadValidatorMetadata'],
596596
'translation_domain' => 'validators',
597597
'mapping' => [
@@ -609,7 +609,7 @@ protected static function getBundleDefaultConfig()
609609
'serializer' => [
610610
'default_context' => ['foo' => 'bar', JsonDecode::DETAILED_ERROR_MESSAGES => true],
611611
'enabled' => true,
612-
'enable_annotations' => !class_exists(FullStack::class),
612+
'enable_attributes' => !class_exists(FullStack::class),
613613
'mapping' => ['paths' => []],
614614
],
615615
'property_access' => [

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
'annotations' => false,
6464
'serializer' => [
6565
'enabled' => true,
66-
'enable_annotations' => true,
66+
'enable_attributes' => true,
6767
'name_converter' => 'serializer.name_converter.camel_case_to_snake_case',
6868
'circular_reference_handler' => 'my.circular.reference.handler',
6969
'max_depth_handler' => 'my.max.depth.handler',

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/serializer_mapping.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
'php_errors' => ['log' => true],
77
'annotations' => false,
88
'serializer' => [
9-
'enable_annotations' => true,
9+
'enable_attributes' => true,
1010
'mapping' => [
1111
'paths' => [
1212
'%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/files',

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/serializer_mapping_without_annotations.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
'handle_all_throwables' => true,
77
'php_errors' => ['log' => true],
88
'serializer' => [
9-
'enable_annotations' => false,
9+
'enable_attributes' => false,
1010
'mapping' => [
1111
'paths' => [
1212
'%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/files',
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
'secret' => 's3cr3t',
99
'validation' => [
1010
'enabled' => true,
11-
'enable_annotations' => true,
11+
'enable_attributes' => true,
1212
'email_validation_mode' => 'html5',
1313
],
1414
]);

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<framework:validation enabled="true" email-validation-mode="html5" />
3535
<framework:annotations enabled="false" />
3636
<framework:php-errors log="true" />
37-
<framework:serializer enabled="true" enable-annotations="true" name-converter="serializer.name_converter.camel_case_to_snake_case" circular-reference-handler="my.circular.reference.handler" max-depth-handler="my.max.depth.handler">
37+
<framework:serializer enabled="true" enable-attributes="true" name-converter="serializer.name_converter.camel_case_to_snake_case" circular-reference-handler="my.circular.reference.handler" max-depth-handler="my.max.depth.handler">
3838
<framework:default-context>
3939
<framework:enable_max_depth>true</framework:enable_max_depth>
4040
</framework:default-context>

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/serializer_mapping.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<framework:config http-method-override="false" handle-all-throwables="true">
88
<framework:annotations enabled="false" />
99
<framework:php-errors log="true" />
10-
<framework:serializer enable-annotations="true">
10+
<framework:serializer enable-attributes="true">
1111
<framework:mapping>
1212
<framework:path>%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/files</framework:path>
1313
<framework:path>%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/serialization.yml</framework:path>

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/serializer_mapping_without_annotations.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<framework:config http-method-override="false" handle-all-throwables="true">
88
<framework:annotations enabled="false" />
99
<framework:php-errors log="true" />
10-
<framework:serializer enable-annotations="false">
10+
<framework:serializer enable-attributes="false">
1111
<framework:mapping>
1212
<framework:path>%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/files</framework:path>
1313
<framework:path>%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/serialization.yml</framework:path>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<framework:config secret="s3cr3t" http-method-override="false" handle-all-throwables="true">
1010
<framework:annotations enabled="false" />
1111
<framework:php-errors log="true" />
12-
<framework:validation enabled="true" enable-annotations="true" email-validation-mode="html5" />
12+
<framework:validation enabled="true" enable-attributes="true" email-validation-mode="html5" />
1313
</framework:config>
1414

1515
<services>

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ framework:
5353
annotations: false
5454
serializer:
5555
enabled: true
56-
enable_annotations: true
56+
enable_attributes: true
5757
name_converter: serializer.name_converter.camel_case_to_snake_case
5858
circular_reference_handler: my.circular.reference.handler
5959
max_depth_handler: my.max.depth.handler

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/serializer_mapping.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ framework:
55
log: true
66
annotations: false
77
serializer:
8-
enable_annotations: true
8+
enable_attributes: true
99
mapping:
1010
paths:
1111
- "%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/files"

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/serializer_mapping_without_annotations.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ framework:
55
php_errors:
66
log: true
77
serializer:
8-
enable_annotations: false
8+
enable_attributes: false
99
mapping:
1010
paths:
1111
- "%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/files"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ framework:
77
secret: s3cr3t
88
validation:
99
enabled: true
10-
enable_annotations: true
10+
enable_attributes: true
1111
email_validation_mode: html5
1212

1313
services:

0 commit comments

Comments
 (0)
0