validation-bugsnag-email
This commit is contained in:
@@ -55,8 +55,10 @@ class TranslatorPass implements CompilerPassInterface
|
||||
|
||||
foreach ($container->findTaggedServiceIds('validator.constraint_validator', true) as $id => $attributes) {
|
||||
$serviceDefinition = $container->getDefinition($id);
|
||||
// Resolve constraint validator FQCN even if defined as %foo.validator.class% parameter
|
||||
$className = $container->getParameterBag()->resolveValue($serviceDefinition->getClass());
|
||||
// Extraction of the constraint class name from the Constraint Validator FQCN
|
||||
$constraintClassNames[] = str_replace('Validator', '', substr(strrchr($serviceDefinition->getClass(), '\\'), 1));
|
||||
$constraintClassNames[] = str_replace('Validator', '', substr(strrchr($className, '\\'), 1));
|
||||
}
|
||||
|
||||
$constraintVisitorDefinition->setArgument(0, $constraintClassNames);
|
||||
|
@@ -68,6 +68,19 @@ abstract class AbstractVisitor
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function nodeFirstNamedArgumentIndex(Node\Expr\CallLike|Node\Attribute|Node\Expr\New_ $node): int
|
||||
{
|
||||
$args = $node instanceof Node\Expr\CallLike ? $node->getRawArgs() : $node->args;
|
||||
|
||||
foreach ($args as $i => $arg) {
|
||||
if ($arg instanceof Node\Arg && null !== $arg->name) {
|
||||
return $i;
|
||||
}
|
||||
}
|
||||
|
||||
return \PHP_INT_MAX;
|
||||
}
|
||||
|
||||
private function getStringNamedArguments(Node\Expr\CallLike|Node\Attribute $node, string $argumentName = null, bool $isArgumentNamePattern = false): array
|
||||
{
|
||||
$args = $node instanceof Node\Expr\CallLike ? $node->getArgs() : $node->args;
|
||||
|
@@ -37,12 +37,13 @@ final class TransMethodVisitor extends AbstractVisitor implements NodeVisitor
|
||||
$name = (string) $node->name;
|
||||
|
||||
if ('trans' === $name || 't' === $name) {
|
||||
$nodeHasNamedArguments = $this->hasNodeNamedArguments($node);
|
||||
if (!$messages = $this->getStringArguments($node, $nodeHasNamedArguments ? 'message' : 0)) {
|
||||
$firstNamedArgumentIndex = $this->nodeFirstNamedArgumentIndex($node);
|
||||
|
||||
if (!$messages = $this->getStringArguments($node, 0 < $firstNamedArgumentIndex ? 0 : 'message')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$domain = $this->getStringArguments($node, $nodeHasNamedArguments ? 'domain' : 2)[0] ?? null;
|
||||
$domain = $this->getStringArguments($node, 2 < $firstNamedArgumentIndex ? 2 : 'domain')[0] ?? null;
|
||||
|
||||
foreach ($messages as $message) {
|
||||
$this->addMessageToCatalogue($message, $domain, $node->getStartLine());
|
||||
|
@@ -38,13 +38,13 @@ final class TranslatableMessageVisitor extends AbstractVisitor implements NodeVi
|
||||
return null;
|
||||
}
|
||||
|
||||
$nodeHasNamedArguments = $this->hasNodeNamedArguments($node);
|
||||
$firstNamedArgumentIndex = $this->nodeFirstNamedArgumentIndex($node);
|
||||
|
||||
if (!$messages = $this->getStringArguments($node, $nodeHasNamedArguments ? 'message' : 0)) {
|
||||
if (!$messages = $this->getStringArguments($node, 0 < $firstNamedArgumentIndex ? 0 : 'message')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$domain = $this->getStringArguments($node, $nodeHasNamedArguments ? 'domain' : 2)[0] ?? null;
|
||||
$domain = $this->getStringArguments($node, 2 < $firstNamedArgumentIndex ? 2 : 'domain')[0] ?? null;
|
||||
|
||||
foreach ($messages as $message) {
|
||||
$this->addMessageToCatalogue($message, $domain, $node->getStartLine());
|
||||
|
2
vendor/symfony/translation/LICENSE
vendored
2
vendor/symfony/translation/LICENSE
vendored
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2004-2022 Fabien Potencier
|
||||
Copyright (c) 2004-2023 Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
Reference in New Issue
Block a user