1 | <?php |
||||
2 | |||||
3 | namespace Kir\MySQL\Tools; |
||||
4 | |||||
5 | use Kir\MySQL\Builder\Internal\Types; |
||||
6 | use Kir\MySQL\Common\SpecialTable; |
||||
7 | use Kir\MySQL\Database; |
||||
8 | use Stringable; |
||||
9 | |||||
10 | /** |
||||
11 | * @phpstan-type TColumn string|array{name: string, type: string, jsonPath: string} |
||||
12 | * |
||||
13 | * @phpstan-type TColumns list<string|TColumn> |
||||
14 | */ |
||||
15 | class JsonTable implements SpecialTable { |
||||
16 | /** |
||||
17 | * @param string $dataExpression The field to get the source json data from |
||||
18 | * @param string $jsonPath The json path to the array to be turned into a table |
||||
19 | * @param TColumns $columns The projected columns |
||||
0 ignored issues
–
show
|
|||||
20 | */ |
||||
21 | public function __construct( |
||||
22 | private string $dataExpression, |
||||
23 | private string $jsonPath, |
||||
24 | private $columns |
||||
25 | ) {} |
||||
26 | |||||
27 | public function asString(Database $db): string { |
||||
28 | return sprintf( |
||||
29 | 'JSON_TABLE(%s, %s, %s)', |
||||
30 | $this->dataExpression, |
||||
31 | $this->jsonPath, |
||||
32 | $this->translateColumns($db, $this->columns) |
||||
33 | ); |
||||
34 | } |
||||
35 | |||||
36 | /** |
||||
37 | * @param Database $db |
||||
38 | * @param TColumns $columns |
||||
39 | * @return string |
||||
40 | */ |
||||
41 | private function translateColumns(Database $db, $columns) { |
||||
0 ignored issues
–
show
The parameter
$db is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||
42 | $result = []; |
||||
43 | foreach($columns as $column) { |
||||
44 | if(!is_string($column)) { |
||||
45 | $column = sprintf('%s %s PATH \'%s\'', $column['name'], $column['type'], $column['jsonPath']); |
||||
46 | } |
||||
47 | $result[] = $column; |
||||
48 | } |
||||
49 | return sprintf('COLUMNS(%s)', implode(', ', $result)); |
||||
50 | } |
||||
51 | } |
||||
52 |
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