@@ -78,8 +78,7 @@ discard block |
||
78 | 78 | * @param PHPNativeReflectionClass $reflect |
79 | 79 | * @param ReflectionCompositeProviderInterface $provider |
80 | 80 | */ |
81 | - public function __construct |
|
82 | - ( |
|
81 | + public function __construct( |
|
83 | 82 | PHPNativeReflectionClass $reflect, |
84 | 83 | ReflectionCompositeProviderInterface $provider |
85 | 84 | ) |
@@ -117,13 +116,11 @@ discard block |
||
117 | 116 | $file = (new ReflectionFileFactory($fileName))->build(); |
118 | 117 | $this->accessor->setRawValue('file', $file); |
119 | 118 | |
120 | - $this->accessor->setRawValue |
|
121 | - ( |
|
119 | + $this->accessor->setRawValue( |
|
122 | 120 | 'classname', |
123 | 121 | $this->reflector->name |
124 | 122 | ); |
125 | - $this->accessor->setRawValue |
|
126 | - ( |
|
123 | + $this->accessor->setRawValue( |
|
127 | 124 | 'namespace', |
128 | 125 | $file->namespaces[$this->reflector->getNamespaceName()] |
129 | 126 | ); |
@@ -146,8 +143,7 @@ discard block |
||
146 | 143 | $size = count($this->reflector->{'get' . $name}()); |
147 | 144 | foreach ($prefixes as $prefix) |
148 | 145 | { |
149 | - $this->accessor->setRawValue |
|
150 | - ( |
|
146 | + $this->accessor->setRawValue( |
|
151 | 147 | $prefix . $name, |
152 | 148 | new FixedList($size) |
153 | 149 | ); |
@@ -177,8 +173,7 @@ discard block |
||
177 | 173 | * @param bool $checkFile |
178 | 174 | * @param string $singular |
179 | 175 | */ |
180 | - protected function addItems |
|
181 | - ( |
|
176 | + protected function addItems( |
|
182 | 177 | string $name, |
183 | 178 | bool $checkFile, |
184 | 179 | string $signular |
@@ -209,8 +204,7 @@ discard block |
||
209 | 204 | new $factory($item), |
210 | 205 | $item |
211 | 206 | ); |
212 | - $this->accessor->rawAddToValue |
|
213 | - ( |
|
207 | + $this->accessor->rawAddToValue( |
|
214 | 208 | 'local' . ucfirst($name), |
215 | 209 | $item |
216 | 210 | ); |
@@ -227,8 +221,7 @@ discard block |
||
227 | 221 | * @param PHPNativeReflectionClass $reflect |
228 | 222 | * @param string $method |
229 | 223 | */ |
230 | - protected function addInheritance |
|
231 | - ( |
|
224 | + protected function addInheritance( |
|
232 | 225 | string $group, |
233 | 226 | PHPNativeReflectionClass $reflect, |
234 | 227 | string $method = 'rawAddToValue' |
@@ -248,15 +241,13 @@ discard block |
||
248 | 241 | * @param ReflectionPropertyFactory $factory |
249 | 242 | * @return ReflectionProperty |
250 | 243 | */ |
251 | - protected function buildProperty |
|
252 | - ( |
|
244 | + protected function buildProperty( |
|
253 | 245 | ReflectionPropertyFactory $factory, |
254 | 246 | PHPNativeReflectionProperty $reflect |
255 | 247 | ) |
256 | 248 | : ReflectionProperty |
257 | 249 | { |
258 | - return $factory->build |
|
259 | - ( |
|
250 | + return $factory->build( |
|
260 | 251 | $this->object, |
261 | 252 | $this->reflector |
262 | 253 | ->getDefaultProperties()[$reflect->getName()] |
@@ -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 | } |
@@ -169,6 +169,9 @@ |
||
169 | 169 | return new ObjectType($context); |
170 | 170 | } |
171 | 171 | |
172 | + /** |
|
173 | + * @param string $var |
|
174 | + */ |
|
172 | 175 | public function scalarToType($var) : ?AbstractType |
173 | 176 | { |
174 | 177 | switch (strtolower($var)) |
@@ -146,7 +146,7 @@ |
||
146 | 146 | } |
147 | 147 | elseif ($i + 2 !== strlen($value)) |
148 | 148 | { |
149 | - if (!in_array($value{$i + 2}, ['>',','])) |
|
149 | + if (!in_array($value{$i + 2}, ['>', ','])) |
|
150 | 150 | { |
151 | 151 | throw new \Exception('Unexpected char after collection'); |
152 | 152 | } |
@@ -139,12 +139,10 @@ discard block |
||
139 | 139 | if ($i + 1 === strlen($value)) |
140 | 140 | { |
141 | 141 | throw new \Exception('Unexpected EOF'); |
142 | - } |
|
143 | - elseif ($value{$i + 1} !== ']') |
|
142 | + } elseif ($value{$i + 1} !== ']') |
|
144 | 143 | { |
145 | 144 | throw new \Exception('[ must be followed by ]'); |
146 | - } |
|
147 | - elseif ($i + 2 !== strlen($value)) |
|
145 | + } elseif ($i + 2 !== strlen($value)) |
|
148 | 146 | { |
149 | 147 | if (!in_array($value{$i + 2}, ['>',','])) |
150 | 148 | { |
@@ -240,8 +238,7 @@ discard block |
||
240 | 238 | if ($useStatements->containsKey($this->currentValue)) |
241 | 239 | { |
242 | 240 | return $useStatements[$this->currentValue]->classname; |
243 | - } |
|
244 | - else |
|
241 | + } else |
|
245 | 242 | { |
246 | 243 | return $this->context->namespace->namespace |
247 | 244 | . '\\' . $this->currentValue; |
@@ -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 | ) |
@@ -73,8 +73,7 @@ |
||
73 | 73 | } |
74 | 74 | else |
75 | 75 | { |
76 | - throw new DomainException |
|
77 | - ( |
|
76 | + throw new DomainException( |
|
78 | 77 | 'The given IteratorAggregate\'s ' . |
79 | 78 | 'getIterator() method should return an ' . |
80 | 79 | 'Iterator or IteratorAggregate, but it did not' |
@@ -51,12 +51,10 @@ discard block |
||
51 | 51 | if (is_array($iterator)) |
52 | 52 | { |
53 | 53 | $this->iterator = new ArrayIterator($iterator); |
54 | - } |
|
55 | - elseif ($iterator instanceof Iterator) |
|
54 | + } elseif ($iterator instanceof Iterator) |
|
56 | 55 | { |
57 | 56 | $this->iterator = $iterator; |
58 | - } |
|
59 | - elseif ($iterator instanceof IteratorAggregate) |
|
57 | + } elseif ($iterator instanceof IteratorAggregate) |
|
60 | 58 | { |
61 | 59 | while (true) |
62 | 60 | { |
@@ -66,12 +64,10 @@ discard block |
||
66 | 64 | { |
67 | 65 | $this->iterator = $newIterator; |
68 | 66 | break; |
69 | - } |
|
70 | - elseif ($newIterator instanceof IteratorAggregate) |
|
67 | + } elseif ($newIterator instanceof IteratorAggregate) |
|
71 | 68 | { |
72 | 69 | $iterator = $newIterator; |
73 | - } |
|
74 | - else |
|
70 | + } else |
|
75 | 71 | { |
76 | 72 | throw new DomainException |
77 | 73 | ( |
@@ -81,8 +77,7 @@ discard block |
||
81 | 77 | ); |
82 | 78 | } |
83 | 79 | } |
84 | - } |
|
85 | - else |
|
80 | + } else |
|
86 | 81 | { |
87 | 82 | throw new DomainException('Unknown type of iterator'); |
88 | 83 | } |
@@ -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 | } |