This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /** |
||
4 | * This file is part of the Happyr Doctrine Specification package. |
||
5 | * |
||
6 | * (c) Tobias Nyholm <[email protected]> |
||
7 | * Kacper Gunia <[email protected]> |
||
8 | * Peter Gribanov <[email protected]> |
||
9 | * |
||
10 | * For the full copyright and license information, please view the LICENSE |
||
11 | * file that was distributed with this source code. |
||
12 | */ |
||
13 | |||
14 | namespace Happyr\DoctrineSpecification; |
||
15 | |||
16 | use Happyr\DoctrineSpecification\Filter\Comparison; |
||
17 | use Happyr\DoctrineSpecification\Filter\Filter; |
||
18 | use Happyr\DoctrineSpecification\Filter\In; |
||
19 | use Happyr\DoctrineSpecification\Filter\InstanceOfX; |
||
20 | use Happyr\DoctrineSpecification\Filter\IsNotNull; |
||
21 | use Happyr\DoctrineSpecification\Filter\IsNull; |
||
22 | use Happyr\DoctrineSpecification\Filter\Like; |
||
23 | use Happyr\DoctrineSpecification\Filter\MemberOfX; |
||
24 | use Happyr\DoctrineSpecification\Logic\AndX; |
||
25 | use Happyr\DoctrineSpecification\Logic\Not; |
||
26 | use Happyr\DoctrineSpecification\Logic\OrX; |
||
27 | use Happyr\DoctrineSpecification\Operand\Addition; |
||
28 | use Happyr\DoctrineSpecification\Operand\Alias; |
||
29 | use Happyr\DoctrineSpecification\Operand\BitAnd; |
||
30 | use Happyr\DoctrineSpecification\Operand\BitLeftShift; |
||
31 | use Happyr\DoctrineSpecification\Operand\BitNot; |
||
32 | use Happyr\DoctrineSpecification\Operand\BitOr; |
||
33 | use Happyr\DoctrineSpecification\Operand\BitRightShift; |
||
34 | use Happyr\DoctrineSpecification\Operand\BitXor; |
||
35 | use Happyr\DoctrineSpecification\Operand\CountDistinct; |
||
36 | use Happyr\DoctrineSpecification\Operand\Division; |
||
37 | use Happyr\DoctrineSpecification\Operand\Field; |
||
38 | use Happyr\DoctrineSpecification\Operand\LikePattern; |
||
39 | use Happyr\DoctrineSpecification\Operand\Modulo; |
||
40 | use Happyr\DoctrineSpecification\Operand\Multiplication; |
||
41 | use Happyr\DoctrineSpecification\Operand\Operand; |
||
42 | use Happyr\DoctrineSpecification\Operand\PlatformFunction; |
||
43 | use Happyr\DoctrineSpecification\Operand\Subtraction; |
||
44 | use Happyr\DoctrineSpecification\Operand\Value; |
||
45 | use Happyr\DoctrineSpecification\Operand\Values; |
||
46 | use Happyr\DoctrineSpecification\Query\AddSelect; |
||
47 | use Happyr\DoctrineSpecification\Query\Distinct; |
||
48 | use Happyr\DoctrineSpecification\Query\GroupBy; |
||
49 | use Happyr\DoctrineSpecification\Query\IndexBy; |
||
50 | use Happyr\DoctrineSpecification\Query\InnerJoin; |
||
51 | use Happyr\DoctrineSpecification\Query\Join; |
||
52 | use Happyr\DoctrineSpecification\Query\LeftJoin; |
||
53 | use Happyr\DoctrineSpecification\Query\Limit; |
||
54 | use Happyr\DoctrineSpecification\Query\Offset; |
||
55 | use Happyr\DoctrineSpecification\Query\OrderBy; |
||
56 | use Happyr\DoctrineSpecification\Query\QueryModifier; |
||
57 | use Happyr\DoctrineSpecification\Query\Select; |
||
58 | use Happyr\DoctrineSpecification\Query\Selection\SelectAs; |
||
59 | use Happyr\DoctrineSpecification\Query\Selection\SelectEntity; |
||
60 | use Happyr\DoctrineSpecification\Query\Selection\SelectHiddenAs; |
||
61 | use Happyr\DoctrineSpecification\Query\Slice; |
||
62 | use Happyr\DoctrineSpecification\Result\AsArray; |
||
63 | use Happyr\DoctrineSpecification\Result\AsScalar; |
||
64 | use Happyr\DoctrineSpecification\Result\AsSingleScalar; |
||
65 | use Happyr\DoctrineSpecification\Result\Cache; |
||
66 | use Happyr\DoctrineSpecification\Result\RoundDateTime; |
||
67 | use Happyr\DoctrineSpecification\Specification\CountOf; |
||
68 | use Happyr\DoctrineSpecification\Specification\Having; |
||
69 | |||
70 | /** |
||
71 | * Factory class for the specifications. |
||
72 | * |
||
73 | * @method static PlatformFunction CONCAT($str1, $str2) |
||
74 | * @method static PlatformFunction SUBSTRING($str, $start, $length = null) Return substring of given string. |
||
75 | * @method static PlatformFunction TRIM($str) Trim the string by the given trim char, defaults to whitespaces. |
||
76 | * @method static PlatformFunction LOWER($str) Returns the string lowercased. |
||
77 | * @method static PlatformFunction UPPER($str) Return the upper-case of the given string. |
||
78 | * @method static PlatformFunction IDENTITY($expression, $fieldMapping = null) Retrieve the foreign key column of association of the owning side |
||
79 | * @method static PlatformFunction LENGTH($str) Returns the length of the given string |
||
80 | * @method static PlatformFunction LOCATE($needle, $haystack, $offset = 0) Locate the first occurrence of the substring in the string. |
||
81 | * @method static PlatformFunction ABS($expression) |
||
82 | * @method static PlatformFunction SQRT($q) Return the square-root of q. |
||
83 | * @method static PlatformFunction MOD($a, $b) Return a MOD b. |
||
84 | * @method static PlatformFunction SIZE($collection) Return the number of elements in the specified collection |
||
85 | * @method static PlatformFunction DATE_DIFF($date1, $date2) Calculate the difference in days between date1-date2. |
||
86 | * @method static PlatformFunction BIT_AND($a, $b) |
||
87 | * @method static PlatformFunction BIT_OR($a, $b) |
||
88 | * @method static PlatformFunction MIN($a) |
||
89 | * @method static PlatformFunction MAX($a) |
||
90 | * @method static PlatformFunction AVG($a) |
||
91 | * @method static PlatformFunction SUM($a) |
||
92 | * @method static PlatformFunction COUNT($a) |
||
93 | * @method static PlatformFunction CURRENT_DATE() Return the current date |
||
94 | * @method static PlatformFunction CURRENT_TIME() Returns the current time |
||
95 | * @method static PlatformFunction CURRENT_TIMESTAMP() Returns a timestamp of the current date and time. |
||
96 | * @method static PlatformFunction DATE_ADD($date, $days, $unit) Add the number of days to a given date. (Supported units are DAY, MONTH) |
||
97 | * @method static PlatformFunction DATE_SUB($date, $days, $unit) Substract the number of days from a given date. (Supported units are DAY, MONTH) |
||
98 | */ |
||
99 | class Spec |
||
100 | { |
||
101 | /** |
||
102 | * @param string $name |
||
103 | * @param array $arguments |
||
104 | * |
||
105 | * @return PlatformFunction |
||
106 | */ |
||
107 | public static function __callStatic($name, array $arguments = []) |
||
108 | { |
||
109 | // allow use array in arguments of static function |
||
110 | // Spec::DATE_DIFF([$date1, $date2]); |
||
111 | // is equal |
||
112 | // Spec::DATE_DIFF($date1, $date2); |
||
113 | if (1 === count($arguments) && is_array(current($arguments))) { |
||
114 | $arguments = current($arguments); |
||
115 | } |
||
116 | |||
117 | return self::fun($name, $arguments); |
||
118 | } |
||
119 | |||
120 | /* |
||
121 | * Logic |
||
122 | */ |
||
123 | |||
124 | /** |
||
125 | * @return AndX |
||
126 | */ |
||
127 | View Code Duplication | public static function andX() |
|
128 | { |
||
129 | // NEXT_MAJOR: use variable-length argument lists (...$specs) |
||
130 | $spec = (new \ReflectionClass(AndX::class))->newInstanceArgs(func_get_args()); |
||
131 | |||
132 | // hook for PHPStan |
||
133 | if (!($spec instanceof AndX)) { |
||
134 | throw new \RuntimeException( |
||
135 | sprintf('The specification must be an instance of "%s", but got "%s".', AndX::class, get_class($spec)) |
||
136 | ); |
||
137 | } |
||
138 | |||
139 | return $spec; |
||
140 | } |
||
141 | |||
142 | /** |
||
143 | * @return OrX |
||
144 | */ |
||
145 | View Code Duplication | public static function orX() |
|
146 | { |
||
147 | // NEXT_MAJOR: use variable-length argument lists (...$specs) |
||
148 | $spec = (new \ReflectionClass(OrX::class))->newInstanceArgs(func_get_args()); |
||
149 | |||
150 | // hook for PHPStan |
||
151 | if (!($spec instanceof OrX)) { |
||
152 | throw new \RuntimeException( |
||
153 | sprintf('The specification must be an instance of "%s", but got "%s".', OrX::class, get_class($spec)) |
||
154 | ); |
||
155 | } |
||
156 | |||
157 | return $spec; |
||
158 | } |
||
159 | |||
160 | /** |
||
161 | * @param Filter $spec |
||
162 | * |
||
163 | * @return Not |
||
164 | */ |
||
165 | public static function not(Filter $spec) |
||
166 | { |
||
167 | return new Not($spec); |
||
168 | } |
||
169 | |||
170 | /* |
||
171 | * Query modifier |
||
172 | */ |
||
173 | |||
174 | /** |
||
175 | * @param string $field |
||
176 | * @param string $newAlias |
||
177 | * @param string|null $dqlAlias |
||
178 | * |
||
179 | * @return Join |
||
180 | */ |
||
181 | public static function join($field, $newAlias, $dqlAlias = null) |
||
182 | { |
||
183 | return new Join($field, $newAlias, $dqlAlias); |
||
184 | } |
||
185 | |||
186 | /** |
||
187 | * @param string $field |
||
188 | * @param string $newAlias |
||
189 | * @param string|null $dqlAlias |
||
190 | * |
||
191 | * @return LeftJoin |
||
192 | */ |
||
193 | public static function leftJoin($field, $newAlias, $dqlAlias = null) |
||
194 | { |
||
195 | return new LeftJoin($field, $newAlias, $dqlAlias); |
||
196 | } |
||
197 | |||
198 | /** |
||
199 | * @param string $field |
||
200 | * @param string $newAlias |
||
201 | * @param string|null $dqlAlias |
||
202 | * |
||
203 | * @return InnerJoin |
||
204 | */ |
||
205 | public static function innerJoin($field, $newAlias, $dqlAlias = null) |
||
206 | { |
||
207 | return new InnerJoin($field, $newAlias, $dqlAlias); |
||
208 | } |
||
209 | |||
210 | /** |
||
211 | * @param Field|string $field |
||
212 | * @param string|null $dqlAlias |
||
213 | * |
||
214 | * @return IndexBy |
||
215 | */ |
||
216 | public static function indexBy($field, $dqlAlias = null) |
||
217 | { |
||
218 | return new IndexBy($field, $dqlAlias); |
||
219 | } |
||
220 | |||
221 | /** |
||
222 | * @param int $count |
||
223 | * |
||
224 | * @return Limit |
||
225 | */ |
||
226 | public static function limit($count) |
||
227 | { |
||
228 | return new Limit($count); |
||
229 | } |
||
230 | |||
231 | /** |
||
232 | * @param int $count |
||
233 | * |
||
234 | * @return Offset |
||
235 | */ |
||
236 | public static function offset($count) |
||
237 | { |
||
238 | return new Offset($count); |
||
239 | } |
||
240 | |||
241 | /** |
||
242 | * @param int $sliceSize |
||
243 | * @param int $sliceNumber |
||
244 | * |
||
245 | * @return Slice |
||
246 | */ |
||
247 | public static function slice($sliceSize, $sliceNumber = 0) |
||
248 | { |
||
249 | return new Slice($sliceSize, $sliceNumber); |
||
250 | } |
||
251 | |||
252 | /** |
||
253 | * @param Field|Alias|string $field |
||
254 | * @param string $order |
||
255 | * @param string|null $dqlAlias |
||
256 | * |
||
257 | * @return OrderBy |
||
258 | */ |
||
259 | public static function orderBy($field, $order = 'ASC', $dqlAlias = null) |
||
260 | { |
||
261 | return new OrderBy($field, $order, $dqlAlias); |
||
262 | } |
||
263 | |||
264 | /** |
||
265 | * @param Field|Alias|string $field |
||
266 | * @param string|null $dqlAlias |
||
267 | * |
||
268 | * @return GroupBy |
||
269 | */ |
||
270 | public static function groupBy($field, $dqlAlias = null) |
||
271 | { |
||
272 | return new GroupBy($field, $dqlAlias); |
||
273 | } |
||
274 | |||
275 | /** |
||
276 | * @return Distinct |
||
277 | */ |
||
278 | public static function distinct() |
||
279 | { |
||
280 | return new Distinct(); |
||
281 | } |
||
282 | |||
283 | /* |
||
284 | * Selection |
||
285 | */ |
||
286 | |||
287 | /** |
||
288 | * @param mixed $field |
||
289 | * |
||
290 | * @return Select |
||
291 | */ |
||
292 | public static function select($field) |
||
0 ignored issues
–
show
|
|||
293 | { |
||
294 | // NEXT_MAJOR: use variable-length argument lists (...$fields) |
||
295 | return new Select(func_get_args()); |
||
296 | } |
||
297 | |||
298 | /** |
||
299 | * @param mixed $field |
||
300 | * |
||
301 | * @return AddSelect |
||
302 | */ |
||
303 | public static function addSelect($field) |
||
0 ignored issues
–
show
|
|||
304 | { |
||
305 | // NEXT_MAJOR: use variable-length argument lists (...$fields) |
||
306 | return new AddSelect(func_get_args()); |
||
307 | } |
||
308 | |||
309 | /** |
||
310 | * @param string $dqlAlias |
||
311 | * |
||
312 | * @return SelectEntity |
||
313 | */ |
||
314 | public static function selectEntity($dqlAlias) |
||
315 | { |
||
316 | return new SelectEntity($dqlAlias); |
||
317 | } |
||
318 | |||
319 | /** |
||
320 | * @param Filter|Operand|string $expression |
||
321 | * @param string $alias |
||
322 | * |
||
323 | * @return SelectAs |
||
324 | */ |
||
325 | public static function selectAs($expression, $alias) |
||
326 | { |
||
327 | return new SelectAs($expression, $alias); |
||
328 | } |
||
329 | |||
330 | /** |
||
331 | * @param Filter|Operand|string $expression |
||
332 | * @param string $alias |
||
333 | * |
||
334 | * @return SelectHiddenAs |
||
335 | */ |
||
336 | public static function selectHiddenAs($expression, $alias) |
||
337 | { |
||
338 | return new SelectHiddenAs($expression, $alias); |
||
339 | } |
||
340 | |||
341 | /* |
||
342 | * Result modifier |
||
343 | */ |
||
344 | |||
345 | /** |
||
346 | * @return AsArray |
||
347 | */ |
||
348 | public static function asArray() |
||
349 | { |
||
350 | return new AsArray(); |
||
351 | } |
||
352 | |||
353 | /** |
||
354 | * @return AsSingleScalar |
||
355 | */ |
||
356 | public static function asSingleScalar() |
||
357 | { |
||
358 | return new AsSingleScalar(); |
||
359 | } |
||
360 | |||
361 | /** |
||
362 | * @return AsScalar |
||
363 | */ |
||
364 | public static function asScalar() |
||
365 | { |
||
366 | return new AsScalar(); |
||
367 | } |
||
368 | |||
369 | /** |
||
370 | * @param int $cacheLifetime How many seconds the cached entry is valid |
||
371 | * |
||
372 | * @return Cache |
||
373 | */ |
||
374 | public static function cache($cacheLifetime) |
||
375 | { |
||
376 | return new Cache($cacheLifetime); |
||
377 | } |
||
378 | |||
379 | /** |
||
380 | * @param int $roundSeconds How may seconds to round time |
||
381 | * |
||
382 | * @return RoundDateTime |
||
383 | */ |
||
384 | public static function roundDateTimeParams($roundSeconds) |
||
385 | { |
||
386 | return new RoundDateTime($roundSeconds); |
||
387 | } |
||
388 | |||
389 | /* |
||
390 | * Filters |
||
391 | */ |
||
392 | |||
393 | /** |
||
394 | * @param Operand|string $field |
||
395 | * @param string|null $dqlAlias |
||
396 | * |
||
397 | * @return IsNull |
||
398 | */ |
||
399 | public static function isNull($field, $dqlAlias = null) |
||
400 | { |
||
401 | return new IsNull($field, $dqlAlias); |
||
402 | } |
||
403 | |||
404 | /** |
||
405 | * @param Operand|string $field |
||
406 | * @param string|null $dqlAlias |
||
407 | * |
||
408 | * @return IsNotNull |
||
409 | */ |
||
410 | public static function isNotNull($field, $dqlAlias = null) |
||
411 | { |
||
412 | return new IsNotNull($field, $dqlAlias); |
||
413 | } |
||
414 | |||
415 | /** |
||
416 | * Make sure the $field has a value equals to $value. |
||
417 | * |
||
418 | * @param Operand|string $field |
||
419 | * @param Operand|mixed $value |
||
420 | * @param string|null $dqlAlias |
||
421 | * |
||
422 | * @return In |
||
423 | */ |
||
424 | public static function in($field, $value, $dqlAlias = null) |
||
425 | { |
||
426 | return new In($field, $value, $dqlAlias); |
||
427 | } |
||
428 | |||
429 | /** |
||
430 | * @param Operand|string $field |
||
431 | * @param Operand|mixed $value |
||
432 | * @param string|null $dqlAlias |
||
433 | * |
||
434 | * @return Not |
||
435 | */ |
||
436 | public static function notIn($field, $value, $dqlAlias = null) |
||
437 | { |
||
438 | return new Not(new In($field, $value, $dqlAlias)); |
||
439 | } |
||
440 | |||
441 | /** |
||
442 | * @param Operand|string $field |
||
443 | * @param Operand|mixed $value |
||
444 | * @param string|null $dqlAlias |
||
445 | * |
||
446 | * @return Comparison |
||
447 | */ |
||
448 | public static function eq($field, $value, $dqlAlias = null) |
||
449 | { |
||
450 | return new Comparison(Comparison::EQ, $field, $value, $dqlAlias); |
||
451 | } |
||
452 | |||
453 | /** |
||
454 | * @param Operand|string $field |
||
455 | * @param Operand|mixed $value |
||
456 | * @param string|null $dqlAlias |
||
457 | * |
||
458 | * @return Comparison |
||
459 | */ |
||
460 | public static function neq($field, $value, $dqlAlias = null) |
||
461 | { |
||
462 | return new Comparison(Comparison::NEQ, $field, $value, $dqlAlias); |
||
463 | } |
||
464 | |||
465 | /** |
||
466 | * @param Operand|string $field |
||
467 | * @param Operand|mixed $value |
||
468 | * @param string|null $dqlAlias |
||
469 | * |
||
470 | * @return Comparison |
||
471 | */ |
||
472 | public static function lt($field, $value, $dqlAlias = null) |
||
473 | { |
||
474 | return new Comparison(Comparison::LT, $field, $value, $dqlAlias); |
||
475 | } |
||
476 | |||
477 | /** |
||
478 | * @param Operand|string $field |
||
479 | * @param Operand|mixed $value |
||
480 | * @param string|null $dqlAlias |
||
481 | * |
||
482 | * @return Comparison |
||
483 | */ |
||
484 | public static function lte($field, $value, $dqlAlias = null) |
||
485 | { |
||
486 | return new Comparison(Comparison::LTE, $field, $value, $dqlAlias); |
||
487 | } |
||
488 | |||
489 | /** |
||
490 | * @param Operand|string $field |
||
491 | * @param Operand|mixed $value |
||
492 | * @param string|null $dqlAlias |
||
493 | * |
||
494 | * @return Comparison |
||
495 | */ |
||
496 | public static function gt($field, $value, $dqlAlias = null) |
||
497 | { |
||
498 | return new Comparison(Comparison::GT, $field, $value, $dqlAlias); |
||
499 | } |
||
500 | |||
501 | /** |
||
502 | * @param Operand|string $field |
||
503 | * @param Operand|mixed $value |
||
504 | * @param string|null $dqlAlias |
||
505 | * |
||
506 | * @return Comparison |
||
507 | */ |
||
508 | public static function gte($field, $value, $dqlAlias = null) |
||
509 | { |
||
510 | return new Comparison(Comparison::GTE, $field, $value, $dqlAlias); |
||
511 | } |
||
512 | |||
513 | /** |
||
514 | * @param Operand|string $field |
||
515 | * @param LikePattern|string $value |
||
516 | * @param string $format |
||
517 | * @param string|null $dqlAlias |
||
518 | * |
||
519 | * @return Like |
||
520 | */ |
||
521 | public static function like($field, $value, $format = Like::CONTAINS, $dqlAlias = null) |
||
522 | { |
||
523 | return new Like($field, $value, $format, $dqlAlias); |
||
524 | } |
||
525 | |||
526 | /** |
||
527 | * @param string $value |
||
528 | * @param string|null $dqlAlias |
||
529 | * |
||
530 | * @return InstanceOfX |
||
531 | */ |
||
532 | public static function instanceOfX($value, $dqlAlias = null) |
||
533 | { |
||
534 | return new InstanceOfX($value, $dqlAlias); |
||
535 | } |
||
536 | |||
537 | /** |
||
538 | * @param Operand|string $value |
||
539 | * @param Operand|string $field |
||
540 | * @param string|null $dqlAlias |
||
541 | * |
||
542 | * @return MemberOfX |
||
543 | */ |
||
544 | public static function memberOfX($value, $field, $dqlAlias = null) |
||
545 | { |
||
546 | return new MemberOfX($value, $field, $dqlAlias); |
||
547 | } |
||
548 | |||
549 | /* |
||
550 | * Specifications |
||
551 | */ |
||
552 | |||
553 | /** |
||
554 | * @param Filter|QueryModifier $spec |
||
555 | * |
||
556 | * @return CountOf |
||
557 | */ |
||
558 | public static function countOf($spec) |
||
559 | { |
||
560 | return new CountOf($spec); |
||
561 | } |
||
562 | |||
563 | /** |
||
564 | * @param Filter|QueryModifier|string $spec |
||
565 | * |
||
566 | * @return Having |
||
567 | */ |
||
568 | public static function having($spec) |
||
569 | { |
||
570 | if (!($spec instanceof Filter)) { |
||
571 | @trigger_error('Using "'.(is_object($spec) ? get_class($spec) : gettype($spec)).'" as argument in '.__METHOD__.' method is deprecated since version 1.1 and will not be possible in 2.0.', E_USER_DEPRECATED); |
||
572 | } |
||
573 | |||
574 | // NEXT_MAJOR: use here \Happyr\DoctrineSpecification\Query\Having |
||
575 | |||
576 | return new Having($spec); |
||
577 | } |
||
578 | |||
579 | /* |
||
580 | * Operands |
||
581 | */ |
||
582 | |||
583 | /** |
||
584 | * @param string $fieldName |
||
585 | * @param string|null $dqlAlias |
||
586 | * |
||
587 | * @return Field |
||
588 | */ |
||
589 | public static function field($fieldName, $dqlAlias = null) |
||
590 | { |
||
591 | return new Field($fieldName, $dqlAlias); |
||
592 | } |
||
593 | |||
594 | /** |
||
595 | * @param mixed $value |
||
596 | * @param int|string|null $valueType |
||
597 | * |
||
598 | * @return Value |
||
599 | */ |
||
600 | public static function value($value, $valueType = null) |
||
601 | { |
||
602 | return new Value($value, $valueType); |
||
603 | } |
||
604 | |||
605 | /** |
||
606 | * @param array $values |
||
607 | * @param int|string|null $valueType |
||
608 | * |
||
609 | * @return Values |
||
610 | */ |
||
611 | public static function values($values, $valueType = null) |
||
612 | { |
||
613 | return new Values($values, $valueType); |
||
614 | } |
||
615 | |||
616 | /** |
||
617 | * @param string $value |
||
618 | * @param string $format |
||
619 | * |
||
620 | * @return LikePattern |
||
621 | */ |
||
622 | public static function likePattern($value, $format = LikePattern::CONTAINS) |
||
623 | { |
||
624 | return new LikePattern($value, $format); |
||
625 | } |
||
626 | |||
627 | /** |
||
628 | * @param Operand|string $field |
||
629 | * |
||
630 | * @return CountDistinct |
||
631 | */ |
||
632 | public static function countDistinct($field) |
||
633 | { |
||
634 | return new CountDistinct($field); |
||
635 | } |
||
636 | |||
637 | /* |
||
638 | * Arithmetic operands |
||
639 | */ |
||
640 | |||
641 | /** |
||
642 | * @param Operand|string $field |
||
643 | * @param Operand|mixed $value |
||
644 | * |
||
645 | * @return Addition |
||
646 | */ |
||
647 | public static function add($field, $value) |
||
648 | { |
||
649 | return new Addition($field, $value); |
||
650 | } |
||
651 | |||
652 | /** |
||
653 | * @param Operand|string $field |
||
654 | * @param Operand|mixed $value |
||
655 | * |
||
656 | * @return Subtraction |
||
657 | */ |
||
658 | public static function sub($field, $value) |
||
659 | { |
||
660 | return new Subtraction($field, $value); |
||
661 | } |
||
662 | |||
663 | /** |
||
664 | * @param Operand|string $field |
||
665 | * @param Operand|mixed $value |
||
666 | * |
||
667 | * @return Multiplication |
||
668 | */ |
||
669 | public static function mul($field, $value) |
||
670 | { |
||
671 | return new Multiplication($field, $value); |
||
672 | } |
||
673 | |||
674 | /** |
||
675 | * @param Operand|string $field |
||
676 | * @param Operand|mixed $value |
||
677 | * |
||
678 | * @return Division |
||
679 | */ |
||
680 | public static function div($field, $value) |
||
681 | { |
||
682 | return new Division($field, $value); |
||
683 | } |
||
684 | |||
685 | /** |
||
686 | * @deprecated This method is deprecated since version 1.1 and will be removed in 2.0, use Spec::MOD() instead. |
||
687 | * |
||
688 | * @param Operand|string $field |
||
689 | * @param Operand|mixed $value |
||
690 | * |
||
691 | * @return Modulo |
||
692 | */ |
||
693 | public static function mod($field, $value) |
||
694 | { |
||
695 | return new Modulo($field, $value); |
||
696 | } |
||
697 | |||
698 | /* |
||
699 | * Bitwise operands |
||
700 | */ |
||
701 | |||
702 | /** |
||
703 | * @deprecated This method is deprecated since version 1.1 and will be removed in 2.0, use "Spec::BIT_AND($a, $b)" instead. |
||
704 | * |
||
705 | * @param Operand|string $field |
||
706 | * @param Operand|mixed $value |
||
707 | * |
||
708 | * @return BitAnd |
||
709 | */ |
||
710 | public static function bAnd($field, $value) |
||
711 | { |
||
712 | return new BitAnd($field, $value); |
||
713 | } |
||
714 | |||
715 | /** |
||
716 | * @deprecated This method is deprecated since version 1.1 and will be removed in 2.0, use "Spec::BIT_OR($a, $b)" instead. |
||
717 | * |
||
718 | * @param Operand|string $field |
||
719 | * @param Operand|mixed $value |
||
720 | * |
||
721 | * @return BitOr |
||
722 | */ |
||
723 | public static function bOr($field, $value) |
||
724 | { |
||
725 | return new BitOr($field, $value); |
||
726 | } |
||
727 | |||
728 | /** |
||
729 | * @deprecated This method is deprecated since version 1.1 and will be removed in 2.0. |
||
730 | * |
||
731 | * @param Operand|string $field |
||
732 | * @param Operand|mixed $value |
||
733 | * |
||
734 | * @return BitXor |
||
735 | */ |
||
736 | public static function bXor($field, $value) |
||
737 | { |
||
738 | return new BitXor($field, $value); |
||
739 | } |
||
740 | |||
741 | /** |
||
742 | * @deprecated This method is deprecated since version 1.1 and will be removed in 2.0. |
||
743 | * |
||
744 | * @param Operand|string $field |
||
745 | * @param Operand|mixed $value |
||
746 | * |
||
747 | * @return BitLeftShift |
||
748 | */ |
||
749 | public static function bLs($field, $value) |
||
750 | { |
||
751 | return new BitLeftShift($field, $value); |
||
752 | } |
||
753 | |||
754 | /** |
||
755 | * @deprecated This method is deprecated since version 1.1 and will be removed in 2.0. |
||
756 | * |
||
757 | * @param Operand|string $field |
||
758 | * @param Operand|mixed $value |
||
759 | * |
||
760 | * @return BitRightShift |
||
761 | */ |
||
762 | public static function bRs($field, $value) |
||
763 | { |
||
764 | return new BitRightShift($field, $value); |
||
765 | } |
||
766 | |||
767 | /** |
||
768 | * @deprecated This method is deprecated since version 1.1 and will be removed in 2.0. |
||
769 | * |
||
770 | * @param Operand|string $field |
||
771 | * |
||
772 | * @return BitNot |
||
773 | */ |
||
774 | public static function bNot($field) |
||
775 | { |
||
776 | return new BitNot($field); |
||
777 | } |
||
778 | |||
779 | /** |
||
780 | * Call DQL function. |
||
781 | * |
||
782 | * Usage: |
||
783 | * Spec::fun('CURRENT_DATE') |
||
784 | * Spec::fun('DATE_DIFF', $date1, $date2) |
||
785 | * Spec::fun('DATE_DIFF', [$date1, $date2]) |
||
786 | * |
||
787 | * @param string $functionName |
||
788 | * @param mixed $arguments |
||
789 | * |
||
790 | * @return PlatformFunction |
||
791 | */ |
||
792 | public static function fun($functionName, $arguments = []) |
||
793 | { |
||
794 | // NEXT_MAJOR: use variable-length argument lists ($functionName, ...$arguments) |
||
795 | if (2 === func_num_args()) { |
||
796 | $arguments = (array) $arguments; |
||
797 | } else { |
||
798 | $arguments = func_get_args(); |
||
799 | $functionName = array_shift($arguments); |
||
800 | } |
||
801 | |||
802 | return new PlatformFunction($functionName, $arguments); |
||
803 | } |
||
804 | |||
805 | /** |
||
806 | * @param string $alias |
||
807 | * |
||
808 | * @return Alias |
||
809 | */ |
||
810 | public static function alias($alias) |
||
811 | { |
||
812 | return new Alias($alias); |
||
813 | } |
||
814 | } |
||
815 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.