Completed
Push — master ( 9311e4...366210 )
by Emily
02:13
created
src/Factory/Reflection/ReflectionCompositeFactory.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,6 @@
 block discarded – undo
14 14
 
15 15
 namespace Spaark\CompositeUtils\Factory\Reflection;
16 16
 
17
-use Spaark\CompositeUtils\Factory\BaseFactory;
18 17
 use Spaark\CompositeUtils\Model\Reflection\ReflectionComposite;
19 18
 use \ReflectionClass as PHPNativeReflectionClass;
20 19
 use \ReflectionProperty as PHPNativeReflectionProperty;
Please login to merge, or discard this patch.
Spacing   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -61,13 +61,11 @@  discard block
 block discarded – undo
61 61
             (new ReflectionFileFactory($this->reflector->getFileName()))
62 62
                 ->build();
63 63
         $this->accessor->setRawValue('file', $file);
64
-        $this->accessor->setRawValue
65
-        (
64
+        $this->accessor->setRawValue(
66 65
             'classname',
67 66
             $this->reflector->name
68 67
         );
69
-        $this->accessor->setRawValue
70
-        (
68
+        $this->accessor->setRawValue(
71 69
             'namespace',
72 70
             $file->namespaces[$this->reflector->getNamespaceName()]
73 71
         );
@@ -97,20 +95,17 @@  discard block
 block discarded – undo
97 95
      *
98 96
      * @param PHPNativeReflectionProperty
99 97
      */
100
-    protected function buildProperty
101
-    (
98
+    protected function buildProperty(
102 99
         PHPNativeReflectionProperty $reflect
103 100
     )
104 101
     {
105
-        $properties = $this->accessor->getRawValue
106
-        (
102
+        $properties = $this->accessor->getRawValue(
107 103
             'properties'
108 104
         );
109 105
 
110 106
         $properties[$reflect->getName()] = 
111 107
             (new ReflectionPropertyFactory($reflect))
112
-                ->build
113
-                (
108
+                ->build(
114 109
                     $this->object,
115 110
                     $this->reflector
116 111
                         ->getDefaultProperties()[$reflect->getName()]
@@ -125,8 +120,7 @@  discard block
 block discarded – undo
125 120
      */
126 121
     protected function buildMethod(PHPNativeReflectionMethod $reflect)
127 122
     {
128
-        $this->accessor->rawAddToValue
129
-        (
123
+        $this->accessor->rawAddToValue(
130 124
             'methods',
131 125
             (new ReflectionMethodFactory($reflect))
132 126
                 ->build($this->object)
Please login to merge, or discard this patch.
src/Factory/Reflection/ReflectionPropertyFactory.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@
 block discarded – undo
74 74
      * Builds the ReflectionProperty from the provided parameters,
75 75
      * linking to a parent ReflectionComposite
76 76
      *
77
-     * @param ReflectionCompostite $parent The reflector for the class
77
+     * @param ReflectionComposite $parent The reflector for the class
78 78
      *     this property belongs to
79 79
      * @param mixed $default This property's default value
80 80
      * @return ReflectionProperty
Please login to merge, or discard this patch.
Spacing   +10 added lines, -20 removed lines patch added patch discarded remove patch
@@ -64,8 +64,7 @@  discard block
 block discarded – undo
64 64
      */
65 65
     public static function fromName($class, $property)
66 66
     {
67
-        return new static(new PHPNativeReflectionProperty
68
-        (
67
+        return new static(new PHPNativeReflectionProperty(
69 68
             $class, $property
70 69
         ));
71 70
     }
@@ -83,8 +82,7 @@  discard block
 block discarded – undo
83 82
     {
84 83
         $this->accessor->setRawValue('owner', $parent);
85 84
         $this->accessor->setRawValue('defaultValue', $default);
86
-        $this->accessor->setRawValue
87
-        (
85
+        $this->accessor->setRawValue(
88 86
             'name',
89 87
             $this->reflector->getName()
90 88
         );
@@ -189,50 +187,42 @@  discard block
 block discarded – undo
189 187
         switch ($value[0])
190 188
         {
191 189
             case 'required':
192
-                $this->accessor->setRawValue
193
-                (
190
+                $this->accessor->setRawValue(
194 191
                     'passedToConstructor',
195 192
                     true
196 193
                 );
197
-                $this->accessor->setRawValue
198
-                (
194
+                $this->accessor->setRawValue(
199 195
                     'requiredInConstructor',
200 196
                     true
201 197
                 );
202
-                $compositeAccessor->rawAddToValue
203
-                (
198
+                $compositeAccessor->rawAddToValue(
204 199
                     'requiredProperties',
205 200
                     $this->object
206 201
                 );
207 202
                 break;
208 203
             case 'new':
209
-                $this->accessor->setRawValue
210
-                (
204
+                $this->accessor->setRawValue(
211 205
                     'builtInConstructor',
212 206
                     true
213 207
                 );
214
-                $compositeAccessor->rawAddToValue
215
-                (
208
+                $compositeAccessor->rawAddToValue(
216 209
                     'builtProperties',
217 210
                     $this->object
218 211
                 );
219 212
                 break;
220 213
             case 'optional':
221
-                $this->accessor->setRawValue
222
-                (
214
+                $this->accessor->setRawValue(
223 215
                     'passedToConstructor',
224 216
                     true
225 217
                 );
226
-                $compositeAccessor->rawAddToValue
227
-                (
218
+                $compositeAccessor->rawAddToValue(
228 219
                     'optionalProperties',
229 220
                     $this->object
230 221
                 );
231 222
 
232 223
                 if (isset($value[1]) && $value[1] === 'new')
233 224
                 {
234
-                    $this->accessor->setRawValue
235
-                    (
225
+                    $this->accessor->setRawValue(
236 226
                         'builtInConstructor',
237 227
                         true
238 228
                     );
Please login to merge, or discard this patch.
src/Model/Reflection/Type/ObjectType.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
     /**
33 33
      * Creates this ObjectType with the given classname
34 34
      *
35
-     * @param string $class The name of the class this must be an
35
+     * @param string $classname The name of the class this must be an
36 36
      *     instance of
37 37
      */
38 38
     public function __construct(string $classname)
Please login to merge, or discard this patch.
src/Exception/PropertyAccessException.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@
 block discarded – undo
56 56
     {
57 57
         parent::__construct
58 58
         (
59
-              'Cannot ' . static::ACCESS_TYPE . ' property: '
59
+                'Cannot ' . static::ACCESS_TYPE . ' property: '
60 60
             . $class . '::$' . $property . '. ' . static::ERROR_REASON,
61 61
             0,
62 62
             $previous
Please login to merge, or discard this patch.
Spacing   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -47,15 +47,13 @@
 block discarded – undo
47 47
      * @param string $property The property accessed
48 48
      * @param Throwable $previous The exception which caused this
49 49
      */
50
-    public function __construct
51
-    (
50
+    public function __construct(
52 51
         string $class,
53 52
         string $property,
54 53
         Throwable $previous = null
55 54
     )
56 55
     {
57
-        parent::__construct
58
-        (
56
+        parent::__construct(
59 57
               'Cannot ' . static::ACCESS_TYPE . ' property: '
60 58
             . $class . '::$' . $property . '. ' . static::ERROR_REASON,
61 59
             0,
Please login to merge, or discard this patch.
src/Exception/MissingRequiredParameterException.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
     {
40 40
         parent::__construct
41 41
         (
42
-              'Missing required parameter in constructor. '
42
+                'Missing required parameter in constructor. '
43 43
             . $class . ' requires a value for ' . $parameter,
44 44
             0,
45 45
             $previous
Please login to merge, or discard this patch.
Spacing   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -30,15 +30,13 @@
 block discarded – undo
30 30
      * @param string $parameter The name of the missing parameter
31 31
      * @param Throwable The exception which caused this
32 32
      */
33
-    public function __construct
34
-    (
33
+    public function __construct(
35 34
         string $class,
36 35
         string $parameter,
37 36
         Throwable $previous = null
38 37
     )
39 38
     {
40
-        parent::__construct
41
-        (
39
+        parent::__construct(
42 40
               'Missing required parameter in constructor. '
43 41
             . $class . ' requires a value for ' . $parameter,
44 42
             0,
Please login to merge, or discard this patch.
src/Exception/IllegalPropertyTypeException.php 1 patch
Spacing   +3 added lines, -5 removed lines patch added patch discarded remove patch
@@ -32,8 +32,7 @@  discard block
 block discarded – undo
32 32
      * @param string $got The type that was provided
33 33
      * @param Exception $previous The exception which caused this
34 34
      */
35
-    public function __construct
36
-    (
35
+    public function __construct(
37 36
         string $class,
38 37
         string $property,
39 38
         string $expected,
@@ -41,10 +40,9 @@  discard block
 block discarded – undo
41 40
         Exception $previous = null
42 41
     )
43 42
     {
44
-        parent::__construct
45
-        (
43
+        parent::__construct(
46 44
               'Tried to set an illegal property type for '
47
-            . $class .'::$' . $property . '. Excpected ' . $expected
45
+            . $class . '::$' . $property . '. Excpected ' . $expected
48 46
             . ', got ' . $got,
49 47
             0,
50 48
             $previous
Please login to merge, or discard this patch.
src/Service/PropertyAccessor.php 2 patches
Spacing   +10 added lines, -20 removed lines patch added patch discarded remove patch
@@ -65,8 +65,7 @@  discard block
 block discarded – undo
65 65
         {
66 66
             if (!isset($args[$i]))
67 67
             {
68
-                throw new MissingRequiredParameterException
69
-                (
68
+                throw new MissingRequiredParameterException(
70 69
                     get_class($this->object),
71 70
                     $property->name
72 71
                 );
@@ -144,14 +143,12 @@  discard block
 block discarded – undo
144 143
     {
145 144
         if (!$this->reflect->properties->contains($property))
146 145
         {
147
-            throw new CannotWritePropertyException
148
-            (
146
+            throw new CannotWritePropertyException(
149 147
                 get_class($this->object), $property
150 148
             );
151 149
         }
152 150
 
153
-        $this->setAnyValue
154
-        (
151
+        $this->setAnyValue(
155 152
             $this->reflect->properties[$property],
156 153
             $value
157 154
         );
@@ -198,8 +195,7 @@  discard block
 block discarded – undo
198 195
      * @param ReflectionProperty $property The property to set
199 196
      * @param mixed $value The value to set
200 197
      */
201
-    private function setNonNullValue
202
-    (
198
+    private function setNonNullValue(
203 199
         ReflectionProperty $property,
204 200
         $value
205 201
     )
@@ -248,8 +244,7 @@  discard block
 block discarded – undo
248 244
      * @param callable $cast Method to cast a value to the scalar data
249 245
      *     type
250 246
      */
251
-    private function setScalarValue
252
-    (
247
+    private function setScalarValue(
253 248
         ReflectionProperty $property,
254 249
         $value,
255 250
         string $name,
@@ -264,8 +259,7 @@  discard block
 block discarded – undo
264 259
         }
265 260
         elseif (is_object($value) && method_exists([$value, $method]))
266 261
         {
267
-            $this->setScalarValue
268
-            (
262
+            $this->setScalarValue(
269 263
                 $property,
270 264
                 $value->$method(),
271 265
                 $method,
@@ -284,8 +278,7 @@  discard block
 block discarded – undo
284 278
      * @param ReflectionProperty $property The property to set
285 279
      * @param mixed $value The value to set
286 280
      */
287
-    private function setObjectValue
288
-    (
281
+    private function setObjectValue(
289 282
         ReflectionProperty $property,
290 283
         $value
291 284
     )
@@ -306,8 +299,7 @@  discard block
 block discarded – undo
306 299
      * @param ReflectionProperty $property The property to set
307 300
      * @param mixed The value to set
308 301
      */
309
-    private function setCollectionValue
310
-    (
302
+    private function setCollectionValue(
311 303
         ReflectionProperty $property,
312 304
         $value
313 305
     )
@@ -329,15 +321,13 @@  discard block
 block discarded – undo
329 321
      * @param string $expected The expected datatype
330 322
      * @param string $value The value being set
331 323
      */
332
-    private function throwError
333
-    (
324
+    private function throwError(
334 325
         ReflectionProperty $property,
335 326
         string $expected,
336 327
         $value
337 328
     )
338 329
     {
339
-        throw new IllegalPropertyTypeException
340
-        (
330
+        throw new IllegalPropertyTypeException(
341 331
             get_class($this->object),
342 332
             $property->name,
343 333
             $expected,
Please login to merge, or discard this patch.
Braces   +9 added lines, -18 removed lines patch added patch discarded remove patch
@@ -83,15 +83,13 @@  discard block
 block discarded – undo
83 83
             if ($building)
84 84
             {
85 85
                 $this->buildProperty($property);
86
-            }
87
-            else
86
+            } else
88 87
             {
89 88
                 if (isset($args[$i]))
90 89
                 {
91 90
                     $this->setAnyValue($property, $args[$i]);
92 91
                     $i++;
93
-                }
94
-                else
92
+                } else
95 93
                 {
96 94
                     $building = true;
97 95
                     $this->buildProperty($property);
@@ -116,8 +114,7 @@  discard block
 block discarded – undo
116 114
         {
117 115
             $class = $property->type->classname;
118 116
             $this->setRawValue($property->name, new $class());
119
-        }
120
-        else
117
+        } else
121 118
         {
122 119
             $this->setAnyValue($property, 0);
123 120
         }
@@ -168,8 +165,7 @@  discard block
 block discarded – undo
168 165
         if (is_null($value))
169 166
         {
170 167
             $this->setNullValue($property);
171
-        }
172
-        else
168
+        } else
173 169
         {
174 170
             $this->setNonNullValue($property, $value);
175 171
         }
@@ -185,8 +181,7 @@  discard block
 block discarded – undo
185 181
         if ($property->type->nullable)
186 182
         {
187 183
             $this->setRawValue($property->name, null);
188
-        }
189
-        else
184
+        } else
190 185
         {
191 186
             $this->throwError($property, 'NonNull', null);
192 187
         }
@@ -261,8 +256,7 @@  discard block
 block discarded – undo
261 256
         if (is_scalar($value))
262 257
         {
263 258
             $this->setRawValue($property->name, $cast($value));
264
-        }
265
-        elseif (is_object($value) && method_exists([$value, $method]))
259
+        } elseif (is_object($value) && method_exists([$value, $method]))
266 260
         {
267 261
             $this->setScalarValue
268 262
             (
@@ -271,8 +265,7 @@  discard block
 block discarded – undo
271 265
                 $method,
272 266
                 $cast
273 267
             );
274
-        }
275
-        else
268
+        } else
276 269
         {
277 270
             $this->throwError($property, $name, $value);
278 271
         }
@@ -293,8 +286,7 @@  discard block
 block discarded – undo
293 286
         if (is_a($value, $property->type->classname))
294 287
         {
295 288
             $this->setRawValue($property->name, $value);
296
-        }
297
-        else
289
+        } else
298 290
         {
299 291
             $this->throwError($property, $type->classname, $value);
300 292
         }
@@ -315,8 +307,7 @@  discard block
 block discarded – undo
315 307
         if (is_a($value, \ArrayAccess::class) || is_array($value))
316 308
         {
317 309
             $this->setRawValue($property->name, $value);
318
-        }
319
-        else
310
+        } else
320 311
         {
321 312
             $this->throwError($property, 'Collection', $value);
322 313
         }
Please login to merge, or discard this patch.
src/Factory/Reflection/ReflectionMethodFactory.php 1 patch
Spacing   +3 added lines, -5 removed lines patch added patch discarded remove patch
@@ -46,8 +46,7 @@  discard block
 block discarded – undo
46 46
      */
47 47
     public static function fromName(string $class, string $method)
48 48
     {
49
-        return new static(new PHPNativeReflectionMethod
50
-        (
49
+        return new static(new PHPNativeReflectionMethod(
51 50
             $class, $method
52 51
         ));
53 52
     }
@@ -60,11 +59,10 @@  discard block
 block discarded – undo
60 59
      *     this method belongs to
61 60
      * @return ReflectionMethod
62 61
      */
63
-    public function build(?ReflectionComposite $parent = null)
62
+    public function build(? ReflectionComposite $parent = null)
64 63
     {
65 64
         $this->accessor->setRawValue('owner', $parent);
66
-        $this->accessor->setRawValue
67
-        (
65
+        $this->accessor->setRawValue(
68 66
             'name',
69 67
             $this->reflector->getName()
70 68
         );
Please login to merge, or discard this patch.
src/Factory/Reflection/ReflectorFactory.php 1 patch
Spacing   +3 added lines, -5 removed lines patch added patch discarded remove patch
@@ -71,8 +71,7 @@  discard block
 block discarded – undo
71 71
      */
72 72
     protected function parseDocComment()
73 73
     {
74
-        preg_match_all
75
-        (
74
+        preg_match_all(
76 75
               '/^'
77 76
             .     '[ \t]*\*[ \t]*'
78 77
             .     '@([a-zA-Z]+)'
@@ -89,8 +88,7 @@  discard block
 block discarded – undo
89 88
 
90 89
             if (isset($this->acceptedParams[$name]))
91 90
             {
92
-                call_user_func
93
-                (
91
+                call_user_func(
94 92
                     array($this, $this->acceptedParams[$name]),
95 93
                     $name, $value
96 94
                 );
@@ -106,7 +104,7 @@  discard block
 block discarded – undo
106 104
      */
107 105
     protected function setBool($name, $value)
108 106
     {
109
-        switch(strtolower($value))
107
+        switch (strtolower($value))
110 108
         {
111 109
             case '':
112 110
             case 'true':
Please login to merge, or discard this patch.