1
|
|
|
<?php |
2
|
|
|
namespace GoetasWebservices\XML\XSDReader\Schema; |
3
|
|
|
|
4
|
|
|
use Closure; |
5
|
|
|
use DOMElement; |
6
|
|
|
use RuntimeException; |
7
|
|
|
use GoetasWebservices\XML\XSDReader\AbstractSchemaReader; |
8
|
|
|
use GoetasWebservices\XML\XSDReader\SchemaReaderLoadAbstraction; |
9
|
|
|
use GoetasWebservices\XML\XSDReader\Schema\Type\Type; |
10
|
|
|
use GoetasWebservices\XML\XSDReader\Schema\Attribute\Group as AttributeGroup; |
11
|
|
|
use GoetasWebservices\XML\XSDReader\Schema\Element\Group; |
12
|
|
|
use GoetasWebservices\XML\XSDReader\Schema\Element\ElementDef; |
13
|
|
|
use GoetasWebservices\XML\XSDReader\Schema\Element\ElementItem; |
14
|
|
|
use GoetasWebservices\XML\XSDReader\Schema\Exception\TypeNotFoundException; |
15
|
|
|
use GoetasWebservices\XML\XSDReader\Schema\Exception\SchemaException; |
16
|
|
|
use GoetasWebservices\XML\XSDReader\Schema\Attribute\AttributeItem; |
17
|
|
|
use GoetasWebservices\XML\XSDReader\Schema\Attribute\AttributeDef; |
18
|
|
|
use GoetasWebservices\XML\XSDReader\Utils\UrlUtils; |
19
|
|
|
|
20
|
|
|
class Schema extends AbstractSchema |
|
|
|
|
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* {@inheritdoc} |
24
|
|
|
*/ |
25
|
|
|
protected function findSomethingNoThrow( |
26
|
|
|
$getter, |
27
|
|
|
$name, |
28
|
|
|
$namespace = null, |
29
|
|
|
array & $calling = array() |
30
|
|
|
) { |
31
|
|
|
$calling[spl_object_hash($this)] = true; |
32
|
|
|
$cid = "$getter, $name, $namespace"; |
33
|
|
|
|
34
|
|
|
if (isset($this->typeCache[$cid])) { |
35
|
|
|
return $this->typeCache[$cid]; |
36
|
|
|
} elseif ( |
37
|
|
|
$this->getTargetNamespace() === $namespace && |
38
|
|
|
(($item = $this->$getter($name)) instanceof SchemaItem) |
39
|
|
|
) { |
40
|
|
|
return $this->typeCache[$cid] = $item; |
|
|
|
|
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
return $this->findSomethingNoThrowSchemas( |
44
|
|
|
$this->getSchemas(), |
45
|
|
|
$cid, |
46
|
|
|
$getter, |
47
|
|
|
$name, |
48
|
|
|
$namespace, |
49
|
|
|
$calling |
50
|
|
|
); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* {@inheritdoc} |
56
|
|
|
*/ |
57
|
|
|
protected function findSomethingNoThrowSchemas( |
58
|
|
|
array $schemas, |
59
|
|
|
$cid, |
60
|
|
|
$getter, |
61
|
|
|
$name, |
62
|
|
|
$namespace = null, |
63
|
|
|
array & $calling = array() |
64
|
|
|
) { |
65
|
|
|
foreach ($schemas as $childSchema) { |
66
|
|
|
if (!isset($calling[spl_object_hash($childSchema)])) { |
67
|
|
|
$in = $childSchema->findSomethingNoThrow($getter, $name, $namespace, $calling); |
68
|
|
|
|
69
|
|
|
if ($in instanceof SchemaItem) { |
70
|
|
|
return $this->typeCache[$cid] = $in; |
|
|
|
|
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* {@inheritdoc} |
78
|
|
|
*/ |
79
|
|
|
protected function findSomething($getter, $name, $namespace = null, &$calling = array()) |
80
|
|
|
{ |
81
|
|
|
$in = $this->findSomethingNoThrow( |
82
|
|
|
$getter, |
83
|
|
|
$name, |
84
|
|
|
$namespace, |
85
|
|
|
$calling |
86
|
|
|
); |
87
|
|
|
|
88
|
135 |
|
if ($in instanceof SchemaItem) { |
89
|
|
|
return $in; |
90
|
135 |
|
} |
91
|
135 |
|
|
92
|
|
|
throw new TypeNotFoundException(sprintf("Can't find the %s named {%s}#%s.", substr($getter, 3), $namespace, $name)); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* {@inheritdoc} |
97
|
|
|
*/ |
98
|
|
|
protected static function loadImportFreshKeys( |
99
|
|
|
SchemaReaderLoadAbstraction $reader, |
100
|
|
|
$namespace, |
101
|
|
|
$file |
102
|
|
|
) { |
103
|
|
|
$globalSchemaInfo = $reader->getGlobalSchemaInfo(); |
104
|
135 |
|
|
105
|
|
|
$keys = []; |
106
|
135 |
|
|
107
|
135 |
|
if (isset($globalSchemaInfo[$namespace])) { |
108
|
|
|
$keys[] = $globalSchemaInfo[$namespace]; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
$keys[] = $reader->getNamespaceSpecificFileIndex( |
112
|
135 |
|
$file, |
113
|
|
|
$namespace |
114
|
135 |
|
); |
115
|
|
|
|
116
|
|
|
$keys[] = $file; |
117
|
|
|
|
118
|
|
|
return $keys; |
119
|
|
|
} |
120
|
135 |
|
|
121
|
|
|
/** |
122
|
135 |
|
* {@inheritdoc} |
123
|
135 |
|
*/ |
124
|
|
|
protected static function loadImportFreshCallbacksNewSchema( |
125
|
|
|
$namespace, |
126
|
|
|
SchemaReaderLoadAbstraction $reader, |
127
|
|
|
Schema $schema, |
128
|
15 |
|
$file |
129
|
|
|
) { |
130
|
15 |
|
$newSchema = Schema::setLoadedFile( |
131
|
|
|
$file, |
132
|
|
|
($namespace ? new Schema() : $schema) |
133
|
|
|
); |
134
|
|
|
|
135
|
|
|
if ($namespace) { |
136
|
9 |
|
$newSchema->addSchema($reader->getGlobalSchema()); |
137
|
|
|
$schema->addSchema($newSchema); |
138
|
9 |
|
} |
139
|
|
|
|
140
|
|
|
return $newSchema; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
135 |
|
* {@inheritdoc} |
145
|
|
|
*/ |
146
|
135 |
|
protected static function loadImportFreshCallbacks( |
147
|
|
|
$namespace, |
148
|
|
|
SchemaReaderLoadAbstraction $reader, |
149
|
|
|
Schema $schema, |
150
|
|
|
$file |
151
|
|
|
) { |
152
|
3 |
|
return $reader->schemaNode( |
153
|
|
|
static::loadImportFreshCallbacksNewSchema( |
154
|
3 |
|
$namespace, |
155
|
|
|
$reader, |
156
|
|
|
$schema, |
157
|
|
|
$file |
158
|
|
|
), |
159
|
|
|
$reader->getDOM( |
160
|
6 |
|
$reader->hasKnownSchemaLocation($file) |
161
|
|
|
? $reader->getKnownSchemaLocation($file) |
162
|
6 |
|
: $file |
163
|
|
|
)->documentElement, |
164
|
|
|
$schema |
165
|
|
|
); |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
/** |
169
|
|
|
* {@inheritdoc} |
170
|
|
|
*/ |
171
|
|
|
protected static function loadImportFresh( |
172
|
|
|
$namespace, |
173
|
|
|
SchemaReaderLoadAbstraction $reader, |
174
|
|
|
Schema $schema, |
175
|
|
|
$file |
176
|
135 |
|
) { |
177
|
|
|
return function () use ($namespace, $reader, $schema, $file) { |
178
|
135 |
|
foreach ( |
179
|
135 |
|
static::loadImportFreshCallbacks( |
180
|
|
|
$namespace, |
181
|
135 |
|
$reader, |
182
|
|
|
$schema, |
183
|
135 |
|
$file |
184
|
135 |
|
) as $callback |
185
|
|
|
) { |
186
|
135 |
|
$callback(); |
187
|
|
|
} |
188
|
135 |
|
}; |
189
|
135 |
|
} |
190
|
|
|
} |
191
|
|
|
|
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