Skip to content

Conversation

@anomiex
Copy link
Collaborator

@anomiex anomiex commented Aug 16, 2023

PHP 8.1 added a "never" return type that indicates that the function will never return, and raises a fatal error if such a function includes a return. We need to detect and handle such functions in a similar manner as we handle "void".

Also it turns out that the error handling for a "void" redefinition trying to return a value was broken, giving an error like

Fatal error: Uncaught Error: Undefined constant "thrownew\Patchwork\Exceptions\NonNullToVoid" in file line #

so I added a test for that too and adjusted the condense function to collapse whitespace to a single space instead of stripping it completely.

Fixes #140

PHP 8.1 added a "never" return type that indicates that the function
will never return, and raises a fatal error if such a function includes
a `return`. We need to detect and handle such functions in a similar
manner as we handle "void".

Also it turns out that the error handling for a "void" redefinition
trying to return a value was broken, giving an error like
```
Fatal error: Uncaught Error: Undefined constant "thrownew\Patchwork\Exceptions\NonNullToVoid" in file line #
```
so I added a test for that too and adjusted the condense function to
collapse whitespace to a single space instead of stripping it
completely.
@anomiex anomiex requested review from antecedent and jrfnl August 16, 2023 15:31
@anomiex anomiex self-assigned this Aug 16, 2023
@d-claassen
Copy link

Hey! After running into the same issue, Google led me to this issue / PR. I can confirm this PR solved the described issue on the repo I've been working on! 👍

@antecedent antecedent merged commit f2dae08 into master Sep 18, 2023
@antecedent
Copy link
Owner

This is now live in 2.1.26. My apologies for the delay, and thanks to @anomiex for contributing!

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.

Handle PHP 8.1 and PHPUnit 10, 'never' return type

4 participants