Skip to content

Commit

Permalink
Do not crash for comments that raise compile error (#986)
Browse files Browse the repository at this point in the history
  • Loading branch information
kubawerlos committed Aug 16, 2024
1 parent 8d93f68 commit 8701394
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Latest stable version](https://img.shields.io/packagist/v/kubawerlos/php-cs-fixer-custom-fixers.svg?label=current%20version)](https://packagist.org/packages/kubawerlos/php-cs-fixer-custom-fixers)
[![PHP version](https://img.shields.io/packagist/php-v/kubawerlos/php-cs-fixer-custom-fixers.svg)](https://php.net)
[![License](https://img.shields.io/github/license/kubawerlos/php-cs-fixer-custom-fixers.svg)](LICENSE)
![Tests](https://img.shields.io/badge/tests-3547-brightgreen.svg)
![Tests](https://img.shields.io/badge/tests-3548-brightgreen.svg)
[![Downloads](https://img.shields.io/packagist/dt/kubawerlos/php-cs-fixer-custom-fixers.svg)](https://packagist.org/packages/kubawerlos/php-cs-fixer-custom-fixers)

[![CI status](https://github.com/kubawerlos/php-cs-fixer-custom-fixers/actions/workflows/ci.yaml/badge.svg)](https://github.com/kubawerlos/php-cs-fixer-custom-fixers/actions/workflows/ci.yaml)
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/NoCommentedOutCodeFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private function isCorrectSyntax(string $content): bool
{
try {
@Tokens::fromCode($content);
} catch (\ParseError $error) {
} catch (\CompileError $error) {
return false;
}

Expand Down
1 change: 1 addition & 0 deletions tests/Fixer/NoCommentedOutCodeFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public static function provideFixCases(): iterable
yield ['<?php # do not remove me'];
yield ['<?php /* do not remove me */'];
yield ['<?php /** do not remove me */'];
yield ['<?php /** Abstract class Foo */'];
yield ['<?php
/**
* do not remove me
Expand Down

0 comments on commit 8701394

Please sign in to comment.