Skip to content

Commit a6eef72

Browse files
committed
Last phpstan fixes
1 parent 172287b commit a6eef72

File tree

5 files changed

+11
-8
lines changed

5 files changed

+11
-8
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"rollbar/rollbar": "^1.3",
3131
"ruflin/elastica": ">=0.90 <7.0.1",
3232
"swiftmailer/swiftmailer": "^5.3|^6.0",
33-
"phpstan/phpstan": "^0.12.59"
33+
"phpstan/phpstan": "^0.12.91"
3434
},
3535
"suggest": {
3636
"graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",

phpstan.neon.dist

+7-4
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,21 @@ parameters:
1010

1111
ignoreErrors:
1212
- '#zend_monitor_|ZEND_MONITOR_#'
13-
- '#^Cannot call method ltrim\(\) on int\|false.$#'
1413
- '#MongoDB\\(Client|Collection)#'
14+
# Invalid type info on Redis multi
15+
- '#^Cannot call method ltrim\(\) on int\|false.$#'
16+
17+
# Cannot resolve this cleanly as different normalizers return different types but it is safe
1518
- message: '#Return type \(string\) of method Monolog\\Formatter\\LineFormatter::normalizeException\(\) should be compatible with return type \(array\) of method Monolog\\Formatter\\NormalizerFormatter::normalizeException\(\)#'
1619
paths:
1720
- src/Monolog/Formatter/LineFormatter.php
18-
- message: '#Method Monolog\\Handler\\LogglyHandler::loadCurlHandle\(\) never returns resource so it can be removed from the return typehint.#'
19-
paths:
20-
- src/Monolog/Handler/LogglyHandler.php
2121

2222
# blocked until we only support php8+
2323
- '#Parameter \#1 \$socket of function (socket_close|socket_sendto|socket_send) expects Socket, resource\|Socket(\|null)? given\.#'
2424
- '#Parameter \#1 \$handle of function (curl_exec|curl_close|curl_error|curl_errno|curl_setopt) expects CurlHandle, CurlHandle\|resource(\|null)? given\.#'
25+
- message: '#Method Monolog\\Handler\\LogglyHandler::loadCurlHandle\(\) never returns resource so it can be removed from the return typehint.#'
26+
paths:
27+
- src/Monolog/Handler/LogglyHandler.php
2528

2629
# blocked by https://github.com/phpstan/phpstan/issues/5091
2730
- '#has unknown class Monolog\\Handler\\Record#'

src/Monolog/Formatter/NormalizerFormatter.php

+3
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,14 @@ protected function normalize($data, int $depth = 0)
172172
}
173173

174174
if ($data instanceof \JsonSerializable) {
175+
/** @var null|scalar|array<array|scalar|null> $value */
175176
$value = $data->jsonSerialize();
176177
} elseif (method_exists($data, '__toString')) {
178+
/** @var string $value */
177179
$value = $data->__toString();
178180
} else {
179181
// the rest is normalized by json encoding and decoding it
182+
/** @var null|scalar|array<array|scalar|null> $value */
180183
$value = json_decode($this->toJson($data, true), true);
181184
}
182185

src/Monolog/Handler/FirePHPHandler.php

-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ protected function createHeader(array $meta, string $message): array
7474
{
7575
$header = sprintf('%s-%s', static::HEADER_PREFIX, join('-', $meta));
7676

77-
// See https://github.com/phpstan/phpstan/issues/5219
78-
// @phpstan-ignore-next-line
7977
return [$header => $message];
8078
}
8179

src/Monolog/Logger.php

-1
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,6 @@ public static function toMonologLevel($level): int
436436
throw new InvalidArgumentException('Level "'.var_export($level, true).'" is not defined, use one of: '.implode(', ', array_keys(static::$levels) + static::$levels));
437437
}
438438

439-
/** @phpstan-ignore-next-line */
440439
return $level;
441440
}
442441

0 commit comments

Comments
 (0)