Skip to content

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

Description

@coreyworrell

Attempting to use with PHP 8.1 and PHPUnit 10, and getting error:

13:08:11 user@host ~/projects/name master *
$ composer test
> @php phpunit
PHPUnit 10.3.1 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.1.21
Configuration: /home/user/projects/name/phpunit.xml.dist

PHP Fatal error:  A never-returning function must not return in /home/user/projects/name/vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php on line 91
Script @php phpunit handling the test event returned with error code 255

Tracing it back leads to function injectCallInterceptionCode() which calls:

return Generic\prependCodeToFunctions(
	Utils\condense(CALL_INTERCEPTION_CODE),
	Utils\condense(CALL_INTERCEPTION_CODE_VOID_TYPED),
	true
);

Removing the return; from CALL_INTERCEPTION_CODE_VOID_TYPE and then adjusting Patchwork\CodeManipulation\Actions\Generic\isVoidTyped() to check for never corrects the issue, but I don't know if that would be the preferred method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions