Am 08.01.2013 08:56, schrieb Christian Stoller:
But the way 'nullable' properties are defined is not very intuitive and
unclean, in my opinion. Stas has already mentioned that.
`public DateTime $date = NULL;` // this looks like the property is initialized
with null, but it does not show that the property is 'nullable'
To me this makes perfect sense. It takes up the syntax php has been
using for method-definitions. A syntax we would be using to create a
classic setter method if there wasn't a fancy new one.
public function setDate(DateTime $date = NULL) {
$this->date = $date;
}
Anything other than this would result in an inconsistency. Having
accepted that syntax previously and now introducing yet another one,
would be confusing and unnecessary.
Although, as Stas has pointed out, *not* allowing NULL for a property
will not prevent it from being NULL...depending on wether it has been
initalized.
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php