Req #75263 [Com]: function __construct(): void
| From: | spam2 at rhsoft dot net | Date: | Tue, 26 Sep 2017 21:29:35 +0000 |
| Subject: | Req #75263 [Com]: function __construct(): void | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-211370@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75263&edit=1
ID: 75263
Comment by: spam2 at rhsoft dot net
Reported by: saymongcsw at gmail dot com
Summary: function __construct(): void
Status: Open
Type: Feature/Change Request
Package: Class/Object related
Operating System: any
PHP Version: 7.1.10RC1
Block user comment: N
Private report: N
New Comment:
why do you think a void retunr-type would be correct for __construct()
$x = new my_class(1, 2)
call __construct(1, 2) of my_class and returns a object instance
Previous Comments:
------------------------------------------------------------------------
[2017-09-26 20:38:36] saymongcsw at gmail dot com
Description:
------------
Can't declare VOID return type in constructor. (ex. https://3v4l.org/9slJl)
Test script:
---------------
<?php
class Say
{
public function __construct(): void
{
}
public function hello(): string
{
return 'Hello';
}
}
echo (new Say)->hello();
Expected result:
----------------
Hello
Actual result:
--------------
Fatal error: Constructor Say::__construct() cannot declare a return type in %s on line 3
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75263&edit=1