| Conditions | 3 |
| Paths | 3 |
| Total Lines | 13 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 40 | public function highlight($code) |
||
| 41 | { |
||
| 42 | if (!is_string($code)) { |
||
| 43 | throw new \InvalidArgumentException('Argument 1 should be a string of valid PHP code'); |
||
| 44 | } |
||
| 45 | try { |
||
| 46 | $statements = $this->parser->parse($code); |
||
| 47 | } catch (Error $e) { |
||
| 48 | throw new \InvalidArgumentException('PHP could not be parsed'); |
||
| 49 | } |
||
| 50 | |||
| 51 | return $this->printer->prettyPrintFile($statements); |
||
|
|
|||
| 52 | } |
||
| 53 | } |
||
| 54 |
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.