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>|string|Expression $variables |
25
|
|
|
* @param array<mixed>|string|QueryBuilder|Expression|null $in |
26
|
|
|
*/ |
27
|
22 |
|
public function __construct( |
28
|
|
|
array|string|Expression $variables, |
29
|
|
|
array|string|QueryBuilder|Expression $in = null |
30
|
|
|
) { |
31
|
22 |
|
parent::__construct(); |
32
|
|
|
|
33
|
22 |
|
if (!is_array($variables)) { |
|
|
|
|
34
|
|
|
$variables = [$variables]; |
35
|
|
|
} |
36
|
22 |
|
$this->variables = $variables; |
37
|
|
|
|
38
|
22 |
|
$this->in = $in; |
39
|
22 |
|
} |
40
|
|
|
|
41
|
22 |
|
public function compile(QueryBuilder $queryBuilder): string |
42
|
|
|
{ |
43
|
22 |
|
$variables = []; |
44
|
22 |
|
foreach ($this->variables as $key => $value) { |
45
|
22 |
|
$variables[$key] = $queryBuilder->normalizeArgument($value, 'Variable'); |
46
|
22 |
|
$queryBuilder->registerVariable($variables[$key]->compile($queryBuilder)); |
47
|
|
|
} |
48
|
22 |
|
$variableExpression = array_map(function ($variable) use ($queryBuilder) { |
49
|
22 |
|
return $variable->compile($queryBuilder); |
50
|
22 |
|
}, $variables); |
51
|
|
|
|
52
|
22 |
|
$variableExpression = implode(', ', $variableExpression); |
53
|
|
|
|
54
|
22 |
|
$inExpression = ''; |
55
|
22 |
|
if ($this->in !== null) { |
56
|
22 |
|
$this->in = $queryBuilder->normalizeArgument( |
57
|
22 |
|
$this->in, |
58
|
22 |
|
['Collection', 'Range', 'List', 'Reference', 'Query', 'CollectionBind'] |
59
|
|
|
); |
60
|
22 |
|
$inExpression = $this->in->compile($queryBuilder); |
61
|
|
|
} |
62
|
|
|
|
63
|
22 |
|
return "FOR {$variableExpression} IN {$inExpression}"; |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
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