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 9f6cbaa

Browse filesBrowse files
committed
minor #32047 [Validator] prevent double deprecation message (xabbuh)
This PR was merged into the 4.4 branch. Discussion ---------- [Validator] prevent double deprecation message | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Commits ------- ecded5e prevent double deprecation message
2 parents 68d1b3f + ecded5e commit 9f6cbaa
Copy full SHA for 9f6cbaa

File tree

1 file changed

+8
-7
lines changed
Filter options

1 file changed

+8
-7
lines changed

‎src/Symfony/Component/Validator/Constraints/ExpressionValidator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/ExpressionValidator.php
+8-7Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,16 @@ class ExpressionValidator extends ConstraintValidator
2727

2828
public function __construct(/*ExpressionLanguage */$expressionLanguage = null)
2929
{
30-
if (!$expressionLanguage instanceof ExpressionLanguage) {
31-
if (null !== $expressionLanguage) {
32-
@trigger_error(sprintf('The "%s" first argument must be an instance of "%s" or null since 4.4. "%s" given', __METHOD__, ExpressionLanguage::class, \is_object($expressionLanguage) ? \get_class($expressionLanguage) : \gettype($expressionLanguage)), E_USER_DEPRECATED);
33-
}
30+
if (\func_num_args() > 1) {
31+
@trigger_error(sprintf('The "%s" instance should be passed as "%s" first argument instead of second argument since 4.4.', ExpressionLanguage::class, __METHOD__), E_USER_DEPRECATED);
32+
33+
$expressionLanguage = func_get_arg(1);
3434

35-
if (\func_num_args() > 1 && func_get_arg(1) instanceof ExpressionLanguage) {
36-
@trigger_error(sprintf('The "%s" instance should be passed as "%s" first argument instead of second argument since 4.4.', ExpressionLanguage::class, __METHOD__), E_USER_DEPRECATED);
37-
$expressionLanguage = func_get_arg(1);
35+
if (null !== $expressionLanguage && !$expressionLanguage instanceof ExpressionLanguage) {
36+
throw new \TypeError(sprintf('Argument 2 passed to %s() must be an instance of %s or null, %s given. Since 4.4, passing it as the second argument is deprecated and will trigger a deprecation. Pass it as the first argument instead.', __METHOD__, ExpressionLanguage::class, \is_object($expressionLanguage) ? \get_class($expressionLanguage) : \gettype($expressionLanguage)));
3837
}
38+
} elseif (null !== $expressionLanguage && !$expressionLanguage instanceof ExpressionLanguage) {
39+
@trigger_error(sprintf('The "%s" first argument must be an instance of "%s" or null since 4.4. "%s" given', __METHOD__, ExpressionLanguage::class, \is_object($expressionLanguage) ? \get_class($expressionLanguage) : \gettype($expressionLanguage)), E_USER_DEPRECATED);
3940
}
4041

4142
$this->expressionLanguage = $expressionLanguage;

0 commit comments

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