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\XML\{ExtendableAttributesTrait, ExtendableElementTrait}; |
||
10 | use SimpleSAML\XML\{SchemaValidatableElementInterface, SchemaValidatableElementTrait}; |
||
11 | use SimpleSAML\XMLSchema\Exception\{InvalidDOMElementException, MissingElementException, TooManyElementsException}; |
||
12 | use SimpleSAML\XMLSchema\XML\Enumeration\NamespaceEnum; |
||
13 | |||
14 | /** |
||
15 | * Class representing a SOAP-ENV:Envelope element. |
||
16 | * |
||
17 | * @package simplesaml/xml-soap |
||
18 | */ |
||
19 | final class Envelope extends AbstractSoapElement implements SchemaValidatableElementInterface |
||
20 | { |
||
21 | use ExtendableElementTrait; |
||
22 | use ExtendableAttributesTrait; |
||
23 | use SchemaValidatableElementTrait; |
||
24 | |||
25 | /** The namespace-attribute for the xs:any element */ |
||
26 | public const XS_ANY_ELT_NAMESPACE = NamespaceEnum::Other; |
||
27 | |||
28 | /** The namespace-attribute for the xs:anyAttribute element */ |
||
29 | public const XS_ANY_ATTR_NAMESPACE = NamespaceEnum::Other; |
||
30 | |||
31 | |||
32 | /** |
||
33 | * Initialize a SOAP-ENV:Envelope |
||
34 | * |
||
35 | * @param \SimpleSAML\SOAP11\XML\Body $body |
||
36 | * @param \SimpleSAML\SOAP11\XML\Header|null $header |
||
37 | * @param list<\SimpleSAML\XML\SerializableElementInterface> $children |
||
38 | * @param list<\SimpleSAML\XML\Attribute> $namespacedAttributes |
||
0 ignored issues
–
show
|
|||
39 | */ |
||
40 | public function __construct( |
||
41 | protected Body $body, |
||
42 | protected ?Header $header = null, |
||
43 | array $children = [], |
||
44 | array $namespacedAttributes = [], |
||
45 | ) { |
||
46 | $this->setElements($children); |
||
47 | $this->setAttributesNS($namespacedAttributes); |
||
48 | } |
||
49 | |||
50 | |||
51 | /** |
||
52 | * @return \SimpleSAML\SOAP11\XML\Body |
||
53 | */ |
||
54 | public function getBody(): Body |
||
55 | { |
||
56 | return $this->body; |
||
57 | } |
||
58 | |||
59 | |||
60 | /** |
||
61 | * @return \SimpleSAML\SOAP11\XML\Header|null |
||
62 | */ |
||
63 | public function getHeader(): ?Header |
||
64 | { |
||
65 | return $this->header; |
||
66 | } |
||
67 | |||
68 | |||
69 | /** |
||
70 | * Convert XML into an Envelope element |
||
71 | * |
||
72 | * @param \DOMElement $xml The XML element we should load |
||
73 | * @return static |
||
74 | * |
||
75 | * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException |
||
76 | * If the qualified name of the supplied element is wrong |
||
77 | */ |
||
78 | public static function fromXML(DOMElement $xml): static |
||
79 | { |
||
80 | Assert::same($xml->localName, 'Envelope', InvalidDOMElementException::class); |
||
81 | Assert::same($xml->namespaceURI, Envelope::NS, InvalidDOMElementException::class); |
||
82 | |||
83 | $body = Body::getChildrenOfClass($xml); |
||
84 | Assert::count($body, 1, 'Must contain exactly one Body', MissingElementException::class); |
||
85 | |||
86 | $header = Header::getChildrenOfClass($xml); |
||
87 | Assert::maxCount($header, 1, 'Cannot process more than one Header element.', TooManyElementsException::class); |
||
88 | |||
89 | return new static( |
||
90 | array_pop($body), |
||
91 | empty($header) ? null : array_pop($header), |
||
92 | self::getChildElementsFromXML($xml), |
||
93 | self::getAttributesNSFromXML($xml), |
||
94 | ); |
||
95 | } |
||
96 | |||
97 | |||
98 | /** |
||
99 | * Convert this Envelope to XML. |
||
100 | * |
||
101 | * @param \DOMElement|null $parent The element we should add this envelope to. |
||
102 | * @return \DOMElement This Envelope-element. |
||
103 | */ |
||
104 | public function toXML(?DOMElement $parent = null): DOMElement |
||
105 | { |
||
106 | $e = $this->instantiateParentElement($parent); |
||
107 | |||
108 | foreach ($this->getAttributesNS() as $attr) { |
||
109 | $attr->toXML($e); |
||
110 | } |
||
111 | |||
112 | if ($this->getHeader() !== null && !$this->getHeader()->isEmptyElement()) { |
||
113 | $this->getHeader()->toXML($e); |
||
114 | } |
||
115 | |||
116 | $this->getBody()->toXML($e); |
||
117 | |||
118 | /** @psalm-var \SimpleSAML\XML\SerializableElementInterface $child */ |
||
119 | foreach ($this->getElements() as $child) { |
||
120 | if (!$child->isEmptyElement()) { |
||
121 | $child->toXML($e); |
||
122 | } |
||
123 | } |
||
124 | |||
125 | return $e; |
||
126 | } |
||
127 | } |
||
128 |
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