Bug->Doc #76311 [Opn->Ver]: __construct/destruct do not have return types
| From: | requinix@php.net | Date: | Tue, 08 May 2018 15:50:28 +0000 |
| Subject: | Bug->Doc #76311 [Opn->Ver]: __construct/destruct do not have return types | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-15659@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=76311&edit=1
ID: 76311
Updated by: requinix@php.net
Reported by: Andy_Schmidt at HM-Software dot com
-Summary: _destruct should permit "void" as return type
+Summary: __construct/destruct do not have return types
-Status: Open
+Status: Verified
-Type: Bug
+Type: Documentation Problem
-Package: PHP Language Specification
+Package: Class/Object related
PHP Version: 7.2.5
Block user comment: N
Private report: N
New Comment:
Constructors and destructors do not have the concept of a return type. The docs showing anything at
all, even void, is incorrect.
Previous Comments:
------------------------------------------------------------------------
[2018-05-08 15:37:05] Andy_Schmidt at HM-Software dot com
Description:
------------
According to PHP's manual:
http://php.net/manual/en/language.oop5.decon.php
the signature of the __destruct method is:
void __destruct ( void )
Consequently, the following syntax would be correct for 7.2, now that a "void" type hint
is available:
function __destruct(): void {}
Actual result:
--------------
PHP Fatal error: Destructor __destruct() cannot declare a return type
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76311&edit=1