You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Schema generator - ability to use phpstan/psalm number intervals #397
Describe the bug
When you use typehint on property, then use @param to narrow it, it will translate as object in schema generator.
When you use @param int<0, max> $offset in your typehint, Schema generator will translate it to object, even if property itself is integer on language level
To Reproduce
/**
* @param int<0, max> $offset
*/
public function sendMeData(
#[Schema(minimum: 0)]
int $offset,
) {
}
Expected behavior
Offset parameter is generated as type: integer into Schema, but it's object
Additional context
You can override it by adding type: 'integer' into Schema , but it's third time you need to do it for one value. When there is int defined on language level, there should be no way to change it by phpdoc.
I’d like to take this. I reproduced it on the current main: phpDocumentor preserves int<0, max>, but SchemaGenerator does not recognize that refinement and falls through to object, even though the native type is int.
Before opening a PR, I’d like to confirm the intended scope, especially given the direction discussed in #314. My preference is a focused bug fix: treat int<...> as the base JSON Schema integer type, keep #[Schema] as the source of minimum/maximum, and add regression coverage. The broader alternative would parse PHPStan/Psalm interval bounds into minimum/maximum.
Would the focused fix be the preferred direction here?
Thanks for the report @kratkyzobak - and yes, @wWzZb, feel free to go ahead. I would expect this is rather a smaller fix than a larger overhaul; compared to #314
Activity
wWzZb commentedon Aug 14, 2026
I’d like to take this. I reproduced it on the current
main: phpDocumentor preservesint<0, max>, butSchemaGeneratordoes not recognize that refinement and falls through toobject, even though the native type isint.Before opening a PR, I’d like to confirm the intended scope, especially given the direction discussed in #314. My preference is a focused bug fix: treat
int<...>as the base JSON Schemaintegertype, keep#[Schema]as the source ofminimum/maximum, and add regression coverage. The broader alternative would parse PHPStan/Psalm interval bounds intominimum/maximum.Would the focused fix be the preferred direction here?
chr-hertel commentedon Aug 14, 2026
Thanks for the report @kratkyzobak - and yes, @wWzZb, feel free to go ahead. I would expect this is rather a smaller fix than a larger overhaul; compared to #314