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 8d7b203

Browse filesBrowse files
linniksafabpot
authored andcommitted
[Validator] Fix use of GroupSequenceProvider in child classes
1 parent 26c9a0d commit 8d7b203
Copy full SHA for 8d7b203

File tree

3 files changed

+32
-10
lines changed
Filter options

3 files changed

+32
-10
lines changed

‎src/Symfony/Component/Validator/Mapping/ClassMetadata.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Mapping/ClassMetadata.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,10 @@ public function addGetterMethodConstraints($property, $method, array $constraint
381381
*/
382382
public function mergeConstraints(ClassMetadata $source)
383383
{
384+
if ($source->isGroupSequenceProvider()) {
385+
$this->setGroupSequenceProvider(true);
386+
}
387+
384388
foreach ($source->getConstraints() as $constraint) {
385389
$this->addConstraint(clone $constraint);
386390
}
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Validator\Tests\Fixtures;
13+
14+
class GroupSequenceProviderChildEntity extends GroupSequenceProviderEntity
15+
{
16+
}

‎src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php
+12-10Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class ClassMetadataTest extends TestCase
2424
const CLASSNAME = 'Symfony\Component\Validator\Tests\Fixtures\Entity';
2525
const PARENTCLASS = 'Symfony\Component\Validator\Tests\Fixtures\EntityParent';
2626
const PROVIDERCLASS = 'Symfony\Component\Validator\Tests\Fixtures\GroupSequenceProviderEntity';
27+
const PROVIDERCHILDCLASS = 'Symfony\Component\Validator\Tests\Fixtures\GroupSequenceProviderChildEntity';
2728

2829
protected $metadata;
2930

@@ -301,6 +302,17 @@ public function testGroupSequenceProvider()
301302
$this->assertTrue($metadata->isGroupSequenceProvider());
302303
}
303304

305+
public function testMergeConstraintsMergesGroupSequenceProvider()
306+
{
307+
$parent = new ClassMetadata(self::PROVIDERCLASS);
308+
$parent->setGroupSequenceProvider(true);
309+
310+
$metadata = new ClassMetadata(self::PROVIDERCHILDCLASS);
311+
$metadata->mergeConstraints($parent);
312+
313+
$this->assertTrue($metadata->isGroupSequenceProvider());
314+
}
315+
304316
/**
305317
* https://github.com/symfony/symfony/issues/11604.
306318
*/
@@ -309,13 +321,3 @@ public function testGetPropertyMetadataReturnsEmptyArrayWithoutConfiguredMetadat
309321
$this->assertCount(0, $this->metadata->getPropertyMetadata('foo'), '->getPropertyMetadata() returns an empty collection if no metadata is configured for the given property');
310322
}
311323
}
312-
313-
class ParentClass
314-
{
315-
public $example = 0;
316-
}
317-
318-
class ChildClass extends ParentClass
319-
{
320-
public $example = 1; // overrides parent property of same name
321-
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.