@@ -12,20 +12,20 @@ |
||
12 | 12 | */ |
13 | 13 | abstract class ContextSpecificTaggedType extends TaggedType |
14 | 14 | { |
15 | - /** |
|
16 | - * Wrapped element. |
|
17 | - * |
|
18 | - * @var \ASN1\Element $_element |
|
19 | - */ |
|
20 | - protected $_element; |
|
15 | + /** |
|
16 | + * Wrapped element. |
|
17 | + * |
|
18 | + * @var \ASN1\Element $_element |
|
19 | + */ |
|
20 | + protected $_element; |
|
21 | 21 | |
22 | - /** |
|
23 | - * |
|
24 | - * @see \ASN1\Element::typeClass() |
|
25 | - * @return int |
|
26 | - */ |
|
27 | - public function typeClass(): int |
|
28 | - { |
|
29 | - return Identifier::CLASS_CONTEXT_SPECIFIC; |
|
30 | - } |
|
22 | + /** |
|
23 | + * |
|
24 | + * @see \ASN1\Element::typeClass() |
|
25 | + * @return int |
|
26 | + */ |
|
27 | + public function typeClass(): int |
|
28 | + { |
|
29 | + return Identifier::CLASS_CONTEXT_SPECIFIC; |
|
30 | + } |
|
31 | 31 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace ASN1\Type\Tagged; |
6 | 6 |
@@ -12,13 +12,13 @@ |
||
12 | 12 | */ |
13 | 13 | interface ImplicitTagging extends ElementBase |
14 | 14 | { |
15 | - /** |
|
16 | - * Get implicitly tagged wrapped element. |
|
17 | - * |
|
18 | - * @param int $tag Tag of the element |
|
19 | - * @param int $class Expected type class of the element |
|
20 | - * @throws \UnexpectedValueException If expectation fails |
|
21 | - * @return \ASN1\Type\UnspecifiedType |
|
22 | - */ |
|
23 | - public function implicit($tag, int $class = Identifier::CLASS_UNIVERSAL); |
|
15 | + /** |
|
16 | + * Get implicitly tagged wrapped element. |
|
17 | + * |
|
18 | + * @param int $tag Tag of the element |
|
19 | + * @param int $class Expected type class of the element |
|
20 | + * @throws \UnexpectedValueException If expectation fails |
|
21 | + * @return \ASN1\Type\UnspecifiedType |
|
22 | + */ |
|
23 | + public function implicit($tag, int $class = Identifier::CLASS_UNIVERSAL); |
|
24 | 24 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace ASN1\Type\Tagged; |
6 | 6 |
@@ -12,15 +12,15 @@ |
||
12 | 12 | */ |
13 | 13 | interface ExplicitTagging extends ElementBase |
14 | 14 | { |
15 | - /** |
|
16 | - * Get explicitly tagged wrapped element. |
|
17 | - * |
|
18 | - * NOTE! Expectation checking is deprecated and shall be done |
|
19 | - * with UnspecifiedType. |
|
20 | - * |
|
21 | - * @param int|null $expectedTag Expected tag of the underlying type |
|
22 | - * @throws \UnexpectedValueException If expectation fails |
|
23 | - * @return \ASN1\Type\UnspecifiedType |
|
24 | - */ |
|
25 | - public function explicit($expectedTag = null): UnspecifiedType; |
|
15 | + /** |
|
16 | + * Get explicitly tagged wrapped element. |
|
17 | + * |
|
18 | + * NOTE! Expectation checking is deprecated and shall be done |
|
19 | + * with UnspecifiedType. |
|
20 | + * |
|
21 | + * @param int|null $expectedTag Expected tag of the underlying type |
|
22 | + * @throws \UnexpectedValueException If expectation fails |
|
23 | + * @return \ASN1\Type\UnspecifiedType |
|
24 | + */ |
|
25 | + public function explicit($expectedTag = null): UnspecifiedType; |
|
26 | 26 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace ASN1\Type\Tagged; |
6 | 6 |
@@ -16,55 +16,55 @@ |
||
16 | 16 | * decoding the data. |
17 | 17 | */ |
18 | 18 | class ImplicitlyTaggedType extends ContextSpecificTaggedType implements |
19 | - ImplicitTagging |
|
19 | + ImplicitTagging |
|
20 | 20 | { |
21 | - /** |
|
22 | - * Constructor. |
|
23 | - * |
|
24 | - * @param int $tag |
|
25 | - * @param Element $element |
|
26 | - */ |
|
27 | - public function __construct($tag, Element $element) |
|
28 | - { |
|
29 | - $this->_typeTag = $tag; |
|
30 | - $this->_element = $element; |
|
31 | - } |
|
21 | + /** |
|
22 | + * Constructor. |
|
23 | + * |
|
24 | + * @param int $tag |
|
25 | + * @param Element $element |
|
26 | + */ |
|
27 | + public function __construct($tag, Element $element) |
|
28 | + { |
|
29 | + $this->_typeTag = $tag; |
|
30 | + $this->_element = $element; |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * |
|
35 | - * @see \ASN1\Element::isConstructed() |
|
36 | - * @return bool |
|
37 | - */ |
|
38 | - public function isConstructed(): bool |
|
39 | - { |
|
40 | - // depends on the underlying type |
|
41 | - return $this->_element->isConstructed(); |
|
42 | - } |
|
33 | + /** |
|
34 | + * |
|
35 | + * @see \ASN1\Element::isConstructed() |
|
36 | + * @return bool |
|
37 | + */ |
|
38 | + public function isConstructed(): bool |
|
39 | + { |
|
40 | + // depends on the underlying type |
|
41 | + return $this->_element->isConstructed(); |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * |
|
46 | - * @see \ASN1\Element::_encodedContentDER() |
|
47 | - * @return string |
|
48 | - */ |
|
49 | - protected function _encodedContentDER(): string |
|
50 | - { |
|
51 | - return $this->_element->_encodedContentDER(); |
|
52 | - } |
|
44 | + /** |
|
45 | + * |
|
46 | + * @see \ASN1\Element::_encodedContentDER() |
|
47 | + * @return string |
|
48 | + */ |
|
49 | + protected function _encodedContentDER(): string |
|
50 | + { |
|
51 | + return $this->_element->_encodedContentDER(); |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * {@inheritdoc} |
|
56 | - * @see \ASN1\Type\Tagged\ImplicitTagging::implicit() |
|
57 | - * @return UnspecifiedType |
|
58 | - */ |
|
59 | - public function implicit($tag, int $class = Identifier::CLASS_UNIVERSAL): UnspecifiedType |
|
60 | - { |
|
61 | - $this->_element->expectType($tag); |
|
62 | - if ($this->_element->typeClass() != $class) { |
|
63 | - throw new \UnexpectedValueException( |
|
64 | - sprintf("Type class %s expected, got %s.", |
|
65 | - Identifier::classToName($class), |
|
66 | - Identifier::classToName($this->_element->typeClass()))); |
|
67 | - } |
|
68 | - return new UnspecifiedType($this->_element); |
|
69 | - } |
|
54 | + /** |
|
55 | + * {@inheritdoc} |
|
56 | + * @see \ASN1\Type\Tagged\ImplicitTagging::implicit() |
|
57 | + * @return UnspecifiedType |
|
58 | + */ |
|
59 | + public function implicit($tag, int $class = Identifier::CLASS_UNIVERSAL): UnspecifiedType |
|
60 | + { |
|
61 | + $this->_element->expectType($tag); |
|
62 | + if ($this->_element->typeClass() != $class) { |
|
63 | + throw new \UnexpectedValueException( |
|
64 | + sprintf("Type class %s expected, got %s.", |
|
65 | + Identifier::classToName($class), |
|
66 | + Identifier::classToName($this->_element->typeClass()))); |
|
67 | + } |
|
68 | + return new UnspecifiedType($this->_element); |
|
69 | + } |
|
70 | 70 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace ASN1\Type\Tagged; |
6 | 6 |
@@ -14,50 +14,50 @@ |
||
14 | 14 | * is not changed. |
15 | 15 | */ |
16 | 16 | class ExplicitlyTaggedType extends ContextSpecificTaggedType implements |
17 | - ExplicitTagging |
|
17 | + ExplicitTagging |
|
18 | 18 | { |
19 | - /** |
|
20 | - * Constructor. |
|
21 | - * |
|
22 | - * @param int $tag Tag number |
|
23 | - * @param Element $element Wrapped element |
|
24 | - */ |
|
25 | - public function __construct($tag, Element $element) |
|
26 | - { |
|
27 | - $this->_typeTag = $tag; |
|
28 | - $this->_element = $element; |
|
29 | - } |
|
19 | + /** |
|
20 | + * Constructor. |
|
21 | + * |
|
22 | + * @param int $tag Tag number |
|
23 | + * @param Element $element Wrapped element |
|
24 | + */ |
|
25 | + public function __construct($tag, Element $element) |
|
26 | + { |
|
27 | + $this->_typeTag = $tag; |
|
28 | + $this->_element = $element; |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * |
|
33 | - * @see \ASN1\Element::isConstructed() |
|
34 | - * @return bool |
|
35 | - */ |
|
36 | - public function isConstructed(): bool |
|
37 | - { |
|
38 | - return true; |
|
39 | - } |
|
31 | + /** |
|
32 | + * |
|
33 | + * @see \ASN1\Element::isConstructed() |
|
34 | + * @return bool |
|
35 | + */ |
|
36 | + public function isConstructed(): bool |
|
37 | + { |
|
38 | + return true; |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * |
|
43 | - * @see \ASN1\Element::_encodedContentDER() |
|
44 | - * @return string |
|
45 | - */ |
|
46 | - protected function _encodedContentDER(): string |
|
47 | - { |
|
48 | - return $this->_element->toDER(); |
|
49 | - } |
|
41 | + /** |
|
42 | + * |
|
43 | + * @see \ASN1\Element::_encodedContentDER() |
|
44 | + * @return string |
|
45 | + */ |
|
46 | + protected function _encodedContentDER(): string |
|
47 | + { |
|
48 | + return $this->_element->toDER(); |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * {@inheritdoc} |
|
53 | - * @see \ASN1\Type\Tagged\ExplicitTagging::explicit() |
|
54 | - * @return UnspecifiedType |
|
55 | - */ |
|
56 | - public function explicit($expectedTag = null): UnspecifiedType |
|
57 | - { |
|
58 | - if (isset($expectedTag)) { |
|
59 | - $this->_element->expectType($expectedTag); |
|
60 | - } |
|
61 | - return new UnspecifiedType($this->_element); |
|
62 | - } |
|
51 | + /** |
|
52 | + * {@inheritdoc} |
|
53 | + * @see \ASN1\Type\Tagged\ExplicitTagging::explicit() |
|
54 | + * @return UnspecifiedType |
|
55 | + */ |
|
56 | + public function explicit($expectedTag = null): UnspecifiedType |
|
57 | + { |
|
58 | + if (isset($expectedTag)) { |
|
59 | + $this->_element->expectType($expectedTag); |
|
60 | + } |
|
61 | + return new UnspecifiedType($this->_element); |
|
62 | + } |
|
63 | 63 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace ASN1\Type\Tagged; |
6 | 6 |
@@ -20,104 +20,104 @@ |
||
20 | 20 | * May be encoded back to complete DER encoding. |
21 | 21 | */ |
22 | 22 | class DERTaggedType extends TaggedType implements |
23 | - ExplicitTagging, |
|
24 | - ImplicitTagging |
|
23 | + ExplicitTagging, |
|
24 | + ImplicitTagging |
|
25 | 25 | { |
26 | - /** |
|
27 | - * Identifier. |
|
28 | - * |
|
29 | - * @var Identifier |
|
30 | - */ |
|
31 | - private $_identifier; |
|
26 | + /** |
|
27 | + * Identifier. |
|
28 | + * |
|
29 | + * @var Identifier |
|
30 | + */ |
|
31 | + private $_identifier; |
|
32 | 32 | |
33 | - /** |
|
34 | - * DER data. |
|
35 | - * |
|
36 | - * @var string |
|
37 | - */ |
|
38 | - private $_data; |
|
33 | + /** |
|
34 | + * DER data. |
|
35 | + * |
|
36 | + * @var string |
|
37 | + */ |
|
38 | + private $_data; |
|
39 | 39 | |
40 | - /** |
|
41 | - * Offset to data. |
|
42 | - * |
|
43 | - * @var int |
|
44 | - */ |
|
45 | - private $_offset; |
|
40 | + /** |
|
41 | + * Offset to data. |
|
42 | + * |
|
43 | + * @var int |
|
44 | + */ |
|
45 | + private $_offset; |
|
46 | 46 | |
47 | - /** |
|
48 | - * Constructor. |
|
49 | - * |
|
50 | - * @param Identifier $identifier |
|
51 | - * @param string $data |
|
52 | - * @param int $offset Offset to next byte after identifier |
|
53 | - */ |
|
54 | - public function __construct(Identifier $identifier, string $data, int $offset) |
|
55 | - { |
|
56 | - $this->_identifier = $identifier; |
|
57 | - $this->_data = $data; |
|
58 | - $this->_offset = $offset; |
|
59 | - $this->_typeTag = intval($identifier->tag()); |
|
60 | - } |
|
47 | + /** |
|
48 | + * Constructor. |
|
49 | + * |
|
50 | + * @param Identifier $identifier |
|
51 | + * @param string $data |
|
52 | + * @param int $offset Offset to next byte after identifier |
|
53 | + */ |
|
54 | + public function __construct(Identifier $identifier, string $data, int $offset) |
|
55 | + { |
|
56 | + $this->_identifier = $identifier; |
|
57 | + $this->_data = $data; |
|
58 | + $this->_offset = $offset; |
|
59 | + $this->_typeTag = intval($identifier->tag()); |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * |
|
64 | - * @see \ASN1\Element::typeClass() |
|
65 | - * @return int |
|
66 | - */ |
|
67 | - public function typeClass(): int |
|
68 | - { |
|
69 | - return $this->_identifier->typeClass(); |
|
70 | - } |
|
62 | + /** |
|
63 | + * |
|
64 | + * @see \ASN1\Element::typeClass() |
|
65 | + * @return int |
|
66 | + */ |
|
67 | + public function typeClass(): int |
|
68 | + { |
|
69 | + return $this->_identifier->typeClass(); |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * |
|
74 | - * @see \ASN1\Element::isConstructed() |
|
75 | - * @return bool |
|
76 | - */ |
|
77 | - public function isConstructed(): bool |
|
78 | - { |
|
79 | - return $this->_identifier->isConstructed(); |
|
80 | - } |
|
72 | + /** |
|
73 | + * |
|
74 | + * @see \ASN1\Element::isConstructed() |
|
75 | + * @return bool |
|
76 | + */ |
|
77 | + public function isConstructed(): bool |
|
78 | + { |
|
79 | + return $this->_identifier->isConstructed(); |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * |
|
84 | - * @see \ASN1\Element::_encodedContentDER() |
|
85 | - * @return string |
|
86 | - */ |
|
87 | - protected function _encodedContentDER(): string |
|
88 | - { |
|
89 | - $idx = $this->_offset; |
|
90 | - $length = Length::expectFromDER($this->_data, $idx); |
|
91 | - return substr($this->_data, $idx, $length->length()); |
|
92 | - } |
|
82 | + /** |
|
83 | + * |
|
84 | + * @see \ASN1\Element::_encodedContentDER() |
|
85 | + * @return string |
|
86 | + */ |
|
87 | + protected function _encodedContentDER(): string |
|
88 | + { |
|
89 | + $idx = $this->_offset; |
|
90 | + $length = Length::expectFromDER($this->_data, $idx); |
|
91 | + return substr($this->_data, $idx, $length->length()); |
|
92 | + } |
|
93 | 93 | |
94 | - /** |
|
95 | - * {@inheritdoc} |
|
96 | - * @see \ASN1\Type\Tagged\ImplicitTagging::implicit() |
|
97 | - * @return UnspecifiedType |
|
98 | - */ |
|
99 | - public function implicit($tag, int $class = Identifier::CLASS_UNIVERSAL): UnspecifiedType |
|
100 | - { |
|
101 | - $identifier = $this->_identifier->withClass($class)->withTag($tag); |
|
102 | - $cls = self::_determineImplClass($identifier); |
|
103 | - $idx = $this->_offset; |
|
104 | - $element = $cls::_decodeFromDER($identifier, $this->_data, $idx); |
|
105 | - return new UnspecifiedType($element); |
|
106 | - } |
|
94 | + /** |
|
95 | + * {@inheritdoc} |
|
96 | + * @see \ASN1\Type\Tagged\ImplicitTagging::implicit() |
|
97 | + * @return UnspecifiedType |
|
98 | + */ |
|
99 | + public function implicit($tag, int $class = Identifier::CLASS_UNIVERSAL): UnspecifiedType |
|
100 | + { |
|
101 | + $identifier = $this->_identifier->withClass($class)->withTag($tag); |
|
102 | + $cls = self::_determineImplClass($identifier); |
|
103 | + $idx = $this->_offset; |
|
104 | + $element = $cls::_decodeFromDER($identifier, $this->_data, $idx); |
|
105 | + return new UnspecifiedType($element); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * |
|
110 | - * @see \ASN1\Type\Tagged\ExplicitTagging::explicit() |
|
111 | - * @return UnspecifiedType |
|
112 | - */ |
|
113 | - public function explicit($expectedTag = null): UnspecifiedType |
|
114 | - { |
|
115 | - $idx = $this->_offset; |
|
116 | - Length::expectFromDER($this->_data, $idx); |
|
117 | - $element = Element::fromDER($this->_data, $idx); |
|
118 | - if (isset($expectedTag)) { |
|
119 | - $element->expectType($expectedTag); |
|
120 | - } |
|
121 | - return new UnspecifiedType($element); |
|
122 | - } |
|
108 | + /** |
|
109 | + * |
|
110 | + * @see \ASN1\Type\Tagged\ExplicitTagging::explicit() |
|
111 | + * @return UnspecifiedType |
|
112 | + */ |
|
113 | + public function explicit($expectedTag = null): UnspecifiedType |
|
114 | + { |
|
115 | + $idx = $this->_offset; |
|
116 | + Length::expectFromDER($this->_data, $idx); |
|
117 | + $element = Element::fromDER($this->_data, $idx); |
|
118 | + if (isset($expectedTag)) { |
|
119 | + $element->expectType($expectedTag); |
|
120 | + } |
|
121 | + return new UnspecifiedType($element); |
|
122 | + } |
|
123 | 123 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace ASN1\Type\Tagged; |
6 | 6 |
@@ -9,13 +9,13 @@ |
||
9 | 9 | */ |
10 | 10 | trait PrimitiveType |
11 | 11 | { |
12 | - /** |
|
13 | - * |
|
14 | - * @see \ASN1\Element::isConstructed() |
|
15 | - * @return boolean |
|
16 | - */ |
|
17 | - public function isConstructed(): bool |
|
18 | - { |
|
19 | - return false; |
|
20 | - } |
|
12 | + /** |
|
13 | + * |
|
14 | + * @see \ASN1\Element::isConstructed() |
|
15 | + * @return boolean |
|
16 | + */ |
|
17 | + public function isConstructed(): bool |
|
18 | + { |
|
19 | + return false; |
|
20 | + } |
|
21 | 21 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace ASN1\Type; |
6 | 6 |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace ASN1\Type\Primitive; |
6 | 6 |