Skip to content

Commit a200644

Browse files
committed
Fixed bug #1560 : Squiz.Commenting.FunctionComment fatal error when fixing additional param comment lines that have no indent
1 parent cc5174a commit a200644

File tree

5 files changed

+50
-0
lines changed

5 files changed

+50
-0
lines changed

package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
5151
-- Thanks to Michał Bundyra for the patch
5252
- Fixed bug #1549 : Squiz.PHP.EmbeddedPhp fixer conflict with // comment before PHP close tag
5353
-- Thanks to Juliette Reinders Folmer for the patch
54+
- Fixed bug #1560 : Squiz.Commenting.FunctionComment fatal error when fixing additional param comment lines that have no indent
5455
</notes>
5556
<contents>
5657
<dir name="/">

src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,10 @@ protected function checkSpacingAfterParamName(File $phpcsFile, $param, $maxVar,
646646

647647
$diff = ($param['var_space'] - $spaces);
648648
$newIndent = ($param['commentLines'][$lineNum]['indent'] - $diff);
649+
if ($newIndent <= 0) {
650+
continue;
651+
}
652+
649653
$phpcsFile->fixer->replaceToken(
650654
($param['commentLines'][$lineNum]['token'] - 1),
651655
str_repeat(' ', $newIndent)

src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,3 +877,24 @@ function yieldFromTest()
877877
{
878878
yield from foo();
879879
}
880+
881+
/**
882+
* Audio
883+
*
884+
* Generates an audio element to embed sounds
885+
*
886+
* @param mixed $src Either a source string or
887+
* an array of sources.
888+
* @param string $unsupportedMessage The message to display
889+
* if the media tag is not supported by the browser.
890+
* @param string $attributes HTML attributes.
891+
* @return string
892+
*/
893+
function audio(
894+
$src,
895+
string $unsupportedMessage = '',
896+
string $attributes = '',
897+
): string
898+
{
899+
return 'test';
900+
}

src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc.fixed

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,3 +877,24 @@ function yieldFromTest()
877877
{
878878
yield from foo();
879879
}
880+
881+
/**
882+
* Audio
883+
*
884+
* Generates an audio element to embed sounds
885+
*
886+
* @param mixed $src Either a source string or
887+
* an array of sources.
888+
* @param string $unsupportedMessage The message to display
889+
* if the media tag is not supported by the browser.
890+
* @param string $attributes HTML attributes.
891+
* @return string
892+
*/
893+
function audio(
894+
$src,
895+
string $unsupportedMessage = '',
896+
string $attributes = '',
897+
): string
898+
{
899+
return 'test';
900+
}

src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ public function getErrorList()
107107
840 => 1,
108108
852 => 1,
109109
864 => 1,
110+
886 => 1,
111+
888 => 1,
112+
890 => 1,
110113
);
111114

112115
// The yield tests will only work in PHP versions where yield exists and

0 commit comments

Comments
 (0)