Skip to content

Commit

Permalink
fix: Catch Throwable when doing reflection, for fatal errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gskema committed May 24, 2024
1 parent c6f60c1 commit 2976a27
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to `phpcs-type-sniff` will be documented in this file.

Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) principles.

## 81.6.2 - 2024-05-24
### Fixed
- Catch `Throwable` when doing reflection, for fatal errors

## 81.6.1 - 2024-05-23
### Changed
- Limit `IteratorAggregate` item type tag check to direct implementation only, exclude parents for now
Expand Down
4 changes: 2 additions & 2 deletions src/Sniffs/CodeElement/IteratorItemTypeSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Gskema\TypeSniff\Sniffs\CodeElement;

use Error;
use Gskema\TypeSniff\Core\CodeElement\Element\AbstractFqcnElement;
use Gskema\TypeSniff\Core\CodeElement\Element\ClassElement;
use Gskema\TypeSniff\Core\CodeElement\Element\CodeElementInterface;
Expand All @@ -11,6 +10,7 @@
use PHP_CodeSniffer\Files\File;
use ReflectionClass;
use ReflectionException;
use Throwable;

class IteratorItemTypeSniff implements CodeElementSniffInterface
{
Expand Down Expand Up @@ -46,7 +46,7 @@ public function process(File $file, CodeElementInterface $element, CodeElementIn
{
try {
$ref = new ReflectionClass($element->getFqcn());
} catch (Error | ReflectionException) {
} catch (Throwable | ReflectionException) {
return; // give up...
}

Expand Down

0 comments on commit 2976a27

Please sign in to comment.