Skip to content

Commit 9445108

Browse files
committed
Fixed bug #3666 : PEAR.Functions.FunctionCallSignature incorrect indent fix when checking mixed HTML/PHP files
1 parent 1985539 commit 9445108

File tree

5 files changed

+46
-1
lines changed

5 files changed

+46
-1
lines changed

package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
4444
-- Thanks to Alex Panshin (@enl) for the patch
4545
- Fixed bug #3653 : False positives for match() in OperatorSpacingSniff
4646
-- Thanks to Jaroslav Hanslík (@kukulich) for the patch
47+
- Fixed bug #3666 : PEAR.Functions.FunctionCallSignature incorrect indent fix when checking mixed HTML/PHP files
4748
</notes>
4849
<contents>
4950
<dir name="/">

src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,11 +390,14 @@ public function processMultiLineCall(File $phpcsFile, $stackPtr, $openBracket, $
390390
$padding = str_repeat(' ', $functionIndent);
391391
if ($foundFunctionIndent === 0) {
392392
$phpcsFile->fixer->addContentBefore($first, $padding);
393+
} else if ($tokens[$first]['code'] === T_INLINE_HTML) {
394+
$newContent = $padding.ltrim($tokens[$first]['content']);
395+
$phpcsFile->fixer->replaceToken($first, $newContent);
393396
} else {
394397
$phpcsFile->fixer->replaceToken(($first - 1), $padding);
395398
}
396399
}
397-
}
400+
}//end if
398401

399402
$next = $phpcsFile->findNext(Tokens::$emptyTokens, ($openBracket + 1), null, true);
400403
if ($tokens[$next]['line'] === $tokens[$openBracket]['line']) {

src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,3 +548,22 @@ array_fill_keys(
548548
), value: true,
549549
);
550550
// phpcs:set PEAR.Functions.FunctionCallSignature allowMultipleArguments true
551+
552+
?>
553+
<div>
554+
<p/><?php require get_theme_file_path(
555+
'/theme_extra/test_block.php'
556+
); ?></p>
557+
</div>
558+
<div>
559+
<p/><?php require get_theme_file_path(
560+
'/theme_extra/test_block.php'
561+
); ?></p>
562+
</div>
563+
<?php
564+
echo 'hi';
565+
?>
566+
content
567+
<p><?php require get_theme_file_path(
568+
'/theme_extra/test_block.php'
569+
); ?></p>

src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc.fixed

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,3 +563,22 @@ array_fill_keys(
563563
value: true,
564564
);
565565
// phpcs:set PEAR.Functions.FunctionCallSignature allowMultipleArguments true
566+
567+
?>
568+
<div>
569+
<p/><?php require get_theme_file_path(
570+
'/theme_extra/test_block.php'
571+
); ?></p>
572+
</div>
573+
<div>
574+
<p/><?php require get_theme_file_path(
575+
'/theme_extra/test_block.php'
576+
); ?></p>
577+
</div>
578+
<?php
579+
echo 'hi';
580+
?>
581+
content
582+
<p><?php require get_theme_file_path(
583+
'/theme_extra/test_block.php'
584+
); ?></p>

src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ public function getErrorList($testFile='FunctionCallSignatureUnitTest.inc')
131131
546 => 1,
132132
547 => 1,
133133
548 => 1,
134+
559 => 1,
135+
567 => 1,
136+
568 => 1,
134137
];
135138

136139
}//end getErrorList()

0 commit comments

Comments
 (0)