Doc #71082 [Asn->Csd]: Documentation is unclear on the other of use clause and return type declaration

From: Date: Mon, 13 Sep 2021 15:22:08 +0000
Subject: Doc #71082 [Asn->Csd]: Documentation is unclear on the other of use clause and return type declaration
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-19177@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71082&edit=1 ID: 71082 Updated by: cmb@php.net 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

« previous php.doc.bugs (#19177) next »