Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEAR/FunctionCallSignature: minor tweaks + extra test #3667

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,8 @@ public function processMultiLineCall(File $phpcsFile, $stackPtr, $openBracket, $
// call itself is, so we can work out how far to
// indent the arguments.
$first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $stackPtr, true);
if ($tokens[$first]['code'] === T_CONSTANT_ENCAPSED_STRING
if ($first !== false
&& $tokens[$first]['code'] === T_CONSTANT_ENCAPSED_STRING
&& $tokens[($first - 1)]['code'] === T_CONSTANT_ENCAPSED_STRING
) {
// We are in a multi-line string, so find the start and use
Expand Down Expand Up @@ -386,8 +387,10 @@ public function processMultiLineCall(File $phpcsFile, $stackPtr, $openBracket, $

$fix = $phpcsFile->addFixableError($error, $first, 'OpeningIndent', $data);
if ($fix === true) {
// Set adjustment for use later to determine whether argument indentation is correct when fixing.
$adjustment = ($functionIndent - $foundFunctionIndent);
$padding = str_repeat(' ', $functionIndent);

$padding = str_repeat(' ', $functionIndent);
if ($foundFunctionIndent === 0) {
$phpcsFile->fixer->addContentBefore($first, $padding);
} else if ($tokens[$first]['code'] === T_INLINE_HTML) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -567,3 +567,10 @@ content
<p><?php require get_theme_file_path(
'/theme_extra/test_block.php'
); ?></p>

<!-- If the first token is inline HTML, the token itself should be adjusted, not the token before. -->
<?php if (check_me() == 'value'): ?>
<?php include get_file_path(
'my_file.php'
); ?>
<?php endif; ?>
Original file line number Diff line number Diff line change
Expand Up @@ -582,3 +582,10 @@ content
<p><?php require get_theme_file_path(
'/theme_extra/test_block.php'
); ?></p>

<!-- If the first token is inline HTML, the token itself should be adjusted, not the token before. -->
<?php if (check_me() == 'value'): ?>
<?php include get_file_path(
'my_file.php'
); ?>
<?php endif; ?>
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ public function getErrorList($testFile='FunctionCallSignatureUnitTest.inc')
559 => 1,
567 => 1,
568 => 1,
573 => 1,
574 => 1,
];

}//end getErrorList()
Expand Down