diff --git a/composer.json b/composer.json index 70b2221..e672221 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "require": { "php": ">=8.2", "phpstan/phpdoc-parser": "^2.0", - "symfony/type-info": "^7.3.8 || ^7.4.1 || ^8.0" + "symfony/type-info": "^7.3.8 || ^7.4.1 || ^8.0 || ^8.1-@dev" }, "autoload": { "psr-4": { "Radebatz\\TypeInfoExtras\\": "src" }, diff --git a/src/Type/ExplicitType.php b/src/Type/ExplicitType.php index 9adbe76..a067fee 100644 --- a/src/Type/ExplicitType.php +++ b/src/Type/ExplicitType.php @@ -8,7 +8,7 @@ /** * A special type of `BuiltinType` for when a more specific type exits. * - * When using this library either code would have to check for `BuiltinType|ExplicitType` or just rely on `Type::getTypeIdentifier()`. + * When using this library, either code would have to check for `BuiltinType|ExplicitType` or just rely on `Type::getTypeIdentifier()`. * * @template T of TypeIdentifier */ diff --git a/src/TypeResolver/StringTypeResolver.php b/src/TypeResolver/StringTypeResolver.php index 8d5ff17..064a628 100644 --- a/src/TypeResolver/StringTypeResolver.php +++ b/src/TypeResolver/StringTypeResolver.php @@ -125,7 +125,17 @@ private function getTypeFromNode(TypeNode $node, ?TypeContext $typeContext): Bas } if ($node instanceof ObjectShapeNode) { - return Type::object(); + $shape = []; + foreach ($node->items as $item) { + $shape[(string) $item->keyName] = [ + 'type' => $this->getTypeFromNode($item->valueType, $typeContext), + 'optional' => $item->optional, + ]; + } + + return ($shape && method_exists(Type::class, 'objectShape')) + ? Type::objectShape($shape) + : Type::object(); } if ($node instanceof ThisTypeNode) {