Skip to content

Expand TypeInfo component to support advanced scalar types #59733

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

Open
zmitic opened this issue Feb 8, 2025 · 1 comment
Open

Expand TypeInfo component to support advanced scalar types #59733

zmitic opened this issue Feb 8, 2025 · 1 comment

Comments

@zmitic
Copy link

zmitic commented Feb 8, 2025

Description

For a method like this:

/**
 * @param non-empty-string $name
 * @param int<0,100> $percent
 */
private function test($name, $percent): void
{
}

TypeResolver::resolve returns BuiltinType(string) and BuiltinType(int), without extra information. It would be really nice if we could read more of them, at least these 2 as they are most useful.


If you are interested in the use-case, I can provide an example. But in short: it is about static analysis and forms when we must use empty_data closure. When it fails, then #[Assert] attributes will not be read and user will never get any validation errors.

I already made an extension that solves this problem for builtin types (by using reflection and constraints normalizer), but these advanced one are tricky. I could have used phpstan/phpdoc-parser, but TypeInfo component already supports it so it would be nice to re-use it.

Example

No response

@mtarld
Copy link
Contributor

mtarld commented Feb 14, 2025

For information, there is an ongoing PR on that subject: #59676.

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

No branches or pull requests

3 participants