Skip to content

Schema generator - ability to use phpstan/psalm number intervals #397

Description

@kratkyzobak

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.

phpdoc typehint is usefull for phpStan here.

Activity

  1. wWzZb commented on Aug 14, 2026

    @wWzZb
    Contributor

    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?

  2. added
    ServerIssues & PRs related to the Server component
    P2Moderate issues affecting some users, edge cases, potentially valuable feature
    on Aug 14, 2026
  3. chr-hertel commented on Aug 14, 2026

    @chr-hertel
    Member

    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Moderate issues affecting some users, edge cases, potentially valuable featureServerIssues & PRs related to the Server componentbugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions