#33325 [Opn->Bgs]: Type hinting and defaults of NULL
| From: | iliaa@php.net | Date: | Mon, 13 Jun 2005 21:44:37 +0000 |
| Subject: | #33325 [Opn->Bgs]: Type hinting and defaults of NULL | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-80263@lists.php.net to get a copy of this message | ||
ID: 33325
Updated by: iliaa@php.net
Reported By: jacob at jacobweber dot com
-Status: Open
+Status: Bogus
Bug Type: Class/Object related
Operating System: All
PHP Version: 5.0.4
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
This is intended behaviour.
Previous Comments:
------------------------------------------------------------------------
[2005-06-13 19:17:22] jacob at jacobweber dot com
Description:
------------
When using type-hinting in a function's arguments, PHP should allow a
default value of NULL. Otherwise you have to manaully check the type
with instanceof. This would make it more convenient, and more
consistent with Java.
Reproduce code:
---------------
function f (MyClass $o = NULL) {
echo "success";
}
f();
Expected result:
----------------
success
Actual result:
--------------
PHP compiler error.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=33325&edit=1