1 | <?php |
||
2 | namespace Kir\MySQL\Builder\Traits; |
||
3 | |||
4 | use Kir\MySQL\Builder\Internal\Types; |
||
5 | use Kir\MySQL\Database; |
||
6 | use Kir\MySQL\Tools\VirtualTable; |
||
7 | |||
8 | /** |
||
9 | * @phpstan-import-type DBTableNameType from Types |
||
10 | */ |
||
11 | trait TableNameBuilder { |
||
12 | use AbstractAliasReplacer; |
||
13 | |||
14 | /** |
||
15 | * @param string|null $alias |
||
16 | * @param DBTableNameType $name |
||
0 ignored issues
–
show
|
|||
17 | * @return string |
||
18 | */ |
||
19 | protected function buildTableName(?string $alias, $name): string { |
||
20 | if(is_object($name) && !($name instanceof VirtualTable) && method_exists($name, '__toString')) { |
||
21 | $name = (string) $name; |
||
22 | $lines = explode("\n", $name); |
||
23 | $lines = array_map(static fn(string $line) => "\t{$line}", $lines); |
||
24 | $name = implode("\n", $lines); |
||
25 | $name = '(' . trim(rtrim(trim($name), ';')) . ')'; |
||
26 | } |
||
27 | if(is_array($name)) { |
||
28 | $parts = []; |
||
29 | foreach($name as /*$index => */$bucket) { |
||
30 | if(is_scalar($bucket)/* && ctype_digit((string) $index)*/) { |
||
31 | $parts[] = "SELECT {$this->db()->quote($bucket)} AS {$this->db()->quoteField('value')}"; |
||
32 | } else { |
||
33 | $values = []; |
||
34 | foreach($bucket as $field => $value) { |
||
35 | $values[] = sprintf('%s AS %s', $this->db()->quote($value), $this->db()->quoteField($field)); |
||
36 | } |
||
37 | $parts[] = sprintf("SELECT %s", implode(', ', $values)); |
||
38 | } |
||
39 | } |
||
40 | $name = '(' . implode("\n\tUNION ALL\n\t", $parts) . ')'; |
||
41 | } |
||
42 | if((is_string($name) || $name instanceof VirtualTable) && $this->db()->getVirtualTables()->has($name)) { |
||
43 | $select = (string) $this->db()->getVirtualTables()->get($name); |
||
44 | $name = sprintf('(%s)', implode("\n\t", explode("\n", trim($select)))); |
||
45 | } |
||
46 | $name = $this->aliasReplacer()->replace((string) $name); |
||
47 | if($alias !== null) { |
||
48 | return sprintf("%s %s", $name, $alias); |
||
49 | } |
||
50 | return $name; |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * @return Database |
||
55 | */ |
||
56 | abstract protected function db(); |
||
57 | } |
||
58 |
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