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

vec(positive_int()) throws away positive from int #11

Open
simPod opened this issue Jan 23, 2023 · 7 comments
Open

vec(positive_int()) throws away positive from int #11

simPod opened this issue Jan 23, 2023 · 7 comments

Comments

@simPod
Copy link
Contributor

simPod commented Jan 23, 2023

\PHPStan\dumpType(vec(positive_int())->assert([]));

gives Dumped type: list<int>, it should give int<1, max>.

v1
psl 2.3.1
phpstan v1.9.14

@azjezz
Copy link

azjezz commented Jan 23, 2023

this seems to be a bug in phpstan, not psl.

ref: https://phpstan.org/r/dd513470-8f0b-4ac2-aeb2-f1a744361b50

cc @ondrejmirtes

@azjezz azjezz closed this as completed Jan 23, 2023
@azjezz
Copy link

azjezz commented Jan 23, 2023

the same code works in psalm: https://psalm.dev/r/2bd5bdfee1

@ondrejmirtes
Copy link
Collaborator

I think it's valuable to keep this open. This isn't a PSL repo, but a PSL PHPStan extension repo.

@ondrejmirtes ondrejmirtes reopened this Jan 23, 2023
@ondrejmirtes
Copy link
Collaborator

Even if the root cause fix belongs in PHPStan, it'd be valuable to land a regression test here.

@azjezz
Copy link

azjezz commented Jan 23, 2023

Oh, right! i thought this was the PSL repo 😅

@ondrejmirtes
Copy link
Collaborator

BTW to make your example green, you need template-covariant: https://phpstan.org/r/93cf74a1-99a4-4064-89b2-49eadd6208e6

@azjezz
Copy link

azjezz commented Jan 23, 2023

it shouldn't need to be covariant tho 🤔

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

No branches or pull requests

3 participants