|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #71082 Documentation is unclear on the other of use clause and return type declaration
Submitted: 2015-12-10 15:59 UTC Modified: 2021-09-13 15:22 UTC
Avg. Score:4.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: lists dot ban at herbesfolles dot org Assigned: levim (profile)
Status: Closed Package: Documentation problem
PHP Version: 7.0.0 OS:
Private report: No CVE-ID: None
 [2015-12-10 15:59 UTC] lists dot ban at herbesfolles dot org
From manual page:

Syntax for mixing `use` Closure clause with return type declaration doesn't seem to be documented anywhere.  It's then unclear whether the `use` clause should come before (where PHP7 actually wants it) or after (where HHVM wants it) the return type hint.

    $closure = function (string $str) use (&$something) : int {}

    $closure = function (string $str) : int use (&$something) {}

As this not only isn't obvious, but also is inconsistent with what HHVM supports for some time, it seems very useful to me to document this clearly.

Test script:

$something = 42;
$closure = function (string $str) use (&$something) : int {
	return strlen($str) + $something;


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-12-19 04:19 UTC]
-Assigned To: +Assigned To: levim
 [2021-09-13 15:22 UTC]
-Status: Assigned +Status: Closed
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Sep 19 15:03:37 2021 UTC