Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.0.0a2

Bug #20190 Invalid regex in Squiz_Sniffs_WhiteSpace_SuperfluousWhitespaceSniff
Submitted: 2014-01-31 07:03 UTC Modified: 2014-02-04 23:19 UTC
From: endeveit Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.5.1)
PHP Version: Irrelevant OS: Mac OS X
Roadmaps: (Not assigned)    
Subscription  


 [2014-01-31 07:03 UTC] endeveit (Nikita Vershinin)
Description: ------------ There is a regular expression to check lines for whitespaces in Squiz_Sniffs_WhiteSpace_SuperfluousWhitespaceSniff on line 200. With unicode cyrillic characters it doesn't work and should be this: '|^.*\s+$|u'

Comments

 [2014-02-02 23:25 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Feedback -Assigned To: +Assigned To: squiz
Are you able to provide me with some sample code that fails so I can write a unit test for it?
 [2014-02-03 07:09 UTC] endeveit (Nikita Vershinin)
Sure. The test PHP code: <?php function arrayWalkCallback() { // … some business logic // ?????? ?? ????????? ??????? ??? ????? ?????????? ?? ??????? $serviceKeys = ['re', 'hot', 'color', 'up', 'torg', 'wphoto', 'hasphoto', 'auto_re', 'uuid']; // … other business logic } That's how I run PHP_CodeSniffer: $ php vendor/bin/phpcs --standard=PSR2 --encoding=utf-8 test.php FILE: /Users/endeveit/projects/temp/test.php -------------------------------------------------------------------------------- FOUND 1 ERROR(S) AFFECTING 1 LINE(S) -------------------------------------------------------------------------------- 6 | ERROR | Whitespace found at end of line --------------------------------------------------------------------------------
 [2014-02-03 07:12 UTC] endeveit (Nikita Vershinin)
Pear has corrupted unicode. Here is the code on GitHub Gist https://gist.github.com/endeveit/8779468
 [2014-02-04 23:19 UTC] squiz (Greg Sherwood)
-Status: Feedback +Status: Closed
Thanks a lot for providing that code. I had already fixed this in the phpcs-fixer branch while doing automated fixes for end of line whitespace. At the time, I removed the regex all together as rtrim() worked well for this case. So I applied the same fix for master: https://github.com/squizlabs/PHP_CodeSniffer/commit/7a976e003d7c812f00b03866d3 3dfc32530cd3c3
 [2014-02-05 03:21 UTC] endeveit (Nikita Vershinin)
Thank you