GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 91afec...2569ae )
by Joni
05:59
created
lib/X509/Certificate/Extension/AAControlsExtension.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
                 ->asImplicit(Element::TYPE_SEQUENCE)
92 92
                 ->asSequence();
93 93
             $permitted = array_map(
94
-                function (UnspecifiedType $el) {
94
+                function(UnspecifiedType $el) {
95 95
                     return $el->asObjectIdentifier()->oid();
96 96
                 }, $attr_seq->elements());
97 97
             $idx++;
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
                 ->asImplicit(Element::TYPE_SEQUENCE)
102 102
                 ->asSequence();
103 103
             $excluded = array_map(
104
-                function (UnspecifiedType $el) {
104
+                function(UnspecifiedType $el) {
105 105
                     return $el->asObjectIdentifier()->oid();
106 106
                 }, $attr_seq->elements());
107 107
             $idx++;
@@ -211,14 +211,14 @@  discard block
 block discarded – undo
211 211
         }
212 212
         if (isset($this->_permittedAttrs)) {
213 213
             $oids = array_map(
214
-                function ($oid) {
214
+                function($oid) {
215 215
                     return new ObjectIdentifier($oid);
216 216
                 }, $this->_permittedAttrs);
217 217
             $elements[] = new ImplicitlyTaggedType(0, new Sequence(...$oids));
218 218
         }
219 219
         if (isset($this->_excludedAttrs)) {
220 220
             $oids = array_map(
221
-                function ($oid) {
221
+                function($oid) {
222 222
                     return new ObjectIdentifier($oid);
223 223
                 }, $this->_excludedAttrs);
224 224
             $elements[] = new ImplicitlyTaggedType(1, new Sequence(...$oids));
Please login to merge, or discard this patch.
Indentation   +198 added lines, -198 removed lines patch added patch discarded remove patch
@@ -19,215 +19,215 @@
 block discarded – undo
19 19
  */
20 20
 class AAControlsExtension extends Extension
21 21
 {
22
-    /**
23
-     * Path length contraint.
24
-     *
25
-     * @var int|null $_pathLenConstraint
26
-     */
27
-    protected $_pathLenConstraint;
22
+	/**
23
+	 * Path length contraint.
24
+	 *
25
+	 * @var int|null $_pathLenConstraint
26
+	 */
27
+	protected $_pathLenConstraint;
28 28
     
29
-    /**
30
-     * Permitted attributes.
31
-     *
32
-     * Array of OID's.
33
-     *
34
-     * @var string[]|null $_permittedAttrs
35
-     */
36
-    protected $_permittedAttrs;
29
+	/**
30
+	 * Permitted attributes.
31
+	 *
32
+	 * Array of OID's.
33
+	 *
34
+	 * @var string[]|null $_permittedAttrs
35
+	 */
36
+	protected $_permittedAttrs;
37 37
     
38
-    /**
39
-     * Excluded attributes.
40
-     *
41
-     * Array of OID's.
42
-     *
43
-     * @var string[]|null $_excludedAttrs
44
-     */
45
-    protected $_excludedAttrs;
38
+	/**
39
+	 * Excluded attributes.
40
+	 *
41
+	 * Array of OID's.
42
+	 *
43
+	 * @var string[]|null $_excludedAttrs
44
+	 */
45
+	protected $_excludedAttrs;
46 46
     
47
-    /**
48
-     * Whether to permit unspecified attributes.
49
-     *
50
-     * @var bool $_permitUnSpecified
51
-     */
52
-    protected $_permitUnSpecified;
47
+	/**
48
+	 * Whether to permit unspecified attributes.
49
+	 *
50
+	 * @var bool $_permitUnSpecified
51
+	 */
52
+	protected $_permitUnSpecified;
53 53
     
54
-    /**
55
-     * Constructor.
56
-     *
57
-     * @param bool $critical
58
-     * @param int|null $path_len
59
-     * @param string[]|null $permitted
60
-     * @param string[]|null $excluded
61
-     * @param bool $permit_unspecified
62
-     */
63
-    public function __construct(bool $critical, $path_len = null,
64
-        array $permitted = null, array $excluded = null, bool $permit_unspecified = true)
65
-    {
66
-        parent::__construct(self::OID_AA_CONTROLS, $critical);
67
-        $this->_pathLenConstraint = isset($path_len) ? intval($path_len) : null;
68
-        $this->_permittedAttrs = $permitted;
69
-        $this->_excludedAttrs = $excluded;
70
-        $this->_permitUnSpecified = $permit_unspecified;
71
-    }
54
+	/**
55
+	 * Constructor.
56
+	 *
57
+	 * @param bool $critical
58
+	 * @param int|null $path_len
59
+	 * @param string[]|null $permitted
60
+	 * @param string[]|null $excluded
61
+	 * @param bool $permit_unspecified
62
+	 */
63
+	public function __construct(bool $critical, $path_len = null,
64
+		array $permitted = null, array $excluded = null, bool $permit_unspecified = true)
65
+	{
66
+		parent::__construct(self::OID_AA_CONTROLS, $critical);
67
+		$this->_pathLenConstraint = isset($path_len) ? intval($path_len) : null;
68
+		$this->_permittedAttrs = $permitted;
69
+		$this->_excludedAttrs = $excluded;
70
+		$this->_permitUnSpecified = $permit_unspecified;
71
+	}
72 72
     
73
-    /**
74
-     *
75
-     * {@inheritdoc}
76
-     * @return self
77
-     */
78
-    protected static function _fromDER(string $data, bool $critical): self
79
-    {
80
-        $seq = UnspecifiedType::fromDER($data)->asSequence();
81
-        $path_len = null;
82
-        $permitted = null;
83
-        $excluded = null;
84
-        $permit_unspecified = true;
85
-        $idx = 0;
86
-        if ($seq->has($idx, Element::TYPE_INTEGER)) {
87
-            $path_len = $seq->at($idx++)
88
-                ->asInteger()
89
-                ->intNumber();
90
-        }
91
-        if ($seq->hasTagged(0)) {
92
-            $attr_seq = $seq->getTagged(0)
93
-                ->asImplicit(Element::TYPE_SEQUENCE)
94
-                ->asSequence();
95
-            $permitted = array_map(
96
-                function (UnspecifiedType $el) {
97
-                    return $el->asObjectIdentifier()->oid();
98
-                }, $attr_seq->elements());
99
-            $idx++;
100
-        }
101
-        if ($seq->hasTagged(1)) {
102
-            $attr_seq = $seq->getTagged(1)
103
-                ->asImplicit(Element::TYPE_SEQUENCE)
104
-                ->asSequence();
105
-            $excluded = array_map(
106
-                function (UnspecifiedType $el) {
107
-                    return $el->asObjectIdentifier()->oid();
108
-                }, $attr_seq->elements());
109
-            $idx++;
110
-        }
111
-        if ($seq->has($idx, Element::TYPE_BOOLEAN)) {
112
-            $permit_unspecified = $seq->at($idx++)
113
-                ->asBoolean()
114
-                ->value();
115
-        }
116
-        return new self($critical, $path_len, $permitted, $excluded,
117
-            $permit_unspecified);
118
-    }
73
+	/**
74
+	 *
75
+	 * {@inheritdoc}
76
+	 * @return self
77
+	 */
78
+	protected static function _fromDER(string $data, bool $critical): self
79
+	{
80
+		$seq = UnspecifiedType::fromDER($data)->asSequence();
81
+		$path_len = null;
82
+		$permitted = null;
83
+		$excluded = null;
84
+		$permit_unspecified = true;
85
+		$idx = 0;
86
+		if ($seq->has($idx, Element::TYPE_INTEGER)) {
87
+			$path_len = $seq->at($idx++)
88
+				->asInteger()
89
+				->intNumber();
90
+		}
91
+		if ($seq->hasTagged(0)) {
92
+			$attr_seq = $seq->getTagged(0)
93
+				->asImplicit(Element::TYPE_SEQUENCE)
94
+				->asSequence();
95
+			$permitted = array_map(
96
+				function (UnspecifiedType $el) {
97
+					return $el->asObjectIdentifier()->oid();
98
+				}, $attr_seq->elements());
99
+			$idx++;
100
+		}
101
+		if ($seq->hasTagged(1)) {
102
+			$attr_seq = $seq->getTagged(1)
103
+				->asImplicit(Element::TYPE_SEQUENCE)
104
+				->asSequence();
105
+			$excluded = array_map(
106
+				function (UnspecifiedType $el) {
107
+					return $el->asObjectIdentifier()->oid();
108
+				}, $attr_seq->elements());
109
+			$idx++;
110
+		}
111
+		if ($seq->has($idx, Element::TYPE_BOOLEAN)) {
112
+			$permit_unspecified = $seq->at($idx++)
113
+				->asBoolean()
114
+				->value();
115
+		}
116
+		return new self($critical, $path_len, $permitted, $excluded,
117
+			$permit_unspecified);
118
+	}
119 119
     
120
-    /**
121
-     * Check whether path length constraint is present.
122
-     *
123
-     * @return bool
124
-     */
125
-    public function hasPathLen(): bool
126
-    {
127
-        return isset($this->_pathLenConstraint);
128
-    }
120
+	/**
121
+	 * Check whether path length constraint is present.
122
+	 *
123
+	 * @return bool
124
+	 */
125
+	public function hasPathLen(): bool
126
+	{
127
+		return isset($this->_pathLenConstraint);
128
+	}
129 129
     
130
-    /**
131
-     * Get path length constraint.
132
-     *
133
-     * @throws \LogicException
134
-     * @return int
135
-     */
136
-    public function pathLen(): int
137
-    {
138
-        if (!$this->hasPathLen()) {
139
-            throw new \LogicException("pathLen not set.");
140
-        }
141
-        return $this->_pathLenConstraint;
142
-    }
130
+	/**
131
+	 * Get path length constraint.
132
+	 *
133
+	 * @throws \LogicException
134
+	 * @return int
135
+	 */
136
+	public function pathLen(): int
137
+	{
138
+		if (!$this->hasPathLen()) {
139
+			throw new \LogicException("pathLen not set.");
140
+		}
141
+		return $this->_pathLenConstraint;
142
+	}
143 143
     
144
-    /**
145
-     * Check whether permitted attributes are present.
146
-     *
147
-     * @return bool
148
-     */
149
-    public function hasPermittedAttrs(): bool
150
-    {
151
-        return isset($this->_permittedAttrs);
152
-    }
144
+	/**
145
+	 * Check whether permitted attributes are present.
146
+	 *
147
+	 * @return bool
148
+	 */
149
+	public function hasPermittedAttrs(): bool
150
+	{
151
+		return isset($this->_permittedAttrs);
152
+	}
153 153
     
154
-    /**
155
-     * Get OID's of permitted attributes.
156
-     *
157
-     * @throws \LogicException
158
-     * @return string[]
159
-     */
160
-    public function permittedAttrs(): array
161
-    {
162
-        if (!$this->hasPermittedAttrs()) {
163
-            throw new \LogicException("permittedAttrs not set.");
164
-        }
165
-        return $this->_permittedAttrs;
166
-    }
154
+	/**
155
+	 * Get OID's of permitted attributes.
156
+	 *
157
+	 * @throws \LogicException
158
+	 * @return string[]
159
+	 */
160
+	public function permittedAttrs(): array
161
+	{
162
+		if (!$this->hasPermittedAttrs()) {
163
+			throw new \LogicException("permittedAttrs not set.");
164
+		}
165
+		return $this->_permittedAttrs;
166
+	}
167 167
     
168
-    /**
169
-     * Check whether excluded attributes are present.
170
-     *
171
-     * @return bool
172
-     */
173
-    public function hasExcludedAttrs(): bool
174
-    {
175
-        return isset($this->_excludedAttrs);
176
-    }
168
+	/**
169
+	 * Check whether excluded attributes are present.
170
+	 *
171
+	 * @return bool
172
+	 */
173
+	public function hasExcludedAttrs(): bool
174
+	{
175
+		return isset($this->_excludedAttrs);
176
+	}
177 177
     
178
-    /**
179
-     * Get OID's of excluded attributes.
180
-     *
181
-     * @throws \LogicException
182
-     * @return string[]
183
-     */
184
-    public function excludedAttrs(): array
185
-    {
186
-        if (!$this->hasExcludedAttrs()) {
187
-            throw new \LogicException("excludedAttrs not set.");
188
-        }
189
-        return $this->_excludedAttrs;
190
-    }
178
+	/**
179
+	 * Get OID's of excluded attributes.
180
+	 *
181
+	 * @throws \LogicException
182
+	 * @return string[]
183
+	 */
184
+	public function excludedAttrs(): array
185
+	{
186
+		if (!$this->hasExcludedAttrs()) {
187
+			throw new \LogicException("excludedAttrs not set.");
188
+		}
189
+		return $this->_excludedAttrs;
190
+	}
191 191
     
192
-    /**
193
-     * Whether to permit attributes that are not explicitly specified in
194
-     * neither permitted nor excluded list.
195
-     *
196
-     * @return bool
197
-     */
198
-    public function permitUnspecified(): bool
199
-    {
200
-        return $this->_permitUnSpecified;
201
-    }
192
+	/**
193
+	 * Whether to permit attributes that are not explicitly specified in
194
+	 * neither permitted nor excluded list.
195
+	 *
196
+	 * @return bool
197
+	 */
198
+	public function permitUnspecified(): bool
199
+	{
200
+		return $this->_permitUnSpecified;
201
+	}
202 202
     
203
-    /**
204
-     *
205
-     * {@inheritdoc}
206
-     * @return Sequence
207
-     */
208
-    protected function _valueASN1(): Sequence
209
-    {
210
-        $elements = array();
211
-        if (isset($this->_pathLenConstraint)) {
212
-            $elements[] = new Integer($this->_pathLenConstraint);
213
-        }
214
-        if (isset($this->_permittedAttrs)) {
215
-            $oids = array_map(
216
-                function ($oid) {
217
-                    return new ObjectIdentifier($oid);
218
-                }, $this->_permittedAttrs);
219
-            $elements[] = new ImplicitlyTaggedType(0, new Sequence(...$oids));
220
-        }
221
-        if (isset($this->_excludedAttrs)) {
222
-            $oids = array_map(
223
-                function ($oid) {
224
-                    return new ObjectIdentifier($oid);
225
-                }, $this->_excludedAttrs);
226
-            $elements[] = new ImplicitlyTaggedType(1, new Sequence(...$oids));
227
-        }
228
-        if ($this->_permitUnSpecified !== true) {
229
-            $elements[] = new Boolean(false);
230
-        }
231
-        return new Sequence(...$elements);
232
-    }
203
+	/**
204
+	 *
205
+	 * {@inheritdoc}
206
+	 * @return Sequence
207
+	 */
208
+	protected function _valueASN1(): Sequence
209
+	{
210
+		$elements = array();
211
+		if (isset($this->_pathLenConstraint)) {
212
+			$elements[] = new Integer($this->_pathLenConstraint);
213
+		}
214
+		if (isset($this->_permittedAttrs)) {
215
+			$oids = array_map(
216
+				function ($oid) {
217
+					return new ObjectIdentifier($oid);
218
+				}, $this->_permittedAttrs);
219
+			$elements[] = new ImplicitlyTaggedType(0, new Sequence(...$oids));
220
+		}
221
+		if (isset($this->_excludedAttrs)) {
222
+			$oids = array_map(
223
+				function ($oid) {
224
+					return new ObjectIdentifier($oid);
225
+				}, $this->_excludedAttrs);
226
+			$elements[] = new ImplicitlyTaggedType(1, new Sequence(...$oids));
227
+		}
228
+		if ($this->_permitUnSpecified !== true) {
229
+			$elements[] = new Boolean(false);
230
+		}
231
+		return new Sequence(...$elements);
232
+	}
233 233
 }
Please login to merge, or discard this patch.
lib/X509/Certificate/Extension/CertificatePolicy/PolicyInformation.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
         $qualifiers = array();
65 65
         if (count($seq) > 1) {
66 66
             $qualifiers = array_map(
67
-                function (UnspecifiedType $el) {
67
+                function(UnspecifiedType $el) {
68 68
                     return PolicyQualifierInfo::fromASN1($el->asSequence());
69 69
                 },
70 70
                 $seq->at(1)
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
         $elements = array(new ObjectIdentifier($this->_oid));
189 189
         if (count($this->_qualifiers)) {
190 190
             $qualifiers = array_map(
191
-                function (PolicyQualifierInfo $pqi) {
191
+                function(PolicyQualifierInfo $pqi) {
192 192
                     return $pqi->toASN1();
193 193
                 }, array_values($this->_qualifiers));
194 194
             $elements[] = new Sequence(...$qualifiers);
Please login to merge, or discard this patch.
Indentation   +203 added lines, -203 removed lines patch added patch discarded remove patch
@@ -16,207 +16,207 @@
 block discarded – undo
16 16
  */
17 17
 class PolicyInformation implements \Countable, \IteratorAggregate
18 18
 {
19
-    /**
20
-     * Wildcard policy.
21
-     *
22
-     * @var string
23
-     */
24
-    const OID_ANY_POLICY = "2.5.29.32.0";
25
-    
26
-    /**
27
-     * Policy identifier.
28
-     *
29
-     * @var string $_oid
30
-     */
31
-    protected $_oid;
32
-    
33
-    /**
34
-     * Policy qualifiers.
35
-     *
36
-     * @var PolicyQualifierInfo[] $_qualifiers
37
-     */
38
-    protected $_qualifiers;
39
-    
40
-    /**
41
-     * Constructor.
42
-     *
43
-     * @param string $oid
44
-     * @param PolicyQualifierInfo ...$qualifiers
45
-     */
46
-    public function __construct(string $oid, PolicyQualifierInfo ...$qualifiers)
47
-    {
48
-        $this->_oid = $oid;
49
-        $this->_qualifiers = array();
50
-        foreach ($qualifiers as $qual) {
51
-            $this->_qualifiers[$qual->oid()] = $qual;
52
-        }
53
-    }
54
-    
55
-    /**
56
-     * Initialize from ASN.1.
57
-     *
58
-     * @param Sequence $seq
59
-     * @return self
60
-     */
61
-    public static function fromASN1(Sequence $seq): self
62
-    {
63
-        $oid = $seq->at(0)
64
-            ->asObjectIdentifier()
65
-            ->oid();
66
-        $qualifiers = array();
67
-        if (count($seq) > 1) {
68
-            $qualifiers = array_map(
69
-                function (UnspecifiedType $el) {
70
-                    return PolicyQualifierInfo::fromASN1($el->asSequence());
71
-                },
72
-                $seq->at(1)
73
-                    ->asSequence()
74
-                    ->elements());
75
-        }
76
-        return new self($oid, ...$qualifiers);
77
-    }
78
-    
79
-    /**
80
-     * Get policy identifier.
81
-     *
82
-     * @return string
83
-     */
84
-    public function oid(): string
85
-    {
86
-        return $this->_oid;
87
-    }
88
-    
89
-    /**
90
-     * Check whether this policy is anyPolicy.
91
-     *
92
-     * @return bool
93
-     */
94
-    public function isAnyPolicy(): bool
95
-    {
96
-        return self::OID_ANY_POLICY === $this->_oid;
97
-    }
98
-    
99
-    /**
100
-     * Get policy qualifiers.
101
-     *
102
-     * @return PolicyQualifierInfo[]
103
-     */
104
-    public function qualifiers(): array
105
-    {
106
-        return array_values($this->_qualifiers);
107
-    }
108
-    
109
-    /**
110
-     * Check whether qualifier is present.
111
-     *
112
-     * @param string $oid
113
-     * @return boolean
114
-     */
115
-    public function has(string $oid): bool
116
-    {
117
-        return isset($this->_qualifiers[$oid]);
118
-    }
119
-    
120
-    /**
121
-     * Get qualifier by OID.
122
-     *
123
-     * @param string $oid
124
-     * @throws \OutOfBoundsException
125
-     * @return PolicyQualifierInfo
126
-     */
127
-    public function get(string $oid): PolicyQualifierInfo
128
-    {
129
-        if (!$this->has($oid)) {
130
-            throw new \LogicException("No $oid qualifier.");
131
-        }
132
-        return $this->_qualifiers[$oid];
133
-    }
134
-    
135
-    /**
136
-     * Check whether CPS qualifier is present.
137
-     *
138
-     * @return bool
139
-     */
140
-    public function hasCPSQualifier(): bool
141
-    {
142
-        return $this->has(PolicyQualifierInfo::OID_CPS);
143
-    }
144
-    
145
-    /**
146
-     * Get CPS qualifier.
147
-     *
148
-     * @throws \LogicException
149
-     * @return CPSQualifier
150
-     */
151
-    public function CPSQualifier(): CPSQualifier
152
-    {
153
-        if (!$this->hasCPSQualifier()) {
154
-            throw new \LogicException("CPS qualifier not set.");
155
-        }
156
-        return $this->get(PolicyQualifierInfo::OID_CPS);
157
-    }
158
-    
159
-    /**
160
-     * Check whether user notice qualifier is present.
161
-     *
162
-     * @return bool
163
-     */
164
-    public function hasUserNoticeQualifier(): bool
165
-    {
166
-        return $this->has(PolicyQualifierInfo::OID_UNOTICE);
167
-    }
168
-    
169
-    /**
170
-     * Get user notice qualifier.
171
-     *
172
-     * @throws \LogicException
173
-     * @return UserNoticeQualifier
174
-     */
175
-    public function userNoticeQualifier(): UserNoticeQualifier
176
-    {
177
-        if (!$this->hasUserNoticeQualifier()) {
178
-            throw new \LogicException("User notice qualifier not set.");
179
-        }
180
-        return $this->get(PolicyQualifierInfo::OID_UNOTICE);
181
-    }
182
-    
183
-    /**
184
-     * Get ASN.1 structure.
185
-     *
186
-     * @return Sequence
187
-     */
188
-    public function toASN1(): Sequence
189
-    {
190
-        $elements = array(new ObjectIdentifier($this->_oid));
191
-        if (count($this->_qualifiers)) {
192
-            $qualifiers = array_map(
193
-                function (PolicyQualifierInfo $pqi) {
194
-                    return $pqi->toASN1();
195
-                }, array_values($this->_qualifiers));
196
-            $elements[] = new Sequence(...$qualifiers);
197
-        }
198
-        return new Sequence(...$elements);
199
-    }
200
-    
201
-    /**
202
-     * Get number of qualifiers.
203
-     *
204
-     * @see \Countable::count()
205
-     * @return int
206
-     */
207
-    public function count(): int
208
-    {
209
-        return count($this->_qualifiers);
210
-    }
211
-    
212
-    /**
213
-     * Get iterator for qualifiers.
214
-     *
215
-     * @see \IteratorAggregate::getIterator()
216
-     * @return \ArrayIterator
217
-     */
218
-    public function getIterator(): \ArrayIterator
219
-    {
220
-        return new \ArrayIterator($this->_qualifiers);
221
-    }
19
+	/**
20
+	 * Wildcard policy.
21
+	 *
22
+	 * @var string
23
+	 */
24
+	const OID_ANY_POLICY = "2.5.29.32.0";
25
+    
26
+	/**
27
+	 * Policy identifier.
28
+	 *
29
+	 * @var string $_oid
30
+	 */
31
+	protected $_oid;
32
+    
33
+	/**
34
+	 * Policy qualifiers.
35
+	 *
36
+	 * @var PolicyQualifierInfo[] $_qualifiers
37
+	 */
38
+	protected $_qualifiers;
39
+    
40
+	/**
41
+	 * Constructor.
42
+	 *
43
+	 * @param string $oid
44
+	 * @param PolicyQualifierInfo ...$qualifiers
45
+	 */
46
+	public function __construct(string $oid, PolicyQualifierInfo ...$qualifiers)
47
+	{
48
+		$this->_oid = $oid;
49
+		$this->_qualifiers = array();
50
+		foreach ($qualifiers as $qual) {
51
+			$this->_qualifiers[$qual->oid()] = $qual;
52
+		}
53
+	}
54
+    
55
+	/**
56
+	 * Initialize from ASN.1.
57
+	 *
58
+	 * @param Sequence $seq
59
+	 * @return self
60
+	 */
61
+	public static function fromASN1(Sequence $seq): self
62
+	{
63
+		$oid = $seq->at(0)
64
+			->asObjectIdentifier()
65
+			->oid();
66
+		$qualifiers = array();
67
+		if (count($seq) > 1) {
68
+			$qualifiers = array_map(
69
+				function (UnspecifiedType $el) {
70
+					return PolicyQualifierInfo::fromASN1($el->asSequence());
71
+				},
72
+				$seq->at(1)
73
+					->asSequence()
74
+					->elements());
75
+		}
76
+		return new self($oid, ...$qualifiers);
77
+	}
78
+    
79
+	/**
80
+	 * Get policy identifier.
81
+	 *
82
+	 * @return string
83
+	 */
84
+	public function oid(): string
85
+	{
86
+		return $this->_oid;
87
+	}
88
+    
89
+	/**
90
+	 * Check whether this policy is anyPolicy.
91
+	 *
92
+	 * @return bool
93
+	 */
94
+	public function isAnyPolicy(): bool
95
+	{
96
+		return self::OID_ANY_POLICY === $this->_oid;
97
+	}
98
+    
99
+	/**
100
+	 * Get policy qualifiers.
101
+	 *
102
+	 * @return PolicyQualifierInfo[]
103
+	 */
104
+	public function qualifiers(): array
105
+	{
106
+		return array_values($this->_qualifiers);
107
+	}
108
+    
109
+	/**
110
+	 * Check whether qualifier is present.
111
+	 *
112
+	 * @param string $oid
113
+	 * @return boolean
114
+	 */
115
+	public function has(string $oid): bool
116
+	{
117
+		return isset($this->_qualifiers[$oid]);
118
+	}
119
+    
120
+	/**
121
+	 * Get qualifier by OID.
122
+	 *
123
+	 * @param string $oid
124
+	 * @throws \OutOfBoundsException
125
+	 * @return PolicyQualifierInfo
126
+	 */
127
+	public function get(string $oid): PolicyQualifierInfo
128
+	{
129
+		if (!$this->has($oid)) {
130
+			throw new \LogicException("No $oid qualifier.");
131
+		}
132
+		return $this->_qualifiers[$oid];
133
+	}
134
+    
135
+	/**
136
+	 * Check whether CPS qualifier is present.
137
+	 *
138
+	 * @return bool
139
+	 */
140
+	public function hasCPSQualifier(): bool
141
+	{
142
+		return $this->has(PolicyQualifierInfo::OID_CPS);
143
+	}
144
+    
145
+	/**
146
+	 * Get CPS qualifier.
147
+	 *
148
+	 * @throws \LogicException
149
+	 * @return CPSQualifier
150
+	 */
151
+	public function CPSQualifier(): CPSQualifier
152
+	{
153
+		if (!$this->hasCPSQualifier()) {
154
+			throw new \LogicException("CPS qualifier not set.");
155
+		}
156
+		return $this->get(PolicyQualifierInfo::OID_CPS);
157
+	}
158
+    
159
+	/**
160
+	 * Check whether user notice qualifier is present.
161
+	 *
162
+	 * @return bool
163
+	 */
164
+	public function hasUserNoticeQualifier(): bool
165
+	{
166
+		return $this->has(PolicyQualifierInfo::OID_UNOTICE);
167
+	}
168
+    
169
+	/**
170
+	 * Get user notice qualifier.
171
+	 *
172
+	 * @throws \LogicException
173
+	 * @return UserNoticeQualifier
174
+	 */
175
+	public function userNoticeQualifier(): UserNoticeQualifier
176
+	{
177
+		if (!$this->hasUserNoticeQualifier()) {
178
+			throw new \LogicException("User notice qualifier not set.");
179
+		}
180
+		return $this->get(PolicyQualifierInfo::OID_UNOTICE);
181
+	}
182
+    
183
+	/**
184
+	 * Get ASN.1 structure.
185
+	 *
186
+	 * @return Sequence
187
+	 */
188
+	public function toASN1(): Sequence
189
+	{
190
+		$elements = array(new ObjectIdentifier($this->_oid));
191
+		if (count($this->_qualifiers)) {
192
+			$qualifiers = array_map(
193
+				function (PolicyQualifierInfo $pqi) {
194
+					return $pqi->toASN1();
195
+				}, array_values($this->_qualifiers));
196
+			$elements[] = new Sequence(...$qualifiers);
197
+		}
198
+		return new Sequence(...$elements);
199
+	}
200
+    
201
+	/**
202
+	 * Get number of qualifiers.
203
+	 *
204
+	 * @see \Countable::count()
205
+	 * @return int
206
+	 */
207
+	public function count(): int
208
+	{
209
+		return count($this->_qualifiers);
210
+	}
211
+    
212
+	/**
213
+	 * Get iterator for qualifiers.
214
+	 *
215
+	 * @see \IteratorAggregate::getIterator()
216
+	 * @return \ArrayIterator
217
+	 */
218
+	public function getIterator(): \ArrayIterator
219
+	{
220
+		return new \ArrayIterator($this->_qualifiers);
221
+	}
222 222
 }
Please login to merge, or discard this patch.
lib/X509/Feature/AttributeContainer.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
     {
74 74
         $oid = AttributeType::attrNameToOID($name);
75 75
         $attrs = array_filter($this->_attributes,
76
-            function (Attribute $attr) use ($oid) {
76
+            function(Attribute $attr) use ($oid) {
77 77
                 return $attr->oid() == $oid;
78 78
             });
79 79
         return array_values($attrs);
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
     {
117 117
         $obj = clone $this;
118 118
         $obj->_attributes = array_filter($obj->_attributes,
119
-            function (Attribute $a) use ($attr) {
119
+            function(Attribute $a) use ($attr) {
120 120
                 return $a->oid() != $attr->oid();
121 121
             });
122 122
         $obj->_attributes[] = $attr;
Please login to merge, or discard this patch.
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -14,136 +14,136 @@
 block discarded – undo
14 14
  */
15 15
 trait AttributeContainer
16 16
 {
17
-    /**
18
-     * Array of attributes.
19
-     *
20
-     * @var Attribute[] $_attributes
21
-     */
22
-    protected $_attributes;
17
+	/**
18
+	 * Array of attributes.
19
+	 *
20
+	 * @var Attribute[] $_attributes
21
+	 */
22
+	protected $_attributes;
23 23
     
24
-    /**
25
-     * Find first attribute of given name or OID.
26
-     *
27
-     * @param string $name
28
-     * @return Attribute|null
29
-     */
30
-    protected function _findFirst(string $name)
31
-    {
32
-        $oid = AttributeType::attrNameToOID($name);
33
-        foreach ($this->_attributes as $attr) {
34
-            if ($attr->oid() == $oid) {
35
-                return $attr;
36
-            }
37
-        }
38
-        return null;
39
-    }
24
+	/**
25
+	 * Find first attribute of given name or OID.
26
+	 *
27
+	 * @param string $name
28
+	 * @return Attribute|null
29
+	 */
30
+	protected function _findFirst(string $name)
31
+	{
32
+		$oid = AttributeType::attrNameToOID($name);
33
+		foreach ($this->_attributes as $attr) {
34
+			if ($attr->oid() == $oid) {
35
+				return $attr;
36
+			}
37
+		}
38
+		return null;
39
+	}
40 40
     
41
-    /**
42
-     * Check whether attribute is present.
43
-     *
44
-     * @param string $name OID or attribute name
45
-     * @return boolean
46
-     */
47
-    public function has(string $name): bool
48
-    {
49
-        return null !== $this->_findFirst($name);
50
-    }
41
+	/**
42
+	 * Check whether attribute is present.
43
+	 *
44
+	 * @param string $name OID or attribute name
45
+	 * @return boolean
46
+	 */
47
+	public function has(string $name): bool
48
+	{
49
+		return null !== $this->_findFirst($name);
50
+	}
51 51
     
52
-    /**
53
-     * Get first attribute by OID or attribute name.
54
-     *
55
-     * @param string $name OID or attribute name
56
-     * @throws \OutOfBoundsException
57
-     * @return Attribute
58
-     */
59
-    public function firstOf(string $name): Attribute
60
-    {
61
-        $attr = $this->_findFirst($name);
62
-        if (!$attr) {
63
-            throw new \UnexpectedValueException("No $name attribute.");
64
-        }
65
-        return $attr;
66
-    }
52
+	/**
53
+	 * Get first attribute by OID or attribute name.
54
+	 *
55
+	 * @param string $name OID or attribute name
56
+	 * @throws \OutOfBoundsException
57
+	 * @return Attribute
58
+	 */
59
+	public function firstOf(string $name): Attribute
60
+	{
61
+		$attr = $this->_findFirst($name);
62
+		if (!$attr) {
63
+			throw new \UnexpectedValueException("No $name attribute.");
64
+		}
65
+		return $attr;
66
+	}
67 67
     
68
-    /**
69
-     * Get all attributes of given name.
70
-     *
71
-     * @param string $name OID or attribute name
72
-     * @return Attribute[]
73
-     */
74
-    public function allOf(string $name): array
75
-    {
76
-        $oid = AttributeType::attrNameToOID($name);
77
-        $attrs = array_filter($this->_attributes,
78
-            function (Attribute $attr) use ($oid) {
79
-                return $attr->oid() == $oid;
80
-            });
81
-        return array_values($attrs);
82
-    }
68
+	/**
69
+	 * Get all attributes of given name.
70
+	 *
71
+	 * @param string $name OID or attribute name
72
+	 * @return Attribute[]
73
+	 */
74
+	public function allOf(string $name): array
75
+	{
76
+		$oid = AttributeType::attrNameToOID($name);
77
+		$attrs = array_filter($this->_attributes,
78
+			function (Attribute $attr) use ($oid) {
79
+				return $attr->oid() == $oid;
80
+			});
81
+		return array_values($attrs);
82
+	}
83 83
     
84
-    /**
85
-     * Get all attributes.
86
-     *
87
-     * @return Attribute[]
88
-     */
89
-    public function all(): array
90
-    {
91
-        return $this->_attributes;
92
-    }
84
+	/**
85
+	 * Get all attributes.
86
+	 *
87
+	 * @return Attribute[]
88
+	 */
89
+	public function all(): array
90
+	{
91
+		return $this->_attributes;
92
+	}
93 93
     
94
-    /**
95
-     * Get self with additional attributes added.
96
-     *
97
-     * @param Attribute ...$attribs
98
-     * @return self
99
-     */
100
-    public function withAdditional(Attribute ...$attribs): self
101
-    {
102
-        $obj = clone $this;
103
-        foreach ($attribs as $attr) {
104
-            $obj->_attributes[] = $attr;
105
-        }
106
-        return $obj;
107
-    }
94
+	/**
95
+	 * Get self with additional attributes added.
96
+	 *
97
+	 * @param Attribute ...$attribs
98
+	 * @return self
99
+	 */
100
+	public function withAdditional(Attribute ...$attribs): self
101
+	{
102
+		$obj = clone $this;
103
+		foreach ($attribs as $attr) {
104
+			$obj->_attributes[] = $attr;
105
+		}
106
+		return $obj;
107
+	}
108 108
     
109
-    /**
110
-     * Get self with single unique attribute added.
111
-     *
112
-     * All previous attributes of the same type are removed.
113
-     *
114
-     * @param Attribute $attr
115
-     * @return self
116
-     */
117
-    public function withUnique(Attribute $attr): self
118
-    {
119
-        $obj = clone $this;
120
-        $obj->_attributes = array_filter($obj->_attributes,
121
-            function (Attribute $a) use ($attr) {
122
-                return $a->oid() != $attr->oid();
123
-            });
124
-        $obj->_attributes[] = $attr;
125
-        return $obj;
126
-    }
109
+	/**
110
+	 * Get self with single unique attribute added.
111
+	 *
112
+	 * All previous attributes of the same type are removed.
113
+	 *
114
+	 * @param Attribute $attr
115
+	 * @return self
116
+	 */
117
+	public function withUnique(Attribute $attr): self
118
+	{
119
+		$obj = clone $this;
120
+		$obj->_attributes = array_filter($obj->_attributes,
121
+			function (Attribute $a) use ($attr) {
122
+				return $a->oid() != $attr->oid();
123
+			});
124
+		$obj->_attributes[] = $attr;
125
+		return $obj;
126
+	}
127 127
     
128
-    /**
129
-     * Get number of attributes.
130
-     *
131
-     * @see \Countable::count()
132
-     * @return int
133
-     */
134
-    public function count(): int
135
-    {
136
-        return count($this->_attributes);
137
-    }
128
+	/**
129
+	 * Get number of attributes.
130
+	 *
131
+	 * @see \Countable::count()
132
+	 * @return int
133
+	 */
134
+	public function count(): int
135
+	{
136
+		return count($this->_attributes);
137
+	}
138 138
     
139
-    /**
140
-     * Get iterator for attributes.
141
-     *
142
-     * @see \IteratorAggregate::getIterator()
143
-     * @return \ArrayIterator
144
-     */
145
-    public function getIterator(): \ArrayIterator
146
-    {
147
-        return new \ArrayIterator($this->_attributes);
148
-    }
139
+	/**
140
+	 * Get iterator for attributes.
141
+	 *
142
+	 * @see \IteratorAggregate::getIterator()
143
+	 * @return \ArrayIterator
144
+	 */
145
+	public function getIterator(): \ArrayIterator
146
+	{
147
+		return new \ArrayIterator($this->_attributes);
148
+	}
149 149
 }
Please login to merge, or discard this patch.
X509/AttributeCertificate/Attribute/AuthenticationInfoAttributeValue.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -11,19 +11,19 @@
 block discarded – undo
11 11
  */
12 12
 class AuthenticationInfoAttributeValue extends SvceAuthInfo
13 13
 {
14
-    const OID = "1.3.6.1.5.5.7.10.1";
14
+	const OID = "1.3.6.1.5.5.7.10.1";
15 15
     
16
-    /**
17
-     * Constructor.
18
-     *
19
-     * @param GeneralName $service
20
-     * @param GeneralName $ident
21
-     * @param string|null $auth_info
22
-     */
23
-    public function __construct(GeneralName $service, GeneralName $ident,
24
-        $auth_info = null)
25
-    {
26
-        parent::__construct($service, $ident, $auth_info);
27
-        $this->_oid = self::OID;
28
-    }
16
+	/**
17
+	 * Constructor.
18
+	 *
19
+	 * @param GeneralName $service
20
+	 * @param GeneralName $ident
21
+	 * @param string|null $auth_info
22
+	 */
23
+	public function __construct(GeneralName $service, GeneralName $ident,
24
+		$auth_info = null)
25
+	{
26
+		parent::__construct($service, $ident, $auth_info);
27
+		$this->_oid = self::OID;
28
+	}
29 29
 }
Please login to merge, or discard this patch.
lib/X509/AttributeCertificate/Attribute/ChargingIdentityAttributeValue.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -9,16 +9,16 @@
 block discarded – undo
9 9
  */
10 10
 class ChargingIdentityAttributeValue extends IetfAttrSyntax
11 11
 {
12
-    const OID = "1.3.6.1.5.5.7.10.3";
12
+	const OID = "1.3.6.1.5.5.7.10.3";
13 13
     
14
-    /**
15
-     * Constructor.
16
-     *
17
-     * @param IetfAttrValue ...$values
18
-     */
19
-    public function __construct(IetfAttrValue ...$values)
20
-    {
21
-        parent::__construct(...$values);
22
-        $this->_oid = self::OID;
23
-    }
14
+	/**
15
+	 * Constructor.
16
+	 *
17
+	 * @param IetfAttrValue ...$values
18
+	 */
19
+	public function __construct(IetfAttrValue ...$values)
20
+	{
21
+		parent::__construct(...$values);
22
+		$this->_oid = self::OID;
23
+	}
24 24
 }
Please login to merge, or discard this patch.
lib/X509/AttributeCertificate/Attribute/IetfAttrSyntax.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
             ++$idx;
64 64
         }
65 65
         $values = array_map(
66
-            function (UnspecifiedType $el) {
66
+            function(UnspecifiedType $el) {
67 67
                 return IetfAttrValue::fromASN1($el);
68 68
             },
69 69
             $seq->at($idx)
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
                 $this->_policyAuthority->toASN1());
149 149
         }
150 150
         $values = array_map(
151
-            function (IetfAttrValue $val) {
151
+            function(IetfAttrValue $val) {
152 152
                 return $val->toASN1();
153 153
             }, $this->_values);
154 154
         $elements[] = new Sequence(...$values);
Please login to merge, or discard this patch.
Indentation   +183 added lines, -183 removed lines patch added patch discarded remove patch
@@ -19,203 +19,203 @@
 block discarded – undo
19 19
  * @link https://tools.ietf.org/html/rfc5755#section-4.4
20 20
  */
21 21
 abstract class IetfAttrSyntax extends AttributeValue implements 
22
-    \Countable,
23
-    \IteratorAggregate
22
+	\Countable,
23
+	\IteratorAggregate
24 24
 {
25
-    /**
26
-     * Policy authority.
27
-     *
28
-     * @var GeneralNames|null $_policyAuthority
29
-     */
30
-    protected $_policyAuthority;
25
+	/**
26
+	 * Policy authority.
27
+	 *
28
+	 * @var GeneralNames|null $_policyAuthority
29
+	 */
30
+	protected $_policyAuthority;
31 31
     
32
-    /**
33
-     * Values.
34
-     *
35
-     * @var IetfAttrValue[] $_values
36
-     */
37
-    protected $_values;
32
+	/**
33
+	 * Values.
34
+	 *
35
+	 * @var IetfAttrValue[] $_values
36
+	 */
37
+	protected $_values;
38 38
     
39
-    /**
40
-     * Constructor.
41
-     * 
42
-     * @param IetfAttrValue ...$values
43
-     */
44
-    public function __construct(IetfAttrValue ...$values)
45
-    {
46
-        $this->_policyAuthority = null;
47
-        $this->_values = $values;
48
-    }
39
+	/**
40
+	 * Constructor.
41
+	 * 
42
+	 * @param IetfAttrValue ...$values
43
+	 */
44
+	public function __construct(IetfAttrValue ...$values)
45
+	{
46
+		$this->_policyAuthority = null;
47
+		$this->_values = $values;
48
+	}
49 49
     
50
-    /**
51
-     *
52
-     * @param UnspecifiedType $el
53
-     * @return self
54
-     */
55
-    public static function fromASN1(UnspecifiedType $el): self
56
-    {
57
-        $seq = $el->asSequence();
58
-        $authority = null;
59
-        $idx = 0;
60
-        if ($seq->hasTagged(0)) {
61
-            $authority = GeneralNames::fromASN1(
62
-                $seq->getTagged(0)
63
-                    ->asImplicit(Element::TYPE_SEQUENCE)
64
-                    ->asSequence());
65
-            ++$idx;
66
-        }
67
-        $values = array_map(
68
-            function (UnspecifiedType $el) {
69
-                return IetfAttrValue::fromASN1($el);
70
-            },
71
-            $seq->at($idx)
72
-                ->asSequence()
73
-                ->elements());
74
-        $obj = new static(...$values);
75
-        $obj->_policyAuthority = $authority;
76
-        return $obj;
77
-    }
50
+	/**
51
+	 *
52
+	 * @param UnspecifiedType $el
53
+	 * @return self
54
+	 */
55
+	public static function fromASN1(UnspecifiedType $el): self
56
+	{
57
+		$seq = $el->asSequence();
58
+		$authority = null;
59
+		$idx = 0;
60
+		if ($seq->hasTagged(0)) {
61
+			$authority = GeneralNames::fromASN1(
62
+				$seq->getTagged(0)
63
+					->asImplicit(Element::TYPE_SEQUENCE)
64
+					->asSequence());
65
+			++$idx;
66
+		}
67
+		$values = array_map(
68
+			function (UnspecifiedType $el) {
69
+				return IetfAttrValue::fromASN1($el);
70
+			},
71
+			$seq->at($idx)
72
+				->asSequence()
73
+				->elements());
74
+		$obj = new static(...$values);
75
+		$obj->_policyAuthority = $authority;
76
+		return $obj;
77
+	}
78 78
     
79
-    /**
80
-     * Get self with policy authority.
81
-     *
82
-     * @param GeneralNames $names
83
-     * @return self
84
-     */
85
-    public function withPolicyAuthority(GeneralNames $names): self
86
-    {
87
-        $obj = clone $this;
88
-        $obj->_policyAuthority = $names;
89
-        return $obj;
90
-    }
79
+	/**
80
+	 * Get self with policy authority.
81
+	 *
82
+	 * @param GeneralNames $names
83
+	 * @return self
84
+	 */
85
+	public function withPolicyAuthority(GeneralNames $names): self
86
+	{
87
+		$obj = clone $this;
88
+		$obj->_policyAuthority = $names;
89
+		return $obj;
90
+	}
91 91
     
92
-    /**
93
-     * Check whether policy authority is present.
94
-     *
95
-     * @return bool
96
-     */
97
-    public function hasPolicyAuthority(): bool
98
-    {
99
-        return isset($this->_policyAuthority);
100
-    }
92
+	/**
93
+	 * Check whether policy authority is present.
94
+	 *
95
+	 * @return bool
96
+	 */
97
+	public function hasPolicyAuthority(): bool
98
+	{
99
+		return isset($this->_policyAuthority);
100
+	}
101 101
     
102
-    /**
103
-     * Get policy authority.
104
-     *
105
-     * @throws \LogicException
106
-     * @return GeneralNames
107
-     */
108
-    public function policyAuthority(): GeneralNames
109
-    {
110
-        if (!$this->hasPolicyAuthority()) {
111
-            throw new \LogicException("policyAuthority not set.");
112
-        }
113
-        return $this->_policyAuthority;
114
-    }
102
+	/**
103
+	 * Get policy authority.
104
+	 *
105
+	 * @throws \LogicException
106
+	 * @return GeneralNames
107
+	 */
108
+	public function policyAuthority(): GeneralNames
109
+	{
110
+		if (!$this->hasPolicyAuthority()) {
111
+			throw new \LogicException("policyAuthority not set.");
112
+		}
113
+		return $this->_policyAuthority;
114
+	}
115 115
     
116
-    /**
117
-     * Get values.
118
-     *
119
-     * @return IetfAttrValue[]
120
-     */
121
-    public function values(): array
122
-    {
123
-        return $this->_values;
124
-    }
116
+	/**
117
+	 * Get values.
118
+	 *
119
+	 * @return IetfAttrValue[]
120
+	 */
121
+	public function values(): array
122
+	{
123
+		return $this->_values;
124
+	}
125 125
     
126
-    /**
127
-     * Get first value.
128
-     *
129
-     * @throws \LogicException
130
-     * @return IetfAttrValue
131
-     */
132
-    public function first(): IetfAttrValue
133
-    {
134
-        if (!count($this->_values)) {
135
-            throw new \LogicException("No values.");
136
-        }
137
-        return $this->_values[0];
138
-    }
126
+	/**
127
+	 * Get first value.
128
+	 *
129
+	 * @throws \LogicException
130
+	 * @return IetfAttrValue
131
+	 */
132
+	public function first(): IetfAttrValue
133
+	{
134
+		if (!count($this->_values)) {
135
+			throw new \LogicException("No values.");
136
+		}
137
+		return $this->_values[0];
138
+	}
139 139
     
140
-    /**
141
-     *
142
-     * @see \X501\ASN1\AttributeValue\AttributeValue::toASN1()
143
-     * @return Sequence
144
-     */
145
-    public function toASN1(): Sequence
146
-    {
147
-        $elements = array();
148
-        if (isset($this->_policyAuthority)) {
149
-            $elements[] = new ImplicitlyTaggedType(0,
150
-                $this->_policyAuthority->toASN1());
151
-        }
152
-        $values = array_map(
153
-            function (IetfAttrValue $val) {
154
-                return $val->toASN1();
155
-            }, $this->_values);
156
-        $elements[] = new Sequence(...$values);
157
-        return new Sequence(...$elements);
158
-    }
140
+	/**
141
+	 *
142
+	 * @see \X501\ASN1\AttributeValue\AttributeValue::toASN1()
143
+	 * @return Sequence
144
+	 */
145
+	public function toASN1(): Sequence
146
+	{
147
+		$elements = array();
148
+		if (isset($this->_policyAuthority)) {
149
+			$elements[] = new ImplicitlyTaggedType(0,
150
+				$this->_policyAuthority->toASN1());
151
+		}
152
+		$values = array_map(
153
+			function (IetfAttrValue $val) {
154
+				return $val->toASN1();
155
+			}, $this->_values);
156
+		$elements[] = new Sequence(...$values);
157
+		return new Sequence(...$elements);
158
+	}
159 159
     
160
-    /**
161
-     *
162
-     * @see \X501\ASN1\AttributeValue\AttributeValue::stringValue()
163
-     * @return string
164
-     */
165
-    public function stringValue(): string
166
-    {
167
-        return "#" . bin2hex($this->toASN1()->toDER());
168
-    }
160
+	/**
161
+	 *
162
+	 * @see \X501\ASN1\AttributeValue\AttributeValue::stringValue()
163
+	 * @return string
164
+	 */
165
+	public function stringValue(): string
166
+	{
167
+		return "#" . bin2hex($this->toASN1()->toDER());
168
+	}
169 169
     
170
-    /**
171
-     *
172
-     * @see \X501\ASN1\AttributeValue\AttributeValue::equalityMatchingRule()
173
-     * @return BinaryMatch
174
-     */
175
-    public function equalityMatchingRule(): BinaryMatch
176
-    {
177
-        return new BinaryMatch();
178
-    }
170
+	/**
171
+	 *
172
+	 * @see \X501\ASN1\AttributeValue\AttributeValue::equalityMatchingRule()
173
+	 * @return BinaryMatch
174
+	 */
175
+	public function equalityMatchingRule(): BinaryMatch
176
+	{
177
+		return new BinaryMatch();
178
+	}
179 179
     
180
-    /**
181
-     *
182
-     * @see \X501\ASN1\AttributeValue\AttributeValue::rfc2253String()
183
-     * @return string
184
-     */
185
-    public function rfc2253String(): string
186
-    {
187
-        return $this->stringValue();
188
-    }
180
+	/**
181
+	 *
182
+	 * @see \X501\ASN1\AttributeValue\AttributeValue::rfc2253String()
183
+	 * @return string
184
+	 */
185
+	public function rfc2253String(): string
186
+	{
187
+		return $this->stringValue();
188
+	}
189 189
     
190
-    /**
191
-     *
192
-     * @see \X501\ASN1\AttributeValue\AttributeValue::_transcodedString()
193
-     * @return string
194
-     */
195
-    protected function _transcodedString(): string
196
-    {
197
-        return $this->stringValue();
198
-    }
190
+	/**
191
+	 *
192
+	 * @see \X501\ASN1\AttributeValue\AttributeValue::_transcodedString()
193
+	 * @return string
194
+	 */
195
+	protected function _transcodedString(): string
196
+	{
197
+		return $this->stringValue();
198
+	}
199 199
     
200
-    /**
201
-     * Get number of values.
202
-     *
203
-     * @see \Countable::count()
204
-     * @return int
205
-     */
206
-    public function count(): int
207
-    {
208
-        return count($this->_values);
209
-    }
200
+	/**
201
+	 * Get number of values.
202
+	 *
203
+	 * @see \Countable::count()
204
+	 * @return int
205
+	 */
206
+	public function count(): int
207
+	{
208
+		return count($this->_values);
209
+	}
210 210
     
211
-    /**
212
-     * Get iterator for values.
213
-     *
214
-     * @see \IteratorAggregate::getIterator()
215
-     * @return \ArrayIterator
216
-     */
217
-    public function getIterator(): \ArrayIterator
218
-    {
219
-        return new \ArrayIterator($this->_values);
220
-    }
211
+	/**
212
+	 * Get iterator for values.
213
+	 *
214
+	 * @see \IteratorAggregate::getIterator()
215
+	 * @return \ArrayIterator
216
+	 */
217
+	public function getIterator(): \ArrayIterator
218
+	{
219
+		return new \ArrayIterator($this->_values);
220
+	}
221 221
 }
Please login to merge, or discard this patch.
lib/X509/AttributeCertificate/Attribute/AccessIdentityAttributeValue.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -11,17 +11,17 @@
 block discarded – undo
11 11
  */
12 12
 class AccessIdentityAttributeValue extends SvceAuthInfo
13 13
 {
14
-    const OID = "1.3.6.1.5.5.7.10.2";
14
+	const OID = "1.3.6.1.5.5.7.10.2";
15 15
     
16
-    /**
17
-     * Constructor.
18
-     *
19
-     * @param GeneralName $service
20
-     * @param GeneralName $ident
21
-     */
22
-    public function __construct(GeneralName $service, GeneralName $ident)
23
-    {
24
-        parent::__construct($service, $ident, null);
25
-        $this->_oid = self::OID;
26
-    }
16
+	/**
17
+	 * Constructor.
18
+	 *
19
+	 * @param GeneralName $service
20
+	 * @param GeneralName $ident
21
+	 */
22
+	public function __construct(GeneralName $service, GeneralName $ident)
23
+	{
24
+		parent::__construct($service, $ident, null);
25
+		$this->_oid = self::OID;
26
+	}
27 27
 }
Please login to merge, or discard this patch.
lib/X509/AttributeCertificate/Attribute/GroupAttributeValue.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -9,16 +9,16 @@
 block discarded – undo
9 9
  */
10 10
 class GroupAttributeValue extends IetfAttrSyntax
11 11
 {
12
-    const OID = "1.3.6.1.5.5.7.10.4";
12
+	const OID = "1.3.6.1.5.5.7.10.4";
13 13
     
14
-    /**
15
-     * Constructor.
16
-     *
17
-     * @param IetfAttrValue ...$values
18
-     */
19
-    public function __construct(IetfAttrValue ...$values)
20
-    {
21
-        parent::__construct(...$values);
22
-        $this->_oid = self::OID;
23
-    }
14
+	/**
15
+	 * Constructor.
16
+	 *
17
+	 * @param IetfAttrValue ...$values
18
+	 */
19
+	public function __construct(IetfAttrValue ...$values)
20
+	{
21
+		parent::__construct(...$values);
22
+		$this->_oid = self::OID;
23
+	}
24 24
 }
Please login to merge, or discard this patch.
lib/X509/CertificationPath/Policy/PolicyTree.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
         // is not in the user-initial-policy-set and is not anyPolicy,
93 93
         // delete this node and all its children.
94 94
         $valid_policy_node_set = array_filter($valid_policy_node_set,
95
-            function (PolicyNode $node) use ($policies) {
95
+            function(PolicyNode $node) use ($policies) {
96 96
                 if ($node->isAnyPolicy()) {
97 97
                     return true;
98 98
                 }
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
             });
105 105
         // array of valid policy OIDs
106 106
         $valid_policy_set = array_map(
107
-            function (PolicyNode $node) {
107
+            function(PolicyNode $node) {
108 108
                 return $node->validPolicy();
109 109
             }, $valid_policy_node_set);
110 110
         // 3. If the valid_policy_tree includes a node of depth n with
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
         }
385 385
         // for each node in a tree
386 386
         $this->_root->walkNodes(
387
-            function (PolicyNode $node) use (&$set) {
387
+            function(PolicyNode $node) use (&$set) {
388 388
                 $parents = $node->parents();
389 389
                 // node has parents
390 390
                 if (count($parents)) {
Please login to merge, or discard this patch.
Indentation   +393 added lines, -393 removed lines patch added patch discarded remove patch
@@ -10,411 +10,411 @@
 block discarded – undo
10 10
 
11 11
 class PolicyTree
12 12
 {
13
-    /**
14
-     * Root node at depth zero.
15
-     *
16
-     * @var PolicyNode|null
17
-     */
18
-    protected $_root;
13
+	/**
14
+	 * Root node at depth zero.
15
+	 *
16
+	 * @var PolicyNode|null
17
+	 */
18
+	protected $_root;
19 19
     
20
-    /**
21
-     * Constructor.
22
-     *
23
-     * @param PolicyNode $root Initial root node
24
-     */
25
-    public function __construct(PolicyNode $root)
26
-    {
27
-        $this->_root = $root;
28
-    }
20
+	/**
21
+	 * Constructor.
22
+	 *
23
+	 * @param PolicyNode $root Initial root node
24
+	 */
25
+	public function __construct(PolicyNode $root)
26
+	{
27
+		$this->_root = $root;
28
+	}
29 29
     
30
-    /**
31
-     * Process policy information from the certificate.
32
-     *
33
-     * Certificate policies extension must be present.
34
-     *
35
-     * @param ValidatorState $state
36
-     * @param Certificate $cert
37
-     * @return ValidatorState
38
-     */
39
-    public function processPolicies(ValidatorState $state, Certificate $cert): ValidatorState
40
-    {
41
-        $policies = $cert->tbsCertificate()
42
-            ->extensions()
43
-            ->certificatePolicies();
44
-        $tree = clone $this;
45
-        // (d.1) for each policy P not equal to anyPolicy
46
-        foreach ($policies as $policy) {
47
-            if ($policy->isAnyPolicy()) {
48
-                $tree->_processAnyPolicy($policy, $cert, $state);
49
-            } else {
50
-                $tree->_processPolicy($policy, $state);
51
-            }
52
-        }
53
-        // if whole tree is pruned
54
-        if (!$tree->_pruneTree($state->index() - 1)) {
55
-            return $state->withoutValidPolicyTree();
56
-        }
57
-        return $state->withValidPolicyTree($tree);
58
-    }
30
+	/**
31
+	 * Process policy information from the certificate.
32
+	 *
33
+	 * Certificate policies extension must be present.
34
+	 *
35
+	 * @param ValidatorState $state
36
+	 * @param Certificate $cert
37
+	 * @return ValidatorState
38
+	 */
39
+	public function processPolicies(ValidatorState $state, Certificate $cert): ValidatorState
40
+	{
41
+		$policies = $cert->tbsCertificate()
42
+			->extensions()
43
+			->certificatePolicies();
44
+		$tree = clone $this;
45
+		// (d.1) for each policy P not equal to anyPolicy
46
+		foreach ($policies as $policy) {
47
+			if ($policy->isAnyPolicy()) {
48
+				$tree->_processAnyPolicy($policy, $cert, $state);
49
+			} else {
50
+				$tree->_processPolicy($policy, $state);
51
+			}
52
+		}
53
+		// if whole tree is pruned
54
+		if (!$tree->_pruneTree($state->index() - 1)) {
55
+			return $state->withoutValidPolicyTree();
56
+		}
57
+		return $state->withValidPolicyTree($tree);
58
+	}
59 59
     
60
-    /**
61
-     * Process policy mappings from the certificate.
62
-     *
63
-     * @param ValidatorState $state
64
-     * @param Certificate $cert
65
-     * @return ValidatorState
66
-     */
67
-    public function processMappings(ValidatorState $state, Certificate $cert): ValidatorState
68
-    {
69
-        $tree = clone $this;
70
-        if ($state->policyMapping() > 0) {
71
-            $tree->_applyMappings($cert, $state);
72
-        } else if ($state->policyMapping() == 0) {
73
-            $tree->_deleteMappings($cert, $state);
74
-        }
75
-        // if whole tree is pruned
76
-        if (!$tree->_root) {
77
-            return $state->withoutValidPolicyTree();
78
-        }
79
-        return $state->withValidPolicyTree($tree);
80
-    }
60
+	/**
61
+	 * Process policy mappings from the certificate.
62
+	 *
63
+	 * @param ValidatorState $state
64
+	 * @param Certificate $cert
65
+	 * @return ValidatorState
66
+	 */
67
+	public function processMappings(ValidatorState $state, Certificate $cert): ValidatorState
68
+	{
69
+		$tree = clone $this;
70
+		if ($state->policyMapping() > 0) {
71
+			$tree->_applyMappings($cert, $state);
72
+		} else if ($state->policyMapping() == 0) {
73
+			$tree->_deleteMappings($cert, $state);
74
+		}
75
+		// if whole tree is pruned
76
+		if (!$tree->_root) {
77
+			return $state->withoutValidPolicyTree();
78
+		}
79
+		return $state->withValidPolicyTree($tree);
80
+	}
81 81
     
82
-    /**
83
-     * Calculate policy intersection as specified in Wrap-Up Procedure 6.1.5.g.
84
-     *
85
-     * @param ValidatorState $state
86
-     * @param array $policies
87
-     * @return ValidatorState
88
-     */
89
-    public function calculateIntersection(ValidatorState $state, array $policies): ValidatorState
90
-    {
91
-        $tree = clone $this;
92
-        $valid_policy_node_set = $tree->_validPolicyNodeSet();
93
-        // 2. If the valid_policy of any node in the valid_policy_node_set
94
-        // is not in the user-initial-policy-set and is not anyPolicy,
95
-        // delete this node and all its children.
96
-        $valid_policy_node_set = array_filter($valid_policy_node_set,
97
-            function (PolicyNode $node) use ($policies) {
98
-                if ($node->isAnyPolicy()) {
99
-                    return true;
100
-                }
101
-                if (in_array($node->validPolicy(), $policies)) {
102
-                    return true;
103
-                }
104
-                $node->remove();
105
-                return false;
106
-            });
107
-        // array of valid policy OIDs
108
-        $valid_policy_set = array_map(
109
-            function (PolicyNode $node) {
110
-                return $node->validPolicy();
111
-            }, $valid_policy_node_set);
112
-        // 3. If the valid_policy_tree includes a node of depth n with
113
-        // the valid_policy anyPolicy and the user-initial-policy-set 
114
-        // is not any-policy
115
-        foreach ($tree->_nodesAtDepth($state->index()) as $node) {
116
-            if ($node->hasParent() && $node->isAnyPolicy()) {
117
-                // a. Set P-Q to the qualifier_set in the node of depth n
118
-                // with valid_policy anyPolicy.
119
-                $pq = $node->qualifiers();
120
-                // b. For each P-OID in the user-initial-policy-set that is not
121
-                // the valid_policy of a node in the valid_policy_node_set,
122
-                // create a child node whose parent is the node of depth n-1
123
-                // with the valid_policy anyPolicy.
124
-                $poids = array_diff($policies, $valid_policy_set);
125
-                foreach ($tree->_nodesAtDepth($state->index() - 1) as $parent) {
126
-                    if ($parent->isAnyPolicy()) {
127
-                        // Set the values in the child node as follows: 
128
-                        // set the valid_policy to P-OID, set the qualifier_set
129
-                        // to P-Q, and set the expected_policy_set to {P-OID}.
130
-                        foreach ($poids as $poid) {
131
-                            $parent->addChild(
132
-                                new PolicyNode($poid, $pq, array($poid)));
133
-                        }
134
-                        break;
135
-                    }
136
-                }
137
-                // c. Delete the node of depth n with the
138
-                // valid_policy anyPolicy.
139
-                $node->remove();
140
-            }
141
-        }
142
-        // 4. If there is a node in the valid_policy_tree of depth n-1 or less
143
-        // without any child nodes, delete that node. Repeat this step until
144
-        // there are no nodes of depth n-1 or less without children.
145
-        if (!$tree->_pruneTree($state->index() - 1)) {
146
-            return $state->withoutValidPolicyTree();
147
-        }
148
-        return $state->withValidPolicyTree($tree);
149
-    }
82
+	/**
83
+	 * Calculate policy intersection as specified in Wrap-Up Procedure 6.1.5.g.
84
+	 *
85
+	 * @param ValidatorState $state
86
+	 * @param array $policies
87
+	 * @return ValidatorState
88
+	 */
89
+	public function calculateIntersection(ValidatorState $state, array $policies): ValidatorState
90
+	{
91
+		$tree = clone $this;
92
+		$valid_policy_node_set = $tree->_validPolicyNodeSet();
93
+		// 2. If the valid_policy of any node in the valid_policy_node_set
94
+		// is not in the user-initial-policy-set and is not anyPolicy,
95
+		// delete this node and all its children.
96
+		$valid_policy_node_set = array_filter($valid_policy_node_set,
97
+			function (PolicyNode $node) use ($policies) {
98
+				if ($node->isAnyPolicy()) {
99
+					return true;
100
+				}
101
+				if (in_array($node->validPolicy(), $policies)) {
102
+					return true;
103
+				}
104
+				$node->remove();
105
+				return false;
106
+			});
107
+		// array of valid policy OIDs
108
+		$valid_policy_set = array_map(
109
+			function (PolicyNode $node) {
110
+				return $node->validPolicy();
111
+			}, $valid_policy_node_set);
112
+		// 3. If the valid_policy_tree includes a node of depth n with
113
+		// the valid_policy anyPolicy and the user-initial-policy-set 
114
+		// is not any-policy
115
+		foreach ($tree->_nodesAtDepth($state->index()) as $node) {
116
+			if ($node->hasParent() && $node->isAnyPolicy()) {
117
+				// a. Set P-Q to the qualifier_set in the node of depth n
118
+				// with valid_policy anyPolicy.
119
+				$pq = $node->qualifiers();
120
+				// b. For each P-OID in the user-initial-policy-set that is not
121
+				// the valid_policy of a node in the valid_policy_node_set,
122
+				// create a child node whose parent is the node of depth n-1
123
+				// with the valid_policy anyPolicy.
124
+				$poids = array_diff($policies, $valid_policy_set);
125
+				foreach ($tree->_nodesAtDepth($state->index() - 1) as $parent) {
126
+					if ($parent->isAnyPolicy()) {
127
+						// Set the values in the child node as follows: 
128
+						// set the valid_policy to P-OID, set the qualifier_set
129
+						// to P-Q, and set the expected_policy_set to {P-OID}.
130
+						foreach ($poids as $poid) {
131
+							$parent->addChild(
132
+								new PolicyNode($poid, $pq, array($poid)));
133
+						}
134
+						break;
135
+					}
136
+				}
137
+				// c. Delete the node of depth n with the
138
+				// valid_policy anyPolicy.
139
+				$node->remove();
140
+			}
141
+		}
142
+		// 4. If there is a node in the valid_policy_tree of depth n-1 or less
143
+		// without any child nodes, delete that node. Repeat this step until
144
+		// there are no nodes of depth n-1 or less without children.
145
+		if (!$tree->_pruneTree($state->index() - 1)) {
146
+			return $state->withoutValidPolicyTree();
147
+		}
148
+		return $state->withValidPolicyTree($tree);
149
+	}
150 150
     
151
-    /**
152
-     * Get policies at given policy tree depth.
153
-     *
154
-     * @param int $i Depth in range 1..n
155
-     * @return PolicyInformation[]
156
-     */
157
-    public function policiesAtDepth(int $i): array
158
-    {
159
-        $policies = array();
160
-        foreach ($this->_nodesAtDepth($i) as $node) {
161
-            $policies[] = new PolicyInformation($node->validPolicy(),
162
-                ...$node->qualifiers());
163
-        }
164
-        return $policies;
165
-    }
151
+	/**
152
+	 * Get policies at given policy tree depth.
153
+	 *
154
+	 * @param int $i Depth in range 1..n
155
+	 * @return PolicyInformation[]
156
+	 */
157
+	public function policiesAtDepth(int $i): array
158
+	{
159
+		$policies = array();
160
+		foreach ($this->_nodesAtDepth($i) as $node) {
161
+			$policies[] = new PolicyInformation($node->validPolicy(),
162
+				...$node->qualifiers());
163
+		}
164
+		return $policies;
165
+	}
166 166
     
167
-    /**
168
-     * Process single policy information.
169
-     *
170
-     * @param PolicyInformation $policy
171
-     * @param ValidatorState $state
172
-     */
173
-    protected function _processPolicy(PolicyInformation $policy,
174
-        ValidatorState $state)
175
-    {
176
-        $p_oid = $policy->oid();
177
-        $i = $state->index();
178
-        $match_count = 0;
179
-        // (d.1.i) for each node of depth i-1 in the valid_policy_tree...
180
-        foreach ($this->_nodesAtDepth($i - 1) as $node) {
181
-            // ...where P-OID is in the expected_policy_set
182
-            if ($node->hasExpectedPolicy($p_oid)) {
183
-                $node->addChild(
184
-                    new PolicyNode($p_oid, $policy->qualifiers(), array($p_oid)));
185
-                ++$match_count;
186
-            }
187
-        }
188
-        // (d.1.ii) if there was no match in step (i)...
189
-        if (!$match_count) {
190
-            // ...and the valid_policy_tree includes a node of depth i-1 with
191
-            // the valid_policy anyPolicy
192
-            foreach ($this->_nodesAtDepth($i - 1) as $node) {
193
-                if ($node->isAnyPolicy()) {
194
-                    $node->addChild(
195
-                        new PolicyNode($p_oid, $policy->qualifiers(),
196
-                            array($p_oid)));
197
-                }
198
-            }
199
-        }
200
-    }
167
+	/**
168
+	 * Process single policy information.
169
+	 *
170
+	 * @param PolicyInformation $policy
171
+	 * @param ValidatorState $state
172
+	 */
173
+	protected function _processPolicy(PolicyInformation $policy,
174
+		ValidatorState $state)
175
+	{
176
+		$p_oid = $policy->oid();
177
+		$i = $state->index();
178
+		$match_count = 0;
179
+		// (d.1.i) for each node of depth i-1 in the valid_policy_tree...
180
+		foreach ($this->_nodesAtDepth($i - 1) as $node) {
181
+			// ...where P-OID is in the expected_policy_set
182
+			if ($node->hasExpectedPolicy($p_oid)) {
183
+				$node->addChild(
184
+					new PolicyNode($p_oid, $policy->qualifiers(), array($p_oid)));
185
+				++$match_count;
186
+			}
187
+		}
188
+		// (d.1.ii) if there was no match in step (i)...
189
+		if (!$match_count) {
190
+			// ...and the valid_policy_tree includes a node of depth i-1 with
191
+			// the valid_policy anyPolicy
192
+			foreach ($this->_nodesAtDepth($i - 1) as $node) {
193
+				if ($node->isAnyPolicy()) {
194
+					$node->addChild(
195
+						new PolicyNode($p_oid, $policy->qualifiers(),
196
+							array($p_oid)));
197
+				}
198
+			}
199
+		}
200
+	}
201 201
     
202
-    /**
203
-     * Process anyPolicy policy information.
204
-     *
205
-     * @param PolicyInformation $policy
206
-     * @param Certificate $cert
207
-     * @param ValidatorState $state
208
-     */
209
-    protected function _processAnyPolicy(PolicyInformation $policy,
210
-        Certificate $cert, ValidatorState $state)
211
-    {
212
-        $i = $state->index();
213
-        // if (a) inhibit_anyPolicy is greater than 0 or
214
-        // (b) i<n and the certificate is self-issued
215
-        if (!($state->inhibitAnyPolicy() > 0 ||
216
-             ($i < $state->pathLength() && $cert->isSelfIssued()))) {
217
-            return;
218
-        }
219
-        // for each node in the valid_policy_tree of depth i-1
220
-        foreach ($this->_nodesAtDepth($i - 1) as $node) {
221
-            // for each value in the expected_policy_set
222
-            foreach ($node->expectedPolicies() as $p_oid) {
223
-                // that does not appear in a child node
224
-                if (!$node->hasChildWithValidPolicy($p_oid)) {
225
-                    $node->addChild(
226
-                        new PolicyNode($p_oid, $policy->qualifiers(),
227
-                            array($p_oid)));
228
-                }
229
-            }
230
-        }
231
-    }
202
+	/**
203
+	 * Process anyPolicy policy information.
204
+	 *
205
+	 * @param PolicyInformation $policy
206
+	 * @param Certificate $cert
207
+	 * @param ValidatorState $state
208
+	 */
209
+	protected function _processAnyPolicy(PolicyInformation $policy,
210
+		Certificate $cert, ValidatorState $state)
211
+	{
212
+		$i = $state->index();
213
+		// if (a) inhibit_anyPolicy is greater than 0 or
214
+		// (b) i<n and the certificate is self-issued
215
+		if (!($state->inhibitAnyPolicy() > 0 ||
216
+			 ($i < $state->pathLength() && $cert->isSelfIssued()))) {
217
+			return;
218
+		}
219
+		// for each node in the valid_policy_tree of depth i-1
220
+		foreach ($this->_nodesAtDepth($i - 1) as $node) {
221
+			// for each value in the expected_policy_set
222
+			foreach ($node->expectedPolicies() as $p_oid) {
223
+				// that does not appear in a child node
224
+				if (!$node->hasChildWithValidPolicy($p_oid)) {
225
+					$node->addChild(
226
+						new PolicyNode($p_oid, $policy->qualifiers(),
227
+							array($p_oid)));
228
+				}
229
+			}
230
+		}
231
+	}
232 232
     
233
-    /**
234
-     * Apply policy mappings to the policy tree.
235
-     *
236
-     * @param Certificate $cert
237
-     * @param ValidatorState $state
238
-     */
239
-    protected function _applyMappings(Certificate $cert, ValidatorState $state)
240
-    {
241
-        $policy_mappings = $cert->tbsCertificate()
242
-            ->extensions()
243
-            ->policyMappings();
244
-        // (6.1.4. b.1.) for each node in the valid_policy_tree of depth i...
245
-        foreach ($policy_mappings->flattenedMappings() as $idp => $sdps) {
246
-            $match_count = 0;
247
-            foreach ($this->_nodesAtDepth($state->index()) as $node) {
248
-                // ...where ID-P is the valid_policy
249
-                if ($node->validPolicy() == $idp) {
250
-                    // set expected_policy_set to the set of subjectDomainPolicy
251
-                    // values that are specified as equivalent to ID-P by
252
-                    // the policy mappings extension
253
-                    $node->setExpectedPolicies(...$sdps);
254
-                    ++$match_count;
255
-                }
256
-            }
257
-            // if no node of depth i in the valid_policy_tree has
258
-            // a valid_policy of ID-P...
259
-            if (!$match_count) {
260
-                $this->_applyAnyPolicyMapping($cert, $state, $idp, $sdps);
261
-            }
262
-        }
263
-    }
233
+	/**
234
+	 * Apply policy mappings to the policy tree.
235
+	 *
236
+	 * @param Certificate $cert
237
+	 * @param ValidatorState $state
238
+	 */
239
+	protected function _applyMappings(Certificate $cert, ValidatorState $state)
240
+	{
241
+		$policy_mappings = $cert->tbsCertificate()
242
+			->extensions()
243
+			->policyMappings();
244
+		// (6.1.4. b.1.) for each node in the valid_policy_tree of depth i...
245
+		foreach ($policy_mappings->flattenedMappings() as $idp => $sdps) {
246
+			$match_count = 0;
247
+			foreach ($this->_nodesAtDepth($state->index()) as $node) {
248
+				// ...where ID-P is the valid_policy
249
+				if ($node->validPolicy() == $idp) {
250
+					// set expected_policy_set to the set of subjectDomainPolicy
251
+					// values that are specified as equivalent to ID-P by
252
+					// the policy mappings extension
253
+					$node->setExpectedPolicies(...$sdps);
254
+					++$match_count;
255
+				}
256
+			}
257
+			// if no node of depth i in the valid_policy_tree has
258
+			// a valid_policy of ID-P...
259
+			if (!$match_count) {
260
+				$this->_applyAnyPolicyMapping($cert, $state, $idp, $sdps);
261
+			}
262
+		}
263
+	}
264 264
     
265
-    /**
266
-     * Apply anyPolicy mapping to the policy tree as specified in 6.1.4 (b)(1).
267
-     *
268
-     * @param Certificate $cert
269
-     * @param ValidatorState $state
270
-     * @param string $idp OID of the issuer domain policy
271
-     * @param array $sdps Array of subject domain policy OIDs
272
-     */
273
-    protected function _applyAnyPolicyMapping(Certificate $cert,
274
-        ValidatorState $state, $idp, array $sdps)
275
-    {
276
-        // (6.1.4. b.1.) ...but there is a node of depth i with
277
-        // a valid_policy of anyPolicy
278
-        foreach ($this->_nodesAtDepth($state->index()) as $node) {
279
-            if ($node->isAnyPolicy()) {
280
-                // then generate a child node of the node of depth i-1
281
-                // that has a valid_policy of anyPolicy as follows...
282
-                foreach ($this->_nodesAtDepth($state->index() - 1) as $node) {
283
-                    if ($node->isAnyPolicy()) {
284
-                        // try to fetch qualifiers of anyPolicy certificate policy
285
-                        $qualifiers = array();
286
-                        try {
287
-                            $qualifiers = $cert->tbsCertificate()
288
-                                ->extensions()
289
-                                ->certificatePolicies()
290
-                                ->anyPolicy()
291
-                                ->qualifiers();
292
-                        } catch (\LogicException $e) {
293
-                            // if there's no policies or no qualifiers
294
-                        }
295
-                        $node->addChild(
296
-                            new PolicyNode($idp, $qualifiers, $sdps));
297
-                        // bail after first anyPolicy has been processed
298
-                        break;
299
-                    }
300
-                }
301
-                // bail after first anyPolicy has been processed
302
-                break;
303
-            }
304
-        }
305
-    }
265
+	/**
266
+	 * Apply anyPolicy mapping to the policy tree as specified in 6.1.4 (b)(1).
267
+	 *
268
+	 * @param Certificate $cert
269
+	 * @param ValidatorState $state
270
+	 * @param string $idp OID of the issuer domain policy
271
+	 * @param array $sdps Array of subject domain policy OIDs
272
+	 */
273
+	protected function _applyAnyPolicyMapping(Certificate $cert,
274
+		ValidatorState $state, $idp, array $sdps)
275
+	{
276
+		// (6.1.4. b.1.) ...but there is a node of depth i with
277
+		// a valid_policy of anyPolicy
278
+		foreach ($this->_nodesAtDepth($state->index()) as $node) {
279
+			if ($node->isAnyPolicy()) {
280
+				// then generate a child node of the node of depth i-1
281
+				// that has a valid_policy of anyPolicy as follows...
282
+				foreach ($this->_nodesAtDepth($state->index() - 1) as $node) {
283
+					if ($node->isAnyPolicy()) {
284
+						// try to fetch qualifiers of anyPolicy certificate policy
285
+						$qualifiers = array();
286
+						try {
287
+							$qualifiers = $cert->tbsCertificate()
288
+								->extensions()
289
+								->certificatePolicies()
290
+								->anyPolicy()
291
+								->qualifiers();
292
+						} catch (\LogicException $e) {
293
+							// if there's no policies or no qualifiers
294
+						}
295
+						$node->addChild(
296
+							new PolicyNode($idp, $qualifiers, $sdps));
297
+						// bail after first anyPolicy has been processed
298
+						break;
299
+					}
300
+				}
301
+				// bail after first anyPolicy has been processed
302
+				break;
303
+			}
304
+		}
305
+	}
306 306
     
307
-    /**
308
-     * Delete nodes as specified in 6.1.4 (b)(2).
309
-     *
310
-     * @param Certificate $cert
311
-     * @param ValidatorState $state
312
-     */
313
-    protected function _deleteMappings(Certificate $cert, ValidatorState $state)
314
-    {
315
-        $idps = $cert->tbsCertificate()
316
-            ->extensions()
317
-            ->policyMappings()
318
-            ->issuerDomainPolicies();
319
-        // delete each node of depth i in the valid_policy_tree
320
-        // where ID-P is the valid_policy
321
-        foreach ($this->_nodesAtDepth($state->index()) as $node) {
322
-            if (in_array($node->validPolicy(), $idps)) {
323
-                $node->remove();
324
-            }
325
-        }
326
-        $this->_pruneTree($state->index() - 1);
327
-    }
307
+	/**
308
+	 * Delete nodes as specified in 6.1.4 (b)(2).
309
+	 *
310
+	 * @param Certificate $cert
311
+	 * @param ValidatorState $state
312
+	 */
313
+	protected function _deleteMappings(Certificate $cert, ValidatorState $state)
314
+	{
315
+		$idps = $cert->tbsCertificate()
316
+			->extensions()
317
+			->policyMappings()
318
+			->issuerDomainPolicies();
319
+		// delete each node of depth i in the valid_policy_tree
320
+		// where ID-P is the valid_policy
321
+		foreach ($this->_nodesAtDepth($state->index()) as $node) {
322
+			if (in_array($node->validPolicy(), $idps)) {
323
+				$node->remove();
324
+			}
325
+		}
326
+		$this->_pruneTree($state->index() - 1);
327
+	}
328 328
     
329
-    /**
330
-     * Prune tree starting from given depth.
331
-     *
332
-     * @param int $depth
333
-     * @return int The number of nodes left in a tree
334
-     */
335
-    protected function _pruneTree(int $depth): int
336
-    {
337
-        for ($i = $depth; $i > 0; --$i) {
338
-            foreach ($this->_nodesAtDepth($i) as $node) {
339
-                if (!count($node)) {
340
-                    $node->remove();
341
-                }
342
-            }
343
-        }
344
-        // if root has no children left
345
-        if (!count($this->_root)) {
346
-            $this->_root = null;
347
-            return 0;
348
-        }
349
-        return $this->_root->nodeCount();
350
-    }
329
+	/**
330
+	 * Prune tree starting from given depth.
331
+	 *
332
+	 * @param int $depth
333
+	 * @return int The number of nodes left in a tree
334
+	 */
335
+	protected function _pruneTree(int $depth): int
336
+	{
337
+		for ($i = $depth; $i > 0; --$i) {
338
+			foreach ($this->_nodesAtDepth($i) as $node) {
339
+				if (!count($node)) {
340
+					$node->remove();
341
+				}
342
+			}
343
+		}
344
+		// if root has no children left
345
+		if (!count($this->_root)) {
346
+			$this->_root = null;
347
+			return 0;
348
+		}
349
+		return $this->_root->nodeCount();
350
+	}
351 351
     
352
-    /**
353
-     * Get all nodes at given depth.
354
-     *
355
-     * @param int $i
356
-     * @return PolicyNode[]
357
-     */
358
-    protected function _nodesAtDepth(int $i): array
359
-    {
360
-        if (!$this->_root) {
361
-            return array();
362
-        }
363
-        $depth = 0;
364
-        $nodes = array($this->_root);
365
-        while ($depth < $i) {
366
-            $nodes = self::_gatherChildren(...$nodes);
367
-            if (!count($nodes)) {
368
-                break;
369
-            }
370
-            ++$depth;
371
-        }
372
-        return $nodes;
373
-    }
352
+	/**
353
+	 * Get all nodes at given depth.
354
+	 *
355
+	 * @param int $i
356
+	 * @return PolicyNode[]
357
+	 */
358
+	protected function _nodesAtDepth(int $i): array
359
+	{
360
+		if (!$this->_root) {
361
+			return array();
362
+		}
363
+		$depth = 0;
364
+		$nodes = array($this->_root);
365
+		while ($depth < $i) {
366
+			$nodes = self::_gatherChildren(...$nodes);
367
+			if (!count($nodes)) {
368
+				break;
369
+			}
370
+			++$depth;
371
+		}
372
+		return $nodes;
373
+	}
374 374
     
375
-    /**
376
-     * Get the valid policy node set as specified in spec 6.1.5.(g)(iii)1.
377
-     *
378
-     * @return PolicyNode[]
379
-     */
380
-    protected function _validPolicyNodeSet(): array
381
-    {
382
-        // 1. Determine the set of policy nodes whose parent nodes have
383
-        // a valid_policy of anyPolicy. This is the valid_policy_node_set.
384
-        $set = array();
385
-        if (!$this->_root) {
386
-            return $set;
387
-        }
388
-        // for each node in a tree
389
-        $this->_root->walkNodes(
390
-            function (PolicyNode $node) use (&$set) {
391
-                $parents = $node->parents();
392
-                // node has parents
393
-                if (count($parents)) {
394
-                    // check that each ancestor is an anyPolicy node
395
-                    foreach ($parents as $ancestor) {
396
-                        if (!$ancestor->isAnyPolicy()) {
397
-                            return;
398
-                        }
399
-                    }
400
-                    $set[] = $node;
401
-                }
402
-            });
403
-        return $set;
404
-    }
375
+	/**
376
+	 * Get the valid policy node set as specified in spec 6.1.5.(g)(iii)1.
377
+	 *
378
+	 * @return PolicyNode[]
379
+	 */
380
+	protected function _validPolicyNodeSet(): array
381
+	{
382
+		// 1. Determine the set of policy nodes whose parent nodes have
383
+		// a valid_policy of anyPolicy. This is the valid_policy_node_set.
384
+		$set = array();
385
+		if (!$this->_root) {
386
+			return $set;
387
+		}
388
+		// for each node in a tree
389
+		$this->_root->walkNodes(
390
+			function (PolicyNode $node) use (&$set) {
391
+				$parents = $node->parents();
392
+				// node has parents
393
+				if (count($parents)) {
394
+					// check that each ancestor is an anyPolicy node
395
+					foreach ($parents as $ancestor) {
396
+						if (!$ancestor->isAnyPolicy()) {
397
+							return;
398
+						}
399
+					}
400
+					$set[] = $node;
401
+				}
402
+			});
403
+		return $set;
404
+	}
405 405
     
406
-    /**
407
-     * Gather all children of given nodes to a flattened array.
408
-     *
409
-     * @param PolicyNode ...$nodes
410
-     * @return PolicyNode[]
411
-     */
412
-    private static function _gatherChildren(PolicyNode ...$nodes): array
413
-    {
414
-        $children = array();
415
-        foreach ($nodes as $node) {
416
-            $children = array_merge($children, $node->children());
417
-        }
418
-        return $children;
419
-    }
406
+	/**
407
+	 * Gather all children of given nodes to a flattened array.
408
+	 *
409
+	 * @param PolicyNode ...$nodes
410
+	 * @return PolicyNode[]
411
+	 */
412
+	private static function _gatherChildren(PolicyNode ...$nodes): array
413
+	{
414
+		$children = array();
415
+		foreach ($nodes as $node) {
416
+			$children = array_merge($children, $node->children());
417
+		}
418
+		return $children;
419
+	}
420 420
 }
Please login to merge, or discard this patch.