#28712 [Com]: NULL can't be passed to argument with class type hint.
| From: | imprestavel at gameguru dot com dot br | Date: | Wed, 09 Jun 2004 23:34:39 +0000 |
| Subject: | #28712 [Com]: 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-60681@lists.php.net to get a copy of this message | ||
ID: 28712
Comment by: imprestavel at gameguru dot com dot br
Reported By: davojan at mail dot ru
Status: Open
Bug Type: Zend Engine 2 problem
Operating System: FreeBSD 4.7-RELEASE
PHP Version: PHP5-RC3
New Comment:
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
Previous Comments:
------------------------------------------------------------------------
[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