Hi all,

With these changes, im not entirely sure how one is supposed to indicate that the given argument to a method is not valid, not set, default, etc...

I have been using PHP5 for some time now, but i can't say im up to speed on the internal technicalities of PHP, but i feel that typehinting is a fantastic new feature to help enforce, at a PHP level, your applications integrity, esepcially when you have several people working on projects.

If you can no longer pass nulls, in many (of my) cases the typehinting will have to be removed, undermining the benifit. This is the way that things have been working up until now, and im sure many people have become used to this behaviour, why suddenly change it?

I have also been using null to set default values of typehinted arguments as follows:

function Example(DateTime $date = null) {
        if($date == null) {
                $date = DateTime::Today();
        }
}

This is quite fundamental to a lot of the work i have been doing with PHP5, and as such have had to reverse the patch that was applied before RC3. It is also possible that there is another coding practice i could use here, in which case, any suggestions?

Appologies if this is revisiting already discussed issues, but this is a rather major change in the languages functionality (well, with regards to how i have been using it).

Additionally, are there any plans to allow hinting of built in types such as string, int, double and even object?

Ray



Christian Schneider wrote:
Michael Wallner wrote:

Is there *ANY* serious reason why NULL is not allowed in place
of an object?  PHP will become *really* odd if this is the way
it goes. People won't stick to this new feature...


There was a (very) long discussion about this on this mailing list a couple of weeks ago, please check the archive. It was decided to leave it the way it is for now.

Also, these errors are hard to track because they refer to
the line number where the function definition is, not where the actual violation was comitted.


This is a good point and the same applies to the "Missing argument" error message. Best would be if both lines are mentioned.

- Chris

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



Reply via email to