@@ -2,9 +2,7 @@ |
||
2 | 2 | |
3 | 3 | namespace Spaark\CompositeUtils\Factory\Reflection; |
4 | 4 | |
5 | -use Spaark\CompositeUtils\Factory\BaseFactory; |
|
6 | 5 | use Spaark\CompositeUtils\Model\Reflection\ReflectionComposite; |
7 | -use Spaark\CompositeUtils\Service\PropertyAccessor; |
|
8 | 6 | use \ReflectionClass as PHPNativeReflectionClass; |
9 | 7 | |
10 | 8 | class ReflectionCompositeFactory extends ReflectorFactory |
@@ -39,12 +39,10 @@ discard block |
||
39 | 39 | |
40 | 40 | protected function buildProperty($reflect) |
41 | 41 | { |
42 | - $this->accessor->rawAddToValue |
|
43 | - ( |
|
42 | + $this->accessor->rawAddToValue( |
|
44 | 43 | 'properties', |
45 | 44 | (new ReflectionPropertyFactory($reflect)) |
46 | - ->build |
|
47 | - ( |
|
45 | + ->build( |
|
48 | 46 | $this->object, |
49 | 47 | $this->reflector |
50 | 48 | ->getDefaultProperties()[$reflect->getName()] |
@@ -54,8 +52,7 @@ discard block |
||
54 | 52 | |
55 | 53 | protected function buildMethod($reflect) |
56 | 54 | { |
57 | - $this->accessor->rawAddToValue |
|
58 | - ( |
|
55 | + $this->accessor->rawAddToValue( |
|
59 | 56 | 'methods', |
60 | 57 | (new ReflectionMethodFactory($reflect)) |
61 | 58 | ->build($this->object) |
@@ -4,7 +4,6 @@ |
||
4 | 4 | |
5 | 5 | use Spaark\CompositeUtils\Model\Reflection\ReflectionComposite; |
6 | 6 | use Spaark\CompositeUtils\Model\Reflection\ReflectionProperty; |
7 | -use Spaark\CompositeUtils\Model\Reflection\ReflectionParameter; |
|
8 | 7 | use Spaark\CompositeUtils\Model\Reflection\Type\BooleanType; |
9 | 8 | use Spaark\CompositeUtils\Model\Reflection\Type\CollectionType; |
10 | 9 | use Spaark\CompositeUtils\Model\Reflection\Type\IntegerType; |
@@ -26,8 +26,7 @@ discard block |
||
26 | 26 | |
27 | 27 | public static function fromName($class, $property) |
28 | 28 | { |
29 | - return new static(new PHPNativeReflectionProperty |
|
30 | - ( |
|
29 | + return new static(new PHPNativeReflectionProperty( |
|
31 | 30 | $class, $property |
32 | 31 | )); |
33 | 32 | } |
@@ -36,8 +35,7 @@ discard block |
||
36 | 35 | { |
37 | 36 | $this->accessor->setRawValue('owner', $parent); |
38 | 37 | $this->accessor->setRawValue('defaultValue', $default); |
39 | - $this->accessor->setRawValue |
|
40 | - ( |
|
38 | + $this->accessor->setRawValue( |
|
41 | 39 | 'name', |
42 | 40 | $this->reflector->getName() |
43 | 41 | ); |
@@ -52,8 +52,7 @@ discard block |
||
52 | 52 | if ($value{0} !== '?') |
53 | 53 | { |
54 | 54 | $nullable = false; |
55 | - } |
|
56 | - else |
|
55 | + } else |
|
57 | 56 | { |
58 | 57 | $nullable = true; |
59 | 58 | $value = substr($value, 1); |
@@ -62,8 +61,7 @@ discard block |
||
62 | 61 | if (substr($value, -2) !== '[]') |
63 | 62 | { |
64 | 63 | $collection = false; |
65 | - } |
|
66 | - else |
|
64 | + } else |
|
67 | 65 | { |
68 | 66 | $collection = true; |
69 | 67 | $value = substr($value, 0, -2); |
@@ -29,7 +29,6 @@ discard block |
||
29 | 29 | |
30 | 30 | /** |
31 | 31 | * @param object $object The object to access |
32 | - * @param ReflectionModel|null $reflect A reflection entity |
|
33 | 32 | */ |
34 | 33 | public function __construct($object) |
35 | 34 | { |
@@ -80,7 +79,7 @@ discard block |
||
80 | 79 | * Adds a value to a property, irrespective of access permissions |
81 | 80 | * |
82 | 81 | * @param string $key The property to write to |
83 | - * @param mixed $value The value to add |
|
82 | + * @param \Spaark\CompositeUtils\Model\Reflection\Reflector $value The value to add |
|
84 | 83 | * @throws CannotWritePropertyException In the event the property |
85 | 84 | * does not exist |
86 | 85 | */ |
@@ -48,8 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function setRawValue($key, $value) |
50 | 50 | { |
51 | - $this->getPropertyOrFail |
|
52 | - ( |
|
51 | + $this->getPropertyOrFail( |
|
53 | 52 | $key, |
54 | 53 | CannotWritePropertyException::class |
55 | 54 | ) |
@@ -68,8 +67,7 @@ discard block |
||
68 | 67 | public function getRawValue($key) |
69 | 68 | { |
70 | 69 | return |
71 | - $this->getPropertyOrFail |
|
72 | - ( |
|
70 | + $this->getPropertyOrFail( |
|
73 | 71 | $key, |
74 | 72 | CannotReadPropertyException::class |
75 | 73 | ) |
@@ -86,8 +84,7 @@ discard block |
||
86 | 84 | */ |
87 | 85 | public function rawAddToValue($key, $value) |
88 | 86 | { |
89 | - $property = $this->getPropertyOrFail |
|
90 | - ( |
|
87 | + $property = $this->getPropertyOrFail( |
|
91 | 88 | $key, |
92 | 89 | CannotWritePropertyException::class |
93 | 90 | ); |
@@ -113,8 +110,7 @@ discard block |
||
113 | 110 | } |
114 | 111 | catch (ReflectionException $e) |
115 | 112 | { |
116 | - throw new $class |
|
117 | - ( |
|
113 | + throw new $class( |
|
118 | 114 | get_class($this->object), |
119 | 115 | $key, |
120 | 116 | $e |
@@ -110,8 +110,7 @@ |
||
110 | 110 | $prop->setAccessible(true); |
111 | 111 | |
112 | 112 | return $prop; |
113 | - } |
|
114 | - catch (ReflectionException $e) |
|
113 | + } catch (ReflectionException $e) |
|
115 | 114 | { |
116 | 115 | throw new $class |
117 | 116 | ( |
@@ -39,7 +39,7 @@ |
||
39 | 39 | { |
40 | 40 | preg_match_all |
41 | 41 | ( |
42 | - '/^' |
|
42 | + '/^' |
|
43 | 43 | . '[ \t]*\*[ \t]*' |
44 | 44 | . '@([a-zA-Z]+)' |
45 | 45 | . '(.*)' |
@@ -37,8 +37,7 @@ discard block |
||
37 | 37 | |
38 | 38 | protected function parseDocComment() |
39 | 39 | { |
40 | - preg_match_all |
|
41 | - ( |
|
40 | + preg_match_all( |
|
42 | 41 | '/^' |
43 | 42 | . '[ \t]*\*[ \t]*' |
44 | 43 | . '@([a-zA-Z]+)' |
@@ -55,8 +54,7 @@ discard block |
||
55 | 54 | |
56 | 55 | if (isset($this->acceptedParams[$name])) |
57 | 56 | { |
58 | - call_user_func |
|
59 | - ( |
|
57 | + call_user_func( |
|
60 | 58 | array($this, $this->acceptedParams[$name]), |
61 | 59 | $name, $value |
62 | 60 | ); |
@@ -66,7 +64,7 @@ discard block |
||
66 | 64 | |
67 | 65 | protected function setBool($name, $value) |
68 | 66 | { |
69 | - switch(strtolower($value)) |
|
67 | + switch (strtolower($value)) |
|
70 | 68 | { |
71 | 69 | case '': |
72 | 70 | case 'true': |
@@ -13,17 +13,15 @@ |
||
13 | 13 | |
14 | 14 | public static function fromName($class, $method) |
15 | 15 | { |
16 | - return new static(new PHPNativeReflectionMethod |
|
17 | - ( |
|
16 | + return new static(new PHPNativeReflectionMethod( |
|
18 | 17 | $class, $method |
19 | 18 | )); |
20 | 19 | } |
21 | 20 | |
22 | - public function build(?ReflectionComposite $parent = null) |
|
21 | + public function build(? ReflectionComposite $parent = null) |
|
23 | 22 | { |
24 | 23 | $this->accessor->setRawValue('owner', $parent); |
25 | - $this->accessor->setRawValue |
|
26 | - ( |
|
24 | + $this->accessor->setRawValue( |
|
27 | 25 | 'name', |
28 | 26 | $this->reflector->getName() |
29 | 27 | ); |
@@ -23,8 +23,7 @@ |
||
23 | 23 | if ($this->locked) |
24 | 24 | { |
25 | 25 | return parent::__set($var, $val); |
26 | - } |
|
27 | - else |
|
26 | + } else |
|
28 | 27 | { |
29 | 28 | $this->$var = $val; |
30 | 29 | } |
@@ -27,7 +27,7 @@ |
||
27 | 27 | private function getScalar($value) |
28 | 28 | { |
29 | 29 | return |
30 | - (is_object($value) ? spl_object_hash($value) |
|
30 | + (is_object($value) ? spl_object_hash($value) |
|
31 | 31 | : (is_array($value) ? implode($value) |
32 | 32 | : ( (string)$value))); |
33 | 33 | } |
@@ -28,8 +28,8 @@ |
||
28 | 28 | { |
29 | 29 | return |
30 | 30 | (is_object($value) ? spl_object_hash($value) |
31 | - : (is_array($value) ? implode($value) |
|
32 | - : ( (string)$value))); |
|
31 | + : (is_array($value) ? implode($value) |
|
32 | + : ((string)$value))); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
@@ -43,7 +43,9 @@ |
||
43 | 43 | */ |
44 | 44 | public function popMultiple($i = 1) |
45 | 45 | { |
46 | - if ($i < 1) return NULL; |
|
46 | + if ($i < 1) { |
|
47 | + return NULL; |
|
48 | + } |
|
47 | 49 | |
48 | 50 | $ret = array_slice($this->data, -1 * $i); |
49 | 51 | $this->data = array_slice($this->data, 0, -1 * $i); |
@@ -24,8 +24,8 @@ |
||
24 | 24 | { |
25 | 25 | return |
26 | 26 | (is_object($value) ? spl_object_hash($value) |
27 | - : (is_array($value) ? implode($value) |
|
28 | - : ( (string)$value))); |
|
27 | + : (is_array($value) ? implode($value) |
|
28 | + : ((string)$value))); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | public function add($value) |
@@ -27,7 +27,7 @@ |
||
27 | 27 | private function getScalar($value) |
28 | 28 | { |
29 | 29 | return |
30 | - (is_object($value) ? spl_object_hash($value) |
|
30 | + (is_object($value) ? spl_object_hash($value) |
|
31 | 31 | : (is_array($value) ? implode($value) |
32 | 32 | : ( (string)$value))); |
33 | 33 | } |