@@ -5,46 +5,46 @@ |
||
5 | 5 | |
6 | 6 | class ReflectionClass extends \ReflectionClass |
7 | 7 | { |
8 | - /** @var object */ |
|
9 | - protected $object; |
|
10 | - |
|
11 | - public function __construct($object) |
|
12 | - { |
|
13 | - if (!is_object($object)) { |
|
14 | - throw new \InvalidArgumentException(sprintf('Expected "object", got "%s".', gettype($object))); |
|
15 | - } |
|
16 | - |
|
17 | - parent::__construct($object); |
|
18 | - $this->object = $object; |
|
19 | - } |
|
20 | - |
|
21 | - public static function from($class): self |
|
22 | - { |
|
23 | - return new static($class); |
|
24 | - } |
|
25 | - |
|
26 | - public function invokeMethod(string $method, array $arguments = []) |
|
27 | - { |
|
28 | - $reflection = $this->getMethod($method); |
|
29 | - $reflection->setAccessible(true); |
|
30 | - |
|
31 | - return $reflection->invokeArgs($this->object, $arguments); |
|
32 | - } |
|
33 | - |
|
34 | - public function setPropertyValue(string $property, $value): self |
|
35 | - { |
|
36 | - $reflection = $this->getProperty($property); |
|
37 | - $reflection->setAccessible(true); |
|
38 | - $reflection->setValue($this->object, $value); |
|
39 | - |
|
40 | - return $this; |
|
41 | - } |
|
42 | - |
|
43 | - public function getPropertyValue(string $property) |
|
44 | - { |
|
45 | - $reflection = $this->getProperty($property); |
|
46 | - $reflection->setAccessible(true); |
|
47 | - |
|
48 | - return $reflection->getValue($this->object); |
|
49 | - } |
|
8 | + /** @var object */ |
|
9 | + protected $object; |
|
10 | + |
|
11 | + public function __construct($object) |
|
12 | + { |
|
13 | + if (!is_object($object)) { |
|
14 | + throw new \InvalidArgumentException(sprintf('Expected "object", got "%s".', gettype($object))); |
|
15 | + } |
|
16 | + |
|
17 | + parent::__construct($object); |
|
18 | + $this->object = $object; |
|
19 | + } |
|
20 | + |
|
21 | + public static function from($class): self |
|
22 | + { |
|
23 | + return new static($class); |
|
24 | + } |
|
25 | + |
|
26 | + public function invokeMethod(string $method, array $arguments = []) |
|
27 | + { |
|
28 | + $reflection = $this->getMethod($method); |
|
29 | + $reflection->setAccessible(true); |
|
30 | + |
|
31 | + return $reflection->invokeArgs($this->object, $arguments); |
|
32 | + } |
|
33 | + |
|
34 | + public function setPropertyValue(string $property, $value): self |
|
35 | + { |
|
36 | + $reflection = $this->getProperty($property); |
|
37 | + $reflection->setAccessible(true); |
|
38 | + $reflection->setValue($this->object, $value); |
|
39 | + |
|
40 | + return $this; |
|
41 | + } |
|
42 | + |
|
43 | + public function getPropertyValue(string $property) |
|
44 | + { |
|
45 | + $reflection = $this->getProperty($property); |
|
46 | + $reflection->setAccessible(true); |
|
47 | + |
|
48 | + return $reflection->getValue($this->object); |
|
49 | + } |
|
50 | 50 | } |
@@ -3,13 +3,11 @@ discard block |
||
3 | 3 | |
4 | 4 | namespace Yep\Reflection; |
5 | 5 | |
6 | -class ReflectionClass extends \ReflectionClass |
|
7 | -{ |
|
6 | +class ReflectionClass extends \ReflectionClass { |
|
8 | 7 | /** @var object */ |
9 | 8 | protected $object; |
10 | 9 | |
11 | - public function __construct($object) |
|
12 | - { |
|
10 | + public function __construct($object) { |
|
13 | 11 | if (!is_object($object)) { |
14 | 12 | throw new \InvalidArgumentException(sprintf('Expected "object", got "%s".', gettype($object))); |
15 | 13 | } |
@@ -23,8 +21,7 @@ discard block |
||
23 | 21 | return new static($class); |
24 | 22 | } |
25 | 23 | |
26 | - public function invokeMethod(string $method, array $arguments = []) |
|
27 | - { |
|
24 | + public function invokeMethod(string $method, array $arguments = []) { |
|
28 | 25 | $reflection = $this->getMethod($method); |
29 | 26 | $reflection->setAccessible(true); |
30 | 27 | |
@@ -40,8 +37,7 @@ discard block |
||
40 | 37 | return $this; |
41 | 38 | } |
42 | 39 | |
43 | - public function getPropertyValue(string $property) |
|
44 | - { |
|
40 | + public function getPropertyValue(string $property) { |
|
45 | 41 | $reflection = $this->getProperty($property); |
46 | 42 | $reflection->setAccessible(true); |
47 | 43 |