Skip to content

Commit

Permalink
fix isCandidate for empty monolithic files
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Jan 10, 2024
1 parent 964410d commit 874b011
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Fixer/Comment/HeaderCommentFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function isCandidate(Tokens $tokens): bool
{
if ($tokens->isMonolithicPhp()) {
$openTagIndex = $tokens[0]->isGivenKind(T_INLINE_HTML) ? 1 : 0;
if (!$tokens[$openTagIndex]->isGivenKind(T_OPEN_TAG_WITH_ECHO)) {
if ($tokens->count() > $openTagIndex && !$tokens[$openTagIndex]->isGivenKind(T_OPEN_TAG_WITH_ECHO)) {
return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/PhpTag/BlankLineAfterOpeningTagFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function isCandidate(Tokens $tokens): bool
{
if ($tokens->isMonolithicPhp()) {
$openTagIndex = $tokens[0]->isGivenKind(T_INLINE_HTML) ? 1 : 0;
if (!$tokens[$openTagIndex]->isGivenKind(T_OPEN_TAG_WITH_ECHO)) {
if ($tokens->count() > $openTagIndex && !$tokens[$openTagIndex]->isGivenKind(T_OPEN_TAG_WITH_ECHO)) {
return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/PhpTag/LinebreakAfterOpeningTagFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function isCandidate(Tokens $tokens): bool
{
if ($tokens->isMonolithicPhp()) {
$openTagIndex = $tokens[0]->isGivenKind(T_INLINE_HTML) ? 1 : 0;
if (!$tokens[$openTagIndex]->isGivenKind(T_OPEN_TAG_WITH_ECHO)) {
if ($tokens->count() > $openTagIndex && !$tokens[$openTagIndex]->isGivenKind(T_OPEN_TAG_WITH_ECHO)) {
return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/Strict/DeclareStrictTypesFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function isCandidate(Tokens $tokens): bool
{
if ($tokens->isMonolithicPhp()) {
$openTagIndex = $tokens[0]->isGivenKind(T_INLINE_HTML) ? 1 : 0;
if (!$tokens[$openTagIndex]->isGivenKind(T_OPEN_TAG_WITH_ECHO)) {
if ($tokens->count() > $openTagIndex && !$tokens[$openTagIndex]->isGivenKind(T_OPEN_TAG_WITH_ECHO)) {
return true;
}
}
Expand Down

0 comments on commit 874b011

Please sign in to comment.