Skip to content

Commit 97b518d

Browse files
Fix: Pass builtInOnly parameter correctly for list types
When processing ListOfType in mapGraphQLTypeToPHPType, the $builtInOnly parameter was incorrectly passed as the second argument ($nullable) instead of the third argument ($builtInOnly). This caused the $builtInOnly parameter to default to false when processing list items, resulting in the PHP mapped type being used instead of the primitive JSON type in $data parameter docblocks. Example of the bug: - GraphQL: currencies: [Currency!]! - Config: withScalar('Currency', Type::string(), Type::object(Currency::class)) - Generated docblock: 'currencies': list<Currency> (wrong) - Should be: 'currencies': list<string> (correct) This caused PHPStan errors like: "Parameter #1 $code of class Money\Currency constructor expects non-empty-string, Money\Currency given."
1 parent 7725798 commit 97b518d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/TypeMapper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function mapGraphQLTypeToPHPType(Type $type, ?bool $nullable = null, bool
9393
}
9494

9595
if ($type instanceof ListOfType) {
96-
return SymfonyType::list($this->mapGraphQLTypeToPHPType($type->getWrappedType(), $builtInOnly));
96+
return SymfonyType::list($this->mapGraphQLTypeToPHPType($type->getWrappedType(), null, $builtInOnly));
9797
}
9898

9999
if ($type instanceof ScalarType) {

0 commit comments

Comments
 (0)