From a24f6d455a879922307717e3994d17f88f26c0ca Mon Sep 17 00:00:00 2001 From: Greg Sherwood Date: Mon, 14 Oct 2019 08:40:14 +1100 Subject: [PATCH] Fixed indent check when function is called inside an array declaration (ref #2647) --- .../PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php | 3 ++- .../PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc | 7 +++++++ .../Functions/FunctionCallSignatureUnitTest.inc.fixed | 7 +++++++ .../PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php | 1 + 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php b/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php index 59a41cdbe0..7ac5a90174 100644 --- a/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php +++ b/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php @@ -349,7 +349,8 @@ public function processMultiLineCall(File $phpcsFile, $stackPtr, $openBracket, $ $foundFunctionIndent = 0; if ($first !== false) { if ($tokens[$first]['code'] === T_INLINE_HTML - || $tokens[$first]['code'] === T_CONSTANT_ENCAPSED_STRING + || ($tokens[$first]['code'] === T_CONSTANT_ENCAPSED_STRING + && $tokens[($first - 1)]['code'] === T_CONSTANT_ENCAPSED_STRING) ) { $trimmed = ltrim($tokens[$first]['content']); if ($trimmed === '') { diff --git a/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc b/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc index e6d4f4a35c..270c331bbb 100644 --- a/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc +++ b/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc @@ -457,3 +457,10 @@ WHERE f IN(" . implode( ) . ")"; } } + +$notices = array( + 'index' => sprintf( + translation_function('a text string with %s placeholder'), + 'replacement' + ), +); diff --git a/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc.fixed b/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc.fixed index ecfef3f420..b072f876c6 100644 --- a/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc.fixed +++ b/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc.fixed @@ -467,3 +467,10 @@ WHERE f IN(" . implode( ) . ")"; } } + +$notices = array( + 'index' => sprintf( + translation_function('a text string with %s placeholder'), + 'replacement' + ), +); diff --git a/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php b/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php index ca6cc42032..5f7d8916f3 100644 --- a/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php +++ b/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.php @@ -122,6 +122,7 @@ public function getErrorList($testFile='FunctionCallSignatureUnitTest.inc') 455 => 1, 456 => 1, 457 => 1, + 464 => 1, ]; }//end getErrorList()