1 | <?php |
||
11 | class Unbound extends \LogicException implements ExceptionInterface |
||
12 | { |
||
13 | 2 | public function __toString() |
|
14 | { |
||
15 | 2 | $messages = [sprintf("- %s\n", $this->getMessage())]; |
|
16 | 2 | $e = $this->getPrevious(); |
|
17 | 2 | if (! $e instanceof \Exception) { |
|
18 | 1 | return $this->getMainMessage($this); |
|
19 | } |
||
20 | |||
21 | 1 | return $this->buildMessage($e, $messages) . "\n" . $e->getTraceAsString(); |
|
|
|||
22 | } |
||
23 | |||
24 | /** |
||
25 | * @param Unbound $e |
||
26 | * @param array $msg |
||
27 | * |
||
28 | * @return string |
||
29 | */ |
||
30 | 1 | private function buildMessage(Unbound $e, array $msg) |
|
42 | |||
43 | 2 | private function getMainMessage(Unbound $e) |
|
51 | } |
||
52 |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.