Problem/Motivation
PHP version 8+ allow using named parameters in function calls, such as :
// Without named parameters
t('My @string', ['@string' => 'string'], ['context' => 'example context'];
// With parameters
t(string: 'My @string', args: ['@string' => 'string'], options: ['context' => 'example context'];
But sniffers rules do not handle them, and causes a 'Only string litterals should passed to t() where possible' warning.
Steps to reproduce
Call t() or $this->t() with named parameters.
Proposed resolution
I'm guessing the resolution would be something along the lines of the attached patch, which checks token against T_PARAM_NAME, but I'm pretty out of my league here, especially for the tests part.
Remaining tasks
- Confirm validity of proposed solution
- Add tests
I created this issue under feature request, but I'm unsure whether it should be a bug report instead.
Anyway,
Thanks in advance !
Comments
Comment #2
jmaxant commented