|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-07-10 22:11 UTC] 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')?).
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 20 23:00:01 2025 UTC |
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