Skip to content

Commit a05defe

Browse files
committed
Fix wrong expression language value
1 parent 4e8bb2f commit a05defe

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

Constraints/ExpressionValidator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public function __construct(/*ExpressionLanguage */$expressionLanguage = null)
3737
}
3838
} elseif (null !== $expressionLanguage && !$expressionLanguage instanceof ExpressionLanguage) {
3939
@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);
40+
41+
$expressionLanguage = null;
4042
}
4143

4244
$this->expressionLanguage = $expressionLanguage;

Tests/Constraints/ExpressionValidatorTest.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Validator\Tests\Constraints;
1313

1414
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
15+
use Symfony\Component\PropertyAccess\PropertyAccess;
1516
use Symfony\Component\Validator\Constraints\Expression;
1617
use Symfony\Component\Validator\Constraints\ExpressionValidator;
1718
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
@@ -302,11 +303,13 @@ public function testLegacyExpressionLanguageUsage()
302303

303304
/**
304305
* @group legacy
305-
* @expectedDeprecation The "Symfony\Component\Validator\Constraints\ExpressionValidator::__construct" first argument must be an instance of "Symfony\Component\ExpressionLanguage\ExpressionLanguage" or null since 4.4. "string" given
306+
* @expectedDeprecation The "Symfony\Component\Validator\Constraints\ExpressionValidator::__construct" first argument must be an instance of "Symfony\Component\ExpressionLanguage\ExpressionLanguage" or null since 4.4. "Symfony\Component\PropertyAccess\PropertyAccessor" given
306307
*/
307-
public function testConstructorInvalidType()
308+
public function testDeprecatedArgumentType()
308309
{
309-
new ExpressionValidator('foo');
310+
$validator = new ExpressionValidator(PropertyAccess::createPropertyAccessor());
311+
$validator->initialize($this->createContext());
312+
$validator->validate(null, new Expression(['expression' => 'false']));
310313
}
311314

312315
public function testPassingCustomValues()

0 commit comments

Comments
 (0)