Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
--TEST-- testing anonymous inheritance --FILE-- <?php class Outer { protected $data; ..
Decoded Output download
--TEST--
testing anonymous inheritance
--FILE--
<?php
class Outer {
protected $data;
public function __construct($data) {
$this->data = $data;
}
public function getArrayAccess() {
/* create a proxy object implementing array access */
return new class($this->data) extends Outer implements ArrayAccess {
public function offsetGet($offset): mixed { return $this->data[$offset]; }
public function offsetSet($offset, $data): void { $this->data[$offset] = $data; }
public function offsetUnset($offset): void { unset($this->data[$offset]); }
public function offsetExists($offset): bool { return isset($this->data[$offset]); }
};
}
}
$outer = new Outer(array(
rand(1, 100)
));
/* not null because inheritance */
var_dump($outer->getArrayAccess()[0]);
?>
--EXPECTF--
int(%d)
Did this file decode correctly?
Original Code
--TEST--
testing anonymous inheritance
--FILE--
<?php
class Outer {
protected $data;
public function __construct($data) {
$this->data = $data;
}
public function getArrayAccess() {
/* create a proxy object implementing array access */
return new class($this->data) extends Outer implements ArrayAccess {
public function offsetGet($offset): mixed { return $this->data[$offset]; }
public function offsetSet($offset, $data): void { $this->data[$offset] = $data; }
public function offsetUnset($offset): void { unset($this->data[$offset]); }
public function offsetExists($offset): bool { return isset($this->data[$offset]); }
};
}
}
$outer = new Outer(array(
rand(1, 100)
));
/* not null because inheritance */
var_dump($outer->getArrayAccess()[0]);
?>
--EXPECTF--
int(%d)
Function Calls
None |
Stats
MD5 | 052679a567b028379b02473b1f7dd7b2 |
Eval Count | 0 |
Decode Time | 76 ms |