From 871fdba56fc1afc8a2664b9368ed346b4f60718b Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Mon, 13 Sep 2021 17:20:48 +0200 Subject: [PATCH] Fix 71082: Order of use clause and return type declaration unspecified --- language/functions.xml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/language/functions.xml b/language/functions.xml index dfa0a59231..c5cc4613fe 100644 --- a/language/functions.xml +++ b/language/functions.xml @@ -1049,6 +1049,8 @@ $greet('PHP'); variables must be passed to the use language construct. As of PHP 7.1, these variables must not include &link.superglobals;, $this, or variables with the same name as a parameter. + A return type declaration of the function has to be placed + after the use clause. @@ -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()); ?> ]]> @@ -1107,6 +1115,7 @@ string(5) "hello" string(5) "hello" string(5) "world" string(11) "hello world" +string(11) "hello world" ]]>