File tree 2 files changed +5
-5
lines changed 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,9 @@ public function setPrefix(string $prefix): void
64
64
65
65
protected function canBeExtracted (string $ file ): bool
66
66
{
67
- return 'php ' === pathinfo ($ file , \PATHINFO_EXTENSION ) && $ this ->isFile ($ file );
67
+ return 'php ' === pathinfo ($ file , \PATHINFO_EXTENSION )
68
+ && $ this ->isFile ($ file )
69
+ && preg_match ('/\bt\(|->trans\(|TranslatableMessage|Symfony \\\\Component \\\\Validator \\\\Constraints/i ' , file_get_contents ($ file ));
68
70
}
69
71
70
72
protected function extractFromDirectory (array |string $ resource ): iterable |Finder
Original file line number Diff line number Diff line change 21
21
*/
22
22
final class ConstraintVisitor extends AbstractVisitor implements NodeVisitor
23
23
{
24
- private const CONSTRAINT_VALIDATION_MESSAGE_PATTERN = '/[a-zA-Z]*message/i ' ;
25
-
26
24
public function __construct (
27
25
private readonly array $ constraintClassNames = []
28
26
) {
@@ -65,7 +63,7 @@ public function enterNode(Node $node): ?Node
65
63
}
66
64
67
65
if ($ this ->hasNodeNamedArguments ($ node )) {
68
- $ messages = $ this ->getStringArguments ($ node , self :: CONSTRAINT_VALIDATION_MESSAGE_PATTERN , true );
66
+ $ messages = $ this ->getStringArguments ($ node , ' /message/i ' , true );
69
67
} else {
70
68
if (!$ arg ->value instanceof Node \Expr \Array_) {
71
69
// There is no way to guess which argument is a message to be translated.
@@ -81,7 +79,7 @@ public function enterNode(Node $node): ?Node
81
79
continue ;
82
80
}
83
81
84
- if (! preg_match ( self :: CONSTRAINT_VALIDATION_MESSAGE_PATTERN , $ item ->key ->value ?? '' )) {
82
+ if (false === stripos ( $ item ->key ->value ?? '' , ' message ' )) {
85
83
continue ;
86
84
}
87
85
You can’t perform that action at this time.
0 commit comments