I also don't like the
?
for
nullable
. Just stick with PHP
convention and do:
class Foo {
public Bar $bar = NULL;
}
There is no such PHP convention. The PHP convention is *not restrict type*
(+"loosely typed" addons).
So NULL is automatically allowed.
For properties, yes, but the idea it stems from is type-hints. Given
the following type-hint, passing a null is not allowed:
class Foo {
function bar(Bar $bar) {}
}
Whereas in the following NULL is allowed:
class Foo {
function bar(Bar $bar = NULL) {}
}
This is what I mean by the PHP convention for allowing NULL.
Hello Levi,
you absolutly right. I was confused by the syntax. This properties are normal
methods and should behave the same. Mixing "initialize-with-NULL" and
"optional/nullable" is somewhat messy though.
cryptocompress