Completed
Push — master ( 01a9e5...1f9a78 )
by Emily
01:59
created
src/Factory/Reflection/ReflectionFileFactory.php 2 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -93,8 +93,7 @@  discard block
 block discarded – undo
93 93
                 {
94 94
                     $as .= $token[1];
95 95
                 }
96
-            }
97
-            elseif ($matching)
96
+            } elseif ($matching)
98 97
             {
99 98
                 switch ($token[0])
100 99
                 {
@@ -105,8 +104,7 @@  discard block
 block discarded – undo
105 104
                     case T_AS:
106 105
                         $matching = T_AS;
107 106
                 }
108
-            }
109
-            else
107
+            } else
110 108
             {
111 109
                 switch ($token[0])
112 110
                 {
Please login to merge, or discard this patch.
Spacing   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -60,8 +60,7 @@  discard block
 block discarded – undo
60 60
                     case T_NAMESPACE:
61 61
                         $ns = new NamespaceBlock($classname);
62 62
                         $currentNS = new RawPropertyAccessor($ns);
63
-                        $this->accessor->getRawValue
64
-                        (
63
+                        $this->accessor->getRawValue(
65 64
                             'namespaces'
66 65
                         )
67 66
                         ->add($classname, $ns);
@@ -76,8 +75,7 @@  discard block
 block discarded – undo
76 75
                             $as = end($as);
77 76
                         }
78 77
 
79
-                        $currentNS->getRawValue
80
-                        (
78
+                        $currentNS->getRawValue(
81 79
                             'useStatements'
82 80
                         )
83 81
                         ->add($as, new UseStatement($classname, $as));
Please login to merge, or discard this patch.
src/Service/PropertyAccessor.php 4 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,6 @@
 block discarded – undo
8 8
 use Spaark\CompositeUtils\Model\Reflection\Type\StringType;
9 9
 use Spaark\CompositeUtils\Model\Reflection\Type\IntegerType;
10 10
 use Spaark\CompositeUtils\Model\Reflection\Type\BooleanType;
11
-use Spaark\CompositeUtils\Model\Reflection\Type\FloatType;
12 11
 use Spaark\CompositeUtils\Model\Reflection\Type\CollectionType;
13 12
 use Spaark\CompositeUtils\Exception\CannotWritePropertyException;
14 13
 use Spaark\CompositeUtils\Exception\IllegalPropertyTypeException;
Please login to merge, or discard this patch.
Spacing   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -36,14 +36,12 @@  discard block
 block discarded – undo
36 36
     {
37 37
         if (!$this->reflect->properties->contains($property))
38 38
         {
39
-            throw new CannotWritePropertyException
40
-            (
39
+            throw new CannotWritePropertyException(
41 40
                 get_class($this->object), $property
42 41
             );
43 42
         }
44 43
 
45
-        $this->setAnyValue
46
-        (
44
+        $this->setAnyValue(
47 45
             $this->reflect->properties[$property],
48 46
             $value
49 47
         );
@@ -57,8 +55,7 @@  discard block
 block discarded – undo
57 55
         }
58 56
         else
59 57
         {
60
-            $this->setNonNullValue
61
-            (
58
+            $this->setNonNullValue(
62 59
                 $property->name,
63 60
                 $value,
64 61
                 $property->type
@@ -125,8 +122,7 @@  discard block
 block discarded – undo
125 122
         }
126 123
         elseif (is_object($value) && method_exists([$value, $method]))
127 124
         {
128
-            $this->setScalarValue
129
-            (
125
+            $this->setScalarValue(
130 126
                 $property,
131 127
                 $value->$method(),
132 128
                 $method,
@@ -165,8 +161,7 @@  discard block
 block discarded – undo
165 161
 
166 162
     private function throwError($property, $expected, $value)
167 163
     {
168
-        throw new IllegalPropertyTypeException
169
-        (
164
+        throw new IllegalPropertyTypeException(
170 165
             get_class($this->object),
171 166
             $property,
172 167
             $expected,
Please login to merge, or discard this patch.
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -54,8 +54,7 @@  discard block
 block discarded – undo
54 54
         if (is_null($value))
55 55
         {
56 56
             $this->setNullValue($property->name, $property->type);
57
-        }
58
-        else
57
+        } else
59 58
         {
60 59
             $this->setNonNullValue
61 60
             (
@@ -71,8 +70,7 @@  discard block
 block discarded – undo
71 70
         if ($type->nullable)
72 71
         {
73 72
             $this->setRawValue($property, null);
74
-        }
75
-        else
73
+        } else
76 74
         {
77 75
             $this->throwError($property, 'NonNull', null);
78 76
         }
@@ -122,8 +120,7 @@  discard block
 block discarded – undo
122 120
         if (is_scalar($value))
123 121
         {
124 122
             $this->setRawValue($property, $cast($value));
125
-        }
126
-        elseif (is_object($value) && method_exists([$value, $method]))
123
+        } elseif (is_object($value) && method_exists([$value, $method]))
127 124
         {
128 125
             $this->setScalarValue
129 126
             (
@@ -132,8 +129,7 @@  discard block
 block discarded – undo
132 129
                 $method,
133 130
                 $cast
134 131
             );
135
-        }
136
-        else
132
+        } else
137 133
         {
138 134
             $this->throwError($property, $name, $value);
139 135
         }
@@ -144,8 +140,7 @@  discard block
 block discarded – undo
144 140
         if (is_a($value, $type->classname))
145 141
         {
146 142
             $this->setRawValue($property, $value);
147
-        }
148
-        else
143
+        } else
149 144
         {
150 145
             $this->throwError($property, $type->classname, $value);
151 146
         }
@@ -156,8 +151,7 @@  discard block
 block discarded – undo
156 151
         if (is_a($value, \ArrayAccess::class) || is_array($value))
157 152
         {
158 153
             $this->setRawValue($property, $value);
159
-        }
160
-        else
154
+        } else
161 155
         {
162 156
             $this->throwError($property, 'Collection', $value);
163 157
         }
Please login to merge, or discard this patch.
Doc Comments   +7 added lines patch added patch discarded remove patch
@@ -20,6 +20,9 @@  discard block
 block discarded – undo
20 20
      */
21 21
     protected $reflect;
22 22
 
23
+    /**
24
+     * @param \Spaark\Composite\Traits\PropertyAccessTrait $object
25
+     */
23 26
     public function __construct($object, ReflectionComposite $reflect)
24 27
     {
25 28
         parent::__construct($object);
@@ -115,6 +118,10 @@  discard block
 block discarded – undo
115 118
         }
116 119
     }
117 120
 
121
+    /**
122
+     * @param string $name
123
+     * @param \Closure $cast
124
+     */
118 125
     private function setScalarValue($property, $value, $name, $cast)
119 126
     {
120 127
         $method = '__to' . $name;
Please login to merge, or discard this patch.
src/Exception/IllegalPropertyTypeException.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
     {
18 18
         parent::__construct
19 19
         (
20
-              'Tried to set an illegal property type for '
20
+                'Tried to set an illegal property type for '
21 21
             . $class .'::$' . $property . '. Excpected ' . $expected
22 22
             . ', got ' . $got,
23 23
             0,
Please login to merge, or discard this patch.
Spacing   +3 added lines, -5 removed lines patch added patch discarded remove patch
@@ -6,8 +6,7 @@  discard block
 block discarded – undo
6 6
 
7 7
 class IllegalPropertyTypeException extends Exception
8 8
 {
9
-    public function __construct
10
-    (
9
+    public function __construct(
11 10
         string $class,
12 11
         string $property,
13 12
         string $expected,
@@ -15,10 +14,9 @@  discard block
 block discarded – undo
15 14
         Exception $previous = null
16 15
     )
17 16
     {
18
-        parent::__construct
19
-        (
17
+        parent::__construct(
20 18
               'Tried to set an illegal property type for '
21
-            . $class .'::$' . $property . '. Excpected ' . $expected
19
+            . $class . '::$' . $property . '. Excpected ' . $expected
22 20
             . ', got ' . $got,
23 21
             0,
24 22
             $previous
Please login to merge, or discard this patch.
src/Exception/PropertyNotReadableException.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
     {
11 11
         parent::__construct
12 12
         (
13
-              'Tried to read unreadable property '
13
+                'Tried to read unreadable property '
14 14
             . $class . '::$' . $property,
15 15
             0,
16 16
             $previous
Please login to merge, or discard this patch.
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,8 +8,7 @@
 block discarded – undo
8 8
 {
9 9
     public function __construct($class, $property, $previous = null)
10 10
     {
11
-        parent::__construct
12
-        (
11
+        parent::__construct(
13 12
               'Tried to read unreadable property '
14 13
             . $class . '::$' . $property,
15 14
             0,
Please login to merge, or discard this patch.
src/Exception/PropertyNotWritableException.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
     {
11 11
         parent::__construct
12 12
         (
13
-              'Tried to write to unwritable property '
13
+                'Tried to write to unwritable property '
14 14
             . $class . '::$' . $property,
15 15
             0,
16 16
             $previous
Please login to merge, or discard this patch.
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,8 +8,7 @@
 block discarded – undo
8 8
 {
9 9
     public function __construct($class, $property, $previous = null)
10 10
     {
11
-        parent::__construct
12
-        (
11
+        parent::__construct(
13 12
               'Tried to write to unwritable property '
14 13
             . $class . '::$' . $property,
15 14
             0,
Please login to merge, or discard this patch.
src/Service/ConditionalPropertyAccessor.php 2 patches
Spacing   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -15,8 +15,7 @@  discard block
 block discarded – undo
15 15
         }
16 16
         else
17 17
         {
18
-            throw new PropertyNotWritableException
19
-            (
18
+            throw new PropertyNotWritableException(
20 19
                 get_class($this->object),
21 20
                 $property->name
22 21
             );
@@ -27,16 +26,14 @@  discard block
 block discarded – undo
27 26
     {
28 27
         if (!$this->reflect->properties->contains($property))
29 28
         {
30
-            throw new CannotReadPropertyException
31
-            (
29
+            throw new CannotReadPropertyException(
32 30
                 get_class($this->object),
33 31
                 $property
34 32
             );
35 33
         }
36 34
         elseif (!$this->reflect->properties[$property]->readable)
37 35
         {
38
-            throw new PropertyNotReadableException
39
-            (
36
+            throw new PropertyNotReadableException(
40 37
                 get_class($this->object),
41 38
                 $property
42 39
             );
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,8 +12,7 @@  discard block
 block discarded – undo
12 12
         if ($property->writable)
13 13
         {
14 14
             parent::setAnyValue($property, $value);
15
-        }
16
-        else
15
+        } else
17 16
         {
18 17
             throw new PropertyNotWritableException
19 18
             (
@@ -32,8 +31,7 @@  discard block
 block discarded – undo
32 31
                 get_class($this->object),
33 32
                 $property
34 33
             );
35
-        }
36
-        elseif (!$this->reflect->properties[$property]->readable)
34
+        } elseif (!$this->reflect->properties[$property]->readable)
37 35
         {
38 36
             throw new PropertyNotReadableException
39 37
             (
Please login to merge, or discard this patch.
src/Traits/PropertyAccessTrait.php 1 patch
Spacing   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -14,8 +14,7 @@  discard block
 block discarded – undo
14 14
         if (!static::$reflectionComposite)
15 15
         {
16 16
             static::$reflectComposite =
17
-                ReflectionCompositeFactory::fromClassName
18
-                (
17
+                ReflectionCompositeFactory::fromClassName(
19 18
                     get_called_class()
20 19
                 )
21 20
                 ->build();
@@ -36,8 +35,7 @@  discard block
 block discarded – undo
36 35
 
37 36
     protected function initPropertyAccessTrait()
38 37
     {
39
-        $this->accessor = new ConditionalPropertyAccessor
40
-        (
38
+        $this->accessor = new ConditionalPropertyAccessor(
41 39
             $this,
42 40
             self::getReflectionComposite()
43 41
         );
Please login to merge, or discard this patch.