@@ -23,7 +23,7 @@ |
||
23 | 23 | * }, ...); |
24 | 24 | * </code> |
25 | 25 | */ |
26 | - if (! \defined('_')) { |
|
26 | + if (!\defined('_')) { |
|
27 | 27 | \define('_', \RDS\Hydrogen\Collection\HigherOrderCollectionProxy::PATTERN); |
28 | 28 | } |
29 | 29 | } |
@@ -64,6 +64,6 @@ |
||
64 | 64 | */ |
65 | 65 | public function isDesc(): bool |
66 | 66 | { |
67 | - return ! $this->asc; |
|
67 | + return !$this->asc; |
|
68 | 68 | } |
69 | 69 | } |
@@ -34,6 +34,7 @@ discard block |
||
34 | 34 | |
35 | 35 | /** |
36 | 36 | * @param string ...$fields |
37 | + * @param string[] $fields |
|
37 | 38 | * @return Query|$this|self |
38 | 39 | */ |
39 | 40 | public function asc(string ...$fields): self |
@@ -70,6 +71,7 @@ discard block |
||
70 | 71 | |
71 | 72 | /** |
72 | 73 | * @param string ...$fields |
74 | + * @param string[] $fields |
|
73 | 75 | * @return Query|$this|self |
74 | 76 | */ |
75 | 77 | public function desc(string ...$fields): self |
@@ -62,7 +62,7 @@ |
||
62 | 62 | return \iterator_to_array($value); |
63 | 63 | |
64 | 64 | case \is_object($value) && \method_exists($value, '__toString'): |
65 | - return (string)$value; |
|
65 | + return (string) $value; |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | return $value; |
@@ -40,7 +40,7 @@ |
||
40 | 40 | } |
41 | 41 | |
42 | 42 | $error = 'Relation should be string ("relation_name") '. |
43 | - 'or array (["relation" => function]), ' . |
|
43 | + 'or array (["relation" => function]), '. |
|
44 | 44 | 'but %s given'; |
45 | 45 | |
46 | 46 | throw new \InvalidArgumentException(\sprintf($error, \gettype($relation))); |
@@ -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 | } |
@@ -21,6 +21,7 @@ discard block |
||
21 | 21 | { |
22 | 22 | /** |
23 | 23 | * @param string ...$fields |
24 | + * @param string[] $fields |
|
24 | 25 | * @return object[]|iterable |
25 | 26 | */ |
26 | 27 | public function get(string ...$fields): iterable |
@@ -167,6 +168,7 @@ discard block |
||
167 | 168 | |
168 | 169 | /** |
169 | 170 | * @param string ...$fields |
171 | + * @param string[] $fields |
|
170 | 172 | * @return Collection |
171 | 173 | */ |
172 | 174 | public function collect(string ...$fields): Collection |
@@ -9,7 +9,6 @@ |
||
9 | 9 | |
10 | 10 | namespace RDS\Hydrogen\Query; |
11 | 11 | |
12 | -use Illuminate\Support\Arr; |
|
13 | 12 | use RDS\Hydrogen\Query; |
14 | 13 | use RDS\Hydrogen\Collection\Collection; |
15 | 14 |
@@ -75,25 +75,25 @@ discard block |
||
75 | 75 | |
76 | 76 | switch ($typeOf) { |
77 | 77 | case 'callable': |
78 | - return function (callable $applicator = null) use ($result) { |
|
78 | + return function(callable $applicator = null) use ($result) { |
|
79 | 79 | return ($applicator ?? '\\value')($result); |
80 | 80 | }; |
81 | 81 | |
82 | 82 | case 'object': |
83 | - return (object)$result; |
|
83 | + return (object) $result; |
|
84 | 84 | |
85 | 85 | case 'array': |
86 | 86 | case 'iterable': |
87 | - return (array)$result; |
|
87 | + return (array) $result; |
|
88 | 88 | |
89 | 89 | case 'string': |
90 | - return (string)$result; |
|
90 | + return (string) $result; |
|
91 | 91 | } |
92 | 92 | |
93 | - $function = $typeOf . 'val'; |
|
93 | + $function = $typeOf.'val'; |
|
94 | 94 | |
95 | - if (! \function_exists($function)) { |
|
96 | - throw new \InvalidArgumentException('Could not cast to type ' . $typeOf); |
|
95 | + if (!\function_exists($function)) { |
|
96 | + throw new \InvalidArgumentException('Could not cast to type '.$typeOf); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | return $function($result); |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | } |
112 | 112 | |
113 | 113 | return $this |
114 | - ->select('COUNT(' . $field . ') AS __count') |
|
114 | + ->select('COUNT('.$field.') AS __count') |
|
115 | 115 | ->scalar('__count', 'int'); |
116 | 116 | } |
117 | 117 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | public function sum(string $field = null): int |
124 | 124 | { |
125 | 125 | return $this |
126 | - ->select('SUM(' . $field . ') AS __sum') |
|
126 | + ->select('SUM('.$field.') AS __sum') |
|
127 | 127 | ->scalar('__sum', 'int'); |
128 | 128 | } |
129 | 129 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | public function avg(string $field = null): int |
136 | 136 | { |
137 | 137 | return $this |
138 | - ->select('AVG(' . $field . ') AS __avg') |
|
138 | + ->select('AVG('.$field.') AS __avg') |
|
139 | 139 | ->scalar('__avg', 'int'); |
140 | 140 | } |
141 | 141 | |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | public function max(string $field = null): int |
148 | 148 | { |
149 | 149 | return $this |
150 | - ->select('MAX(' . $field . ') AS __max') |
|
150 | + ->select('MAX('.$field.') AS __max') |
|
151 | 151 | ->scalar('__max', 'int'); |
152 | 152 | } |
153 | 153 | |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | public function min(string $field = null): int |
160 | 160 | { |
161 | 161 | return $this |
162 | - ->select('MIN(' . $field . ') AS __min') |
|
162 | + ->select('MIN('.$field.') AS __min') |
|
163 | 163 | ->scalar('__min', 'int'); |
164 | 164 | } |
165 | 165 |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | /** |
80 | 80 | * @param Lexer $lexer |
81 | - * @return \Generator|string[] |
|
81 | + * @return \Generator |
|
82 | 82 | */ |
83 | 83 | private function analyse(Lexer $lexer): \Generator |
84 | 84 | { |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
185 | - * @return iterable|Field[] |
|
185 | + * @return \Generator |
|
186 | 186 | */ |
187 | 187 | public function getIterator(): iterable |
188 | 188 | { |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $before = \substr($query, 0, $analyzed->getReturn()); |
74 | 74 | $after = \substr($query, $analyzed->getReturn() + \max(0, $haystack - 1)); |
75 | 75 | |
76 | - $this->wrapper = $before . '%s' . $after; |
|
76 | + $this->wrapper = $before.'%s'.$after; |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | - return (int)$offset; |
|
120 | + return (int) $offset; |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |