#28712 [Opn->Bgs]: NULL can't be passed to argument with class type hint.
| From: | derick@php.net | Date: | Thu, 10 Jun 2004 07:01:20 +0000 |
| Subject: | #28712 [Opn->Bgs]: NULL can't be passed to argument with class type hint. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-60690@lists.php.net to get a copy of this message | ||
ID: 28712
Updated by: derick@php.net
Reported By: davojan at mail dot ru
-Status: Open
+Status: Bogus
Bug Type: Zend Engine 2 problem
Operating System: FreeBSD 4.7-RELEASE
PHP Version: PHP5-RC3
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
For a reason, please read the internals@ archive of about 2 months ago.
Previous Comments:
------------------------------------------------------------------------
[2004-06-10 01:34:37] imprestavel at gameguru dot com dot br
or just drop the type-hint
unless you use your class as if it was NULL (do nothing with it), you
are going to check that argument anyway
keep it simple
maybe it doesnt make much difference, but since php team already
discussed it, probably with a similar example in mind, and went this
way, i think we would need to give them a much better reason to change
back
------------------------------------------------------------------------
[2004-06-09 19:19:21] davojan at mail dot ru
The compromise can be to add new configuration parameter, something
like "allow_type_hinted_pass_null", to enable or disable this feature.
------------------------------------------------------------------------
[2004-06-09 19:02:58] davojan at mail dot ru
Description:
------------
Actually it was tested in RC3 (I don't find it in PHP version list).
It's very inconveniently, if I can't pass NULL instead of object to the
function.
In the example below the default value is used, but there is a same
behaviour, when I pass NULL explicitly.
I understand, that the report:
http://bugs.php.net/bug.php?id=26780&edit=2
intersects with my, but my opinion is that not accepting NULLs is an
evident bug, very serious bug! And my example with the default value
illustrates it very well.
Reproduce code:
---------------
<?
class foo {};
function bar (foo $f = NULL) { echo 'ok'; }
bar();
?>
Expected result:
----------------
ok
Actual result:
--------------
Fatal error: Argument 1 must not be null in
/usr/local/www/data-dist/ils/admin/test/null.php on line 3
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=28712&edit=1