These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * |
||
4 | */ |
||
5 | |||
6 | namespace Mvc5\Exception; |
||
7 | |||
8 | use Mvc5\Arg; |
||
9 | use Mvc5\Exception as _Exception; |
||
10 | |||
11 | trait Base |
||
12 | { |
||
13 | /** |
||
14 | * @param mixed|\Throwable $exception |
||
15 | * @param int $offset |
||
16 | * @return \Throwable |
||
17 | */ |
||
18 | 31 | protected static function backtrace(\Throwable $exception, $offset = 2) |
|
19 | { |
||
20 | 31 | $offset && ($origin = $exception->getTrace()[$offset]) && isset($origin[Arg::FILE]) |
|
21 | 31 | && ($exception->file = $origin[Arg::FILE]) && ($exception->line = $origin[Arg::LINE]); |
|
0 ignored issues
–
show
Accessing
line on the interface Throwable suggest that you code against a concrete implementation. How about adding an instanceof check?
If you access a property on an interface, you most likely code against a concrete implementation of the interface. Available Fixes
Loading history...
|
|||
22 | |||
23 | 31 | return static::offset($exception, $offset); |
|
24 | } |
||
25 | |||
26 | /** |
||
27 | * @param string $exception |
||
28 | * @param array|string $params |
||
29 | * @param int $offset |
||
30 | * @return \Throwable |
||
31 | */ |
||
32 | 31 | protected static function create($exception, $params = [], $offset = 2) |
|
33 | { |
||
34 | 31 | return static::backtrace(static::instance($exception, (array) $params), $offset); |
|
35 | } |
||
36 | |||
37 | /** |
||
38 | * @param string $exception |
||
39 | * @param array $params |
||
40 | * @return \Throwable |
||
41 | */ |
||
42 | 34 | protected static function instance($exception, array $params = []) |
|
43 | { |
||
44 | 34 | return new $exception(...$params); |
|
45 | } |
||
46 | |||
47 | /** |
||
48 | * @param $exception |
||
49 | * @param int $offset |
||
50 | * @return \Throwable |
||
51 | */ |
||
52 | 34 | protected static function offset($exception, $offset = 1) |
|
53 | { |
||
54 | 34 | $offset && $exception->offset = $offset; |
|
55 | |||
56 | 34 | return $exception; |
|
57 | } |
||
58 | |||
59 | /** |
||
60 | * @param $exception |
||
61 | * @return mixed |
||
62 | * @throws \Throwable |
||
63 | */ |
||
64 | 38 | static function raise(\Throwable $exception) |
|
0 ignored issues
–
show
|
|||
65 | { |
||
66 | 38 | throw $exception; |
|
67 | } |
||
68 | } |
||
69 |
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: