@@ -93,8 +93,7 @@ discard block |
||
| 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 |
||
| 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 | { |
@@ -60,8 +60,7 @@ discard block |
||
| 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 |
||
| 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)); |
@@ -103,6 +103,10 @@ |
||
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | + /** |
|
| 107 | + * @param string $name |
|
| 108 | + * @param \Closure $cast |
|
| 109 | + */ |
|
| 106 | 110 | private function setScalarValue($property, $value, $name, $cast) |
| 107 | 111 | { |
| 108 | 112 | $method = '__to' . $name; |
@@ -8,7 +8,6 @@ |
||
| 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; |
@@ -47,8 +47,7 @@ discard block |
||
| 47 | 47 | { |
| 48 | 48 | if (!isset($args[$i])) |
| 49 | 49 | { |
| 50 | - throw new MissingRequiredParameterException |
|
| 51 | - ( |
|
| 50 | + throw new MissingRequiredParameterException( |
|
| 52 | 51 | get_class($this->object), |
| 53 | 52 | $property->name |
| 54 | 53 | ); |
@@ -109,14 +108,12 @@ discard block |
||
| 109 | 108 | { |
| 110 | 109 | if (!$this->reflect->properties->contains($property)) |
| 111 | 110 | { |
| 112 | - throw new CannotWritePropertyException |
|
| 113 | - ( |
|
| 111 | + throw new CannotWritePropertyException( |
|
| 114 | 112 | get_class($this->object), $property |
| 115 | 113 | ); |
| 116 | 114 | } |
| 117 | 115 | |
| 118 | - $this->setAnyValue |
|
| 119 | - ( |
|
| 116 | + $this->setAnyValue( |
|
| 120 | 117 | $this->reflect->properties[$property], |
| 121 | 118 | $value |
| 122 | 119 | ); |
@@ -130,8 +127,7 @@ discard block |
||
| 130 | 127 | } |
| 131 | 128 | else |
| 132 | 129 | { |
| 133 | - $this->setNonNullValue |
|
| 134 | - ( |
|
| 130 | + $this->setNonNullValue( |
|
| 135 | 131 | $property->name, |
| 136 | 132 | $value, |
| 137 | 133 | $property->type |
@@ -198,8 +194,7 @@ discard block |
||
| 198 | 194 | } |
| 199 | 195 | elseif (is_object($value) && method_exists([$value, $method])) |
| 200 | 196 | { |
| 201 | - $this->setScalarValue |
|
| 202 | - ( |
|
| 197 | + $this->setScalarValue( |
|
| 203 | 198 | $property, |
| 204 | 199 | $value->$method(), |
| 205 | 200 | $method, |
@@ -238,8 +233,7 @@ discard block |
||
| 238 | 233 | |
| 239 | 234 | private function throwError($property, $expected, $value) |
| 240 | 235 | { |
| 241 | - throw new IllegalPropertyTypeException |
|
| 242 | - ( |
|
| 236 | + throw new IllegalPropertyTypeException( |
|
| 243 | 237 | get_class($this->object), |
| 244 | 238 | $property, |
| 245 | 239 | $expected, |
@@ -65,15 +65,13 @@ discard block |
||
| 65 | 65 | if ($building) |
| 66 | 66 | { |
| 67 | 67 | $this->buildProperty($property); |
| 68 | - } |
|
| 69 | - else |
|
| 68 | + } else |
|
| 70 | 69 | { |
| 71 | 70 | if (isset($args[$i])) |
| 72 | 71 | { |
| 73 | 72 | $this->setAnyValue($property, $args[$i]); |
| 74 | 73 | $i++; |
| 75 | - } |
|
| 76 | - else |
|
| 74 | + } else |
|
| 77 | 75 | { |
| 78 | 76 | $building = true; |
| 79 | 77 | $this->buildProperty($property); |
@@ -93,8 +91,7 @@ discard block |
||
| 93 | 91 | { |
| 94 | 92 | $class = $property->type->classname; |
| 95 | 93 | $this->setRawValue($property->name, new $class()); |
| 96 | - } |
|
| 97 | - else |
|
| 94 | + } else |
|
| 98 | 95 | { |
| 99 | 96 | $this->setAnyValue($property, 0); |
| 100 | 97 | } |
@@ -127,8 +124,7 @@ discard block |
||
| 127 | 124 | if (is_null($value)) |
| 128 | 125 | { |
| 129 | 126 | $this->setNullValue($property->name, $property->type); |
| 130 | - } |
|
| 131 | - else |
|
| 127 | + } else |
|
| 132 | 128 | { |
| 133 | 129 | $this->setNonNullValue |
| 134 | 130 | ( |
@@ -144,8 +140,7 @@ discard block |
||
| 144 | 140 | if ($type->nullable) |
| 145 | 141 | { |
| 146 | 142 | $this->setRawValue($property, null); |
| 147 | - } |
|
| 148 | - else |
|
| 143 | + } else |
|
| 149 | 144 | { |
| 150 | 145 | $this->throwError($property, 'NonNull', null); |
| 151 | 146 | } |
@@ -195,8 +190,7 @@ discard block |
||
| 195 | 190 | if (is_scalar($value)) |
| 196 | 191 | { |
| 197 | 192 | $this->setRawValue($property, $cast($value)); |
| 198 | - } |
|
| 199 | - elseif (is_object($value) && method_exists([$value, $method])) |
|
| 193 | + } elseif (is_object($value) && method_exists([$value, $method])) |
|
| 200 | 194 | { |
| 201 | 195 | $this->setScalarValue |
| 202 | 196 | ( |
@@ -205,8 +199,7 @@ discard block |
||
| 205 | 199 | $method, |
| 206 | 200 | $cast |
| 207 | 201 | ); |
| 208 | - } |
|
| 209 | - else |
|
| 202 | + } else |
|
| 210 | 203 | { |
| 211 | 204 | $this->throwError($property, $name, $value); |
| 212 | 205 | } |
@@ -217,8 +210,7 @@ discard block |
||
| 217 | 210 | if (is_a($value, $type->classname)) |
| 218 | 211 | { |
| 219 | 212 | $this->setRawValue($property, $value); |
| 220 | - } |
|
| 221 | - else |
|
| 213 | + } else |
|
| 222 | 214 | { |
| 223 | 215 | $this->throwError($property, $type->classname, $value); |
| 224 | 216 | } |
@@ -229,8 +221,7 @@ discard block |
||
| 229 | 221 | if (is_a($value, \ArrayAccess::class) || is_array($value)) |
| 230 | 222 | { |
| 231 | 223 | $this->setRawValue($property, $value); |
| 232 | - } |
|
| 233 | - else |
|
| 224 | + } else |
|
| 234 | 225 | { |
| 235 | 226 | $this->throwError($property, 'Collection', $value); |
| 236 | 227 | } |
@@ -17,7 +17,7 @@ |
||
| 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, |
@@ -6,8 +6,7 @@ discard block |
||
| 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 |
||
| 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 |
@@ -10,7 +10,7 @@ |
||
| 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 |
@@ -8,8 +8,7 @@ |
||
| 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, |
@@ -10,7 +10,7 @@ |
||
| 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 |
@@ -8,8 +8,7 @@ |
||
| 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, |
@@ -15,8 +15,7 @@ discard block |
||
| 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 |
||
| 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 | ); |
@@ -12,8 +12,7 @@ discard block |
||
| 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 |
||
| 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 | ( |
@@ -25,8 +25,7 @@ |
||
| 25 | 25 | if (!static::$reflectionComposite) |
| 26 | 26 | { |
| 27 | 27 | static::$reflectionComposite = |
| 28 | - ReflectionCompositeFactory::fromClassName |
|
| 29 | - ( |
|
| 28 | + ReflectionCompositeFactory::fromClassName( |
|
| 30 | 29 | get_called_class() |
| 31 | 30 | ) |
| 32 | 31 | ->build(); |
@@ -29,8 +29,7 @@ |
||
| 29 | 29 | { |
| 30 | 30 | if (!$this->accessor) |
| 31 | 31 | { |
| 32 | - $this->accessor = new ConditionalPropertyAccessor |
|
| 33 | - ( |
|
| 32 | + $this->accessor = new ConditionalPropertyAccessor( |
|
| 34 | 33 | $this, |
| 35 | 34 | self::getReflectionComposite() |
| 36 | 35 | ); |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | { |
| 21 | 21 | parent::__construct |
| 22 | 22 | ( |
| 23 | - 'Missing required parameter in constructor. ' |
|
| 23 | + 'Missing required parameter in constructor. ' |
|
| 24 | 24 | . $class . ' requires a value for ' . $property, |
| 25 | 25 | 0, |
| 26 | 26 | $previous |
@@ -18,8 +18,7 @@ |
||
| 18 | 18 | { |
| 19 | 19 | public function __construct($class, $property, $previous = null) |
| 20 | 20 | { |
| 21 | - parent::__construct |
|
| 22 | - ( |
|
| 21 | + parent::__construct( |
|
| 23 | 22 | 'Missing required parameter in constructor. ' |
| 24 | 23 | . $class . ' requires a value for ' . $property, |
| 25 | 24 | 0, |