Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitdc8a43b

Browse files
committed
bug#40416 FixConstraintViolation#getMessageTemplate() to always returnstring (Ocramius)
This PR was merged into the 5.2 branch.Discussion----------Fix `ConstraintViolation#getMessageTemplate()` to always return `string`| Q | A| ------------- | ---| Branch? | 5.2| Bug fix? | yes| New feature? | no| Deprecations? | no| Tickets || License | MIT| Doc PR |`ConstraintViolation#getMessageTemplate()`'s inherited signature states that `string` isto be returned by it at all times, yet the implementation returns `null` when no messagetemplate had been provided at instantiation.This patch obviates it, returning an empty string when themessage template is `null`.Ref:#40415 (comment)Commits-------72a464e Fix `ConstraintViolation#getMessageTemplate()` to always return `string`
2 parents16bacb1 +72a464e commitdc8a43b

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

‎src/Symfony/Component/Validator/ConstraintViolation.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function __toString()
100100
*/
101101
publicfunctiongetMessageTemplate()
102102
{
103-
return$this->messageTemplate;
103+
return(string)$this->messageTemplate;
104104
}
105105

106106
/**

‎src/Symfony/Component/Validator/Tests/ConstraintViolationTest.php‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,19 @@ public function testRetrievedPropertyPathIsAStringEvenIfNotSet()
171171
))->getPropertyPath()
172172
);
173173
}
174+
175+
publicfunctiontestRetrievedMessageTemplateIsAStringEvenIfNotSet()
176+
{
177+
self::assertSame(
178+
'',
179+
(newConstraintViolation(
180+
'irrelevant',
181+
null,
182+
[],
183+
'irrelevant',
184+
'irrelevant',
185+
null
186+
))->getMessageTemplate()
187+
);
188+
}
174189
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp