@@ -46,12 +46,10 @@ |
||
| 46 | 46 | ) |
| 47 | 47 | { |
| 48 | 48 | return true; |
| 49 | - } |
|
| 50 | - elseif ($parent instanceof ScalarType) |
|
| 49 | + } elseif ($parent instanceof ScalarType) |
|
| 51 | 50 | { |
| 52 | 51 | return get_class($parent) === get_class($child); |
| 53 | - } |
|
| 54 | - elseif ($parent instanceof ObjectType) |
|
| 52 | + } elseif ($parent instanceof ObjectType) |
|
| 55 | 53 | { |
| 56 | 54 | if |
| 57 | 55 | ( |
@@ -35,8 +35,7 @@ discard block |
||
| 35 | 35 | * @param AbstractType $child |
| 36 | 36 | * @return boolean |
| 37 | 37 | */ |
| 38 | - public function compatible |
|
| 39 | - ( |
|
| 38 | + public function compatible( |
|
| 40 | 39 | AbstractType $parent, |
| 41 | 40 | AbstractType $child |
| 42 | 41 | ) |
@@ -47,8 +46,7 @@ discard block |
||
| 47 | 46 | $parent = $this->getGenericType($parent); |
| 48 | 47 | } |
| 49 | 48 | |
| 50 | - if |
|
| 51 | - ( |
|
| 49 | + if ( |
|
| 52 | 50 | ($child instanceof NullType && $parent->nullable) || |
| 53 | 51 | ($parent instanceof MixedType) |
| 54 | 52 | ) |
@@ -61,11 +59,9 @@ discard block |
||
| 61 | 59 | } |
| 62 | 60 | elseif ($parent instanceof ObjectType) |
| 63 | 61 | { |
| 64 | - if |
|
| 65 | - ( |
|
| 62 | + if ( |
|
| 66 | 63 | $child instanceof ObjectType && |
| 67 | - is_a |
|
| 68 | - ( |
|
| 64 | + is_a( |
|
| 69 | 65 | $child->classname->__toString(), |
| 70 | 66 | $parent->classname->__toString(), |
| 71 | 67 | true |
@@ -74,8 +70,7 @@ discard block |
||
| 74 | 70 | { |
| 75 | 71 | foreach ($child->generics as $i => $generic) |
| 76 | 72 | { |
| 77 | - $compare = $this->compatible |
|
| 78 | - ( |
|
| 73 | + $compare = $this->compatible( |
|
| 79 | 74 | $parent->generics[$i], |
| 80 | 75 | $generic |
| 81 | 76 | ); |
@@ -92,8 +87,7 @@ discard block |
||
| 92 | 87 | return false; |
| 93 | 88 | } |
| 94 | 89 | |
| 95 | - throw new \DomainException |
|
| 96 | - ( |
|
| 90 | + throw new \DomainException( |
|
| 97 | 91 | 'Unknown type: ' . get_class($parent) |
| 98 | 92 | ); |
| 99 | 93 | } |
@@ -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 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | $i = 0; |
| 83 | 83 | |
| 84 | 84 | $code = |
| 85 | - 'namespace ' . $class->namespace . ';' |
|
| 85 | + 'namespace ' . $class->namespace . ';' |
|
| 86 | 86 | . 'class ' . $class->classname . ' ' |
| 87 | 87 | . 'extends \\' . $originalClass |
| 88 | 88 | . '{'; |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | return |
| 121 | - ($method->scope === 'static' ? 'static ' : '') |
|
| 121 | + ($method->scope === 'static' ? 'static ' : '') |
|
| 122 | 122 | . 'function ' . $method->name |
| 123 | 123 | . '(' . implode(',', $params) . '){' |
| 124 | 124 | . '__generic_' . $method->name |
@@ -73,8 +73,7 @@ |
||
| 73 | 73 | public function generateClassCode(...$generics) : string |
| 74 | 74 | { |
| 75 | 75 | $object = $this->createObject(...$generics); |
| 76 | - $this->nameProvider = new GenericNameProvider |
|
| 77 | - ( |
|
| 76 | + $this->nameProvider = new GenericNameProvider( |
|
| 78 | 77 | new GenericContext($object, $this->reflect) |
| 79 | 78 | ); |
| 80 | 79 | $class = $this->nameProvider->inferName($object); |
@@ -14,8 +14,6 @@ |
||
| 14 | 14 | |
| 15 | 15 | namespace Spaark\CompositeUtils\Model\Collection\Map; |
| 16 | 16 | |
| 17 | -use Spaark\CompositeUtils\Traits\AutoConstructTrait; |
|
| 18 | - |
|
| 19 | 17 | /** |
| 20 | 18 | * Abstract Iterator for Map datatypes |
| 21 | 19 | * |
@@ -37,8 +37,6 @@ discard block |
||
| 37 | 37 | /** |
| 38 | 38 | * Adds an element to the Map |
| 39 | 39 | * |
| 40 | - * @param KeyType $key The key to add |
|
| 41 | - * @param ValueType $value The value to add |
|
| 42 | 40 | */ |
| 43 | 41 | public function insert(Pair $pair) |
| 44 | 42 | { |
@@ -59,7 +57,7 @@ discard block |
||
| 59 | 57 | /** |
| 60 | 58 | * Checks if a key exists |
| 61 | 59 | * |
| 62 | - * @param KeyType $key The key to search for |
|
| 60 | + * @param string $key The key to search for |
|
| 63 | 61 | * @return boolean |
| 64 | 62 | */ |
| 65 | 63 | public function containsKey($key) : bool |
@@ -103,6 +101,9 @@ discard block |
||
| 103 | 101 | return $this->list->size(); |
| 104 | 102 | } |
| 105 | 103 | |
| 104 | + /** |
|
| 105 | + * @param string $key |
|
| 106 | + */ |
|
| 106 | 107 | public function indexOfKey($key) |
| 107 | 108 | { |
| 108 | 109 | return $this->getPair($key)->index; |
@@ -44,8 +44,7 @@ |
||
| 44 | 44 | { |
| 45 | 45 | if (!$pair instanceof OrderedPair) |
| 46 | 46 | { |
| 47 | - $pair = new OrderedPair |
|
| 48 | - ( |
|
| 47 | + $pair = new OrderedPair( |
|
| 49 | 48 | $this->size(), |
| 50 | 49 | $pair->key, |
| 51 | 50 | $pair->value |
@@ -45,10 +45,9 @@ |
||
| 45 | 45 | /** |
| 46 | 46 | * {@inheritDoc} |
| 47 | 47 | */ |
| 48 | - public function splice |
|
| 49 | - ( |
|
| 48 | + public function splice( |
|
| 50 | 49 | int $offset, |
| 51 | - ?int $length = null, |
|
| 50 | + ? int $length = null, |
|
| 52 | 51 | array $replacement = [] |
| 53 | 52 | ) |
| 54 | 53 | { |
@@ -29,8 +29,7 @@ |
||
| 29 | 29 | if ($offset === null) |
| 30 | 30 | { |
| 31 | 31 | $this->add($value); |
| 32 | - } |
|
| 33 | - else |
|
| 32 | + } else |
|
| 34 | 33 | { |
| 35 | 34 | $this->set($offset, $value); |
| 36 | 35 | } |
@@ -33,10 +33,9 @@ |
||
| 33 | 33 | * @param int $length The number of elements to remove |
| 34 | 34 | * @param array $items Items to add |
| 35 | 35 | */ |
| 36 | - public function splice |
|
| 37 | - ( |
|
| 36 | + public function splice( |
|
| 38 | 37 | int $offset, |
| 39 | - ?int$length = null, |
|
| 38 | + ? int$length = null, |
|
| 40 | 39 | array $items = [] |
| 41 | 40 | ); |
| 42 | 41 | |
@@ -45,10 +45,9 @@ |
||
| 45 | 45 | /** |
| 46 | 46 | * {@inheritDoc} |
| 47 | 47 | */ |
| 48 | - public function splice |
|
| 49 | - ( |
|
| 48 | + public function splice( |
|
| 50 | 49 | int $offset, |
| 51 | - ?int $length = null, |
|
| 50 | + ? int $length = null, |
|
| 52 | 51 | array $replacement = [] |
| 53 | 52 | ) |
| 54 | 53 | { |
@@ -41,8 +41,7 @@ discard block |
||
| 41 | 41 | return static::$defaultHashProducer; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - public static function setDefaultHashProducer |
|
| 45 | - ( |
|
| 44 | + public static function setDefaultHashProducer( |
|
| 46 | 45 | HashProducerInterface $hashProducer |
| 47 | 46 | ) |
| 48 | 47 | : HashProducerInterface |
@@ -60,9 +59,8 @@ discard block |
||
| 60 | 59 | */ |
| 61 | 60 | protected $hashProducer; |
| 62 | 61 | |
| 63 | - public function __construct |
|
| 64 | - ( |
|
| 65 | - ?HashProducerInterface $hashProducer = null |
|
| 62 | + public function __construct( |
|
| 63 | + ? HashProducerInterface $hashProducer = null |
|
| 66 | 64 | ) |
| 67 | 65 | { |
| 68 | 66 | $this->hashProducer = |