@@ -4,7 +4,6 @@ |
||
| 4 | 4 | |
| 5 | 5 | use Spaark\CompositeUtils\Model\Reflection\ReflectionComposite; |
| 6 | 6 | use Spaark\CompositeUtils\Model\Reflection\ReflectionProperty; |
| 7 | -use Spaark\CompositeUtils\Model\Reflection\ReflectionParameter; |
|
| 8 | 7 | use Spaark\CompositeUtils\Model\Reflection\Type\BooleanType; |
| 9 | 8 | use Spaark\CompositeUtils\Model\Reflection\Type\CollectionType; |
| 10 | 9 | use Spaark\CompositeUtils\Model\Reflection\Type\IntegerType; |
@@ -74,7 +74,7 @@ |
||
| 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 |
@@ -64,8 +64,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 | ); |
@@ -105,8 +105,7 @@ discard block |
||
| 105 | 105 | if ($value{0} !== '?') |
| 106 | 106 | { |
| 107 | 107 | $nullable = false; |
| 108 | - } |
|
| 109 | - else |
|
| 108 | + } else |
|
| 110 | 109 | { |
| 111 | 110 | $nullable = true; |
| 112 | 111 | $value = substr($value, 1); |
@@ -115,8 +114,7 @@ discard block |
||
| 115 | 114 | if (substr($value, -2) !== '[]') |
| 116 | 115 | { |
| 117 | 116 | $collection = false; |
| 118 | - } |
|
| 119 | - else |
|
| 117 | + } else |
|
| 120 | 118 | { |
| 121 | 119 | $collection = true; |
| 122 | 120 | $value = substr($value, 0, -2); |
@@ -149,8 +147,7 @@ discard block |
||
| 149 | 147 | if ($useStatements->containsKey($value)) |
| 150 | 148 | { |
| 151 | 149 | $value = $useStatements[$value]->classname; |
| 152 | - } |
|
| 153 | - else |
|
| 150 | + } else |
|
| 154 | 151 | { |
| 155 | 152 | $value = $this->object->owner->namespace->namespace |
| 156 | 153 | . '\\' . $value; |
@@ -39,7 +39,7 @@ |
||
| 39 | 39 | { |
| 40 | 40 | preg_match_all |
| 41 | 41 | ( |
| 42 | - '/^' |
|
| 42 | + '/^' |
|
| 43 | 43 | . '[ \t]*\*[ \t]*' |
| 44 | 44 | . '@([a-zA-Z]+)' |
| 45 | 45 | . '(.*)' |
@@ -71,8 +71,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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': |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | private function getScalar($value) |
| 28 | 28 | { |
| 29 | 29 | return |
| 30 | - (is_object($value) ? spl_object_hash($value) |
|
| 30 | + (is_object($value) ? spl_object_hash($value) |
|
| 31 | 31 | : (is_array($value) ? implode($value) |
| 32 | 32 | : ( (string)$value))); |
| 33 | 33 | } |
@@ -28,8 +28,8 @@ |
||
| 28 | 28 | { |
| 29 | 29 | return |
| 30 | 30 | (is_object($value) ? spl_object_hash($value) |
| 31 | - : (is_array($value) ? implode($value) |
|
| 32 | - : ( (string)$value))); |
|
| 31 | + : (is_array($value) ? implode($value) |
|
| 32 | + : ((string)$value))); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -43,7 +43,9 @@ |
||
| 43 | 43 | */ |
| 44 | 44 | public function popMultiple($i = 1) |
| 45 | 45 | { |
| 46 | - if ($i < 1) return NULL; |
|
| 46 | + if ($i < 1) { |
|
| 47 | + return NULL; |
|
| 48 | + } |
|
| 47 | 49 | |
| 48 | 50 | $ret = array_slice($this->data, -1 * $i); |
| 49 | 51 | $this->data = array_slice($this->data, 0, -1 * $i); |
@@ -48,8 +48,7 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | public function setRawValue($key, $value) |
| 50 | 50 | { |
| 51 | - $this->getPropertyOrFail |
|
| 52 | - ( |
|
| 51 | + $this->getPropertyOrFail( |
|
| 53 | 52 | $key, |
| 54 | 53 | CannotWritePropertyException::class |
| 55 | 54 | ) |
@@ -68,8 +67,7 @@ discard block |
||
| 68 | 67 | public function getRawValue($key) |
| 69 | 68 | { |
| 70 | 69 | return |
| 71 | - $this->getPropertyOrFail |
|
| 72 | - ( |
|
| 70 | + $this->getPropertyOrFail( |
|
| 73 | 71 | $key, |
| 74 | 72 | CannotReadPropertyException::class |
| 75 | 73 | ) |
@@ -86,8 +84,7 @@ discard block |
||
| 86 | 84 | */ |
| 87 | 85 | public function rawAddToValue($key, $value) |
| 88 | 86 | { |
| 89 | - $property = $this->getPropertyOrFail |
|
| 90 | - ( |
|
| 87 | + $property = $this->getPropertyOrFail( |
|
| 91 | 88 | $key, |
| 92 | 89 | CannotWritePropertyException::class |
| 93 | 90 | ); |
@@ -113,8 +110,7 @@ discard block |
||
| 113 | 110 | } |
| 114 | 111 | catch (ReflectionException $e) |
| 115 | 112 | { |
| 116 | - throw new $class |
|
| 117 | - ( |
|
| 113 | + throw new $class( |
|
| 118 | 114 | get_class($this->object), |
| 119 | 115 | $key, |
| 120 | 116 | $e |
@@ -110,8 +110,7 @@ |
||
| 110 | 110 | $prop->setAccessible(true); |
| 111 | 111 | |
| 112 | 112 | return $prop; |
| 113 | - } |
|
| 114 | - catch (ReflectionException $e) |
|
| 113 | + } catch (ReflectionException $e) |
|
| 115 | 114 | { |
| 116 | 115 | throw new $class |
| 117 | 116 | ( |
@@ -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)); |
@@ -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, |
@@ -32,8 +32,7 @@ discard block |
||
| 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 |
||
| 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 |
@@ -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 | ( |
@@ -35,8 +35,7 @@ discard block |
||
| 35 | 35 | } |
| 36 | 36 | else |
| 37 | 37 | { |
| 38 | - throw new PropertyNotWritableException |
|
| 39 | - ( |
|
| 38 | + throw new PropertyNotWritableException( |
|
| 40 | 39 | get_class($this->object), |
| 41 | 40 | $property->name |
| 42 | 41 | ); |
@@ -50,16 +49,14 @@ discard block |
||
| 50 | 49 | { |
| 51 | 50 | if (!$this->reflect->properties->containsKey($property)) |
| 52 | 51 | { |
| 53 | - throw new CannotReadPropertyException |
|
| 54 | - ( |
|
| 52 | + throw new CannotReadPropertyException( |
|
| 55 | 53 | get_class($this->object), |
| 56 | 54 | $property |
| 57 | 55 | ); |
| 58 | 56 | } |
| 59 | 57 | elseif (!$this->reflect->properties[$property]->readable) |
| 60 | 58 | { |
| 61 | - throw new PropertyNotReadableException |
|
| 62 | - ( |
|
| 59 | + throw new PropertyNotReadableException( |
|
| 63 | 60 | get_class($this->object), |
| 64 | 61 | $property |
| 65 | 62 | ); |
@@ -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(); |