Skip to content

Commit 8b8d200

Browse files
committed
fix downgrade json const and fix token as array
1 parent df89283 commit 8b8d200

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

rules/DowngradePhp73/Rector/ConstFetch/DowngradePhp73JsonConstRector.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
use PhpParser\Node\Expr\ConstFetch;
1515
use PhpParser\Node\Expr\FuncCall;
1616
use PhpParser\Node\Expr\New_;
17+
use PhpParser\Node\Expr\Throw_;
1718
use PhpParser\Node\Name;
1819
use PhpParser\Node\Name\FullyQualified as NameFullyQualified;
1920
use PhpParser\Node\Stmt\Class_;
2021
use PhpParser\Node\Stmt\Expression;
2122
use PhpParser\Node\Stmt\Function_;
2223
use PhpParser\Node\Stmt\If_;
23-
use PhpParser\Node\Stmt\Throw_;
2424
use PhpParser\Node\Stmt\TryCatch;
2525
use PhpParser\Node\VariadicPlaceholder;
2626
use PhpParser\NodeVisitor;
@@ -219,12 +219,12 @@ private function refactorStmt(Expression $Expression): ?array
219219
),
220220
[
221221
'stmts' => [
222-
new Throw_(
222+
new Expression(new Throw_(
223223
new New_(
224224
new NameFullyQualified('Exception'),
225225
[new Arg(new FuncCall(new Name('json_last_error_msg')))]
226226
)
227-
),
227+
)),
228228
],
229229
]
230230
);

rules/DowngradePhp73/Tokenizer/FollowedByNewlineOnlyMaybeWithSemicolonAnalyzer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ public function isFollowed(File $file, Node $node): bool
1515

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

18-
if (isset($oldTokens[$nextTokenPosition]) && $oldTokens[$nextTokenPosition] === ';') {
18+
if (isset($oldTokens[$nextTokenPosition]) && (string) $oldTokens[$nextTokenPosition] === ';') {
1919
++$nextTokenPosition;
2020
}
2121

2222
return ! isset($oldTokens[$nextTokenPosition]) ||
23-
isset($oldTokens[$nextTokenPosition][1]) &&
24-
\str_starts_with((string) $oldTokens[$nextTokenPosition][1], "\n");
23+
isset($oldTokens[$nextTokenPosition]) &&
24+
\str_starts_with((string) $oldTokens[$nextTokenPosition], "\n");
2525
}
2626
}

0 commit comments

Comments
 (0)