#41958 [Bgs]: Typehinting support null value but the docs hide the facts!
| From: | colder@php.net | Date: | Thu, 16 Aug 2007 12:37:09 +0000 |
| Subject: | #41958 [Bgs]: Typehinting support null value but the docs hide the facts! | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969377407@lists.php.net to get a copy of this message | ||
ID: 41958
Updated by: colder@php.net
Reported By: baldurien at bbnwn dot eu
Status: Bogus
Bug Type: Documentation problem
PHP Version: Irrelevant
New Comment:
There is in fact something special with typehinted arguments, as only
few types of values are permitted:
function foo(Bar $b = 2) {} is not permitted, for example
Previous Comments:
------------------------------------------------------------------------
[2007-08-16 12:21:53] vrana@php.net
Every parameter can have a default value. There's nothing special with
type-hinted parameters.
------------------------------------------------------------------------
[2007-07-10 22:11:32] baldurien at bbnwn dot eu
Description:
------------
The documentation is missing the fact that the following statement is
possible :
function o1(Foo $arg0 = null, $x) {}
function o2(Foo& $arg0 = null, $x) {}
The code above works on 5.2.3 (which is fine).
The fact that a typehinted parameter can have a default (enforced to
null) value should be explained at least in the type hinting part of the
doc [http://ch2.php.net/manual/en/language.oop5.typehinting], with the
version of php that support it (I can't remember it it was working on
5.1).
Note also that the syntax can be misleading: one can easily think that
$arg0 take a default value, and that o1('a') is possible (or
o1(,'a')?).
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41958&edit=1