php.net |  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: 2015-12-19 04:19 UTC
Votes:2
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: Assigned Package: Documentation problem
PHP Version: 7.0.0 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: lists dot ban at herbesfolles dot org
New email:
PHP Version: OS:

 

 [2015-12-10 15:59 UTC] lists dot ban at herbesfolles dot org
Description:
------------
---
From manual page: http://www.php.net/functions.anonymous
---

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.

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

HHVM:
    $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:
---------------
<?php

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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-12-19 04:19 UTC] levim@php.net
-Assigned To: +Assigned To: levim
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri May 24 13:01:27 2019 UTC