Closed
Description
Description
ConstantUsageSniff (Magento2.Translation.ConstantUsage) should be deleted because it encourage code duplication (what is bad practice) by message: Constants are not allowed as the first argument of translation function, use string literal instead
.
Expected behavior
Don't inspect if constants used as first argument of translation function.
Benefits
Less code duplicates - less bugs.
Additional information
Seems that this Sniff and code recomendation exists because magento command bin/magento i18n:collect-phrases
in current implementation couldn't extract strings from constants.
Some ideas how to fix it:
- implement constant resolving in
i18n:collect-phrases
(maybe by nikic/PHP-Parser) - the most obvious but difficult for implementation way; - extract constants used in translation function that would be inspected manually by developers (with pointing to file and line) by command line option - the most easy for implementation way;
- extract all strings from files or just strings that not used in translation function by command line option;
- extract all constant strings by command line option;