Using default argument values in the middle of the argument list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

as I accidentally found out that PHP allows default argument values
to occur not only at the end of parameter list:

function ( Classname $a, Classname $b = null, Classname $c ) ...

Unfortunately, documentation does not state what is supposed to happen in such situation.
It appears $b can be an instance of Classname or a null.

I've draw up simple test case (https://gist.github.com/2829626) to verify my assumption and it seems to work at least since PHP 5.3.0. It is extremely useful to allow null
value and retain the power of type hints at the same time.

Is there anything else to test? Does it work for your setup? Can it be used that way?
And if yes, can it be officially documented?

Do not hesitate to prove I'm wrong.

-- Oliver

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux