Skip to content

Commit

Permalink
Fix phpstan errors, update baseline
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Jun 20, 2023
1 parent 06276fc commit 8941155
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 35 deletions.
34 changes: 2 additions & 32 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,6 @@ parameters:
count: 1
path: src/Monolog/Formatter/WildfireFormatter.php

-
message: "#^Instanceof between Monolog\\\\Handler\\\\HandlerInterface and Monolog\\\\Handler\\\\HandlerInterface will always evaluate to true\\.$#"
count: 1
path: src/Monolog/Handler/FilterHandler.php

-
message: "#^Instanceof between Monolog\\\\Handler\\\\HandlerInterface and Monolog\\\\Handler\\\\HandlerInterface will always evaluate to true\\.$#"
count: 1
path: src/Monolog/Handler/FingersCrossedHandler.php

-
message: "#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#"
count: 1
Expand All @@ -50,11 +40,6 @@ parameters:
count: 1
path: src/Monolog/Handler/MandrillHandler.php

-
message: "#^Instanceof between Swift_Message and Swift_Message will always evaluate to true\\.$#"
count: 1
path: src/Monolog/Handler/MandrillHandler.php

-
message: "#^Parameter \\$message of method Monolog\\\\Handler\\\\MandrillHandler\\:\\:__construct\\(\\) has invalid type Swift_Message\\.$#"
count: 3
Expand All @@ -66,9 +51,9 @@ parameters:
path: src/Monolog/Handler/MandrillHandler.php

-
message: "#^Instanceof between Monolog\\\\Handler\\\\HandlerInterface and Monolog\\\\Handler\\\\HandlerInterface will always evaluate to true\\.$#"
message: "#^Negated boolean expression is always false\\.$#"
count: 1
path: src/Monolog/Handler/SamplingHandler.php
path: src/Monolog/Handler/SyslogHandler.php

-
message: "#^Variable property access on \\$this\\(Monolog\\\\LogRecord\\)\\.$#"
Expand All @@ -95,22 +80,7 @@ parameters:
count: 1
path: src/Monolog/Logger.php

-
message: "#^Comparison operation \"\\<\" between int\\<1, 32\\> and 1 is always false\\.$#"
count: 1
path: src/Monolog/Processor/UidProcessor.php

-
message: "#^Comparison operation \"\\>\" between int\\<1, 32\\> and 32 is always false\\.$#"
count: 1
path: src/Monolog/Processor/UidProcessor.php

-
message: "#^Parameter \\#1 \\$length of function random_bytes expects int\\<1, max\\>, int given\\.$#"
count: 1
path: src/Monolog/Processor/UidProcessor.php

-
message: "#^Parameter \\#2 \\$callback of function preg_replace_callback expects callable\\(array\\<int\\|string, string\\>\\)\\: string, Closure\\(mixed\\)\\: array\\<int, string\\>\\|string\\|false given\\.$#"
count: 1
path: src/Monolog/Utils.php
5 changes: 3 additions & 2 deletions src/Monolog/Handler/FingersCrossedHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,9 @@ public function clear(): void
private function flushBuffer(): void
{
if (null !== $this->passthruLevel) {
$this->buffer = array_filter($this->buffer, function ($record) {
return $this->passthruLevel->includes($record->level);
$passthruLevel = $this->passthruLevel;
$this->buffer = array_filter($this->buffer, static function ($record) use ($passthruLevel) {
return $passthruLevel->includes($record->level);
});
if (count($this->buffer) > 0) {
$this->getHandler(end($this->buffer))->handleBatch($this->buffer);
Expand Down
2 changes: 1 addition & 1 deletion src/Monolog/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ private static function detectAndCleanUtf8(&$data): void
if (is_string($data) && preg_match('//u', $data) !== 1) {
$data = preg_replace_callback(
'/[\x80-\xFF]+/',
function ($m) {
function (array $m): string {
return function_exists('mb_convert_encoding') ? mb_convert_encoding($m[0], 'UTF-8', 'ISO-8859-1') : utf8_encode($m[0]);
},
$data
Expand Down

0 comments on commit 8941155

Please sign in to comment.