Req #36265 [Opn->Csd]: Object as default function argument
| From: | cmb@php.net | Date: | Mon, 11 Oct 2021 11:04:25 +0000 |
| Subject: | Req #36265 [Opn->Csd]: Object as default function argument | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-237135@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=36265&edit=1
ID: 36265
Updated by: cmb@php.net
Reported by: rael at grad dot icmc dot usp dot br
Summary: Object as default function argument
-Status: Open
+Status: Closed
Type: Feature/Change Request
Package: Scripting Engine problem
Operating System: Any
PHP Version: 5.1.2
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
This is supported as of PHP 8.1.0[1].
[1] <https://wiki.php.net/rfc/new_in_initializers>
Previous Comments:
------------------------------------------------------------------------
[2006-02-02 20:03:49] rael at grad dot icmc dot usp dot br
Description:
------------
In some cases, it's a very usefull feature use an object as default function argument, what is
not possible, generating an error in current versions of PHP.
Reproduce code:
---------------
<?php
class Foo {}
function bar(Foo $foo = new Foo()){}
?>
Expected result:
----------------
A blank webpage.
Actual result:
--------------
Parse error: parse error, unexpected T_NEW in c:\Inetpub\wwwroot\phobos\testes\index.php on line 5
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=36265&edit=1