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

Bug #20372 LineLength Rule with Multibyte Encoding
Submitted: 2014-08-20 15:22 UTC
From: xfragger Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.5.4)
PHP Version: 5.5.14 OS: MacOSX
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 7 - 6 = ?

 
 [2014-08-20 15:22 UTC] xfragger (Michael Fr)
Description: ------------ A Line, which contains 120 characters, but one character is multibyte, PHPCS counts 121 characters. Test script: --------------- $foo = ['name' => 'Möller', 'bar' => 'bar', 'xhsfjskahfsdjkashdjak' => 'lorem ipsum', 'anotherKey' => 'anotherValue12']; Expected result: ---------------- no warning Actual result: -------------- WARNING | Line exceeds 120 characters; contains 121 characters

Comments

 [2014-08-21 09:56 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Feedback -Assigned To: +Assigned To: squiz
If your code contains, or may contain, chars in a different charset, you need to specify the --encoding command line argument. Example is here: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#specifying- an-encoding In the 2.x versions, you can specify this in a custom coding standard as well. See the hard-coded command line values example here: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml You would use this: <arg name="encoding" value="utf8"/> This mostly just affects the line length checks, so the reduced performance isn't always desired for large code bases that don't tend to really care about line length warnings, so it isn't the default behaviour. In the future, I would like it to be, but I'd probably increase the min PHP version at the same time.
 [2014-08-21 16:41 UTC] xfragger (Michael Fr)
-Status: Feedback +Status: Closed
well, thanks... didn't see that encoding-settings