Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down
2 changes: 1 addition & 1 deletion src/Type/ExplicitType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
12 changes: 11 additions & 1 deletion src/TypeResolver/StringTypeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down