@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | /** {@inheritdoc} */ |
| 39 | 39 | public function fetch(Entity $self, EntityManager $entityManager) |
| 40 | 40 | { |
| 41 | - $key = array_map([$self, '__get' ], array_keys($this->reference)); |
|
| 41 | + $key = array_map([$self, '__get'], array_keys($this->reference)); |
|
| 42 | 42 | |
| 43 | 43 | if (in_array(null, $key)) { |
| 44 | 44 | return null; |
@@ -82,6 +82,6 @@ discard block |
||
| 82 | 82 | $expression[] = $alias . '.' . $myVar . ' = ' . $this->name . '.' . $hisVar; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - call_user_func([ $fetcher, $join ], $this->class, implode(' AND ', $expression), $this->name, [], true); |
|
| 85 | + call_user_func([$fetcher, $join], $this->class, implode(' AND ', $expression), $this->name, [], true); |
|
| 86 | 86 | } |
| 87 | 87 | } |
@@ -61,8 +61,8 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | $this->tableName = $entityManager->escapeIdentifier($class::getTableName()); |
| 63 | 63 | $this->alias = 't0'; |
| 64 | - $this->columns = [ 't0.*' ]; |
|
| 65 | - $this->modifier = [ 'DISTINCT' ]; |
|
| 64 | + $this->columns = ['t0.*']; |
|
| 65 | + $this->modifier = ['DISTINCT']; |
|
| 66 | 66 | |
| 67 | 67 | $this->classMapping['byClass'][$class] = 't0'; |
| 68 | 68 | $this->classMapping['byAlias']['t0'] = $class; |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | $alias = $this->alias; |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - call_user_func([ $class, 'getRelation' ], $relation)->addJoin($this, $join, $alias); |
|
| 186 | + call_user_func([$class, 'getRelation'], $relation)->addJoin($this, $join, $alias); |
|
| 187 | 187 | return $this; |
| 188 | 188 | } |
| 189 | 189 | |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | return null; |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | - $class = $this->class; |
|
| 233 | + $class = $this->class; |
|
| 234 | 234 | $newEntity = new $class($data, $this->entityManager, true); |
| 235 | 235 | $entity = $this->entityManager->map($newEntity); |
| 236 | 236 | |
@@ -275,11 +275,11 @@ discard block |
||
| 275 | 275 | public function count() |
| 276 | 276 | { |
| 277 | 277 | // set the columns and reset after get query |
| 278 | - $this->columns = [ 'COUNT(DISTINCT t0.*)' ]; |
|
| 278 | + $this->columns = ['COUNT(DISTINCT t0.*)']; |
|
| 279 | 279 | $this->modifier = []; |
| 280 | 280 | $query = $this->getQuery(); |
| 281 | - $this->columns = [ 't0.*' ]; |
|
| 282 | - $this->modifier = [ 'DISTINCT' ]; |
|
| 281 | + $this->columns = ['t0.*']; |
|
| 282 | + $this->modifier = ['DISTINCT']; |
|
| 283 | 283 | |
| 284 | 284 | return (int) $this->entityManager->getConnection()->query($query)->fetchColumn(); |
| 285 | 285 | } |
@@ -384,8 +384,7 @@ discard block |
||
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | return $useAutoIncrement && $entity::isAutoIncremented() ? |
| 387 | - $this->getDbal()->insertAndSyncWithAutoInc($entity) : |
|
| 388 | - $this->getDbal()->insertAndSync($entity); |
|
| 387 | + $this->getDbal()->insertAndSyncWithAutoInc($entity) : $this->getDbal()->insertAndSync($entity); |
|
| 389 | 388 | } |
| 390 | 389 | |
| 391 | 390 | /** |
@@ -501,7 +500,7 @@ discard block |
||
| 501 | 500 | return new EntityFetcher($this, $class); |
| 502 | 501 | } |
| 503 | 502 | |
| 504 | - $primaryKey = $this::buildPrimaryKey($class, (array)$primaryKey); |
|
| 503 | + $primaryKey = $this::buildPrimaryKey($class, (array) $primaryKey); |
|
| 505 | 504 | $checksum = $this::buildChecksum($primaryKey); |
| 506 | 505 | |
| 507 | 506 | if (isset($this->map[$class][$checksum])) { |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | return new EntityFetcherMock($this, $class); |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - $primaryKey = $this->buildPrimaryKey($class, (array)$primaryKey); |
|
| 23 | + $primaryKey = $this->buildPrimaryKey($class, (array) $primaryKey); |
|
| 24 | 24 | $checksum = $this->buildChecksum($primaryKey); |
| 25 | 25 | |
| 26 | 26 | if (isset($this->map[$class][$checksum])) { |
@@ -56,8 +56,9 @@ |
||
| 56 | 56 | * |
| 57 | 57 | * As the results are mocked to come from the database they will also get a primary key if they don't have already. |
| 58 | 58 | * |
| 59 | - * @param $class |
|
| 59 | + * @param string $class |
|
| 60 | 60 | * @param Entity ...$entities |
| 61 | + * @param Entity[] $entities |
|
| 61 | 62 | * @return Result|m\MockInterface |
| 62 | 63 | * @codeCoverageIgnore proxy method |
| 63 | 64 | */ |
@@ -176,7 +176,7 @@ |
||
| 176 | 176 | $em = $this->ormGetEntityManagerInstance($class); |
| 177 | 177 | |
| 178 | 178 | /** @var m\MockInterface|EntityFetcher $fetcher */ |
| 179 | - $fetcher = m::mock(EntityFetcher::class, [ $em, $class ])->makePartial(); |
|
| 179 | + $fetcher = m::mock(EntityFetcher::class, [$em, $class])->makePartial(); |
|
| 180 | 180 | $expectation = $em->shouldReceive('fetch')->with($class)->andReturn($fetcher); |
| 181 | 181 | |
| 182 | 182 | $fetcher->shouldReceive('count')->with()->andReturn(count($entities))->byDefault(); |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | /** |
| 21 | 21 | * Get the EntityManagerMock for $class |
| 22 | 22 | * |
| 23 | - * @param $class |
|
| 23 | + * @param string $class |
|
| 24 | 24 | * @return EntityManagerMock|m\MockInterface|EntityManager |
| 25 | 25 | * @codeCoverageIgnore proxy method |
| 26 | 26 | */ |
@@ -130,6 +130,7 @@ discard block |
||
| 130 | 130 | * |
| 131 | 131 | * @param string $class The class of an Entity |
| 132 | 132 | * @param Entity ...$entities The entities that will be returned |
| 133 | + * @param Entity[] $entities |
|
| 133 | 134 | * @return EntityFetcherMock\Result|m\MockInterface |
| 134 | 135 | * @codeCoverageIgnore trivial code |
| 135 | 136 | */ |
@@ -260,7 +261,7 @@ discard block |
||
| 260 | 261 | * |
| 261 | 262 | * Entity has to be a mock use `emCreateMockedEntity()` to create it. |
| 262 | 263 | * |
| 263 | - * @param Entity|m\MockInterface $entity |
|
| 264 | + * @param m\MockInterface $entity |
|
| 264 | 265 | * @param array $changingData Emulate changing data during update statement (triggers etc) |
| 265 | 266 | * @param array $updatedData Emulate data changes in database |
| 266 | 267 | */ |
@@ -275,7 +276,7 @@ discard block |
||
| 275 | 276 | * |
| 276 | 277 | * Entity has to be a mock use `emCreateMockedEntity()` to create it. |
| 277 | 278 | * |
| 278 | - * @param Entity|m\MockInterface $entity |
|
| 279 | + * @param m\MockInterface $entity |
|
| 279 | 280 | * @param array $changingData Emulate changing data during update statement (triggers etc) |
| 280 | 281 | * @param array $updatedData Emulate data changes in database |
| 281 | 282 | * @return m\Expectation |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | protected static function getRegisteredType(array $columnDefinition) |
| 42 | 42 | { |
| 43 | 43 | foreach (self::$registeredTypes as $class) { |
| 44 | - if (call_user_func([ $class, 'fits' ], $columnDefinition)) { |
|
| 44 | + if (call_user_func([$class, 'fits'], $columnDefinition)) { |
|
| 45 | 45 | return $class; |
| 46 | 46 | } |
| 47 | 47 | } |
@@ -114,8 +114,7 @@ discard block |
||
| 114 | 114 | public function __get($name) |
| 115 | 115 | { |
| 116 | 116 | $method = [$this, 'get' . ucfirst($name)]; |
| 117 | - return is_callable($method) ? call_user_func($method) : |
|
| 118 | - (isset($this->columnDefinition[$name]) ? $this->columnDefinition[$name] : null); |
|
| 117 | + return is_callable($method) ? call_user_func($method) : (isset($this->columnDefinition[$name]) ? $this->columnDefinition[$name] : null); |
|
| 119 | 118 | } |
| 120 | 119 | |
| 121 | 120 | /** |
@@ -183,11 +182,11 @@ discard block |
||
| 183 | 182 | $class = $this->columnDefinition['type']; |
| 184 | 183 | } |
| 185 | 184 | |
| 186 | - if ($class === null || !is_callable([ $class, 'factory' ])) { |
|
| 185 | + if ($class === null || !is_callable([$class, 'factory'])) { |
|
| 187 | 186 | $class = Type\Text::class; |
| 188 | 187 | } |
| 189 | 188 | |
| 190 | - $this->type = call_user_func([ $class, 'factory' ], $this->dbal, $this->columnDefinition); |
|
| 189 | + $this->type = call_user_func([$class, 'factory'], $this->dbal, $this->columnDefinition); |
|
| 191 | 190 | } |
| 192 | 191 | |
| 193 | 192 | return $this->type; |
@@ -89,7 +89,7 @@ |
||
| 89 | 89 | * Escape a date time object for query |
| 90 | 90 | * |
| 91 | 91 | * @param DateTime $value |
| 92 | - * @return mixed |
|
| 92 | + * @return string |
|
| 93 | 93 | */ |
| 94 | 94 | protected function escapeDateTime(DateTime $value) |
| 95 | 95 | { |
@@ -39,6 +39,7 @@ discard block |
||
| 39 | 39 | * RANDOM_KEY_MIN and RANDOM_KEY_MAX (at the time writing this it is 1000000000 and 1000999999). |
| 40 | 40 | * |
| 41 | 41 | * @param Entity ...$entities |
| 42 | + * @param Entity[] $entities |
|
| 42 | 43 | * @return Entity[] |
| 43 | 44 | */ |
| 44 | 45 | public static function completePrimaryKeys(Entity ...$entities) |
@@ -97,6 +98,7 @@ discard block |
||
| 97 | 98 | * |
| 98 | 99 | * @param $class |
| 99 | 100 | * @param Entity ...$entities |
| 101 | + * @param Entity[] $entities |
|
| 100 | 102 | * @return Result|m\MockInterface |
| 101 | 103 | */ |
| 102 | 104 | public function addResult($class, Entity ...$entities) |