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\IMethods; |
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
|
|
|
* Query |
15
|
|
|
* @author Ryuichi TANAKA. |
16
|
|
|
* @since 2013/10/20 |
17
|
|
|
* @version 0.4 |
18
|
|
|
* |
19
|
|
|
* @Annotation |
20
|
|
|
* @Target("METHOD") |
21
|
|
|
*/ |
22
|
|
|
class Query extends Annotation implements IMethods, 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
|
6 |
|
public function onInject(array $injectAnnotation) |
38
|
|
|
{ |
39
|
6 |
|
$this->injectAnnotation = $injectAnnotation; |
40
|
6 |
|
$this->readAnnotation = []; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* {@inheritdoc} |
45
|
|
|
*/ |
46
|
4 |
|
public function getAnnotationInfo(): array |
47
|
|
|
{ |
48
|
4 |
|
return $this->readAnnotation; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* {@inheritdoc} |
53
|
|
|
*/ |
54
|
6 |
|
public function onMethodInject(IAnnotatable $instance, \ReflectionMethod $method, Container $container) |
55
|
|
|
{ |
56
|
6 |
|
$key = $method->class . "#" . $method->name; |
57
|
6 |
|
if (!array_key_exists('file', $this->injectAnnotation)) { |
58
|
|
|
throw new AnnotationException("'file' attribute must be required in @Query"); |
|
|
|
|
59
|
|
|
} |
60
|
|
|
|
61
|
6 |
|
$xmlObjects = []; |
62
|
6 |
|
$filePath = $this->injectAnnotation['file']; |
63
|
6 |
|
if (!is_array($filePath)) { |
64
|
6 |
|
$filePath = [$filePath]; |
65
|
|
|
} |
66
|
|
|
|
67
|
6 |
|
foreach ($filePath as $file) { |
68
|
6 |
|
$file = new File($container->rootPath . '/' . $file); |
69
|
6 |
|
if (!$file->isFile()) { |
70
|
1 |
|
throw new DatabaseException("Failded to read query file: " . $file->getFilePath()); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
try { |
74
|
5 |
|
$xmlObject = new \SimpleXMLElement($file->getAbsoluteFilePath(), null, true); |
75
|
4 |
|
$xmlObjects[] = $xmlObject; |
76
|
1 |
|
} catch (\Exception $e) { |
77
|
1 |
|
throw new DatabaseException($e->getMessage() . ": " . $file->getFilePath()); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
81
|
4 |
|
$this->readAnnotation[$key] = $xmlObjects; |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|
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