Skip to content

Commit

Permalink
chore: refactor
Browse files Browse the repository at this point in the history
Signed-off-by: Ben James <[email protected]>
  • Loading branch information
benjam-es committed Jan 18, 2025
1 parent 8dd2209 commit bd66a8c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
7 changes: 6 additions & 1 deletion src/Checkers/SourceCodeChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Peck\ValueObjects\Misspelling;
use ReflectionClass;
use ReflectionClassConstant;
use ReflectionException;
use ReflectionMethod;
use ReflectionParameter;
use ReflectionProperty;
Expand Down Expand Up @@ -83,7 +84,11 @@ private function getIssuesFromSourceFile(SplFileInfo $file): array
return [];
}

$reflection = new ReflectionClass($definition);
try {
$reflection = new ReflectionClass($definition);
} catch (ReflectionException) { // @phpstan-ignore-line
return [];
}

$namesToCheck = [
...$this->getMethodNames($reflection),
Expand Down
16 changes: 11 additions & 5 deletions tests/Integration/CheckCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@

$output = $commandTester->getDisplay();

expect(trim($output))->toContain('Did you mean: property, propriety, properer, properest');
expect(trim($output))->toContain('Did you mean: property, propriety, properer, properest')
->and($commandTester->getStatusCode())->toBe(1);
});

it('may pass', function (): void {
Expand All @@ -37,7 +38,8 @@

$output = $commandTester->getDisplay();

expect(trim($output))->toContain('PASS No misspellings found in your project.');
expect(trim($output))->toContain('PASS No misspellings found in your project.')
->and($commandTester->getStatusCode())->toBe(0);
});

it('may pass with lineless issues', function (): void {
Expand All @@ -55,7 +57,8 @@

$output = $commandTester->getDisplay();

expect(trim($output))->toContain('Misspelling');
expect(trim($output))->toContain('Misspelling')
->and($commandTester->getStatusCode())->toBe(1);
});

it('may pass with init option', function (): void {
Expand All @@ -73,7 +76,8 @@

$output = $commandTester->getDisplay();

expect(trim($output))->toContain('INFO Configuration file already exists.');
expect(trim($output))->toContain('INFO Configuration file already exists.')
->and($commandTester->getStatusCode())->toBe(1);
});

it('may pass with ignore-all option', function (): void {
Expand All @@ -91,5 +95,7 @@

$output = $commandTester->getDisplay();

expect(trim($output))->toContain('PASS No misspellings found in your project.');
expect(trim($output))->toContain('PASS No misspellings found in your project.')
->and($commandTester->getStatusCode())->toBe(0);

});

0 comments on commit bd66a8c

Please sign in to comment.