Created
November 14, 2021 14:42
-
-
Save wouterj/130433d044089d1dbf73758ab989c771 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"require": { | |
"symfony/error-handler": "^5.3" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once 'vendor/autoload.php'; | |
use Psr\Log\AbstractLogger; | |
use Symfony\Component\ErrorHandler\ErrorHandler; | |
ErrorHandler::register() | |
->setDefaultLogger(new class extends AbstractLogger { | |
public function log($level, string|\Stringable $message, array $context = []): void | |
{ | |
$formattedLogLine = sprintf( | |
'[%s] %s: %s%s'.PHP_EOL, | |
date('Y-m-dTH:i:s.uP'), | |
$level, | |
(string) $message, | |
($context['exception'] ?? false) instanceof \Throwable | |
? sprintf(' in %s:%s', $context['exception']->getFile(), $context['exception']->getLine()) | |
: '' | |
); | |
file_put_contents(__DIR__.'/deprecations.log', $formattedLogLine, \FILE_APPEND); | |
} | |
}, \E_DEPRECATED | \E_USER_DEPRECATED) | |
; | |
// "null" argument deprecated as of PHP 8.1 | |
var_dump(str_contains('foo', null)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment