|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace LaravelFreelancerNL\FluentAQL\Clauses; |
|
6
|
|
|
|
|
7
|
|
|
use LaravelFreelancerNL\FluentAQL\Expressions\Expression; |
|
8
|
|
|
use LaravelFreelancerNL\FluentAQL\Expressions\ExpressionInterface; |
|
9
|
|
|
use LaravelFreelancerNL\FluentAQL\QueryBuilder; |
|
10
|
|
|
|
|
11
|
|
|
class ForClause extends Clause |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* @var array<string|Expression> |
|
15
|
|
|
*/ |
|
16
|
|
|
protected array $variables; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @var array<mixed>|Expression|ExpressionInterface|QueryBuilder|string|null |
|
20
|
|
|
*/ |
|
21
|
|
|
protected array|Expression|ExpressionInterface|QueryBuilder|string|null $in; |
|
|
|
|
|
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @param array<string|Expression> $variables |
|
25
|
|
|
* @param array<mixed>|string|QueryBuilder|Expression|null $in |
|
26
|
|
|
*/ |
|
27
|
24 |
|
public function __construct( |
|
28
|
|
|
array $variables, |
|
29
|
|
|
array|string|QueryBuilder|Expression $in = null |
|
30
|
|
|
) { |
|
31
|
24 |
|
parent::__construct(); |
|
32
|
|
|
|
|
33
|
24 |
|
$this->variables = $variables; |
|
34
|
|
|
|
|
35
|
24 |
|
$this->in = $in; |
|
36
|
24 |
|
} |
|
37
|
|
|
|
|
38
|
24 |
|
public function compile(QueryBuilder $queryBuilder): string |
|
39
|
|
|
{ |
|
40
|
24 |
|
$variables = []; |
|
41
|
24 |
|
foreach ($this->variables as $key => $value) { |
|
42
|
24 |
|
$variables[$key] = $queryBuilder->normalizeArgument($value, 'Variable'); |
|
43
|
24 |
|
$queryBuilder->registerVariable($variables[$key]->compile($queryBuilder)); |
|
44
|
|
|
} |
|
45
|
24 |
|
$variableExpression = array_map(function ($variable) use ($queryBuilder) { |
|
46
|
24 |
|
return $variable->compile($queryBuilder); |
|
47
|
24 |
|
}, $variables); |
|
48
|
|
|
|
|
49
|
24 |
|
$variableExpression = implode(', ', $variableExpression); |
|
50
|
|
|
|
|
51
|
24 |
|
$inExpression = ''; |
|
52
|
24 |
|
if ($this->in !== null) { |
|
53
|
24 |
|
$this->in = $queryBuilder->normalizeArgument( |
|
54
|
24 |
|
$this->in, |
|
55
|
24 |
|
['Collection', 'Range', 'List', 'Reference', 'Query', 'CollectionBind'] |
|
56
|
|
|
); |
|
57
|
24 |
|
$inExpression = $this->in->compile($queryBuilder); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
24 |
|
return "FOR {$variableExpression} IN {$inExpression}"; |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths