Skip to content

Commit 8701394

Browse files
authored
Do not crash for comments that raise compile error (#986)
1 parent 8d93f68 commit 8701394

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![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)
66
[![PHP version](https://img.shields.io/packagist/php-v/kubawerlos/php-cs-fixer-custom-fixers.svg)](https://php.net)
77
[![License](https://img.shields.io/github/license/kubawerlos/php-cs-fixer-custom-fixers.svg)](LICENSE)
8-
![Tests](https://img.shields.io/badge/tests-3547-brightgreen.svg)
8+
![Tests](https://img.shields.io/badge/tests-3548-brightgreen.svg)
99
[![Downloads](https://img.shields.io/packagist/dt/kubawerlos/php-cs-fixer-custom-fixers.svg)](https://packagist.org/packages/kubawerlos/php-cs-fixer-custom-fixers)
1010

1111
[![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)

src/Fixer/NoCommentedOutCodeFixer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ private function isCorrectSyntax(string $content): bool
131131
{
132132
try {
133133
@Tokens::fromCode($content);
134-
} catch (\ParseError $error) {
134+
} catch (\CompileError $error) {
135135
return false;
136136
}
137137

tests/Fixer/NoCommentedOutCodeFixerTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public static function provideFixCases(): iterable
4040
yield ['<?php # do not remove me'];
4141
yield ['<?php /* do not remove me */'];
4242
yield ['<?php /** do not remove me */'];
43+
yield ['<?php /** Abstract class Foo */'];
4344
yield ['<?php
4445
/**
4546
* do not remove me

0 commit comments

Comments
 (0)