@@ -5,62 +5,62 @@ |
||
5 | 5 | |
6 | 6 | class ReflectionClass extends \ReflectionClass |
7 | 7 | { |
8 | - /** @var object */ |
|
9 | - protected $object; |
|
8 | + /** @var object */ |
|
9 | + protected $object; |
|
10 | 10 | |
11 | - public function __construct($class, $object = null) |
|
12 | - { |
|
13 | - if (is_object($class) && !is_object($object)) { |
|
14 | - $object = $class; |
|
15 | - } |
|
11 | + public function __construct($class, $object = null) |
|
12 | + { |
|
13 | + if (is_object($class) && !is_object($object)) { |
|
14 | + $object = $class; |
|
15 | + } |
|
16 | 16 | |
17 | - if (!is_object($object)) { |
|
18 | - throw new \InvalidArgumentException( |
|
19 | - sprintf('Expected "object", got "%s".', gettype($object)) |
|
20 | - ); |
|
21 | - } |
|
17 | + if (!is_object($object)) { |
|
18 | + throw new \InvalidArgumentException( |
|
19 | + sprintf('Expected "object", got "%s".', gettype($object)) |
|
20 | + ); |
|
21 | + } |
|
22 | 22 | |
23 | - parent::__construct($class); |
|
24 | - $this->object = $object; |
|
25 | - } |
|
23 | + parent::__construct($class); |
|
24 | + $this->object = $object; |
|
25 | + } |
|
26 | 26 | |
27 | - public function getObject() |
|
28 | - { |
|
29 | - return $this->object; |
|
30 | - } |
|
27 | + public function getObject() |
|
28 | + { |
|
29 | + return $this->object; |
|
30 | + } |
|
31 | 31 | |
32 | - public static function from($class, $object = null): self |
|
33 | - { |
|
34 | - return new static($class, $object); |
|
35 | - } |
|
32 | + public static function from($class, $object = null): self |
|
33 | + { |
|
34 | + return new static($class, $object); |
|
35 | + } |
|
36 | 36 | |
37 | - public function invokeMethod(string $method, array $arguments = []) |
|
38 | - { |
|
39 | - $reflection = $this->getMethod($method); |
|
40 | - $reflection->setAccessible(true); |
|
37 | + public function invokeMethod(string $method, array $arguments = []) |
|
38 | + { |
|
39 | + $reflection = $this->getMethod($method); |
|
40 | + $reflection->setAccessible(true); |
|
41 | 41 | |
42 | - return $reflection->invokeArgs($this->object, $arguments); |
|
43 | - } |
|
42 | + return $reflection->invokeArgs($this->object, $arguments); |
|
43 | + } |
|
44 | 44 | |
45 | - public function setPropertyValue(string $property, $value): self |
|
46 | - { |
|
47 | - $reflection = $this->getProperty($property); |
|
48 | - $reflection->setAccessible(true); |
|
49 | - $reflection->setValue($this->object, $value); |
|
45 | + public function setPropertyValue(string $property, $value): self |
|
46 | + { |
|
47 | + $reflection = $this->getProperty($property); |
|
48 | + $reflection->setAccessible(true); |
|
49 | + $reflection->setValue($this->object, $value); |
|
50 | 50 | |
51 | - return $this; |
|
52 | - } |
|
51 | + return $this; |
|
52 | + } |
|
53 | 53 | |
54 | - public function getPropertyValue(string $property) |
|
55 | - { |
|
56 | - $reflection = $this->getProperty($property); |
|
57 | - $reflection->setAccessible(true); |
|
54 | + public function getPropertyValue(string $property) |
|
55 | + { |
|
56 | + $reflection = $this->getProperty($property); |
|
57 | + $reflection->setAccessible(true); |
|
58 | 58 | |
59 | - return $reflection->getValue($this->object); |
|
60 | - } |
|
59 | + return $reflection->getValue($this->object); |
|
60 | + } |
|
61 | 61 | |
62 | - public function getParent() |
|
63 | - { |
|
64 | - return self::from($this->getParentClass()->getName(), $this->object); |
|
65 | - } |
|
62 | + public function getParent() |
|
63 | + { |
|
64 | + return self::from($this->getParentClass()->getName(), $this->object); |
|
65 | + } |
|
66 | 66 | } |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | |
4 | 4 | namespace Yep\Reflection; |
5 | 5 |
@@ -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($class, $object = null) |
|
12 | - { |
|
10 | + public function __construct($class, $object = null) { |
|
13 | 11 | if (is_object($class) && !is_object($object)) { |
14 | 12 | $object = $class; |
15 | 13 | } |
@@ -24,8 +22,7 @@ discard block |
||
24 | 22 | $this->object = $object; |
25 | 23 | } |
26 | 24 | |
27 | - public function getObject() |
|
28 | - { |
|
25 | + public function getObject() { |
|
29 | 26 | return $this->object; |
30 | 27 | } |
31 | 28 | |
@@ -34,8 +31,7 @@ discard block |
||
34 | 31 | return new static($class, $object); |
35 | 32 | } |
36 | 33 | |
37 | - public function invokeMethod(string $method, array $arguments = []) |
|
38 | - { |
|
34 | + public function invokeMethod(string $method, array $arguments = []) { |
|
39 | 35 | $reflection = $this->getMethod($method); |
40 | 36 | $reflection->setAccessible(true); |
41 | 37 | |
@@ -51,16 +47,14 @@ discard block |
||
51 | 47 | return $this; |
52 | 48 | } |
53 | 49 | |
54 | - public function getPropertyValue(string $property) |
|
55 | - { |
|
50 | + public function getPropertyValue(string $property) { |
|
56 | 51 | $reflection = $this->getProperty($property); |
57 | 52 | $reflection->setAccessible(true); |
58 | 53 | |
59 | 54 | return $reflection->getValue($this->object); |
60 | 55 | } |
61 | 56 | |
62 | - public function getParent() |
|
63 | - { |
|
57 | + public function getParent() { |
|
64 | 58 | return self::from($this->getParentClass()->getName(), $this->object); |
65 | 59 | } |
66 | 60 | } |