Conditions | 7 |
Paths | 4 |
Total Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
13 | public function canSolve(Throwable $throwable): bool |
||
14 | { |
||
15 | if (! ($throwable instanceof FatalThrowableError || $throwable instanceof \ParseError)) { |
||
16 | return false; |
||
17 | } |
||
18 | |||
19 | if (Str::startsWith($throwable->getMessage(), 'syntax error, unexpected \'<<\'')) { |
||
|
|||
20 | $file = file_get_contents($throwable->getFile()); |
||
21 | if (strpos($file, '<<<<<<<') !== false && |
||
22 | strpos($file, '=======') !== false && |
||
23 | strpos($file, '>>>>>>>') !== false |
||
24 | ) { |
||
25 | return true; |
||
26 | } |
||
27 | } |
||
28 | |||
29 | return false; |
||
30 | } |
||
31 | |||
46 |
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: