Edit report at https://bugs.php.net/bug.php?id=71082&edit=1
ID: 71082
Updated by: [email protected]
Reported by: lists dot ban at herbesfolles dot org
Summary: Documentation is unclear on the other of use clause
and return type declaration
-Status: Assigned
+Status: Closed
Type: Documentation Problem
Package: Documentation problem
PHP Version: 7.0.0
Assigned To: levim
Block user comment: N
Private report: N
New Comment:
Fixed as <https://github.com/php/doc-en/commit/871fdba56fc1afc8a2664b9368ed346b4f60718b>.
Previous Comments:
------------------------------------------------------------------------
[2015-12-10 15:59:32] 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;
};
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71082&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.