Skip to content

Commit

Permalink
[#1949] UseSuggestedReplacementFixer: harden against exceptions in bl…
Browse files Browse the repository at this point in the history
…ade files.
  • Loading branch information
ea-inspections-team committed Sep 20, 2024
1 parent 3b958a5 commit 7198dc3
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,18 @@ public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descri
.createPhpPsiFromText(project, ParenthesizedExpression.class, '(' + this.expression + ')')
.getArgument();
if (replacement != null && !project.isDisposed()) {
expression.replace(replacement);
try {
expression.replace(replacement);
} catch (final Throwable failure) {
/*
* It were multiple reports pointing to exceptions which might be related to blade support implementation.
* The best we can do is to make it less disruptive for blade files and keep exception for other files.
*/
final boolean isBladeFile = descriptor.getPsiElement().getContainingFile().getVirtualFile().getName().endsWith(".blade.php");
if (! isBladeFile) {
throw failure;
}
}
}
}
}
Expand Down

0 comments on commit 7198dc3

Please sign in to comment.