Skip to content

Commit 6598d09

Browse files
committed
Check exceptions with PHPStan
1 parent 7243f25 commit 6598d09

File tree

5 files changed

+20
-0
lines changed

5 files changed

+20
-0
lines changed

phpstan.neon

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ parameters:
99
- 'var_dump()'
1010
message: 'avoid committing debug calls'
1111

12+
exceptions:
13+
check:
14+
missingCheckedExceptionInThrows: true
15+
tooWideThrowType: true
16+
17+
uncheckedExceptionClasses:
18+
- LogicException
19+
1220
level: 8
1321
paths:
1422
- src

src/GrammarProcessing/Ebnf/Parser.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ public function __construct(
3737

3838

3939

40+
/**
41+
* @throws GrammarProcessing\CannotConsumeTokenException
42+
* @throws GrammarProcessing\UnexpectedTokenException
43+
*/
4044
public function parseGrammarFromSource(string $source): GrammarProcessing\Grammar
4145
{
4246
return $this->parseGrammarFromAbstractSyntaxTree(

src/GrammarProcessing/Grammar.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ public function __construct(
4343

4444

4545

46+
/**
47+
* @throws UnexpectedTokenException
48+
*/
4649
public function tokenizeSource(string $source): TokenStream
4750
{
4851
return $this->lexicalGrammar->parseSource($source);
@@ -55,6 +58,7 @@ public function tokenizeSource(string $source): TokenStream
5558
* @param TRootSymbol $rootSymbol
5659
* @return AbstractSyntaxTree<TRootSymbol>
5760
* @throws CannotConsumeTokenException
61+
* @throws UnexpectedTokenException
5862
*/
5963
public function parseSource(string $source, string $rootSymbol): AbstractSyntaxTree
6064
{

src/GrammarProcessing/TokenStream.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ public function consumeTokenWithType(string $type): Token
102102

103103

104104

105+
/**
106+
* @throws CannotConsumeTokenException
107+
*/
105108
public function consumeTokenWithValue(string $value): Token
106109
{
107110
if (isset($this->tokens[$this->currentToken]) === FALSE) {

src/GrammarProcessing/Vocabulary/Symbol.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ function getPattern(array $nonterminals): string;
1717

1818
/**
1919
* @param array<string, Symbol> $nonterminals
20+
* @throws GrammarProcessing\CannotConsumeTokenException
2021
*/
2122
function acceptNode(
2223
GrammarProcessing\Error $error,

0 commit comments

Comments
 (0)