On Wed, 2016-03-16 at 15:29 -0400, Phil Sturgeon wrote:
> > What's expected here:
> >
> > class A {
> >   public int $i;
> > }
> >
> > $a = new A();
> > $r = &$a->i;
> > $r = "foobar";

> I put your code into 3v4l so you could see what would happen:
> 
> https://3v4l.org/taC8D
> 
> Fatal error: Uncaught TypeError: Typed property A::$i must not be referenced
> 
> Is that what you expect? If not, what would you expect?

Well, I think a naïve user would expect to get an error about "foobar"
not being an integer and would expect $r = 42; to work.

Maybe the other example from the discussion with Bob might be more clear
about the issue:

class A {
    private array $data = [42, 23];
    public function sort() {
        sort($this->data);
        print_r($this->data);
    }
}
$a = new A();
$a->sort();

An "Uncaught TypeError" is completely unexpected there.


btw. while testing this it seems the patch is broken:

https://3v4l.org/sOBca/rfc#tabs - this gives a strange error ("A::$data
must be array, unknown used") in the print_r call!?
https://3v4l.org/kl5e2/rfc#tabs - this changes the type

johannes

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to