@@ -41,8 +41,7 @@ discard block |
||
41 | 41 | if (!static::$reflectionComposite) |
42 | 42 | { |
43 | 43 | static::$reflectionComposite = |
44 | - ReflectionCompositeFactory::fromClassName |
|
45 | - ( |
|
44 | + ReflectionCompositeFactory::fromClassName( |
|
46 | 45 | get_called_class() |
47 | 46 | ) |
48 | 47 | ->build(); |
@@ -54,8 +53,7 @@ discard block |
||
54 | 53 | /** |
55 | 54 | * Set the default ReflectionComposite for this class |
56 | 55 | */ |
57 | - protected static function setDefaultReflectionComposite |
|
58 | - ( |
|
56 | + protected static function setDefaultReflectionComposite( |
|
59 | 57 | ReflectionComposite $defaultReflectionComposite |
60 | 58 | ) |
61 | 59 | { |
@@ -25,7 +25,7 @@ |
||
25 | 25 | /** |
26 | 26 | * Checks if the given class is equal to this one |
27 | 27 | * |
28 | - * @param Type $oject |
|
28 | + * @param Type $object |
|
29 | 29 | * @return boolean |
30 | 30 | */ |
31 | 31 | public function equals($object) : bool; |
@@ -35,7 +35,7 @@ |
||
35 | 35 | { |
36 | 36 | parent::__construct |
37 | 37 | ( |
38 | - 'Cannot serialize object containing generics without ' |
|
38 | + 'Cannot serialize object containing generics without ' |
|
39 | 39 | . 'context', |
40 | 40 | 0, |
41 | 41 | $previous |
@@ -28,13 +28,11 @@ |
||
28 | 28 | * |
29 | 29 | * @param Throwable $previous The exception which caused this |
30 | 30 | */ |
31 | - public function __construct |
|
32 | - ( |
|
31 | + public function __construct( |
|
33 | 32 | Throwable $previous = null |
34 | 33 | ) |
35 | 34 | { |
36 | - parent::__construct |
|
37 | - ( |
|
35 | + parent::__construct( |
|
38 | 36 | 'Cannot serialize object containing generics without ' |
39 | 37 | . 'context', |
40 | 38 | 0, |
@@ -54,8 +54,7 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @param ReflectionCompositeProviderInterface $default |
56 | 56 | */ |
57 | - public static function setDefault |
|
58 | - ( |
|
57 | + public static function setDefault( |
|
59 | 58 | ReflectionCompositeProviderInterface $default |
60 | 59 | ) |
61 | 60 | { |
@@ -90,8 +89,7 @@ discard block |
||
90 | 89 | { |
91 | 90 | $this->cache[$classname] = |
92 | 91 | ( |
93 | - ReflectionCompositeFactory::fromClassName |
|
94 | - ( |
|
92 | + ReflectionCompositeFactory::fromClassName( |
|
95 | 93 | $classname |
96 | 94 | ) |
97 | 95 | ) |
@@ -43,7 +43,7 @@ |
||
43 | 43 | /** |
44 | 44 | * Creates this ObjectType with the given classname |
45 | 45 | * |
46 | - * @param mixed $class The name of the class this must be an |
|
46 | + * @param string $classname The name of the class this must be an |
|
47 | 47 | * instance of |
48 | 48 | */ |
49 | 49 | public function __construct($classname) |
@@ -14,7 +14,6 @@ |
||
14 | 14 | |
15 | 15 | namespace Spaark\CompositeUtils\Model\Reflection\Type; |
16 | 16 | |
17 | -use Spaark\CompositeUtils\Model\Collection\ListCollection\FlexibleList; |
|
18 | 17 | use Spaark\CompositeUtils\Model\ClassName; |
19 | 18 | |
20 | 19 | /** |
@@ -50,8 +50,7 @@ |
||
50 | 50 | */ |
51 | 51 | public function equals($type) : bool |
52 | 52 | { |
53 | - if |
|
54 | - ( |
|
53 | + if ( |
|
55 | 54 | $type instanceof ObjectType && |
56 | 55 | $type->classname->equals($this->classname) |
57 | 56 | ) |
@@ -46,8 +46,7 @@ |
||
46 | 46 | if (!$matches) |
47 | 47 | { |
48 | 48 | $this->classname = $classname; |
49 | - } |
|
50 | - else |
|
49 | + } else |
|
51 | 50 | { |
52 | 51 | $this->classname = $matches[2]; |
53 | 52 | $this->namespace = $matches[1]; |
@@ -62,7 +62,7 @@ |
||
62 | 62 | public function __toString() |
63 | 63 | { |
64 | 64 | return |
65 | - ($this->namespace ? $this->namespace . '\\' : '') |
|
65 | + ($this->namespace ? $this->namespace . '\\' : '') |
|
66 | 66 | . $this->classname; |
67 | 67 | } |
68 | 68 |
@@ -17,11 +17,6 @@ |
||
17 | 17 | use Spaark\CompositeUtils\Model\Reflection\ReflectionComposite; |
18 | 18 | use Spaark\CompositeUtils\Model\Reflection\ReflectionProperty; |
19 | 19 | use Spaark\CompositeUtils\Model\Reflection\Type\ObjectType; |
20 | -use Spaark\CompositeUtils\Model\Reflection\Type\MixedType; |
|
21 | -use Spaark\CompositeUtils\Model\Reflection\Type\StringType; |
|
22 | -use Spaark\CompositeUtils\Model\Reflection\Type\IntegerType; |
|
23 | -use Spaark\CompositeUtils\Model\Reflection\Type\BooleanType; |
|
24 | -use Spaark\CompositeUtils\Model\Reflection\Type\CollectionType; |
|
25 | 20 | use Spaark\CompositeUtils\Model\Reflection\Type\ScalarType; |
26 | 21 | use Spaark\CompositeUtils\Model\Reflection\Type\AbstractType; |
27 | 22 | use Spaark\CompositeUtils\Exception\CannotWritePropertyException; |
@@ -69,8 +69,7 @@ discard block |
||
69 | 69 | { |
70 | 70 | if (!isset($args[$i])) |
71 | 71 | { |
72 | - throw new MissingRequiredParameterException |
|
73 | - ( |
|
72 | + throw new MissingRequiredParameterException( |
|
74 | 73 | get_class($this->object), |
75 | 74 | $property->name |
76 | 75 | ); |
@@ -148,14 +147,12 @@ discard block |
||
148 | 147 | { |
149 | 148 | if (!$this->reflect->properties->containsKey($property)) |
150 | 149 | { |
151 | - throw new CannotWritePropertyException |
|
152 | - ( |
|
150 | + throw new CannotWritePropertyException( |
|
153 | 151 | get_class($this->object), $property |
154 | 152 | ); |
155 | 153 | } |
156 | 154 | |
157 | - $this->setAnyValue |
|
158 | - ( |
|
155 | + $this->setAnyValue( |
|
159 | 156 | $this->reflect->properties[$property], |
160 | 157 | $value |
161 | 158 | ); |
@@ -193,8 +190,7 @@ discard block |
||
193 | 190 | * @param ScalarType $valueType The scalar type |
194 | 191 | * @param mixed $value The value to set |
195 | 192 | */ |
196 | - private function setScalarValue |
|
197 | - ( |
|
193 | + private function setScalarValue( |
|
198 | 194 | ReflectionProperty $property, |
199 | 195 | ScalarType $valueType, |
200 | 196 | $value |
@@ -204,16 +200,14 @@ discard block |
||
204 | 200 | |
205 | 201 | if (is_scalar($value)) |
206 | 202 | { |
207 | - $this->setRawValue |
|
208 | - ( |
|
203 | + $this->setRawValue( |
|
209 | 204 | $property->name, |
210 | 205 | $property->type->cast($value) |
211 | 206 | ); |
212 | 207 | } |
213 | 208 | elseif (is_object($value) && method_exists([$value, $method])) |
214 | 209 | { |
215 | - $this->setScalarValue |
|
216 | - ( |
|
210 | + $this->setScalarValue( |
|
217 | 211 | $property, |
218 | 212 | $valueType, |
219 | 213 | $value->$method() |
@@ -231,14 +225,12 @@ discard block |
||
231 | 225 | * @param ReflectionProperty $property The property being set |
232 | 226 | * @param AbstractType $valueType The value being set |
233 | 227 | */ |
234 | - private function throwError |
|
235 | - ( |
|
228 | + private function throwError( |
|
236 | 229 | ReflectionProperty $property, |
237 | 230 | AbstractType $valueType |
238 | 231 | ) |
239 | 232 | { |
240 | - throw new IllegalPropertyTypeException |
|
241 | - ( |
|
233 | + throw new IllegalPropertyTypeException( |
|
242 | 234 | get_class($this->object), |
243 | 235 | $property->name, |
244 | 236 | $property->type, |
@@ -87,15 +87,13 @@ discard block |
||
87 | 87 | if ($building) |
88 | 88 | { |
89 | 89 | $this->buildProperty($property); |
90 | - } |
|
91 | - else |
|
90 | + } else |
|
92 | 91 | { |
93 | 92 | if (isset($args[$i])) |
94 | 93 | { |
95 | 94 | $this->setAnyValue($property, $args[$i]); |
96 | 95 | $i++; |
97 | - } |
|
98 | - else |
|
96 | + } else |
|
99 | 97 | { |
100 | 98 | $building = true; |
101 | 99 | $this->buildProperty($property); |
@@ -119,8 +117,7 @@ discard block |
||
119 | 117 | if (!$property->type instanceof ObjectType) |
120 | 118 | { |
121 | 119 | $this->setAnyValue($property, 0); |
122 | - } |
|
123 | - elseif ($property->builtInConstructor) |
|
120 | + } elseif ($property->builtInConstructor) |
|
124 | 121 | { |
125 | 122 | $class = (string)$property->type->classname; |
126 | 123 | $this->setRawValue($property->name, new $class()); |
@@ -175,12 +172,10 @@ discard block |
||
175 | 172 | if ($comparator->compatible($property->type, $valueType)) |
176 | 173 | { |
177 | 174 | $this->setRawValue($property->name, $value); |
178 | - } |
|
179 | - elseif ($property->type instanceof ScalarType) |
|
175 | + } elseif ($property->type instanceof ScalarType) |
|
180 | 176 | { |
181 | 177 | $this->setScalarValue($property, $valueType, $value); |
182 | - } |
|
183 | - else |
|
178 | + } else |
|
184 | 179 | { |
185 | 180 | $this->throwError($property, $valueType); |
186 | 181 | } |
@@ -209,8 +204,7 @@ discard block |
||
209 | 204 | $property->name, |
210 | 205 | $property->type->cast($value) |
211 | 206 | ); |
212 | - } |
|
213 | - elseif (is_object($value) && method_exists([$value, $method])) |
|
207 | + } elseif (is_object($value) && method_exists([$value, $method])) |
|
214 | 208 | { |
215 | 209 | $this->setScalarValue |
216 | 210 | ( |
@@ -218,8 +212,7 @@ discard block |
||
218 | 212 | $valueType, |
219 | 213 | $value->$method() |
220 | 214 | ); |
221 | - } |
|
222 | - else |
|
215 | + } else |
|
223 | 216 | { |
224 | 217 | $this->throwError($property, $valueType); |
225 | 218 | } |
@@ -46,12 +46,10 @@ |
||
46 | 46 | ) |
47 | 47 | { |
48 | 48 | return true; |
49 | - } |
|
50 | - elseif ($parent instanceof ScalarType) |
|
49 | + } elseif ($parent instanceof ScalarType) |
|
51 | 50 | { |
52 | 51 | return get_class($parent) === get_class($child); |
53 | - } |
|
54 | - elseif ($parent instanceof ObjectType) |
|
52 | + } elseif ($parent instanceof ObjectType) |
|
55 | 53 | { |
56 | 54 | if |
57 | 55 | ( |
@@ -32,15 +32,13 @@ discard block |
||
32 | 32 | * @param AbstractType $child |
33 | 33 | * @return boolean |
34 | 34 | */ |
35 | - public function compatible |
|
36 | - ( |
|
35 | + public function compatible( |
|
37 | 36 | AbstractType $parent, |
38 | 37 | AbstractType $child |
39 | 38 | ) |
40 | 39 | : bool |
41 | 40 | { |
42 | - if |
|
43 | - ( |
|
41 | + if ( |
|
44 | 42 | ($child instanceof NullType && $parent->nullable) || |
45 | 43 | ($parent instanceof MixedType) |
46 | 44 | ) |
@@ -53,11 +51,9 @@ discard block |
||
53 | 51 | } |
54 | 52 | elseif ($parent instanceof ObjectType) |
55 | 53 | { |
56 | - if |
|
57 | - ( |
|
54 | + if ( |
|
58 | 55 | $child instanceof ObjectType && |
59 | - is_a |
|
60 | - ( |
|
56 | + is_a( |
|
61 | 57 | $child->classname->__toString(), |
62 | 58 | $parent->classname->__toString(), |
63 | 59 | true |
@@ -70,8 +66,7 @@ discard block |
||
70 | 66 | return false; |
71 | 67 | } |
72 | 68 | |
73 | - throw new \DomainException |
|
74 | - ( |
|
69 | + throw new \DomainException( |
|
75 | 70 | 'Unknown type: ' . get_class($parent) |
76 | 71 | ); |
77 | 72 | } |
@@ -14,8 +14,6 @@ |
||
14 | 14 | |
15 | 15 | namespace Spaark\CompositeUtils\Model\Collection\Map; |
16 | 16 | |
17 | -use Spaark\CompositeUtils\Traits\AutoConstructTrait; |
|
18 | - |
|
19 | 17 | /** |
20 | 18 | * Abstract Iterator for Map datatypes |
21 | 19 | * |