Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Not all integer range types supported #2252

Open
RobertMe opened this issue Apr 2, 2024 · 3 comments
Open

[Bug]: Not all integer range types supported #2252

RobertMe opened this issue Apr 2, 2024 · 3 comments
Labels

Comments

@RobertMe
Copy link

RobertMe commented Apr 2, 2024

Version

4.25.0

Description

The release notes of 4.24.0 mention that integer range types are now supported, and links to PHPStans documentation for an explanation. But it seems like non-negative-int, which is on that list, isn't supported?

When I use:

        /**
         * @var non-negative-int
         */
        #[Assert\Range(min: 0)]
        #[Property(
            description: '...',
        )]
        public readonly int $pageNumber = 0;

A LogicException is thrown:

Schema of type "\<my namespace>\non-negative-int" can't be generated, no describer supports it. Class "\<my namespace>\non-negative-int" does not exist, did you forget a use statement, or typed it wrong?

And the same applies to non-positive-int as well.

Additional context

No response

@RobertMe RobertMe added the bug label Apr 2, 2024
@DjordyKoert
Copy link
Collaborator

Sadly non-negative-int is not supported, you can read more about it in the related PR discussion #2236 (comment)

@RobertMe
Copy link
Author

RobertMe commented Apr 2, 2024

Hmm, bit strange that the release notes mention something which doesn't work then (i.e.: linking to PHPStan documentation listing type names which aren't supported).

As a work-a-round I'm now using int<0, max>, which behaves identical / for which non-negative-int is an alias. So it seems a bit odd that one "style" works and the other doesn't.

@DjordyKoert
Copy link
Collaborator

As a work-a-round I'm now using int<0, max>, which behaves identical / for which non-negative-int is an alias. So it seems a bit odd that one "style" works and the other doesn't.

It is odd yes, you could try and open an issue or maybe even a PR at https://github.com/phpDocumentor/TypeResolver about this issue 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants