From f0d51a0579863db43c894c3903fb60e5b7d3457d Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 10 Feb 2026 13:52:51 +0000 Subject: [PATCH 1/2] 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 --- phpstan.neon | 8 -------- src/Debug/Tracy/BlueScreen/ValidationBlueScreen.php | 9 +++++++-- .../SchemaDefinition/Entity/EntityAdapter.php | 12 +++++++----- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index e5c21e6..5cf0462 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -39,14 +39,6 @@ parameters: # This should not happen because null is returned on error - '#Method Apitte\\Core\\Utils\\Helpers::slashless\(\) should return string but returns string\|null\.#' - # Nette changed return typehint - - message: "#^Method Apitte\\\\OpenApi\\\\SchemaDefinition\\\\Entity\\\\EntityAdapter\\:\\:getNativePropertyType\\(\\) should return string but returns array\\\\|string\\.$#" - path: %currentWorkingDirectory%/src/OpenApi/SchemaDefinition/Entity/EntityAdapter.php - - # Nette changed return typehint - - message: "#^Parameter \\#2 \\$array of function implode expects array\\, array\\\\|string\\> given\\.$#" - path: %currentWorkingDirectory%/src/OpenApi/SchemaDefinition/Entity/EntityAdapter.php - - message: "#^Dead catch - TypeError is never thrown in the try block.$#" path: src/Core/Mapping/Parameter/DateTimeTypeMapper.php count: 1 diff --git a/src/Debug/Tracy/BlueScreen/ValidationBlueScreen.php b/src/Debug/Tracy/BlueScreen/ValidationBlueScreen.php index 62ec872..960e385 100644 --- a/src/Debug/Tracy/BlueScreen/ValidationBlueScreen.php +++ b/src/Debug/Tracy/BlueScreen/ValidationBlueScreen.php @@ -12,14 +12,19 @@ class ValidationBlueScreen public static function register(BlueScreen $blueScreen): void { - $blueScreen->addPanel(static function ($e): ?array { + $blueScreen->addPanel(static function (?\Throwable $e): ?array { if (!($e instanceof InvalidSchemaException)) { return null; } + $panel = self::renderPanel($e); + if ($panel === null) { + return null; + } + return [ 'tab' => self::renderTab($e), - 'panel' => self::renderPanel($e), + 'panel' => $panel, ]; }); } diff --git a/src/OpenApi/SchemaDefinition/Entity/EntityAdapter.php b/src/OpenApi/SchemaDefinition/Entity/EntityAdapter.php index 124df09..9ce12c2 100644 --- a/src/OpenApi/SchemaDefinition/Entity/EntityAdapter.php +++ b/src/OpenApi/SchemaDefinition/Entity/EntityAdapter.php @@ -275,17 +275,19 @@ private function parseAnnotation(Reflector $ref, string $name): ?string private function getNativePropertyType(Type $type, ReflectionProperty $property): string { - if ($type->isSimple() && count($type->getNames()) === 1) { - return $type->getNames()[0]; + $names = array_map(strval(...), $type->getTypes()); + + if ($type->isSimple() && count($names) === 1) { + return $names[0]; } - if ($type->isUnion() || ($type->isSimple() && count($type->getNames()) === 2) // nullable type is single but returns name of type and null in names + if ($type->isUnion() || ($type->isSimple() && count($names) === 2) // nullable type is single but returns name of type and null in names ) { - return implode('|', $type->getNames()); + return implode('|', $names); } if ($type->isIntersection()) { - return implode('&', $type->getNames()); + return implode('&', $names); } throw new RuntimeException(sprintf('Could not parse type "%s"', $property)); From fc7cf6149b69a166c46efd3593a47589aaf90985 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 11 Feb 2026 14:09:03 +0000 Subject: [PATCH 2/2] Use Throwable import instead of FQN in ValidationBlueScreen https://claude.ai/code/session_01FKs9WzzCtJRVsvGKhHWLkR --- src/Debug/Tracy/BlueScreen/ValidationBlueScreen.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Debug/Tracy/BlueScreen/ValidationBlueScreen.php b/src/Debug/Tracy/BlueScreen/ValidationBlueScreen.php index 960e385..2821bd6 100644 --- a/src/Debug/Tracy/BlueScreen/ValidationBlueScreen.php +++ b/src/Debug/Tracy/BlueScreen/ValidationBlueScreen.php @@ -4,6 +4,7 @@ use Apitte\Core\Exception\Logical\InvalidSchemaException; use ReflectionClass; +use Throwable; use Tracy\BlueScreen; use Tracy\Helpers; @@ -12,7 +13,7 @@ class ValidationBlueScreen public static function register(BlueScreen $blueScreen): void { - $blueScreen->addPanel(static function (?\Throwable $e): ?array { + $blueScreen->addPanel(static function (?Throwable $e): ?array { if (!($e instanceof InvalidSchemaException)) { return null; }