Skip to content

Zend: Make Closure covariant to callable #15492

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

Merged
merged 1 commit into from
Jan 24, 2025
Merged

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Aug 19, 2024

Pointed out by @ondrejmirtes

@Girgias Girgias changed the title Zend: Make Closure covariant to callable [W.I.P.] Zend: Make Closure covariant to callable Aug 19, 2024
@ondrejmirtes
Copy link
Contributor

What about all classes with __invoke being covariant with callable?

@Girgias
Copy link
Member Author

Girgias commented Aug 19, 2024

What about all classes with __invoke being covariant with callable?

I don't think there is an "easy" solution for this because PHP is nominally typed and there isn't an interface that is auto-implemented (or manually required) for classes that can be invoked.

It could be done by inspecting the CE to see if the __invoke() method is implemented, but that's more on the lines of structural typing, which is a whole other can of worms.

@ondrejmirtes
Copy link
Contributor

I see, makes sense, we'd need a Stringable equivalent for __invoke().

@Girgias Girgias changed the title [W.I.P.] Zend: Make Closure covariant to callable Zend: Make Closure covariant to callable Nov 10, 2024
@Girgias Girgias marked this pull request as ready for review November 10, 2024 20:40
@Girgias Girgias requested a review from dstogov as a code owner November 10, 2024 20:40
@Girgias Girgias requested a review from arnaud-lb November 10, 2024 20:40
Copy link
Member

@dstogov dstogov left a comment

Choose a reason for hiding this comment

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

I think this makes sense.

Copy link
Member

@arnaud-lb arnaud-lb left a comment

Choose a reason for hiding this comment

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

This makes sense and I can't find any issue or BC break with this change.

I'm not sure if this requires an RFC.

@Girgias Girgias merged commit 32fb260 into php:master Jan 24, 2025
8 of 9 checks passed
@Girgias Girgias deleted the callable-variance branch January 24, 2025 17:32
iluuu1994 added a commit to iluuu1994/php-src that referenced this pull request Jan 28, 2025
Caused by phpGH-15492. While the parent might contain callable, it may also
contain other types. zend_is_class_subtype_of_type() may be checking a
member that is not callable itself.

Discovered by a failing Laravel test in nightly.
iluuu1994 added a commit to iluuu1994/php-src that referenced this pull request Jan 28, 2025
Caused by phpGH-15492. While the parent might contain callable, it may also
contain other types. zend_is_class_subtype_of_type() may be checking a
member that is not callable itself. Fall back to the normal class
subtype check.

Discovered by a failing Laravel test in nightly.
iluuu1994 added a commit to iluuu1994/php-src that referenced this pull request Jan 28, 2025
Caused by phpGH-15492. While the parent might contain callable, it may also
contain other types. zend_is_class_subtype_of_type() may be checking a
member that is not callable itself. Fall back to the normal class
subtype check.

Discovered by a failing Laravel test in nightly.
iluuu1994 added a commit to iluuu1994/php-src that referenced this pull request Jan 28, 2025
Caused by phpGH-15492. While the parent might contain callable, it may also
contain other types. zend_is_class_subtype_of_type() may be checking a
member that is not callable itself. Fall back to the normal class
subtype check.

Discovered by a failing Laravel test in nightly.
iluuu1994 added a commit that referenced this pull request Jan 28, 2025
Caused by GH-15492. While the parent might contain callable, it may also
contain other types. zend_is_class_subtype_of_type() may be checking a
member that is not callable itself. Fall back to the normal class
subtype check.

Discovered by a failing Laravel test in nightly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants