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 0254e4b
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 @@ -113,7 +113,7 @@ public function getDefinition(): FixerDefinitionInterface
public function isCandidate(Tokens $tokens): bool
{
if ($tokens->isMonolithicPhp()) {
$openTagIndex = $tokens[0]->isGivenKind(T_INLINE_HTML) ? 1 : 0;
$openTagIndex = $tokens[0]->isGivenKind(T_INLINE_HTML) && $tokens->count() > 1 ? 1 : 0;
if (!$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 @@ -49,7 +49,7 @@ public function getPriority(): int
public function isCandidate(Tokens $tokens): bool
{
if ($tokens->isMonolithicPhp()) {
$openTagIndex = $tokens[0]->isGivenKind(T_INLINE_HTML) ? 1 : 0;
$openTagIndex = $tokens[0]->isGivenKind(T_INLINE_HTML) && $tokens->count() > 1 ? 1 : 0;
if (!$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 @@ -38,7 +38,7 @@ public function getDefinition(): FixerDefinitionInterface
public function isCandidate(Tokens $tokens): bool
{
if ($tokens->isMonolithicPhp()) {
$openTagIndex = $tokens[0]->isGivenKind(T_INLINE_HTML) ? 1 : 0;
$openTagIndex = $tokens[0]->isGivenKind(T_INLINE_HTML) && $tokens->count() > 1 ? 1 : 0;
if (!$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 @@ -54,7 +54,7 @@ public function getPriority(): int
public function isCandidate(Tokens $tokens): bool
{
if ($tokens->isMonolithicPhp()) {
$openTagIndex = $tokens[0]->isGivenKind(T_INLINE_HTML) ? 1 : 0;
$openTagIndex = $tokens[0]->isGivenKind(T_INLINE_HTML) && $tokens->count() > 1 ? 1 : 0;
if (!$tokens[$openTagIndex]->isGivenKind(T_OPEN_TAG_WITH_ECHO)) {
return true;
}
Expand Down

0 comments on commit 0254e4b

Please sign in to comment.