Skip to content

Commit 2bb00bc

Browse files
committed
Fixed bug #20119 : PHP warning: invalid argument to str_repeat() in SVN blame report with -s
1 parent 9814996 commit 2bb00bc

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

CodeSniffer/Reports/VersionControl.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,14 @@ public function generate(
170170
continue;
171171
}
172172

173-
$line = str_repeat(' ', (5 - strlen($count))).$count;
174-
echo ' '.$source.str_repeat(' ', ($width - 14 - strlen($source))).$line.PHP_EOL;
173+
$line = str_repeat(' ', (5 - strlen($count))).$count;
174+
$padding = ($width - 14 - strlen($source));
175+
if ($padding < 0) {
176+
$source = substr($source, 0, ($padding - 3)).'...';
177+
$padding = 0;
178+
}
179+
180+
echo ' '.$source.str_repeat(' ', $padding).$line.PHP_EOL;
175181
}
176182
}
177183
}//end foreach

package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
4141
-- Thanks to Maksim Kochkin for the patch
4242
- Fixed bug #20097 : CLI.php throws error in php 5.2
4343
- Fixed bug #20100 : incorrect Function mysql() has been deprecated report
44+
- Fixed bug #20119 : PHP warning: invalid argument to str_repeat() in SVN blame report with -s
4445
- Fixed bug #20123 : PSR2 complains about an empty second statement in for-loop
4546
- Fixed bug #20131 : PHP errors in svnblame report, if there are files not under version control
4647
</notes>

0 commit comments

Comments
 (0)