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