Re: [VOTE] Alternative typehinting syntax for accessors

From: Date: Mon, 21 Jan 2013 22:54:43 +0000
Subject: Re: [VOTE] Alternative typehinting syntax for accessors
References: 1  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
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

Thread (11 messages)

« previous php.internals (#65060) next »