| Conditions | 12 |
| Paths | 38 |
| Total Lines | 94 |
| Code Lines | 52 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 110 | public function errorHandler($errorSeverity, $errorMessage, $errorFile, $errorLine, $errorContext = []) |
||
| 111 | { |
||
| 112 | $isFatalError = (((E_ERROR | E_COMPILE_ERROR | E_CORE_ERROR | E_USER_ERROR) & $errorSeverity) === $errorSeverity); |
||
| 113 | |||
| 114 | if (strpos($errorFile, 'parser') !== false) { |
||
| 115 | if (function_exists('parser')) { |
||
| 116 | if (services()->has('presenter')) { |
||
| 117 | $vars = presenter()->getArrayCopy(); |
||
| 118 | extract($vars); |
||
| 119 | } |
||
| 120 | |||
| 121 | $errorFile = str_replace(PATH_ROOT, DIRECTORY_SEPARATOR, parser()->getSourceFilePath()); |
||
| 122 | $error = new ErrorException($errorMessage, $errorSeverity, $errorFile, $errorLine, $errorContext); |
||
| 123 | |||
| 124 | $filePath = $this->getFilePath('error'); |
||
| 125 | |||
| 126 | ob_start(); |
||
| 127 | include $filePath; |
||
| 128 | $htmlOutput = ob_get_contents(); |
||
| 129 | ob_end_clean(); |
||
| 130 | |||
| 131 | echo $htmlOutput; |
||
| 132 | |||
| 133 | return true; |
||
| 134 | } |
||
| 135 | } |
||
| 136 | |||
| 137 | // When the error is fatal the Kernel will throw it as an exception. |
||
| 138 | if ($isFatalError) { |
||
| 139 | throw new ErrorException($errorMessage, $errorSeverity, $errorLine, $errorLine, $errorContext); |
||
| 140 | } |
||
| 141 | |||
| 142 | // Should we ignore the error? We'll get the current error_reporting |
||
| 143 | // level and add its bits with the severity bits to find out. |
||
| 144 | if (($errorSeverity & error_reporting()) !== $errorSeverity) { |
||
| 145 | return false; |
||
| 146 | } |
||
| 147 | |||
| 148 | $error = new ErrorException($errorMessage, $errorSeverity, $errorFile, $errorLine, $errorContext); |
||
| 149 | |||
| 150 | // Logged the error |
||
| 151 | if(services()->has('logger')) { |
||
| 152 | logger()->error( |
||
| 153 | implode( |
||
| 154 | ' ', |
||
| 155 | [ |
||
| 156 | '[ ' . $error->getStringSeverity() . ' ] ', |
||
| 157 | $error->getMessage(), |
||
| 158 | $error->getFile() . ':' . $error->getLine(), |
||
| 159 | ] |
||
| 160 | ) |
||
| 161 | ); |
||
| 162 | } |
||
| 163 | |||
| 164 | // Should we display the error? |
||
| 165 | if (str_ireplace(['off', 'none', 'no', 'false', 'null'], 0, ini_get('display_errors')) == 1) { |
||
| 166 | if (is_ajax()) { |
||
| 167 | $this->setContentType('application/json'); |
||
| 168 | $this->statusCode = 500; |
||
| 169 | $this->reasonPhrase = 'Internal Server Error'; |
||
| 170 | |||
| 171 | $this->send(implode( |
||
| 172 | ' ', |
||
| 173 | [ |
||
| 174 | '[ ' . $error->getStringSeverity() . ' ] ', |
||
| 175 | $error->getMessage(), |
||
| 176 | $error->getFile() . ':' . $error->getLine(), |
||
| 177 | ] |
||
| 178 | )); |
||
| 179 | exit(EXIT_ERROR); |
||
| 180 | } |
||
| 181 | |||
| 182 | if (services()->has('presenter')) { |
||
| 183 | if (presenter()->theme) { |
||
| 184 | presenter()->theme->load(); |
||
| 185 | } |
||
| 186 | |||
| 187 | $vars = presenter()->getArrayCopy(); |
||
| 188 | extract($vars); |
||
| 189 | } |
||
| 190 | |||
| 191 | $filePath = $this->getFilePath('error'); |
||
| 192 | |||
| 193 | ob_start(); |
||
| 194 | include $filePath; |
||
| 195 | $htmlOutput = ob_get_contents(); |
||
| 196 | ob_end_clean(); |
||
| 197 | |||
| 198 | if (services()->has('presenter')) { |
||
| 199 | $htmlOutput = presenter()->assets->parseSourceCode($htmlOutput); |
||
| 200 | } |
||
| 201 | |||
| 202 | echo $htmlOutput; |
||
| 203 | exit(EXIT_ERROR); |
||
| 204 | } |
||
| 274 | } |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths