PHP :: Doc Bug #71082 :: Documentation is unclear on the other of use clause and return type declaration
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:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.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
Have you experienced this issue?
Rate the importance of this bug to you:

 [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-2018 The PHP Group
All rights reserved.
Last updated: Sat Aug 18 00:01:26 2018 UTC