Skip to content

Property switching from virtual and to backed duplicates the property when the grandchild has a set hook #19053

Description

@bwoebi

Description

The following code (https://3v4l.org/AupSE#v8.4.10):

<?php

abstract class GP {
    public abstract mixed $foo { get; }
}

class P extends GP {
    public mixed $foo;
    public function x() { 
        ++$this->foo;
        return $this;
    }
}

class C1 extends P {
    public mixed $foo = 0 { set { parent::$foo::set($value); } }
}

var_dump((new C1)->x());

Resulted in this output:

object(C1)#1 (1) {
  ["foo"]=>
  uninitialized(mixed)
  ["foo"]=>
  int(1)
}

But I expected this output instead:

object(C1)#1 (1) {
  ["foo"]=>
  int(1)
}

PHP Version

PHP 8.4.10

Operating System

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions