| 1 | <?php | ||
| 11 | class MissingSemicolonSolutionProvider implements HasSolutionsForThrowable | ||
| 12 | { | ||
| 13 | protected const REGEX = "/syntax error, unexpected \'(.*?)\'(.*?);/"; | ||
| 14 | |||
| 15 | public function canSolve(Throwable $throwable): bool | ||
| 16 |     { | ||
| 17 |         if (! $throwable instanceof FatalThrowableError && ! $throwable instanceof ParseError) { | ||
| 18 | return false; | ||
| 19 | } | ||
| 20 | preg_match(self::REGEX, $throwable->getMessage(), $matches); | ||
|  | |||
| 21 | |||
| 22 | return isset($matches[1]); | ||
| 23 | } | ||
| 24 | |||
| 25 | public function getSolutions(Throwable $throwable): array | ||
| 36 | } | ||
| 37 | 
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: