Skip to content

Instantly share code, notes, and snippets.

@midorikocak
Last active April 18, 2016 21:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save midorikocak/c5325d19699254f6926af8eebdd1ee8a to your computer and use it in GitHub Desktop.
Save midorikocak/c5325d19699254f6926af8eebdd1ee8a to your computer and use it in GitHub Desktop.
<?php
class Brainfuck
{
public $ref;
function &__get($x) {
$this->ref = new class($this->ref) {
private $p;
function __construct(&$p) {
$this->p = &$p;
}
function __isset($x) {
$this->p = new Brainfuck;
return false;
}
function __get($x) {
}
function __set($x, $y) {
$this->$x = $y;
}
};
return $this->ref;
}
function __set($x, $y) { /* not called */
var_dump($x, $y);
}
function __isset($x) {
return true;
}
}
$a = new Brainfuck;
$a->b->c = $a->b->c ?? 2;
$a->b->c ??= $b;
isset($a->b) ? ( $_ = $a->b; $_->c ?? $_->c = $b ) : $a->b->c = $b;
var_dump($a);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment