| Conditions | 2 |
| Paths | 6 |
| Total Lines | 15 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 6 |
| CRAP Score | 2.0625 |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 29 | 11 | public function parse(string $code): ParserResult |
|
| 30 | { |
||
| 31 | try { |
||
| 32 | 11 | $stmts = $this->parser->parse($code); |
|
| 33 | |||
| 34 | 11 | $visitor = $this->createVisitor(); |
|
| 35 | 11 | $this->nodeTraverser->addVisitor($visitor); |
|
| 36 | |||
| 37 | 11 | $this->nodeTraverser->traverse($stmts); |
|
|
|
|||
| 38 | |||
| 39 | 11 | return $visitor->getResult(); |
|
| 40 | } catch (Error $e) { |
||
| 41 | throw new ParserException("Failed to parse PHP file: ".$e->getMessage(), $e->getCode(), $e); |
||
| 42 | } |
||
| 43 | } |
||
| 44 | |||
| 50 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.