Andi Gutmans wrote:
So one suggestion (also made a few months ago) was that the following:
function method(MyClass $obj = NULL);
would mark $obj as allowing NULL parameter.

The only restrictions I see is that it makes the parameter optional as well (something I don't consider a problem as it is probably desirable in most cases anyway to be able to leave out an explicit null) and that it only works if no mandatory parameter follows, e.g.
function method(MyClass $obj = null, $mandatory);
is not possible. Not a real problem either IMHO.


I still like this option more than anything else proposed here because it doesn't add new syntax and is simple to understand ("I can leave the parameter out then it will be null or I can pass null as I could also have left it out instead, otherwise I need to pass an object of MyClass").

- Chris

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to