2. Magento v2.4.5-p1
3. PHP v8.1
4. magento/magento-coding-standart v29
### Steps to reproduce
vendor/bin/phpcs --standart=Magento2 app/code/MyModule
### Expected result
No errors
### Actual result
Fatal PHP error:
PHP Fatal error: Uncaught ValueError: strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) in /var/www/html/vendor/magento/magento-coding-standard/Magento2/Sniffs/Less/ClassNamingSniff.php:69
Stack trace:
thrown in /var/www/html/vendor/magento/magento-coding-standard/Magento2/Sniffs/Less/ClassNamingSniff.php on line 69
### Additional description
The similar error was described in the other issue ( #425 ). But in that case, the problem relates directly to the length of the class name in one character (".a" is expected).
However, this report shows that the problem may be more global. In this example, a common construction of the LESS library is used. It allows usage the parameter of the mixin as a selector for the class name (link to the official LESS documentation, which confirms the validity of this construction: https://lesscss.org/features/#variables-feature-variable-interpolation).
**The parser treats the "@" symbol as a class name, when in fact it is not.**
I may be using an outdated version of the module "magento/magento-coding-standart" (v29), though I haven't found a newer one for Magento v2.4.5-p1.
Please, if it's not difficult, fix this bug, if it is.
Please suggest a temporary workaround for this issue.
Also, it may be useful:
- this error was not reproduced in Magento v2.4.3-p1, PHP v7.4, magento/magento-coding-standart v6
Preconditions
.mixin-example(input-box)
PHP Fatal error: Uncaught ValueError: strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) in /var/www/html/vendor/magento/magento-coding-standard/Magento2/Sniffs/Less/ClassNamingSniff.php:69 Stack trace:
0 /var/www/html/vendor/magento/magento-coding-standard/Magento2/Sniffs/Less/ClassNamingSniff.php(69): strpos('@', '_', 2)
1 /var/www/html/vendor/squizlabs/php_codesniffer/src/Files/File.php(498): Magento2\Sniffs\Less\ClassNamingSniff->process()
2 /var/www/html/vendor/squizlabs/php_codesniffer/src/Files/LocalFile.php(92): PHP_CodeSniffer\Files\File->process()
3 /var/www/html/vendor/squizlabs/php_codesniffer/src/Runner.php(628): PHP_CodeSniffer\Files\LocalFile->process()
4 /var/www/html/vendor/squizlabs/php_codesniffer/src/Runner.php(434): PHP_CodeSniffer\Runner->processFile()
5 /var/www/html/vendor/squizlabs/php_codesniffer/src/Runner.php(114): PHP_CodeSniffer\Runner->run()
6 /var/www/html/vendor/squizlabs/php_codesniffer/bin/phpcs(18): PHP_CodeSniffer\Runner->runPHPCS()
7 {main}
thrown in /var/www/html/vendor/magento/magento-coding-standard/Magento2/Sniffs/Less/ClassNamingSniff.php on line 69