|
20 | 20 | use Config\Exceptions as ExceptionsConfig;
|
21 | 21 | use Config\Paths;
|
22 | 22 | use ErrorException;
|
| 23 | +use Psr\Log\LogLevel; |
23 | 24 | use Throwable;
|
24 | 25 |
|
25 | 26 | /**
|
@@ -152,12 +153,46 @@ public function exceptionHandler(Throwable $exception)
|
152 | 153 | public function errorHandler(int $severity, string $message, ?string $file = null, ?int $line = null)
|
153 | 154 | {
|
154 | 155 | if (error_reporting() & $severity) {
|
| 156 | + // @TODO Remove if Faker is fixed. |
| 157 | + if ($this->isFakerDeprecationError($severity, $message, $file, $line)) { |
| 158 | + // Ignore the error. |
| 159 | + return true; |
| 160 | + } |
| 161 | + |
155 | 162 | throw new ErrorException($message, 0, $severity, $file, $line);
|
156 | 163 | }
|
157 | 164 |
|
158 | 165 | return false; // return false to propagate the error to PHP standard error handler
|
159 | 166 | }
|
160 | 167 |
|
| 168 | + /** |
| 169 | + * Workaround for Faker deprecation errors in PHP 8.2. |
| 170 | + * |
| 171 | + * @see https://github.com/FakerPHP/Faker/issues/479 |
| 172 | + */ |
| 173 | + private function isFakerDeprecationError(int $severity, string $message, ?string $file = null, ?int $line = null) |
| 174 | + { |
| 175 | + if ( |
| 176 | + $severity === E_DEPRECATED |
| 177 | + && strpos($file, VENDORPATH . 'fakerphp/faker/') !== false |
| 178 | + && $message === 'Use of "static" in callables is deprecated' |
| 179 | + ) { |
| 180 | + log_message( |
| 181 | + LogLevel::WARNING, |
| 182 | + '[DEPRECATED] {message} in {errFile} on line {errLine}.', |
| 183 | + [ |
| 184 | + 'message' => $message, |
| 185 | + 'errFile' => clean_path($file ?? ''), |
| 186 | + 'errLine' => $line ?? 0, |
| 187 | + ] |
| 188 | + ); |
| 189 | + |
| 190 | + return true; |
| 191 | + } |
| 192 | + |
| 193 | + return false; |
| 194 | + } |
| 195 | + |
161 | 196 | /**
|
162 | 197 | * Checks to see if any errors have happened during shutdown that
|
163 | 198 | * need to be caught and handle them.
|
|
0 commit comments