Skip to content

Commit f0d51a0

Browse files
committed
Fix PHPStan level 8 errors
- ValidationBlueScreen: Type closure parameter as ?\Throwable and handle null panel return to match Tracy\BlueScreen::addPanel() signature - EntityAdapter: Use Type::getTypes() with string casting instead of Type::getNames() which now returns nested arrays in newer nette/utils - Remove stale PHPStan ignore patterns that no longer match https://claude.ai/code/session_01FKs9WzzCtJRVsvGKhHWLkR
1 parent eb43d19 commit f0d51a0

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

phpstan.neon

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,6 @@ parameters:
3939
# This should not happen because null is returned on error
4040
- '#Method Apitte\\Core\\Utils\\Helpers::slashless\(\) should return string but returns string\|null\.#'
4141

42-
# Nette changed return typehint
43-
- message: "#^Method Apitte\\\\OpenApi\\\\SchemaDefinition\\\\Entity\\\\EntityAdapter\\:\\:getNativePropertyType\\(\\) should return string but returns array\\<string\\>\\|string\\.$#"
44-
path: %currentWorkingDirectory%/src/OpenApi/SchemaDefinition/Entity/EntityAdapter.php
45-
46-
# Nette changed return typehint
47-
- message: "#^Parameter \\#2 \\$array of function implode expects array\\<string\\>, array\\<int, array\\<string\\>\\|string\\> given\\.$#"
48-
path: %currentWorkingDirectory%/src/OpenApi/SchemaDefinition/Entity/EntityAdapter.php
49-
5042
- message: "#^Dead catch - TypeError is never thrown in the try block.$#"
5143
path: src/Core/Mapping/Parameter/DateTimeTypeMapper.php
5244
count: 1

src/Debug/Tracy/BlueScreen/ValidationBlueScreen.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,19 @@ class ValidationBlueScreen
1212

1313
public static function register(BlueScreen $blueScreen): void
1414
{
15-
$blueScreen->addPanel(static function ($e): ?array {
15+
$blueScreen->addPanel(static function (?\Throwable $e): ?array {
1616
if (!($e instanceof InvalidSchemaException)) {
1717
return null;
1818
}
1919

20+
$panel = self::renderPanel($e);
21+
if ($panel === null) {
22+
return null;
23+
}
24+
2025
return [
2126
'tab' => self::renderTab($e),
22-
'panel' => self::renderPanel($e),
27+
'panel' => $panel,
2328
];
2429
});
2530
}

src/OpenApi/SchemaDefinition/Entity/EntityAdapter.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -275,17 +275,19 @@ private function parseAnnotation(Reflector $ref, string $name): ?string
275275

276276
private function getNativePropertyType(Type $type, ReflectionProperty $property): string
277277
{
278-
if ($type->isSimple() && count($type->getNames()) === 1) {
279-
return $type->getNames()[0];
278+
$names = array_map(strval(...), $type->getTypes());
279+
280+
if ($type->isSimple() && count($names) === 1) {
281+
return $names[0];
280282
}
281283

282-
if ($type->isUnion() || ($type->isSimple() && count($type->getNames()) === 2) // nullable type is single but returns name of type and null in names
284+
if ($type->isUnion() || ($type->isSimple() && count($names) === 2) // nullable type is single but returns name of type and null in names
283285
) {
284-
return implode('|', $type->getNames());
286+
return implode('|', $names);
285287
}
286288

287289
if ($type->isIntersection()) {
288-
return implode('&', $type->getNames());
290+
return implode('&', $names);
289291
}
290292

291293
throw new RuntimeException(sprintf('Could not parse type "%s"', $property));

0 commit comments

Comments
 (0)