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

Fix Closure::fromCallable and first-class callables not propagating templates. #2962

Draft
wants to merge 1 commit into
base: 1.10.x
Choose a base branch
from

Conversation

mad-briller
Copy link
Contributor

Also improves the array_map return type extension to be smarter about generic callables, specifically for single argument constant arrays.

This improves the situation of phpstan/phpstan#10685 but i hesitate to say it solves it, there are some underlying issues that i'll add to the relevant test locations on this pr

@mad-briller mad-briller marked this pull request as draft March 9, 2024 13:08
* @param callable(N): O $cd
* @return Closure(array{L, N}): array{M, O}
*/
function compose2(callable $ab, callable $cd): Closure
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i had to change the generic type names of this function from A B C D to something else, as identity() and identity2() are also using A and B as generic type names, which made the type resolution fail. Been trying to dig into it a bit but as for why i'm really not sure right now,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this be related to TemplateTypeScope? i'm yet to properly understand it's role in the type resolution but it seems like it could be pertinent

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