Created
December 3, 2012 20:11
-
-
Save rhowardiv/4197652 to your computer and use it in GitHub Desktop.
PHP magic __get only allows itself on the stack once per property
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Dumb { | |
protected $prop; | |
function __get($p) { | |
if ($p === 'prop') { | |
$this->prop = new Dumber($this); | |
return $this->prop; | |
} | |
} | |
} | |
class Dumber { | |
public $prop; | |
function __construct(Dumb $dumb) { | |
$this->prop = $dumb->prop; | |
} | |
} | |
$d = new Dumb(); | |
var_dump($d->prop); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment