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 f825f5d

Browse filesBrowse files
committed
minor #11615 [Validator] return empty metadata collection if none do exist (xabbuh)
This PR was merged into the 2.3 branch. Discussion ---------- [Validator] return empty metadata collection if none do exist | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | [The reference to the documentation PR if any] Backport of #11614 for Symfony 2.3 and 2.4. Commits ------- f5bc18d return empty metadata collection if none do exist
2 parents b674e67 + f5bc18d commit f825f5d
Copy full SHA for f825f5d

File tree

2 files changed

+24
-0
lines changed
Filter options

2 files changed

+24
-0
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Mapping/ClassMetadata.php
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,10 @@ public function hasMemberMetadatas($property)
298298
*/
299299
public function getMemberMetadatas($property)
300300
{
301+
if (!isset($this->members[$property])) {
302+
return array();
303+
}
304+
301305
return $this->members[$property];
302306
}
303307

@@ -314,6 +318,10 @@ public function hasPropertyMetadata($property)
314318
*/
315319
public function getPropertyMetadata($property)
316320
{
321+
if (!isset($this->members[$property])) {
322+
return array();
323+
}
324+
317325
return $this->members[$property];
318326
}
319327

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,4 +222,20 @@ public function testGroupSequenceProvider()
222222
$metadata->setGroupSequenceProvider(true);
223223
$this->assertTrue($metadata->isGroupSequenceProvider());
224224
}
225+
226+
/**
227+
* https://github.com/symfony/symfony/issues/11604
228+
*/
229+
public function testGetMemberMetadatasReturnsEmptyArrayWithoutConfiguredMetadata()
230+
{
231+
$this->assertCount(0, $this->metadata->getMemberMetadatas('foo'), '->getMemberMetadatas() returns an empty collection if no metadata is configured for the given property');
232+
}
233+
234+
/**
235+
* https://github.com/symfony/symfony/issues/11604
236+
*/
237+
public function testGetPropertyMetadataReturnsEmptyArrayWithoutConfiguredMetadata()
238+
{
239+
$this->assertCount(0, $this->metadata->getPropertyMetadata('foo'), '->getPropertyMetadata() returns an empty collection if no metadata is configured for the given property');
240+
}
225241
}

0 commit comments

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