language/control-structures/return.xml
db7aa4f29bd5909f8ab9e3739f60afb77837e4df
...
...
@@ -6,7 +6,7 @@
6
6
<?phpdoc print-version-for="return"?>
7
7
<simpara>
8
8
<literal>return</literal> returns program control to the calling module.
9
-
Execution resumes at the statement following the called module's invocation.
9
+
Execution resumes at the expression following the called module's invocation.
10
10
</simpara>
11
11
<simpara>
12
12
If called from within a function, the <literal>return</literal>
...
...
@@ -39,8 +39,7 @@
39
39
<simpara>
40
40
Note that since <literal>return</literal> is a language
41
41
construct and not a function, the parentheses surrounding its
42
-
arguments are not required. It is common to leave them out, and you
43
-
actually should do so as PHP has less work to do in this case.
42
+
argument are not required and their use is discouraged.
44
43
</simpara>
45
44
</note>
46
45
<note>
...
...
@@ -51,16 +50,12 @@
51
50
with no arguments will result in a parse error.
52
51
</simpara>
53
52
</note>
54
-
<note>
55
-
<simpara>
56
-
You should <emphasis>never</emphasis> use parentheses around your return
57
-
variable when returning by reference, as this will not work. You can
58
-
only return variables by reference, not the result of a statement. If
59
-
you use <literal>return ($a);</literal> then you're not returning a
60
-
variable, but the result of the expression <literal>($a)</literal>
61
-
(which is, of course, the value of <varname>$a</varname>).
62
-
</simpara>
63
-
</note>
53
+
</para>
54
+

55
+
<para>
56
+
As of PHP 7.1.0, return statements without an argument in functions which declare a return type trigger <constant>E_COMPILE_ERROR</constant>,
57
+
unless the return type is <type>void</type>, in which case return statements
58
+
with an argument trigger that error.
64
59
</para>
65
60
</sect1>
66
61

67
62