Issues (341)

src/XMLSchema/XML/AbstractAll.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XMLSchema\XML;
6
7
use SimpleSAML\XML\Assert\Assert;
8
use SimpleSAML\XMLSchema\Exception\SchemaViolationException;
9
use SimpleSAML\XMLSchema\Type\IDValue;
10
use SimpleSAML\XMLSchema\Type\Schema\MaxOccursValue;
11
use SimpleSAML\XMLSchema\Type\Schema\MinOccursValue;
12
use SimpleSAML\XMLSchema\XML\Constants\NS;
13
14
/**
15
 * Abstract class representing the explicitGroup-type.
16
 *
17
 * @package simplesamlphp/xml-common
18
 */
19
abstract class AbstractAll extends AbstractExplicitGroup
20
{
21
    /** The namespace-attribute for the xs:anyAttribute element */
22
    public const string XS_ANY_ATTR_NAMESPACE = NS::OTHER;
0 ignored issues
show
A parse error occurred: Syntax error, unexpected T_STRING, expecting '=' on line 22 at column 24
Loading history...
23
24
25
    /**
26
     * All constructor
27
     *
28
     * @param \SimpleSAML\XMLSchema\Type\Schema\MinOccursValue|null $minOccurs
29
     * @param \SimpleSAML\XMLSchema\Type\Schema\MaxOccursValue|null $maxOccurs
30
     * @param \SimpleSAML\XMLSchema\XML\NarrowMaxMinElement[] $particles
31
     * @param \SimpleSAML\XMLSchema\XML\Annotation|null $annotation
32
     * @param \SimpleSAML\XMLSchema\Type\IDValue|null $id
33
     * @param array<\SimpleSAML\XML\Attribute> $namespacedAttributes
34
     */
35
    public function __construct(
36
        ?MinOccursValue $minOccurs = null,
37
        ?MaxOccursValue $maxOccurs = null,
38
        array $particles = [],
39
        ?Annotation $annotation = null,
40
        ?IDValue $id = null,
41
        array $namespacedAttributes = [],
42
    ) {
43
        if ($minOccurs !== null) {
44
            Assert::oneOf($minOccurs->toInteger(), [0, 1], SchemaViolationException::class);
45
        }
46
47
        if ($maxOccurs !== null) {
48
            Assert::same($maxOccurs->toInteger(), 1, SchemaViolationException::class);
49
        }
50
51
        Assert::allIsInstanceOf(
52
            $particles,
53
            NarrowMaxMinElement::class,
54
            SchemaViolationException::class,
55
        );
56
57
        parent::__construct(
58
            nestedParticles: $particles,
59
            minOccurs: $minOccurs,
60
            maxOccurs: $maxOccurs,
61
            annotation: $annotation,
62
            id: $id,
63
            namespacedAttributes: $namespacedAttributes,
64
        );
65
    }
66
}
67