Skip to content

Commit f6d38e7

Browse files
Bernhard Schmittmficzel
authored andcommitted
Adjust Neos.Flow.Log
1 parent f0ee451 commit f6d38e7

File tree

6 files changed

+18
-23
lines changed

6 files changed

+18
-23
lines changed

Neos.Flow.Log/Classes/Backend/AbstractBackend.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ abstract class AbstractBackend implements BackendInterface
4242
*/
4343
public function __construct($options = [])
4444
{
45-
if (is_array($options) || $options instanceof \ArrayAccess) {
45+
if (is_iterable($options)) {
4646
foreach ($options as $optionKey => $optionValue) {
4747
$methodName = 'set' . ucfirst($optionKey);
4848
if (method_exists($this, $methodName)) {

Neos.Flow.Log/Classes/Backend/AnsiConsoleBackend.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class AnsiConsoleBackend extends ConsoleBackend
4040
const END = "\033[0m";
4141

4242
/**
43-
* @var array
43+
* @var array<string,string>
4444
*/
4545
protected $tagFormats = [];
4646

@@ -75,12 +75,7 @@ public function open(): void
7575
/**
7676
* Appends the given message along with the additional information into the log.
7777
*
78-
* @param string $message
79-
* @param int $severity
80-
* @param array $additionalData
81-
* @param string $packageKey
82-
* @param string $className
83-
* @param string $methodName
78+
* @param array<mixed>|null $additionalData
8479
* @return void
8580
*/
8681
public function append(string $message, int $severity = LOG_INFO, $additionalData = null, ?string $packageKey = null, ?string $className = null, ?string $methodName = null): void
@@ -118,15 +113,15 @@ protected function formatOutput($output)
118113
} else {
119114
return str_replace('|', $matches[3], $format);
120115
}
121-
}, $output);
116+
}, $output) ?: '';
122117
} while ($lastOutput !== $output);
123118
return $output;
124119
}
125120

126121
/**
127122
* @param boolean $disableAnsi
128123
*/
129-
public function setDisableAnsi($disableAnsi)
124+
public function setDisableAnsi($disableAnsi): void
130125
{
131126
$this->disableAnsi = $disableAnsi;
132127
}

Neos.Flow.Log/Classes/Backend/ConsoleBackend.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ConsoleBackend extends AbstractBackend
2525
{
2626
/**
2727
* An array of severity labels, indexed by their integer constant
28-
* @var array
28+
* @var array<int,string>
2929
*/
3030
protected $severityLabels;
3131

@@ -61,10 +61,11 @@ public function open(): void
6161
LOG_DEBUG => 'DEBUG ',
6262
];
6363

64-
$this->streamHandle = fopen('php://' . $this->streamName, 'w');
65-
if (!is_resource($this->streamHandle)) {
64+
$streamHandle = fopen('php://' . $this->streamName, 'w');
65+
if (!is_resource($streamHandle)) {
6666
throw new CouldNotOpenResourceException('Could not open stream "' . $this->streamName . '" for write access.', 1310986609);
6767
}
68+
$this->streamHandle = $streamHandle;
6869
}
6970

7071
/**

Neos.Flow.Log/Classes/Backend/FileBackend.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class FileBackend extends AbstractBackend
2727
{
2828
/**
2929
* An array of severity labels, indexed by their integer constant
30-
* @var array
30+
* @var array<int,string>
3131
*/
3232
protected $severityLabels;
3333

Neos.Flow.Log/Classes/PlainTextFormatter.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ public function __construct($variable)
2222
}
2323

2424
/**
25-
* @param $spaces
26-
* @return string
25+
* @return ?string
2726
*/
28-
public function format($spaces = 4)
27+
public function format(int $spaces = 4)
2928
{
3029
return $this->renderVariableAsPlaintext($this->variable, $spaces);
3130
}

Neos.Flow.Log/Classes/Psr/Logger.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class Logger implements LoggerInterface
4545
/**
4646
* Constructs the PSR-3 Logger.
4747
*
48-
* @param iterable $backends
48+
* @param iterable<mixed> $backends
4949
*/
5050
public function __construct(iterable $backends)
5151
{
@@ -61,7 +61,7 @@ public function __construct(iterable $backends)
6161
/**
6262
* @param mixed $level
6363
* @param string|\Stringable $message
64-
* @param array $context
64+
* @param array<string,mixed> $context
6565
* @api
6666
*/
6767
public function log($level, string|\Stringable $message, array $context = []): void
@@ -80,8 +80,8 @@ public function log($level, string|\Stringable $message, array $context = []): v
8080
}
8181

8282
/**
83-
* @param array $context
84-
* @return array list of packageKey, className and methodName either string or null
83+
* @param array<string,mixed> $context
84+
* @return array<int,string|null> list of packageKey, className and methodName either string or null
8585
*/
8686
protected function extractLegacyDataFromContext(array $context): array
8787
{
@@ -93,8 +93,8 @@ protected function extractLegacyDataFromContext(array $context): array
9393
}
9494

9595
/**
96-
* @param array $context
97-
* @return array
96+
* @param array<string,mixed> $context
97+
* @return array<string,mixed>
9898
*/
9999
protected function removeLegacyDataFromContext(array $context): array
100100
{

0 commit comments

Comments
 (0)