Description
Symfony version(s) affected
6.4.3
Description
PR #53624 ([Translation] Fix constant domain resolution in PhpAstExtractor) Introduces a new visitor for the PhpAstExtractor, that resolves methods and constant name spaces. See
The problem is that the TransMethodVisitor is unable to handle these namespaces. It is only aware of matching method names.
How to reproduce
- Checkout symonfy/symfony
- Run composer update
- Go to
src/Symfony/Component/Translation/Tests/Fixtures/extractor-ast/translatable-short.html.php
and replace the second line
- <?php t('translatable-short single-quoted key'); ?>
+ <?php use function Symfony\Component\Translation\t; t('translatable-short single-quoted key'); ?>
(e.g. importing the function that is used like people would do it in reallife. Just having t()
would result in an undefined function 't' and therefore this test case as it is at the moment does not reflect real life)
- Run the corresponding tests with
php ./phpunit symfony src/Symfony/Component/Translation/Tests/Extractor/PhpAstExtractorTest.php
Possible Solution
There are technically two solutions:
- Revert this pull request which breaks the extraction [Translation] Fix constant domain resolution in PhpAstExtractor #53624
- Fix the TransMethodVisitor so it can handle the fully qualified namespace of the detected method.
I am happy to invest my time to tackle solution 2, but obiously only if that would be the way to go. Please let me know ASAP
Additional Context
No response