@@ -16,16 +16,9 @@ |
||
| 16 | 16 | |
| 17 | 17 | use Spaark\CompositeUtils\Model\Reflection\ReflectionComposite; |
| 18 | 18 | use Spaark\CompositeUtils\Model\Reflection\ReflectionMethod; |
| 19 | -use Spaark\CompositeUtils\Model\Reflection\Type\BooleanType; |
|
| 20 | -use Spaark\CompositeUtils\Model\Reflection\Type\CollectionType; |
|
| 21 | -use Spaark\CompositeUtils\Model\Reflection\Type\IntegerType; |
|
| 22 | -use Spaark\CompositeUtils\Model\Reflection\Type\MixedType; |
|
| 23 | 19 | use Spaark\CompositeUtils\Model\Reflection\Type\ObjectType; |
| 24 | -use Spaark\CompositeUtils\Model\Reflection\Type\StringType; |
|
| 25 | -use Spaark\CompositeUtils\Model\Reflection\Type\GenericType; |
|
| 26 | 20 | use Spaark\CompositeUtils\Model\Generic\GenericContext; |
| 27 | 21 | use Spaark\CompositeUtils\Model\ClassName; |
| 28 | -use Spaark\CompositeUtils\Service\RawPropertyAccessor; |
|
| 29 | 22 | use Spaark\CompositeUtils\Service\GenericNameProvider; |
| 30 | 23 | use Spaark\CompositeUtils\Traits\AutoConstructPropertyAccessTrait; |
| 31 | 24 | use Spaark\CompositeUtils\Traits\GenericTrait; |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | $i = 0; |
| 93 | 93 | |
| 94 | 94 | $code = |
| 95 | - 'namespace ' . $class->namespace . ';' |
|
| 95 | + 'namespace ' . $class->namespace . ';' |
|
| 96 | 96 | . 'class ' . $class->classname . ' ' |
| 97 | 97 | . 'extends \\' . $originalClass . ' ' |
| 98 | 98 | . 'implements \\' . Generic::class |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | return |
| 133 | - ($method->scope === 'static' ? 'static ' : '') |
|
| 133 | + ($method->scope === 'static' ? 'static ' : '') |
|
| 134 | 134 | . 'function ' . $method->name |
| 135 | 135 | . '(' . implode(',', $params) . '){' |
| 136 | 136 | . '__generic_' . $method->name |
@@ -65,8 +65,7 @@ discard block |
||
| 65 | 65 | { |
| 66 | 66 | if (!$this->genericContext) |
| 67 | 67 | { |
| 68 | - $this->genericContext = new GenericContext |
|
| 69 | - ( |
|
| 68 | + $this->genericContext = new GenericContext( |
|
| 70 | 69 | $this->getObjectType(), |
| 71 | 70 | static::getReflectionComposite() |
| 72 | 71 | ); |
@@ -86,8 +85,7 @@ discard block |
||
| 86 | 85 | { |
| 87 | 86 | if ($this->genericContext) |
| 88 | 87 | { |
| 89 | - throw new ImmutablePropertyException |
|
| 90 | - ( |
|
| 88 | + throw new ImmutablePropertyException( |
|
| 91 | 89 | (string)$this->getObjectType(), |
| 92 | 90 | 'genericContext' |
| 93 | 91 | ); |
@@ -88,15 +88,13 @@ discard block |
||
| 88 | 88 | if ($building) |
| 89 | 89 | { |
| 90 | 90 | $this->buildProperty($property); |
| 91 | - } |
|
| 92 | - else |
|
| 91 | + } else |
|
| 93 | 92 | { |
| 94 | 93 | if (isset($args[$i])) |
| 95 | 94 | { |
| 96 | 95 | $this->setAnyValue($property, $args[$i]); |
| 97 | 96 | $i++; |
| 98 | - } |
|
| 99 | - else |
|
| 97 | + } else |
|
| 100 | 98 | { |
| 101 | 99 | $building = true; |
| 102 | 100 | $this->buildProperty($property); |
@@ -120,8 +118,7 @@ discard block |
||
| 120 | 118 | if (!$property->type instanceof ObjectType) |
| 121 | 119 | { |
| 122 | 120 | $this->setAnyValue($property, 0); |
| 123 | - } |
|
| 124 | - elseif ($property->builtInConstructor) |
|
| 121 | + } elseif ($property->builtInConstructor) |
|
| 125 | 122 | { |
| 126 | 123 | $class = (string)$property->type->classname; |
| 127 | 124 | $this->setRawValue($property->name, new $class()); |
@@ -175,8 +172,7 @@ discard block |
||
| 175 | 172 | if ($value instanceof Generic) |
| 176 | 173 | { |
| 177 | 174 | $valueType = $value->getObjectType(); |
| 178 | - } |
|
| 179 | - else |
|
| 175 | + } else |
|
| 180 | 176 | { |
| 181 | 177 | $valueType = (new TypeParser())->parseFromType($value); |
| 182 | 178 | } |
@@ -184,12 +180,10 @@ discard block |
||
| 184 | 180 | if ($comparator->compatible($property->type, $valueType)) |
| 185 | 181 | { |
| 186 | 182 | $this->setRawValue($property->name, $value); |
| 187 | - } |
|
| 188 | - elseif ($property->type instanceof ScalarType) |
|
| 183 | + } elseif ($property->type instanceof ScalarType) |
|
| 189 | 184 | { |
| 190 | 185 | $this->setScalarValue($property, $valueType, $value); |
| 191 | - } |
|
| 192 | - else |
|
| 186 | + } else |
|
| 193 | 187 | { |
| 194 | 188 | $this->throwError($property, $valueType); |
| 195 | 189 | } |
@@ -218,8 +212,7 @@ discard block |
||
| 218 | 212 | $property->name, |
| 219 | 213 | $property->type->cast($value) |
| 220 | 214 | ); |
| 221 | - } |
|
| 222 | - elseif (is_object($value) && method_exists([$value, $method])) |
|
| 215 | + } elseif (is_object($value) && method_exists([$value, $method])) |
|
| 223 | 216 | { |
| 224 | 217 | $this->setScalarValue |
| 225 | 218 | ( |
@@ -227,8 +220,7 @@ discard block |
||
| 227 | 220 | $valueType, |
| 228 | 221 | $value->$method() |
| 229 | 222 | ); |
| 230 | - } |
|
| 231 | - else |
|
| 223 | + } else |
|
| 232 | 224 | { |
| 233 | 225 | $this->throwError($property, $valueType); |
| 234 | 226 | } |