Skip to content

Commit

Permalink
fix phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
klausi committed Dec 31, 2024
1 parent 3864ca6 commit cd24c23
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions coder_sniffer/Drupal/Sniffs/WhiteSpace/ScopeIndentSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class ScopeIndentSniff implements Sniff
* or PHP open/close tags can escape from here and have their own
* rules elsewhere.
*
* @var int[]
* @var array<int, int|string>
*/
public $ignoreIndentationTokens = [];

Expand Down Expand Up @@ -153,6 +153,7 @@ public function process(File $phpcsFile, $stackPtr)
$setIndents = [];
$disableExactStack = [];
$disableExactEnd = 0;
$tokenIndent = 0;

$tokens = $phpcsFile->getTokens();
$first = $phpcsFile->findFirstOnLine(T_INLINE_HTML, $stackPtr);
Expand Down Expand Up @@ -189,11 +190,6 @@ public function process(File $phpcsFile, $stackPtr)
$checkAnnotations = $phpcsFile->config->annotations;

for ($i = ($stackPtr + 1); $i < $phpcsFile->numTokens; $i++) {
if ($i === false) {
// Something has gone very wrong; maybe a parse error.
break;
}

if ($checkAnnotations === true
&& $tokens[$i]['code'] === T_PHPCS_SET
&& isset($tokens[$i]['sniffCode']) === true
Expand Down Expand Up @@ -1573,7 +1569,7 @@ protected function adjustIndent(File $phpcsFile, $stackPtr, $length, $change)
$padding = '';
if ($length > 0) {
if ($this->tabIndent === true) {
$numTabs = floor($length / $this->tabWidth);
$numTabs = (int) floor($length / $this->tabWidth);
if ($numTabs > 0) {
$numSpaces = ($length - ($numTabs * $this->tabWidth));
$padding = str_repeat("\t", $numTabs).str_repeat(' ', $numSpaces);
Expand Down Expand Up @@ -1611,7 +1607,7 @@ protected function adjustIndent(File $phpcsFile, $stackPtr, $length, $change)
$padding = ($length + $change);
if ($padding > 0) {
if ($this->tabIndent === true) {
$numTabs = floor($padding / $this->tabWidth);
$numTabs = (int) floor($padding / $this->tabWidth);
$numSpaces = ($padding - ($numTabs * $this->tabWidth));
$padding = str_repeat("\t", $numTabs).str_repeat(' ', $numSpaces);
} else {
Expand Down

0 comments on commit cd24c23

Please sign in to comment.