Skip to content

Commit a7b9cbf

Browse files
committed
do not parse attributes on abstract classes with DI < 7.4
1 parent 10fc77d commit a7b9cbf

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

DependencyInjection/FrameworkExtension.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
use Symfony\Component\Console\Debug\CliRequest;
6161
use Symfony\Component\Console\Messenger\RunCommandMessageHandler;
6262
use Symfony\Component\DependencyInjection\Alias;
63+
use Symfony\Component\DependencyInjection\Argument\ArgumentTrait;
6364
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
6465
use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
6566
use Symfony\Component\DependencyInjection\ChildDefinition;
@@ -1817,7 +1818,7 @@ private function registerValidationConfiguration(array $config, ContainerBuilder
18171818

18181819
// When attributes are disabled, it means from runtime-discovery only; autoconfiguration should still happen.
18191820
// And when runtime-discovery of attributes is enabled, we can skip compile-time autoconfiguration in debug mode.
1820-
if (class_exists(ValidatorAttributeMetadataPass::class) && (!($config['enable_attributes'] ?? false) || !$container->getParameter('kernel.debug'))) {
1821+
if (class_exists(ValidatorAttributeMetadataPass::class) && (!($config['enable_attributes'] ?? false) || !$container->getParameter('kernel.debug')) && trait_exists(ArgumentTrait::class)) {
18211822
// The $reflector argument hints at where the attribute could be used
18221823
$container->registerAttributeForAutoconfiguration(Constraint::class, function (ChildDefinition $definition, Constraint $attribute, \ReflectionClass|\ReflectionMethod|\ReflectionProperty $reflector) {
18231824
$definition->addTag('validator.attribute_metadata');

0 commit comments

Comments
 (0)