1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\SOAP\XML\env_200305; |
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_pop; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Class representing a env:Body element. |
21
|
|
|
* |
22
|
|
|
* @package simplesaml/xml-soap |
23
|
|
|
*/ |
24
|
|
|
final class Body extends AbstractSoapElement implements SchemaValidatableElementInterface |
25
|
|
|
{ |
26
|
|
|
use ExtendableAttributesTrait; |
27
|
|
|
use ExtendableElementTrait; |
28
|
|
|
use SchemaValidatableElementTrait; |
29
|
|
|
|
30
|
|
|
/** The namespace-attribute for the xs:any element */ |
31
|
|
|
public const XS_ANY_ELT_NAMESPACE = NS::ANY; |
32
|
|
|
|
33
|
|
|
/** The namespace-attribute for the xs:anyAttribute element */ |
34
|
|
|
public const XS_ANY_ATTR_NAMESPACE = NS::OTHER; |
35
|
|
|
|
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Initialize a soap:Body |
39
|
|
|
* |
40
|
|
|
* @param \SimpleSAML\SOAP\XML\env_200305\Fault|null $fault |
41
|
|
|
* @param list<\SimpleSAML\XML\SerializableElementInterface> $children |
42
|
|
|
* @param list<\SimpleSAML\XML\Attribute> $namespacedAttributes |
|
|
|
|
43
|
|
|
*/ |
44
|
|
|
public function __construct( |
45
|
|
|
protected ?Fault $fault = null, |
46
|
|
|
array $children = [], |
47
|
|
|
array $namespacedAttributes = [], |
48
|
|
|
) { |
49
|
|
|
if ($fault !== null) { |
50
|
|
|
/** |
51
|
|
|
* 5.4: When generating a fault, SOAP senders MUST NOT include additional element |
52
|
|
|
* information items in the SOAP Body . |
53
|
|
|
*/ |
54
|
|
|
Assert::isEmpty( |
55
|
|
|
$children, |
56
|
|
|
"When generating a fault, SOAP senders MUST NOT include additional elements in the SOAP Body.", |
57
|
|
|
ProtocolViolationException::class, |
58
|
|
|
); |
59
|
|
|
} |
60
|
|
|
Assert::allNotInstanceOf($children, Fault::class, ProtocolViolationException::class); |
61
|
|
|
|
62
|
|
|
$this->setElements($children); |
63
|
|
|
$this->setAttributesNS($namespacedAttributes); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @return \SimpleSAML\SOAP\XML\env_200305\Fault|null |
69
|
|
|
*/ |
70
|
|
|
public function getFault(): ?Fault |
71
|
|
|
{ |
72
|
|
|
return $this->fault; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Test if an object, at the state it's in, would produce an empty XML-element |
78
|
|
|
* |
79
|
|
|
* @return bool |
80
|
|
|
*/ |
81
|
|
|
public function isEmptyElement(): bool |
82
|
|
|
{ |
83
|
|
|
return empty($this->fault) && empty($this->elements) && empty($this->namespacedAttributes); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
|
87
|
|
|
/* |
88
|
|
|
* Convert XML into an Body element |
89
|
|
|
* |
90
|
|
|
* @param \DOMElement $xml The XML element we should load |
91
|
|
|
* @return static |
92
|
|
|
* |
93
|
|
|
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException |
94
|
|
|
* If the qualified name of the supplied element is wrong |
95
|
|
|
*/ |
96
|
|
|
public static function fromXML(DOMElement $xml): static |
97
|
|
|
{ |
98
|
|
|
Assert::same($xml->localName, 'Body', InvalidDOMElementException::class); |
99
|
|
|
Assert::same($xml->namespaceURI, Body::NS, InvalidDOMElementException::class); |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* 5.4: To be recognized as carrying SOAP error information, a SOAP message MUST contain a single SOAP Fault |
103
|
|
|
* element information item as the only child element information item of the SOAP Body . |
104
|
|
|
*/ |
105
|
|
|
$fault = Fault::getChildrenOfClass($xml); |
106
|
|
|
Assert::maxCount($fault, 1, ProtocolViolationException::class); |
107
|
|
|
|
108
|
|
|
return new static( |
109
|
|
|
array_pop($fault), |
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
|
|
|
$child->toXML($e); |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
return $e; |
138
|
|
|
} |
139
|
|
|
} |
140
|
|
|
|
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