@@ -25,7 +25,7 @@ |
||
| 25 | 25 | public function select(...$fields): self |
| 26 | 26 | { |
| 27 | 27 | foreach ($fields as $field) { |
| 28 | - if (! \is_array($field) && ! \is_string($field)) { |
|
| 28 | + if (!\is_array($field) && !\is_string($field)) { |
|
| 29 | 29 | $error = 'Selection should be array (["field" => "alias"]) or string ("field") but %s given'; |
| 30 | 30 | throw new \InvalidArgumentException(\sprintf($error, \gettype($field))); |
| 31 | 31 | } |
@@ -42,7 +42,7 @@ |
||
| 42 | 42 | */ |
| 43 | 43 | public function query(): Query |
| 44 | 44 | { |
| 45 | - if (! $this instanceof EntityRepository) { |
|
| 45 | + if (!$this instanceof EntityRepository) { |
|
| 46 | 46 | $error = 'Could not use %s under non-repository class, but %s given'; |
| 47 | 47 | throw new \LogicException(\sprintf($error, Hydrogen::class, static::class)); |
| 48 | 48 | } |
@@ -120,7 +120,7 @@ |
||
| 120 | 120 | */ |
| 121 | 121 | public function __get(string $key): HigherOrderCollectionProxy |
| 122 | 122 | { |
| 123 | - if (! \in_array($key, static::$proxies, true)) { |
|
| 123 | + if (!\in_array($key, static::$proxies, true)) { |
|
| 124 | 124 | $error = "Property [{$key}] does not exist on this collection instance."; |
| 125 | 125 | throw new \InvalidArgumentException($error); |
| 126 | 126 | } |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | { |
| 28 | 28 | $expression = $this->getDoctrineExpression($having, $builder->expr(), $having->getField()); |
| 29 | 29 | |
| 30 | - yield from $this->extractResult($expression, function ($expr) use ($having, $builder) { |
|
| 30 | + yield from $this->extractResult($expression, function($expr) use ($having, $builder) { |
|
| 31 | 31 | if ($having->isAnd()) { |
| 32 | 32 | $builder->andHaving($expr); |
| 33 | 33 | } else { |
@@ -58,6 +58,6 @@ |
||
| 58 | 58 | { |
| 59 | 59 | $alias = $sqlWalker->getSQLTableAlias($this->table->value, $this->alias->value); |
| 60 | 60 | |
| 61 | - return $alias . '.' . $this->field->value; |
|
| 61 | + return $alias.'.'.$this->field->value; |
|
| 62 | 62 | } |
| 63 | 63 | } |
@@ -72,16 +72,16 @@ |
||
| 72 | 72 | \preg_match('/^([\w\.\:\*]+)[\w\.\:\*\s]*?$/iu', $query, $m); |
| 73 | 73 | if (\count($m)) { |
| 74 | 74 | $wrapper = [\str_replace_first($m[1], '%s', $m[0])]; |
| 75 | - return \array_merge($wrapper, $this->analyzePrefix((string)$m[1])); |
|
| 75 | + return \array_merge($wrapper, $this->analyzePrefix((string) $m[1])); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | \preg_match('/^.+?\(([\w\.\:\*]+).*?$/isu', $query, $m); |
| 79 | 79 | if (\count($m)) { |
| 80 | 80 | $wrapper = [\str_replace_first($m[1], '%s', $m[0])]; |
| 81 | - return \array_merge($wrapper, $this->analyzePrefix((string)$m[1])); |
|
| 81 | + return \array_merge($wrapper, $this->analyzePrefix((string) $m[1])); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - return ['%s', (string)$query, false]; |
|
| 84 | + return ['%s', (string) $query, false]; |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | $processor = $this->getRepository()->getProcessor(); |
| 29 | 29 | |
| 30 | 30 | if (\count($fields)) { |
| 31 | - return \collect($processor->getArrayResult($this))->map(function (array $data) use ($fields) { |
|
| 31 | + return \collect($processor->getArrayResult($this))->map(function(array $data) use ($fields) { |
|
| 32 | 32 | if (isset($data[0]) && \is_array($data[0])) { |
| 33 | 33 | $data = $data[0]; |
| 34 | 34 | } |
@@ -89,22 +89,22 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | switch ($typeOf) { |
| 91 | 91 | case 'callable': |
| 92 | - return function (callable $applicator = null) use ($result) { |
|
| 92 | + return function(callable $applicator = null) use ($result) { |
|
| 93 | 93 | return ($applicator ?? '\\value')($result); |
| 94 | 94 | }; |
| 95 | 95 | |
| 96 | 96 | case 'object': |
| 97 | - return (object)$result; |
|
| 97 | + return (object) $result; |
|
| 98 | 98 | |
| 99 | 99 | case 'array': |
| 100 | 100 | case 'iterable': |
| 101 | - return (array)$result; |
|
| 101 | + return (array) $result; |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - $function = $typeOf . 'val'; |
|
| 104 | + $function = $typeOf.'val'; |
|
| 105 | 105 | |
| 106 | - if (! \function_exists($function)) { |
|
| 107 | - throw new \InvalidArgumentException('Could not cast to type ' . $typeOf); |
|
| 106 | + if (!\function_exists($function)) { |
|
| 107 | + throw new \InvalidArgumentException('Could not cast to type '.$typeOf); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | return $function($result); |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | public function count(?string $field = 'id'): int |
| 119 | 119 | { |
| 120 | - return $this->select('COUNT(' . $field . ') AS __count') |
|
| 120 | + return $this->select('COUNT('.$field.') AS __count') |
|
| 121 | 121 | ->scalar('__count', 'int'); |
| 122 | 122 | } |
| 123 | 123 | |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | public function sum(string $field = null): int |
| 130 | 130 | { |
| 131 | - return $this->select('SUM(' . $field . ') AS __sum') |
|
| 131 | + return $this->select('SUM('.$field.') AS __sum') |
|
| 132 | 132 | ->scalar('__sum', 'int'); |
| 133 | 133 | } |
| 134 | 134 | |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | */ |
| 140 | 140 | public function avg(string $field = null): int |
| 141 | 141 | { |
| 142 | - return $this->select('AVG(' . $field . ') AS __avg') |
|
| 142 | + return $this->select('AVG('.$field.') AS __avg') |
|
| 143 | 143 | ->scalar('__avg', 'int'); |
| 144 | 144 | } |
| 145 | 145 | |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | */ |
| 151 | 151 | public function max(string $field = null): int |
| 152 | 152 | { |
| 153 | - return $this->select('MAX(' . $field . ') AS __max') |
|
| 153 | + return $this->select('MAX('.$field.') AS __max') |
|
| 154 | 154 | ->scalar('__max', 'int'); |
| 155 | 155 | } |
| 156 | 156 | |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | public function min(string $field = null): int |
| 163 | 163 | { |
| 164 | - return $this->select('MIN(' . $field . ') AS __min') |
|
| 164 | + return $this->select('MIN('.$field.') AS __min') |
|
| 165 | 165 | ->scalar('__min', 'int'); |
| 166 | 166 | } |
| 167 | 167 | |
@@ -70,7 +70,7 @@ |
||
| 70 | 70 | private function extract(iterable $result): \Generator |
| 71 | 71 | { |
| 72 | 72 | foreach ($result as $item) { |
| 73 | - if (isset($item[0]) && ! \is_scalar($item[0])) { |
|
| 73 | + if (isset($item[0]) && !\is_scalar($item[0])) { |
|
| 74 | 74 | $entity = \array_shift($item); |
| 75 | 75 | yield $entity => $item; |
| 76 | 76 | } else { |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | $builder->addSelect("RAW('$table', '$alias', '$parent') AS $parent"); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - yield function (iterable $result) use ($association, $selections, $relation) { |
|
| 45 | + yield function(iterable $result) use ($association, $selections, $relation) { |
|
| 46 | 46 | $query = $relation->getQuery(); |
| 47 | 47 | [$table, $alias] = [$this->meta($association['targetEntity'])->getTableName(), $query->getAlias()]; |
| 48 | 48 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | foreach ($selections as $parent => ['relatedTo' => $child, 'values' => $values]) { |
| 56 | 56 | $query->select(["RAW('$table', '$alias', '$child')" => $child]); |
| 57 | - $query = $query->whereIn(':' . $child, $values); |
|
| 57 | + $query = $query->whereIn(':'.$child, $values); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | $this->execute($association['targetEntity'], $query); |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | { |
| 71 | 71 | $association = $metadata->associationMappings[$relation] ?? null; |
| 72 | 72 | |
| 73 | - if (! $association) { |
|
| 73 | + if (!$association) { |
|
| 74 | 74 | $error = 'Invalid relation name "%s" of entity %s'; |
| 75 | 75 | throw new \LogicException(\sprintf($error, $relation, $metadata->name)); |
| 76 | 76 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | { |
| 98 | 98 | $joins = $association['joinColumns'] ?? null; |
| 99 | 99 | |
| 100 | - if (! $joins) { |
|
| 100 | + if (!$joins) { |
|
| 101 | 101 | $error = 'Relation "%s" of entity %s should provide one or more join columns.'; |
| 102 | 102 | throw new \LogicException(\sprintf($error, $association['fieldName'], $association['sourceEntity'])); |
| 103 | 103 | } |