[Schema] Support PHPStan/Psalm integer ranges (#422)
This commit is contained in:
parent
43815e38a8
commit
76778a4d9e
1 changed files with 32 additions and 2 deletions
|
|
@ -677,7 +677,12 @@ final class SchemaGenerator implements SchemaGeneratorInterface
|
|||
return ['array'];
|
||||
}
|
||||
|
||||
// PRIORITY 3: Handle unions (recursive)
|
||||
// PRIORITY 3: Treat PHPStan/Psalm integer ranges as their base type
|
||||
if (preg_match('/^int\s*<\s*[^<>]+\s*>$/i', $normalizedType)) {
|
||||
return ['integer'];
|
||||
}
|
||||
|
||||
// PRIORITY 4: Handle unions (recursive)
|
||||
if (str_contains($normalizedType, '|')) {
|
||||
$types = explode('|', $normalizedType);
|
||||
$jsonTypes = [];
|
||||
|
|
@ -689,7 +694,7 @@ final class SchemaGenerator implements SchemaGeneratorInterface
|
|||
return array_values(array_unique($jsonTypes));
|
||||
}
|
||||
|
||||
// PRIORITY 4: Handle simple built-in types
|
||||
// PRIORITY 5: Handle simple built-in types
|
||||
return match ($normalizedType) {
|
||||
'string', 'scalar' => ['string'],
|
||||
'?string' => ['null', 'string'],
|
||||
|
|
|
|||
Loading…
Reference in a new issue