1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\SOAP\XML\env_200106; |
6
|
|
|
|
7
|
|
|
use DOMElement; |
8
|
|
|
use SimpleSAML\Assert\Assert; |
9
|
|
|
use SimpleSAML\SOAP\Exception\ProtocolViolationException; |
10
|
|
|
use SimpleSAML\XML\Exception\InvalidDOMElementException; |
11
|
|
|
use SimpleSAML\XML\ExtendableAttributesTrait; |
12
|
|
|
use SimpleSAML\XML\ExtendableElementTrait; |
13
|
|
|
use SimpleSAML\XML\SchemaValidatableElementInterface; |
14
|
|
|
use SimpleSAML\XML\SchemaValidatableElementTrait; |
15
|
|
|
use SimpleSAML\XML\XsNamespace as NS; |
16
|
|
|
|
17
|
|
|
use function array_diff; |
18
|
|
|
use function array_filter; |
19
|
|
|
use function array_pop; |
20
|
|
|
use function array_values; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Class representing a env:Body element. |
24
|
|
|
* |
25
|
|
|
* @package simplesaml/xml-soap |
26
|
|
|
*/ |
27
|
|
|
final class Body extends AbstractSoapElement implements SchemaValidatableElementInterface |
28
|
|
|
{ |
29
|
|
|
use ExtendableAttributesTrait; |
30
|
|
|
use ExtendableElementTrait; |
31
|
|
|
use SchemaValidatableElementTrait; |
32
|
|
|
|
33
|
|
|
/** The namespace-attribute for the xs:any element */ |
34
|
|
|
public const XS_ANY_ELT_NAMESPACE = NS::ANY; |
35
|
|
|
|
36
|
|
|
/** The namespace-attribute for the xs:anyAttribute element */ |
37
|
|
|
public const XS_ANY_ATTR_NAMESPACE = NS::ANY; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var \SimpleSAML\SOAP\XML\env_200106\Fault|null |
41
|
|
|
*/ |
42
|
|
|
protected ?Fault $fault; |
43
|
|
|
|
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Initialize a soap:Body |
47
|
|
|
* |
48
|
|
|
* @param list<\SimpleSAML\XML\SerializableElementInterface> $children |
49
|
|
|
* @param list<\SimpleSAML\XML\Attribute> $namespacedAttributes |
|
|
|
|
50
|
|
|
*/ |
51
|
|
|
public function __construct(array $children = [], array $namespacedAttributes = []) |
52
|
|
|
{ |
53
|
|
|
/** |
54
|
|
|
* 4.4: If present, the SOAP Fault element MUST appear as a body entry and MUST NOT |
55
|
|
|
* appear more than once within a Body element. |
56
|
|
|
*/ |
57
|
|
|
$fault = array_values(array_filter($children, function ($elt) { |
58
|
|
|
return $elt instanceof Fault; |
59
|
|
|
})); |
60
|
|
|
Assert::maxCount($fault, 1, ProtocolViolationException::class); |
61
|
|
|
|
62
|
|
|
$this->setFault(array_pop($fault)); |
63
|
|
|
$this->setElements(array_diff($children, $fault)); |
64
|
|
|
$this->setAttributesNS($namespacedAttributes); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @param \SimpleSAML\SOAP\XML\env_200106\Fault|null $fault |
70
|
|
|
*/ |
71
|
|
|
public function setFault(?Fault $fault): void |
72
|
|
|
{ |
73
|
|
|
$this->fault = $fault; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @return \SimpleSAML\SOAP\XML\env_200106\Fault|null |
79
|
|
|
*/ |
80
|
|
|
public function getFault(): ?Fault |
81
|
|
|
{ |
82
|
|
|
return $this->fault; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Test if an object, at the state it's in, would produce an empty XML-element |
88
|
|
|
* |
89
|
|
|
* @return bool |
90
|
|
|
*/ |
91
|
|
|
public function isEmptyElement(): bool |
92
|
|
|
{ |
93
|
|
|
return empty($this->fault) && empty($this->elements) && empty($this->namespacedAttributes); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
|
97
|
|
|
/* |
98
|
|
|
* Convert XML into an Body element |
99
|
|
|
* |
100
|
|
|
* @param \DOMElement $xml The XML element we should load |
101
|
|
|
* @return static |
102
|
|
|
* |
103
|
|
|
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException |
104
|
|
|
* If the qualified name of the supplied element is wrong |
105
|
|
|
*/ |
106
|
|
|
public static function fromXML(DOMElement $xml): static |
107
|
|
|
{ |
108
|
|
|
Assert::same($xml->localName, 'Body', InvalidDOMElementException::class); |
109
|
|
|
Assert::same($xml->namespaceURI, Body::NS, InvalidDOMElementException::class); |
110
|
|
|
|
111
|
|
|
return new static( |
112
|
|
|
self::getChildElementsFromXML($xml), |
113
|
|
|
self::getAttributesNSFromXML($xml), |
114
|
|
|
); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* Convert this Body to XML. |
120
|
|
|
* |
121
|
|
|
* @param \DOMElement|null $parent The element we should add this Body to. |
122
|
|
|
* @return \DOMElement This Body-element. |
123
|
|
|
*/ |
124
|
|
|
public function toXML(?DOMElement $parent = null): DOMElement |
125
|
|
|
{ |
126
|
|
|
$e = $this->instantiateParentElement($parent); |
127
|
|
|
|
128
|
|
|
foreach ($this->getAttributesNS() as $attr) { |
129
|
|
|
$attr->toXML($e); |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
$this->getFault()?->toXML($e); |
133
|
|
|
|
134
|
|
|
/** @psalm-var \SimpleSAML\XML\SerializableElementInterface $child */ |
135
|
|
|
foreach ($this->getElements() as $child) { |
136
|
|
|
if (!$child->isEmptyElement()) { |
137
|
|
|
$child->toXML($e); |
138
|
|
|
} |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
return $e; |
142
|
|
|
} |
143
|
|
|
} |
144
|
|
|
|
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