55use PHP_CodeSniffer \Files \File ;
66use PHP_CodeSniffer \Sniffs \Sniff ;
77use SlevomatCodingStandard \Helpers \FixerHelper ;
8+ use SlevomatCodingStandard \Helpers \IndentationHelper ;
89use SlevomatCodingStandard \Helpers \SniffSettingsHelper ;
910use SlevomatCodingStandard \Helpers \TernaryOperatorHelper ;
1011use SlevomatCodingStandard \Helpers \TokenHelper ;
@@ -24,9 +25,6 @@ class RequireMultiLineTernaryOperatorSniff implements Sniff
2425
2526 public const CODE_MULTI_LINE_TERNARY_OPERATOR_NOT_USED = 'MultiLineTernaryOperatorNotUsed ' ;
2627
27- private const TAB_INDENT = "\t" ;
28- private const SPACES_INDENT = ' ' ;
29-
3028 /** @var int */
3129 public $ lineLengthLimit = 0 ;
3230
@@ -167,11 +165,14 @@ private function getIndentation(File $phpcsFile, int $endOfLinePointer): string
167165 $ actualIndentation = TokenHelper::getContent ($ phpcsFile , $ endOfLinePointer + 1 , $ pointerAfterWhitespace - 1 );
168166
169167 if (strlen ($ actualIndentation ) !== 0 ) {
170- return $ actualIndentation . (substr ($ actualIndentation , -1 ) === self ::TAB_INDENT ? self ::TAB_INDENT : self ::SPACES_INDENT );
168+ return $ actualIndentation . (substr (
169+ $ actualIndentation ,
170+ -1
171+ ) === IndentationHelper::TAB_INDENT ? IndentationHelper::TAB_INDENT : IndentationHelper::SPACES_INDENT );
171172 }
172173
173- $ tabPointer = TokenHelper::findPreviousContent ($ phpcsFile , T_WHITESPACE , self ::TAB_INDENT , $ endOfLinePointer - 1 );
174- return $ tabPointer !== null ? self ::TAB_INDENT : self ::SPACES_INDENT ;
174+ $ tabPointer = TokenHelper::findPreviousContent ($ phpcsFile , T_WHITESPACE , IndentationHelper ::TAB_INDENT , $ endOfLinePointer - 1 );
175+ return $ tabPointer !== null ? IndentationHelper ::TAB_INDENT : IndentationHelper ::SPACES_INDENT ;
175176 }
176177
177178}
0 commit comments