mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 16:38:54 +00:00
Fix 71082: Order of use clause and return type declaration unspecified
This commit is contained in:
parent
f739452fff
commit
871fdba56f
1 changed files with 9 additions and 0 deletions
|
@ -1049,6 +1049,8 @@ $greet('PHP');
|
|||
variables must be passed to the <literal>use</literal> language construct.
|
||||
As of PHP 7.1, these variables must not include &link.superglobals;,
|
||||
<varname>$this</varname>, or variables with the same name as a parameter.
|
||||
A return type declaration of the function has to be placed
|
||||
<emphasis>after</emphasis> the <literal>use</literal> clause.
|
||||
</simpara>
|
||||
|
||||
<example>
|
||||
|
@ -1094,6 +1096,12 @@ $example = function ($arg) use ($message) {
|
|||
var_dump($arg . ' ' . $message);
|
||||
};
|
||||
$example("hello");
|
||||
|
||||
// Return type declaration comes after the use clause
|
||||
$example = function () use ($message): string {
|
||||
return "hello $message";
|
||||
};
|
||||
var_dump($example());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
@ -1107,6 +1115,7 @@ string(5) "hello"
|
|||
string(5) "hello"
|
||||
string(5) "world"
|
||||
string(11) "hello world"
|
||||
string(11) "hello world"
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
|
|
Loading…
Reference in a new issue