| 1 |
<?php |
| 2 |
|
| 3 |
namespace WindPressDeps\Rosua\Leak; |
| 4 |
|
| 5 |
use ReflectionClass; |
| 6 |
class Leaker |
| 7 |
{ |
| 8 |
public object $obj; |
| 9 |
public ReflectionClass $reflected; |
| 10 |
public function __construct(object $obj) |
| 11 |
{ |
| 12 |
$this->obj = $obj; |
| 13 |
$this->reflected = new ReflectionClass($obj); |
| 14 |
} |
| 15 |
public function __get(string $name) |
| 16 |
{ |
| 17 |
$property = $this->reflected->getProperty($name); |
| 18 |
$property->setAccessible(\true); |
| 19 |
return $property->getValue($this->obj); |
| 20 |
} |
| 21 |
public function __set(string $name, $value) : void |
| 22 |
{ |
| 23 |
$property = $this->reflected->getProperty($name); |
| 24 |
$property->setAccessible(\true); |
| 25 |
$property->setValue($this->obj, $value); |
| 26 |
} |
| 27 |
public function __call(string $name, array $params = []) |
| 28 |
{ |
| 29 |
$method = $this->reflected->getMethod($name); |
| 30 |
$method->setAccessible(\true); |
| 31 |
return $method->invoke($this->obj, ...$params); |
| 32 |
} |
| 33 |
public static function __callStatic($name, $arguments) |
| 34 |
{ |
| 35 |
return self::$name(...$arguments); |
| 36 |
} |
| 37 |
} |
| 38 |
|