1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace WebStream\Annotation\Attributes; |
4
|
|
|
|
5
|
|
|
use WebStream\Annotation\Base\Annotation; |
6
|
|
|
use WebStream\Annotation\Base\IAnnotatable; |
7
|
|
|
use WebStream\Annotation\Base\IClass; |
8
|
|
|
use WebStream\Annotation\Base\IRead; |
9
|
|
|
use WebStream\Container\Container; |
|
|
|
|
10
|
|
|
use WebStream\Exception\Extend\DatabaseException; |
|
|
|
|
11
|
|
|
use WebStream\IO\File; |
|
|
|
|
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Database |
15
|
|
|
* @author Ryuichi TANAKA. |
16
|
|
|
* @since 2013/12/07 |
17
|
|
|
* @version 0.7 |
18
|
|
|
* |
19
|
|
|
* @Annotation |
20
|
|
|
* @Target("CLASS") |
21
|
|
|
*/ |
22
|
|
|
class Database extends Annotation implements IClass, IRead |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* @var array<string> 注入アノテーション情報 |
26
|
|
|
*/ |
27
|
|
|
private array $injectAnnotation; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var array<string> 読み込みアノテーション情報 |
31
|
|
|
*/ |
32
|
|
|
private array $readAnnotation; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* {@inheritdoc} |
36
|
|
|
*/ |
37
|
2 |
|
public function onInject(array $injectAnnotation) |
38
|
|
|
{ |
39
|
2 |
|
$this->injectAnnotation = $injectAnnotation; |
40
|
2 |
|
$this->readAnnotation = []; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* {@inheritdoc} |
45
|
|
|
*/ |
46
|
1 |
|
public function getAnnotationInfo(): array |
47
|
|
|
{ |
48
|
1 |
|
return $this->readAnnotation; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* {@inheritdoc} |
53
|
|
|
*/ |
54
|
2 |
|
public function onClassInject(IAnnotatable $instance, \ReflectionClass $class, Container $container) |
55
|
|
|
{ |
56
|
2 |
|
$driver = $this->injectAnnotation['driver']; |
57
|
2 |
|
$config = $this->injectAnnotation['config']; |
58
|
|
|
|
59
|
2 |
|
if (!class_exists($driver)) { |
60
|
1 |
|
throw new DatabaseException("Database driver is undefined:" . $driver); |
61
|
|
|
} |
62
|
|
|
|
63
|
1 |
|
$file = new File($container->rootPath . '/' . $config); |
64
|
1 |
|
$this->readAnnotation['filepath'] = $class->getFileName(); |
65
|
1 |
|
$this->readAnnotation['configPath'] = $file->getAbsoluteFilePath(); |
66
|
1 |
|
$this->readAnnotation['driverClassPath'] = $driver; |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|
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