Regression/unset properties behavior #228

wants to merge 3 commits into


None yet

3 participants

Ocramius commented Nov 8, 2012

This PR introduces a test to avoid regression on a functionality used to implement lazy loading in doctrine/common#168.

The concept is quite simple:

class A 
    public $b;
    public function __get($name)
        echo 'called';

$a = new A();
unset ($a->b);
$a->b; // produces output 'called'

This functionality initially looked like a bug to me, but it turned out to be expected behaviour after asking around for quite a bit. The PR introduces a test to protect this functionality.

Ocramius added some commits Oct 26, 2012
@Ocramius Ocramius Adding regression test for behavior of magic methods with unset publi…
…c properties

Verifies that after having unset a public property, any access to it, be it read or write, causes calls to public magic methods

Signed-off-by: Marco Pivetta <>
@Ocramius Ocramius Fixing test according to @jpauli's suggestions a594587
@Ocramius Ocramius Adding tests for private and protected properties e757645
@Ocramius Ocramius referenced this pull request in doctrine/common Nov 8, 2012

[DCOM-96] ProxyFactory logic moved to doctrine common #168

lstrojny commented Dec 2, 2012

Merged into 5.4, 5.5, master. Thanks!


Comment on behalf of lstrojny at


@php-pulls php-pulls closed this Dec 2, 2012
@Ocramius Ocramius deleted the Ocramius:regression/unset-properties-behavior branch Jan 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment