Skip to content

Commit

Permalink
fix downgrade json const and fix token as array
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Nov 19, 2024
1 parent df89283 commit 8b8d200
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
use PhpParser\Node\Expr\ConstFetch;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Expr\New_;
use PhpParser\Node\Expr\Throw_;
use PhpParser\Node\Name;
use PhpParser\Node\Name\FullyQualified as NameFullyQualified;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\Expression;
use PhpParser\Node\Stmt\Function_;
use PhpParser\Node\Stmt\If_;
use PhpParser\Node\Stmt\Throw_;
use PhpParser\Node\Stmt\TryCatch;
use PhpParser\Node\VariadicPlaceholder;
use PhpParser\NodeVisitor;
Expand Down Expand Up @@ -219,12 +219,12 @@ private function refactorStmt(Expression $Expression): ?array
),
[
'stmts' => [
new Throw_(
new Expression(new Throw_(
new New_(
new NameFullyQualified('Exception'),
[new Arg(new FuncCall(new Name('json_last_error_msg')))]
)
),
)),
],
]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ public function isFollowed(File $file, Node $node): bool

$nextTokenPosition = $node->getEndTokenPos() + 1;

if (isset($oldTokens[$nextTokenPosition]) && $oldTokens[$nextTokenPosition] === ';') {
if (isset($oldTokens[$nextTokenPosition]) && (string) $oldTokens[$nextTokenPosition] === ';') {
++$nextTokenPosition;
}

return ! isset($oldTokens[$nextTokenPosition]) ||
isset($oldTokens[$nextTokenPosition][1]) &&
\str_starts_with((string) $oldTokens[$nextTokenPosition][1], "\n");
isset($oldTokens[$nextTokenPosition]) &&
\str_starts_with((string) $oldTokens[$nextTokenPosition], "\n");
}
}

0 comments on commit 8b8d200

Please sign in to comment.