|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Yiisoft\Yii\Cycle\Schema\Provider; |
|
6
|
|
|
|
|
7
|
|
|
use Closure; |
|
8
|
|
|
use Cycle\Database\DatabaseProviderInterface; |
|
9
|
|
|
use Cycle\Schema\Compiler; |
|
10
|
|
|
use Cycle\Schema\GeneratorInterface; |
|
11
|
|
|
use Cycle\Schema\Provider\SchemaProviderInterface; |
|
12
|
|
|
use Cycle\Schema\Registry; |
|
13
|
|
|
use Yiisoft\Yii\Cycle\Schema\SchemaConveyorInterface; |
|
14
|
|
|
|
|
15
|
|
|
final class FromConveyorSchemaProvider implements SchemaProviderInterface |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* Additional generators when reading Schema |
|
19
|
|
|
* |
|
20
|
|
|
* @var Closure[]|GeneratorInterface[]|string[] |
|
21
|
|
|
*/ |
|
22
|
|
|
private array $generators = []; |
|
23
|
|
|
|
|
24
|
8 |
|
public function __construct( |
|
25
|
|
|
private SchemaConveyorInterface $conveyor, |
|
26
|
|
|
private DatabaseProviderInterface $dbal, |
|
27
|
|
|
) { |
|
28
|
8 |
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @param list<Closure|GeneratorInterface|string> $generators |
|
|
|
|
|
|
32
|
|
|
* Additional {@see SchemaConveyorInterface::STAGE_USERLAND} generators |
|
33
|
|
|
*/ |
|
34
|
1 |
|
public static function config(array $generators): array |
|
35
|
|
|
{ |
|
36
|
1 |
|
return [ |
|
37
|
1 |
|
'generators' => $generators, |
|
38
|
1 |
|
]; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
4 |
|
public function withConfig(array $config): self |
|
42
|
|
|
{ |
|
43
|
4 |
|
$new = clone $this; |
|
44
|
4 |
|
$new->generators = $config['generators'] ?? []; |
|
45
|
4 |
|
return $new; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
5 |
|
public function read(?SchemaProviderInterface $nextProvider = null): ?array |
|
49
|
|
|
{ |
|
50
|
5 |
|
$generators = $this->getGenerators(); |
|
51
|
5 |
|
$schema = (new Compiler())->compile(new Registry($this->dbal), $generators); |
|
52
|
|
|
|
|
53
|
5 |
|
return count($schema) !== 0 || $nextProvider === null ? $schema : $nextProvider->read(); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
1 |
|
public function clear(): bool |
|
57
|
|
|
{ |
|
58
|
1 |
|
return false; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
5 |
|
private function getGenerators(): array |
|
62
|
|
|
{ |
|
63
|
5 |
|
$conveyor = clone $this->conveyor; |
|
64
|
|
|
// add generators to userland stage |
|
65
|
5 |
|
foreach ($this->generators as $generator) { |
|
66
|
1 |
|
$conveyor->addGenerator(SchemaConveyorInterface::STAGE_USERLAND, $generator); |
|
67
|
|
|
} |
|
68
|
5 |
|
return $conveyor->getGenerators(); |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|
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