Deprecate return by reference from never ?
| From: | Juliette Reinders Folmer | Date: | Wed, 09 Jul 2025 00:47:15 +0000 |
| Subject: | Deprecate return by reference from never ? | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-127960@lists.php.net to get a copy of this message | ||
L.S.,
I just noticed something which seems odd to me: PHP 8.1 deprecated declaring a function to return by reference when the return type is void:
function &foo() : void {} results in:
"Deprecated: foo(): Returning by reference from a void function is deprecated"
However, declaring a function to return by reference when the return type is "never" does not yield either an error or a deprecation notice: https://3v4l.org/DWs7t
I might well be missing something, but this feels a bit strange and inconsistent to me.
Should this be fixed by also deprecating return by reference for "never" functions ?
Smile,
Juliette