Skip to content

Commit

Permalink
Fix phpstan build
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Oct 25, 2024
1 parent 63fdb12 commit b4a48dd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Monolog/Handler/RedisHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected function writeCapped(LogRecord $record): void
$mode = \defined('Redis::MULTI') ? Redis::MULTI : 1;
$this->redisClient->multi($mode)
->rPush($this->redisKey, $record->formatted)
->lTrim($this->redisKey, -$this->capSize, -1)
->ltrim($this->redisKey, -$this->capSize, -1)
->exec();
} else {
$redisKey = $this->redisKey;
Expand Down
2 changes: 1 addition & 1 deletion src/Monolog/Handler/TestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ protected function write(LogRecord $record): void
*/
public function __call(string $method, array $args): bool
{
if (preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches) > 0) {
if ((bool) preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches)) {
$genericMethod = $matches[1] . ('Records' !== $matches[3] ? 'Record' : '') . $matches[3];
$level = \constant(Level::class.'::' . $matches[2]);
$callback = [$this, $genericMethod];
Expand Down
5 changes: 3 additions & 2 deletions src/Monolog/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ private static function detectAndCleanUtf8(&$data): void
$data = preg_replace_callback(
'/[\x80-\xFF]+/',
function (array $m): string {
// @phpstan-ignore function.deprecated
return \function_exists('mb_convert_encoding') ? mb_convert_encoding($m[0], 'UTF-8', 'ISO-8859-1') : utf8_encode($m[0]);

Check failure on line 204 in src/Monolog/Utils.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1)

No error with identifier function.deprecated is reported on line 204.
},
$data
Expand Down Expand Up @@ -234,12 +235,12 @@ public static function expandIniShorthandBytes($val)
return (int) $val;
}

if (preg_match('/^\s*(?<val>\d+)(?:\.\d+)?\s*(?<unit>[gmk]?)\s*$/i', $val, $match) !== 1) {
if (!(bool) preg_match('/^\s*(?<val>\d+)(?:\.\d+)?\s*(?<unit>[gmk]?)\s*$/i', $val, $match)) {
return false;
}

$val = (int) $match['val'];
switch (strtolower($match['unit'] ?? '')) {
switch (strtolower($match['unit'])) {
case 'g':
$val *= 1024;
// no break
Expand Down

0 comments on commit b4a48dd

Please sign in to comment.