1 | <?php |
||
32 | class ErrorToException |
||
33 | { |
||
34 | /** |
||
35 | * @var CaptureError |
||
36 | */ |
||
37 | protected $callable; |
||
38 | |||
39 | /** |
||
40 | * Exception class to instantiate |
||
41 | * |
||
42 | * @var string |
||
43 | */ |
||
44 | protected $exception_class_name; |
||
45 | |||
46 | /** |
||
47 | * A new instance |
||
48 | * |
||
49 | * @param CaptureError $callable |
||
50 | * @param string $exception_class_name The exception to be thrown |
||
51 | */ |
||
52 | public function __construct(CaptureError $callable, $exception_class_name = 'RuntimeException') |
||
57 | |||
58 | /** |
||
59 | * Set the Exception class |
||
60 | * |
||
61 | * @param string $className error reporting level |
||
62 | * |
||
63 | * @throws InvalidArgumentException If the class is not a throwable object |
||
64 | */ |
||
65 | public function setExceptionClass($className) |
||
76 | |||
77 | /** |
||
78 | * Is the ClassName a Throwable Object (PHP7+) |
||
79 | * |
||
80 | * @param string $className |
||
81 | * |
||
82 | * @return bool |
||
83 | */ |
||
84 | protected function isThrowable($className) |
||
88 | |||
89 | /** |
||
90 | * Is the ClassName an Exception Object (PHP5+) |
||
91 | * |
||
92 | * @param string $className |
||
93 | * |
||
94 | * @return bool |
||
95 | */ |
||
96 | protected function isException($className) |
||
100 | |||
101 | /** |
||
102 | * Get the current Error Reporting Level |
||
103 | * |
||
104 | * @return string |
||
105 | */ |
||
106 | public function getExceptionClass() |
||
110 | |||
111 | /** |
||
112 | * Process the callable |
||
113 | * |
||
114 | * @param mixed ...$args the arguments associated with the callable |
||
115 | * |
||
116 | * @return mixed |
||
117 | */ |
||
118 | public function __invoke() |
||
130 | } |
||
131 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.