Am 08.01.2013 10:03, schrieb Lazare Inepologlou:
The fact is that the existing syntax for nullable type hinting has its own problems. For example, this is not possible: function foo( Bar $bar = null , $mandatory ) { ... }
Sure it's possible;) I did not get a syntax error for that...I even use that case many times in my code exactly for that purpose, to allow $bar to be null but require $mandatory to be defined explicitly.
I would love to have the question mark syntax for both properties and argument type hinting.
Introducing a BC-Break and/or yet another syntax? Is that worth it?
This does not apply in all cases. Here is an example of a property that is guaranteed not to be null: class Foo { private $_date; public DateTime $date { get { return is_null($date) ? new DateTime() : $this->date; } set { $this->date = $value; } } }
The property is still null;) Only the return value of the getter will not be null. But that's not the issue, is it? I am not arguing the case of NOT allowing null, Stas wanted to always allow null because of this reason and not have a special syntax to declare this.
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php