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