One minute
Log potential calls of a deprecated method
<?php
declare(strict_types=1);
namespace arueckauer\Php80;
use Exception;
use JetBrains\PhpStorm\Deprecated;
use Psr\Log\LoggerInterface;
use function explode;
use const PHP_EOL;
class SomeClass
{
private LoggerInterface $logger;
public function __construct(LoggerInterface $logger)
{
$this->logger = $logger;
}
#[Deprecated]
public function deprecated(): void
{
$this->logger->error(
__METHOD__,
[
'trace' => explode(
PHP_EOL,
(new Exception())->getTraceAsString()
),
]
);
}
}
Read other posts