[doc-en] master: void: document that returning a value is a compile-time error (#5920)
| From: | Satvik Mishra via GitHub | Date: | Thu, 08 Oct 2026 13:41:23 +0000 |
| Subject: | [doc-en] master: void: document that returning a value is a compile-time error (#5920) | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-23820@lists.php.net to get a copy of this message | ||
Author: Satvik Mishra (SatvikMishra08)
Committer: GitHub (web-flow)
Pusher: lacatoire
Date: 2026-10-08T15:41:20+02:00
Commit: https://github.com/php/doc-en/commit/fff1bba97cc9c9f86f7e49e4074e1e5792df77be
Raw diff: https://github.com/php/doc-en/commit/fff1bba97cc9c9f86f7e49e4074e1e5792df77be.diff
void: document that returning a value is a compile-time error (#5920)
Changed paths:
M language/types/void.xml
Diff:
diff --git a/language/types/void.xml b/language/types/void.xml
index 60352d2f3e51..76a5f2fc7c6e 100644
--- a/language/types/void.xml
+++ b/language/types/void.xml
@@ -9,6 +9,15 @@
<link linkend="language.types.type-system.composite.union">union
type</link>
declaration. Available as of PHP 7.1.0.
</para>
+ <simpara>
+ A <literal>return</literal> statement with an expression in a
+ <type>void</type> function is a compile-time error, even if the
+ <literal>return</literal> would not be reached during execution.
+ This includes <literal>return null;</literal>; use a bare
+ <literal>return;</literal> to exit the function early. The
+ <literal>null</literal> mentioned below is only the implicit value of
+ the call.
+ </simpara>
<note>
<simpara>