Skip to content

Commit 5c9586b

Browse files
committed
Fixed bug #2768 : Generic.Files.LineLength false positive for non-breakable strings at exactly the soft limit
1 parent 120c713 commit 5c9586b

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

package.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ http://pear.php.net/dtd/package-2.0.xsd">
3030
-- Thanks to Matthew Peveler for the patch
3131
- Fixed bug #2751 : Autoload relative paths first to avoid confusion with files from the global include path
3232
-- Thanks to Klaus Purer for the patch
33+
- Fixed bug #2768 : Generic.Files.LineLength false positive for non-breakable strings at exactly the soft limit
34+
-- Thanks to Alex Miles for the patch
3335
</notes>
3436
<contents>
3537
<dir name="/">

src/Standards/Generic/Sniffs/Files/LineLengthSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ protected function checkLineLength($phpcsFile, $tokens, $stackPtr)
158158
// to ignore the line length in these cases if the URL would be longer than the max
159159
// line length once you indent it to the correct level.
160160
if ($lineLength > $this->lineLimit) {
161-
$oldLength = $tokens[$stackPtr]['length'];
161+
$oldLength = strlen($tokens[$stackPtr]['content']);
162162
$newLength = strlen(ltrim($tokens[$stackPtr]['content'], "/#\t "));
163163
$indent = (($tokens[$stackPtr]['column'] - 1) + ($oldLength - $newLength));
164164

src/Standards/Generic/Tests/Files/LineLengthUnitTest.3.inc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,12 @@ phpcs:set Generic.Files.LineLength absoluteLineLimit 150
55
/* This line is fine. This line is fine. This line is fine. This line is fine. This line is fine. */
66
/* This line is too long. This line is too long. This line is too long. This line is too long. This line is too long. This line is too long. */
77
/* This line is too long. This line is too long. This line is too long. This line is too long. This line is too long. This line is too long. This line is too long. */
8+
9+
/*
10+
| ...
11+
http://symfony.com/doc/current/cookbook/doctrine/dbal.html#registering-custom-mapping-types-in-the-schematoo
12+
http://symfony.com/doc/current/cookbook/doctrine/dbal.html#registering-custom-mapping-types-in-the-schematool
13+
http://symfony.com/doc/current/cookbook/doctrine/dbal.html#registering-custom-mapping-types-in-the-schematool1
14+
http://symfony.com/doc/current/cookbook/doctrine/dbal.html#registering-custom-mapping-types-in-the-schematool12
15+
| ...
16+
*/

0 commit comments

Comments
 (0)