Issues (341)

src/XMLSchema/XML/AbstractAttributeGroup.php (5 issues)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XMLSchema\XML;
6
7
use DOMElement;
8
use SimpleSAML\XMLSchema\Type\IDValue;
0 ignored issues
show
The type SimpleSAML\XMLSchema\Type\IDValue was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use SimpleSAML\XMLSchema\Type\NCNameValue;
0 ignored issues
show
The type SimpleSAML\XMLSchema\Type\NCNameValue was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use SimpleSAML\XMLSchema\Type\QNameValue;
0 ignored issues
show
The type SimpleSAML\XMLSchema\Type\QNameValue was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use SimpleSAML\XMLSchema\XML\Trait\AttrDeclsTrait;
12
use SimpleSAML\XMLSchema\XML\Trait\DefRefTrait;
13
14
use function strval;
15
16
/**
17
 * Abstract class representing the attributeGroup-type.
18
 *
19
 * @package simplesamlphp/xml-common
20
 */
21
abstract class AbstractAttributeGroup extends AbstractAnnotated
22
{
23
    use AttrDeclsTrait;
24
    use DefRefTrait;
25
26
27
    /**
28
     * AttributeGroup constructor
29
     *
30
     * @param (
31
     *   \SimpleSAML\XMLSchema\XML\LocalAttribute|
32
     *   \SimpleSAML\XMLSchema\XML\ReferencedAttributeGroup
33
     * )[] $attributes
34
     * @param \SimpleSAML\XMLSchema\XML\AnyAttribute|null $anyAttribute
35
     * @param \SimpleSAML\XMLSchema\Type\NCNameValue|null $name
36
     * @param \SimpleSAML\XMLSchema\Type\QNameValue|null $reference
37
     * @param \SimpleSAML\XMLSchema\XML\Annotation|null $annotation
38
     * @param \SimpleSAML\XMLSchema\Type\IDValue|null $id
39
     * @param array<\SimpleSAML\XML\Attribute> $namespacedAttributes
40
     */
41
    public function __construct(
42
        array $attributes = [],
43
        ?AnyAttribute $anyAttribute = null,
0 ignored issues
show
The type SimpleSAML\XMLSchema\XML\AnyAttribute was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
44
        ?NCNameValue $name = null,
45
        ?QNameValue $reference = null,
46
        protected ?Annotation $annotation = null,
0 ignored issues
show
The type SimpleSAML\XMLSchema\XML\Annotation was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
47
        protected ?IDValue $id = null,
48
        array $namespacedAttributes = [],
49
    ) {
50
        parent::__construct($annotation, $id, $namespacedAttributes);
51
52
        $this->setAttributes($attributes);
53
        $this->setAnyAttribute($anyAttribute);
54
        $this->setName($name);
55
        $this->setReference($reference);
56
    }
57
58
59
    /**
60
     * Test if an object, at the state it's in, would produce an empty XML-element
61
     *
62
     * @return bool
63
     */
64
    public function isEmptyElement(): bool
65
    {
66
        return parent::isEmptyElement() &&
67
            empty($this->getName()) &&
68
            empty($this->getReference()) &&
69
            empty($this->getAttributes()) &&
70
            empty($this->getAnyAttribute());
71
    }
72
73
74
    /**
75
     * Add this Annotated to an XML element.
76
     *
77
     * @param \DOMElement|null $parent The element we should append this Annotated to.
78
     * @return \DOMElement
79
     */
80
    public function toXML(?DOMElement $parent = null): DOMElement
81
    {
82
        $e = parent::toXML($parent);
83
84
        if ($this->getName() !== null) {
85
            $e->setAttribute('name', strval($this->getName()));
86
        }
87
88
        if ($this->getReference() !== null) {
89
            $e->setAttribute('ref', strval($this->getReference()));
90
        }
91
92
        foreach ($this->getAttributes() as $attr) {
93
            $attr->toXML($e);
94
        }
95
96
        $this->getAnyAttribute()?->toXML($e);
97
98
        return $e;
99
    }
100
}
101