On Mon, Jan 21, 2013 at 11:54 PM, Crypto Compress < cryptocompr...@googlemail.com> wrote:
> Hello Nikita, > > for me this "maybe-of-type"-typehinting is a small progression in the right > direction. > > But "Default values and nullability" would break existing code as you need > to add a default null at "design-time" (BC break): > > <?php > class C { > public $a; // public string $a = null; > public $b; // public string $b = null; > public function __construct($a, $b) { > $this->a = $a; > $this->b = $b; > } > } > > // test only a > $c = new C("foo", null); > var_dump($c->a === "foo"); > > // test only b > $c = new C(null, "foo"); > var_dump($c->b === "foo"); > ?> > > http://3v4l.org/4oi9k > > cryptocompress > Sorry if it wasn't clear: The nullability stuff only applies if a typehint is used. If no typehint is used, then you can freely assign null, regardless of whether or not you have the "= null" in the declaration (no typehint = everything's valid). "public $foo;" will continue to behave exactly the same way it did before :) Nikita