1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-10-22 00:56:08 +02:00

Add Record/Level/LevelName type aliases and improve phpstan type coverage to level 6

This commit is contained in:
Jordi Boggiano
2021-05-28 10:29:33 +02:00
parent 5c9d9bf43e
commit 01d104aa78
88 changed files with 791 additions and 180 deletions

View File

@@ -19,7 +19,7 @@ namespace Monolog\Processor;
class WebProcessor implements ProcessorInterface
{
/**
* @var array|\ArrayAccess
* @var array<string, mixed>|\ArrayAccess<string, mixed>
*/
protected $serverData;
@@ -28,7 +28,7 @@ class WebProcessor implements ProcessorInterface
*
* Array is structured as [key in record.extra => key in $serverData]
*
* @var array
* @var array<string, string>
*/
protected $extraFields = [
'url' => 'REQUEST_URI',
@@ -39,8 +39,8 @@ class WebProcessor implements ProcessorInterface
];
/**
* @param array|\ArrayAccess|null $serverData Array or object w/ ArrayAccess that provides access to the $_SERVER data
* @param array|null $extraFields Field names and the related key inside $serverData to be added. If not provided it defaults to: url, ip, http_method, server, referrer
* @param array<string, mixed>|\ArrayAccess<string, mixed>|null $serverData Array or object w/ ArrayAccess that provides access to the $_SERVER data
* @param array<string, string>|null $extraFields Field names and the related key inside $serverData to be added. If not provided it defaults to: url, ip, http_method, server, referrer
*/
public function __construct($serverData = null, array $extraFields = null)
{
@@ -69,6 +69,9 @@ class WebProcessor implements ProcessorInterface
}
}
/**
* {@inheritDoc}
*/
public function __invoke(array $record): array
{
// skip processing if for some reason request data
@@ -89,6 +92,10 @@ class WebProcessor implements ProcessorInterface
return $this;
}
/**
* @param mixed[] $extra
* @return mixed[]
*/
private function appendExtraFields(array $extra): array
{
foreach ($this->extraFields as $extraName => $serverName) {