@@ -16,13 +16,6 @@ |
||
| 16 | 16 | |
| 17 | 17 | use Spaark\CompositeUtils\Model\Reflection\ReflectionComposite; |
| 18 | 18 | use Spaark\CompositeUtils\Model\Reflection\ReflectionProperty; |
| 19 | -use Spaark\CompositeUtils\Model\Reflection\ReflectionParameter; |
|
| 20 | -use Spaark\CompositeUtils\Model\Reflection\Type\BooleanType; |
|
| 21 | -use Spaark\CompositeUtils\Model\Reflection\Type\CollectionType; |
|
| 22 | -use Spaark\CompositeUtils\Model\Reflection\Type\IntegerType; |
|
| 23 | -use Spaark\CompositeUtils\Model\Reflection\Type\MixedType; |
|
| 24 | -use Spaark\CompositeUtils\Model\Reflection\Type\ObjectType; |
|
| 25 | -use Spaark\CompositeUtils\Model\Reflection\Type\StringType; |
|
| 26 | 19 | use Spaark\CompositeUtils\Service\RawPropertyAccessor; |
| 27 | 20 | use \ReflectionProperty as PHPNativeReflectionProperty; |
| 28 | 21 | |
@@ -53,8 +53,7 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | public static function fromName($class, $property) |
| 55 | 55 | { |
| 56 | - return new static(new PHPNativeReflectionProperty |
|
| 57 | - ( |
|
| 56 | + return new static(new PHPNativeReflectionProperty( |
|
| 58 | 57 | $class, $property |
| 59 | 58 | )); |
| 60 | 59 | } |
@@ -72,14 +71,12 @@ discard block |
||
| 72 | 71 | { |
| 73 | 72 | $this->accessor->setRawValue('owner', $parent); |
| 74 | 73 | $this->accessor->setRawValue('defaultValue', $default); |
| 75 | - $this->accessor->setRawValue |
|
| 76 | - ( |
|
| 74 | + $this->accessor->setRawValue( |
|
| 77 | 75 | 'name', |
| 78 | 76 | $this->reflector->getName() |
| 79 | 77 | ); |
| 80 | 78 | |
| 81 | - $this->parseDocComment |
|
| 82 | - ([ |
|
| 79 | + $this->parseDocComment([ |
|
| 83 | 80 | 'readable' => 'setBool', |
| 84 | 81 | 'writable' => 'setBool', |
| 85 | 82 | 'var' => 'setType', |
@@ -97,8 +94,7 @@ discard block |
||
| 97 | 94 | */ |
| 98 | 95 | protected function setType($name, $value) |
| 99 | 96 | { |
| 100 | - $this->accessor->setRawValue |
|
| 101 | - ( |
|
| 97 | + $this->accessor->setRawValue( |
|
| 102 | 98 | 'type', |
| 103 | 99 | (new TypeParser($this->object->owner))->parse($value) |
| 104 | 100 | ); |
@@ -120,50 +116,42 @@ discard block |
||
| 120 | 116 | switch ($value[0]) |
| 121 | 117 | { |
| 122 | 118 | case 'required': |
| 123 | - $this->accessor->setRawValue |
|
| 124 | - ( |
|
| 119 | + $this->accessor->setRawValue( |
|
| 125 | 120 | 'passedToConstructor', |
| 126 | 121 | true |
| 127 | 122 | ); |
| 128 | - $this->accessor->setRawValue |
|
| 129 | - ( |
|
| 123 | + $this->accessor->setRawValue( |
|
| 130 | 124 | 'requiredInConstructor', |
| 131 | 125 | true |
| 132 | 126 | ); |
| 133 | - $compositeAccessor->rawAddToValue |
|
| 134 | - ( |
|
| 127 | + $compositeAccessor->rawAddToValue( |
|
| 135 | 128 | 'requiredProperties', |
| 136 | 129 | $this->object |
| 137 | 130 | ); |
| 138 | 131 | break; |
| 139 | 132 | case 'new': |
| 140 | - $this->accessor->setRawValue |
|
| 141 | - ( |
|
| 133 | + $this->accessor->setRawValue( |
|
| 142 | 134 | 'builtInConstructor', |
| 143 | 135 | true |
| 144 | 136 | ); |
| 145 | - $compositeAccessor->rawAddToValue |
|
| 146 | - ( |
|
| 137 | + $compositeAccessor->rawAddToValue( |
|
| 147 | 138 | 'builtProperties', |
| 148 | 139 | $this->object |
| 149 | 140 | ); |
| 150 | 141 | break; |
| 151 | 142 | case 'optional': |
| 152 | - $this->accessor->setRawValue |
|
| 153 | - ( |
|
| 143 | + $this->accessor->setRawValue( |
|
| 154 | 144 | 'passedToConstructor', |
| 155 | 145 | true |
| 156 | 146 | ); |
| 157 | - $compositeAccessor->rawAddToValue |
|
| 158 | - ( |
|
| 147 | + $compositeAccessor->rawAddToValue( |
|
| 159 | 148 | 'optionalProperties', |
| 160 | 149 | $this->object |
| 161 | 150 | ); |
| 162 | 151 | |
| 163 | 152 | if (isset($value[1]) && $value[1] === 'new') |
| 164 | 153 | { |
| 165 | - $this->accessor->setRawValue |
|
| 166 | - ( |
|
| 154 | + $this->accessor->setRawValue( |
|
| 167 | 155 | 'builtInConstructor', |
| 168 | 156 | true |
| 169 | 157 | ); |
@@ -47,6 +47,9 @@ discard block |
||
| 47 | 47 | return $this->innerParse($value); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | + /** |
|
| 51 | + * @param string $value |
|
| 52 | + */ |
|
| 50 | 53 | protected function innerParse($value) |
| 51 | 54 | { |
| 52 | 55 | $nullable = false; |
@@ -120,6 +123,9 @@ discard block |
||
| 120 | 123 | return $this->resolveName($current, $nullable, $collection); |
| 121 | 124 | } |
| 122 | 125 | |
| 126 | + /** |
|
| 127 | + * @param integer $i |
|
| 128 | + */ |
|
| 123 | 129 | protected function checkCollectionClose($value, $i) |
| 124 | 130 | { |
| 125 | 131 | if ($i + 1 === strlen($value)) |
@@ -63,8 +63,7 @@ discard block |
||
| 63 | 63 | $nullable = true; |
| 64 | 64 | break; |
| 65 | 65 | case '<': |
| 66 | - $stack->push($this->resolveGenericName |
|
| 67 | - ( |
|
| 66 | + $stack->push($this->resolveGenericName( |
|
| 68 | 67 | $current, |
| 69 | 68 | $nullable, |
| 70 | 69 | $collection |
@@ -72,8 +71,7 @@ discard block |
||
| 72 | 71 | break; |
| 73 | 72 | case ',': |
| 74 | 73 | $stack->top()->generics[] = |
| 75 | - $this->resolveName |
|
| 76 | - ( |
|
| 74 | + $this->resolveName( |
|
| 77 | 75 | $current, |
| 78 | 76 | $nullable, |
| 79 | 77 | $collection |
@@ -89,8 +87,7 @@ discard block |
||
| 89 | 87 | case '>': |
| 90 | 88 | $item = $stack->pop(); |
| 91 | 89 | $item->generics[] = |
| 92 | - $this->resolveName |
|
| 93 | - ( |
|
| 90 | + $this->resolveName( |
|
| 94 | 91 | $current, |
| 95 | 92 | $nullable, |
| 96 | 93 | $collection |
@@ -132,18 +129,17 @@ discard block |
||
| 132 | 129 | } |
| 133 | 130 | elseif ($i + 2 !== strlen($value)) |
| 134 | 131 | { |
| 135 | - if (!in_array($value{$i + 2}, ['>',','])) |
|
| 132 | + if (!in_array($value{$i + 2}, ['>', ','])) |
|
| 136 | 133 | { |
| 137 | 134 | throw new \Exception('Unexpected char after collection'); |
| 138 | 135 | } |
| 139 | 136 | } |
| 140 | 137 | } |
| 141 | 138 | |
| 142 | - protected function resolveGenericName |
|
| 143 | - ( |
|
| 144 | - string &$value, |
|
| 145 | - bool &$nullable, |
|
| 146 | - bool &$collection |
|
| 139 | + protected function resolveGenericName( |
|
| 140 | + string & $value, |
|
| 141 | + bool & $nullable, |
|
| 142 | + bool & $collection |
|
| 147 | 143 | ) |
| 148 | 144 | { |
| 149 | 145 | $type = $this->resolveName($value, $nullable, $collection); |
@@ -156,11 +152,10 @@ discard block |
||
| 156 | 152 | return $type; |
| 157 | 153 | } |
| 158 | 154 | |
| 159 | - protected function resolveName |
|
| 160 | - ( |
|
| 161 | - string &$value, |
|
| 162 | - bool &$nullable, |
|
| 163 | - bool &$collection |
|
| 155 | + protected function resolveName( |
|
| 156 | + string & $value, |
|
| 157 | + bool & $nullable, |
|
| 158 | + bool & $collection |
|
| 164 | 159 | ) |
| 165 | 160 | { |
| 166 | 161 | switch ($value) |
@@ -106,8 +106,7 @@ discard block |
||
| 106 | 106 | if ($stack->isEmpty()) |
| 107 | 107 | { |
| 108 | 108 | return $item; |
| 109 | - } |
|
| 110 | - else |
|
| 109 | + } else |
|
| 111 | 110 | { |
| 112 | 111 | $stack->top()->types[] = $item; |
| 113 | 112 | } |
@@ -125,12 +124,10 @@ discard block |
||
| 125 | 124 | if ($i + 1 === strlen($value)) |
| 126 | 125 | { |
| 127 | 126 | throw new \Exception('Unexpected EOF'); |
| 128 | - } |
|
| 129 | - elseif ($value{$i + 1} !== ']') |
|
| 127 | + } elseif ($value{$i + 1} !== ']') |
|
| 130 | 128 | { |
| 131 | 129 | throw new \Exception('[ must be followed by ]'); |
| 132 | - } |
|
| 133 | - elseif ($i + 2 !== strlen($value)) |
|
| 130 | + } elseif ($i + 2 !== strlen($value)) |
|
| 134 | 131 | { |
| 135 | 132 | if (!in_array($value{$i + 2}, ['>',','])) |
| 136 | 133 | { |
@@ -189,8 +186,7 @@ discard block |
||
| 189 | 186 | if ($useStatements->containsKey($value)) |
| 190 | 187 | { |
| 191 | 188 | $value = $useStatements[$value]->classname; |
| 192 | - } |
|
| 193 | - else |
|
| 189 | + } else |
|
| 194 | 190 | { |
| 195 | 191 | $value = $this->context->namespace->namespace |
| 196 | 192 | . '\\' . $value; |
@@ -63,8 +63,7 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | protected function parseDocComment(array $acceptedParams) |
| 65 | 65 | { |
| 66 | - preg_match_all |
|
| 67 | - ( |
|
| 66 | + preg_match_all( |
|
| 68 | 67 | '/^' |
| 69 | 68 | . '[ \t]*\*[ \t]*' |
| 70 | 69 | . '@([a-zA-Z]+)' |
@@ -81,8 +80,7 @@ discard block |
||
| 81 | 80 | |
| 82 | 81 | if (isset($acceptedParams[$name])) |
| 83 | 82 | { |
| 84 | - call_user_func |
|
| 85 | - ( |
|
| 83 | + call_user_func( |
|
| 86 | 84 | array($this, $acceptedParams[$name]), |
| 87 | 85 | $name, $value |
| 88 | 86 | ); |
@@ -98,7 +96,7 @@ discard block |
||
| 98 | 96 | */ |
| 99 | 97 | protected function setBool($name, $value) |
| 100 | 98 | { |
| 101 | - switch(strtolower($value)) |
|
| 99 | + switch (strtolower($value)) |
|
| 102 | 100 | { |
| 103 | 101 | case '': |
| 104 | 102 | case 'true': |