Skip to content

Instantly share code, notes, and snippets.

@nikita2206
Created January 8, 2017 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikita2206/915cac6efa1e25e5ded76accf718549a to your computer and use it in GitHub Desktop.
Save nikita2206/915cac6efa1e25e5ded76accf718549a to your computer and use it in GitHub Desktop.
<?php
class A
{
private $a;
public function __construct($a)
{
$this->a = $a;
}
}
class B extends A
{
private $a; // extend A in order to force XDebug to use *A*a for `a` property of `A`
public function __construct($a, $pubA)
{
parent::__construct($a);
$this->a = $pubA;
}
}
$collision = new B([[[123]]], "whatever");
$collision->{"*A*a"} = 789;
$q = [[[$collision]]];
xdebug_break();
// now you won't be able to get the array `[[[123]]]` which lies by the
// path `$q[0][0][0]->*A*a` (where *A*a means field `a` in the scope of `A`)
// Instead, XDebug will always be returning `789` in the response rendering the value above unreachable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment