@@ -6,106 +6,106 @@ |
||
| 6 | 6 | |
| 7 | 7 | class BigInt |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Number as a base10 integer string. |
|
| 11 | - * |
|
| 12 | - * @var string |
|
| 13 | - */ |
|
| 14 | - private $_num; |
|
| 9 | + /** |
|
| 10 | + * Number as a base10 integer string. |
|
| 11 | + * |
|
| 12 | + * @var string |
|
| 13 | + */ |
|
| 14 | + private $_num; |
|
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * Number as an integer type. |
|
| 18 | - * |
|
| 19 | - * @internal Lazily initialized |
|
| 20 | - * @var int|null |
|
| 21 | - */ |
|
| 22 | - private $_intNum; |
|
| 16 | + /** |
|
| 17 | + * Number as an integer type. |
|
| 18 | + * |
|
| 19 | + * @internal Lazily initialized |
|
| 20 | + * @var int|null |
|
| 21 | + */ |
|
| 22 | + private $_intNum; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Constructor. |
|
| 26 | - * |
|
| 27 | - * @param string|int $num |
|
| 28 | - */ |
|
| 29 | - public function __construct($num) |
|
| 30 | - { |
|
| 31 | - $this->_num = strval($num); |
|
| 32 | - } |
|
| 24 | + /** |
|
| 25 | + * Constructor. |
|
| 26 | + * |
|
| 27 | + * @param string|int $num |
|
| 28 | + */ |
|
| 29 | + public function __construct($num) |
|
| 30 | + { |
|
| 31 | + $this->_num = strval($num); |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Get the number as a base10 integer string. |
|
| 36 | - * |
|
| 37 | - * @return string |
|
| 38 | - */ |
|
| 39 | - public function base10(): string |
|
| 40 | - { |
|
| 41 | - return $this->_num; |
|
| 42 | - } |
|
| 34 | + /** |
|
| 35 | + * Get the number as a base10 integer string. |
|
| 36 | + * |
|
| 37 | + * @return string |
|
| 38 | + */ |
|
| 39 | + public function base10(): string |
|
| 40 | + { |
|
| 41 | + return $this->_num; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Get the number as an integer. |
|
| 46 | - * |
|
| 47 | - * @throws \RuntimeException If number overflows integer size |
|
| 48 | - * @return int |
|
| 49 | - */ |
|
| 50 | - public function intVal(): int |
|
| 51 | - { |
|
| 52 | - if (!isset($this->_intNum)) { |
|
| 53 | - $num = gmp_init($this->_num, 10); |
|
| 54 | - if (gmp_cmp($num, $this->_intMaxGmp()) > 0) { |
|
| 55 | - throw new \RuntimeException("Integer overflow."); |
|
| 56 | - } |
|
| 57 | - if (gmp_cmp($num, $this->_intMinGmp()) < 0) { |
|
| 58 | - throw new \RuntimeException("Integer underflow."); |
|
| 59 | - } |
|
| 60 | - $this->_intNum = gmp_intval($num); |
|
| 61 | - } |
|
| 62 | - return $this->_intNum; |
|
| 63 | - } |
|
| 44 | + /** |
|
| 45 | + * Get the number as an integer. |
|
| 46 | + * |
|
| 47 | + * @throws \RuntimeException If number overflows integer size |
|
| 48 | + * @return int |
|
| 49 | + */ |
|
| 50 | + public function intVal(): int |
|
| 51 | + { |
|
| 52 | + if (!isset($this->_intNum)) { |
|
| 53 | + $num = gmp_init($this->_num, 10); |
|
| 54 | + if (gmp_cmp($num, $this->_intMaxGmp()) > 0) { |
|
| 55 | + throw new \RuntimeException("Integer overflow."); |
|
| 56 | + } |
|
| 57 | + if (gmp_cmp($num, $this->_intMinGmp()) < 0) { |
|
| 58 | + throw new \RuntimeException("Integer underflow."); |
|
| 59 | + } |
|
| 60 | + $this->_intNum = gmp_intval($num); |
|
| 61 | + } |
|
| 62 | + return $this->_intNum; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * Get the maximum integer value. |
|
| 67 | - * |
|
| 68 | - * @return \GMP |
|
| 69 | - */ |
|
| 70 | - private function _intMaxGmp(): \GMP |
|
| 71 | - { |
|
| 72 | - static $gmp; |
|
| 73 | - if (!isset($gmp)) { |
|
| 74 | - $gmp = gmp_init(PHP_INT_MAX, 10); |
|
| 75 | - } |
|
| 76 | - return $gmp; |
|
| 77 | - } |
|
| 65 | + /** |
|
| 66 | + * Get the maximum integer value. |
|
| 67 | + * |
|
| 68 | + * @return \GMP |
|
| 69 | + */ |
|
| 70 | + private function _intMaxGmp(): \GMP |
|
| 71 | + { |
|
| 72 | + static $gmp; |
|
| 73 | + if (!isset($gmp)) { |
|
| 74 | + $gmp = gmp_init(PHP_INT_MAX, 10); |
|
| 75 | + } |
|
| 76 | + return $gmp; |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * Get the minimum integer value. |
|
| 81 | - * |
|
| 82 | - * @return \GMP |
|
| 83 | - */ |
|
| 84 | - private function _intMinGmp(): \GMP |
|
| 85 | - { |
|
| 86 | - static $gmp; |
|
| 87 | - if (!isset($gmp)) { |
|
| 88 | - $gmp = gmp_init(PHP_INT_MIN, 10); |
|
| 89 | - } |
|
| 90 | - return $gmp; |
|
| 91 | - } |
|
| 79 | + /** |
|
| 80 | + * Get the minimum integer value. |
|
| 81 | + * |
|
| 82 | + * @return \GMP |
|
| 83 | + */ |
|
| 84 | + private function _intMinGmp(): \GMP |
|
| 85 | + { |
|
| 86 | + static $gmp; |
|
| 87 | + if (!isset($gmp)) { |
|
| 88 | + $gmp = gmp_init(PHP_INT_MIN, 10); |
|
| 89 | + } |
|
| 90 | + return $gmp; |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - /** |
|
| 94 | - * Get the number as a GMP object. |
|
| 95 | - * |
|
| 96 | - * @return \GMP |
|
| 97 | - */ |
|
| 98 | - public function gmpObj(): \GMP |
|
| 99 | - { |
|
| 100 | - return gmp_init($this->_num, 10); |
|
| 101 | - } |
|
| 93 | + /** |
|
| 94 | + * Get the number as a GMP object. |
|
| 95 | + * |
|
| 96 | + * @return \GMP |
|
| 97 | + */ |
|
| 98 | + public function gmpObj(): \GMP |
|
| 99 | + { |
|
| 100 | + return gmp_init($this->_num, 10); |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - /** |
|
| 104 | - * |
|
| 105 | - * @return string |
|
| 106 | - */ |
|
| 107 | - public function __toString() |
|
| 108 | - { |
|
| 109 | - return $this->base10(); |
|
| 110 | - } |
|
| 103 | + /** |
|
| 104 | + * |
|
| 105 | + * @return string |
|
| 106 | + */ |
|
| 107 | + public function __toString() |
|
| 108 | + { |
|
| 109 | + return $this->base10(); |
|
| 110 | + } |
|
| 111 | 111 | } |
@@ -11,141 +11,141 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class Flags |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * Flag octets. |
|
| 16 | - * |
|
| 17 | - * @var string $_flags |
|
| 18 | - */ |
|
| 19 | - protected $_flags; |
|
| 14 | + /** |
|
| 15 | + * Flag octets. |
|
| 16 | + * |
|
| 17 | + * @var string $_flags |
|
| 18 | + */ |
|
| 19 | + protected $_flags; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Number of flags. |
|
| 23 | - * |
|
| 24 | - * @var int $_width |
|
| 25 | - */ |
|
| 26 | - protected $_width; |
|
| 21 | + /** |
|
| 22 | + * Number of flags. |
|
| 23 | + * |
|
| 24 | + * @var int $_width |
|
| 25 | + */ |
|
| 26 | + protected $_width; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Constructor. |
|
| 30 | - * |
|
| 31 | - * @param int|string $flags Flags |
|
| 32 | - * @param int $width The number of flags. If width is larger than number of |
|
| 33 | - * bits in $flags, zeroes are prepended to flag field. |
|
| 34 | - */ |
|
| 35 | - public function __construct($flags, int $width) |
|
| 36 | - { |
|
| 37 | - if (!$width) { |
|
| 38 | - $this->_flags = ""; |
|
| 39 | - } else { |
|
| 40 | - // calculate number of unused bits in last octet |
|
| 41 | - $last_octet_bits = $width % 8; |
|
| 42 | - $unused_bits = $last_octet_bits ? 8 - $last_octet_bits : 0; |
|
| 43 | - $num = gmp_init($flags); |
|
| 44 | - // mask bits outside bitfield width |
|
| 45 | - $mask = gmp_sub(gmp_init(1) << $width, 1); |
|
| 46 | - $num &= $mask; |
|
| 47 | - // shift towards MSB if needed |
|
| 48 | - $data = gmp_export($num << $unused_bits, 1, |
|
| 49 | - GMP_MSW_FIRST | GMP_BIG_ENDIAN); |
|
| 50 | - $octets = unpack("C*", $data); |
|
| 51 | - $bits = count($octets) * 8; |
|
| 52 | - // pad with zeroes |
|
| 53 | - while ($bits < $width) { |
|
| 54 | - array_unshift($octets, 0); |
|
| 55 | - $bits += 8; |
|
| 56 | - } |
|
| 57 | - $this->_flags = pack("C*", ...$octets); |
|
| 58 | - } |
|
| 59 | - $this->_width = $width; |
|
| 60 | - } |
|
| 28 | + /** |
|
| 29 | + * Constructor. |
|
| 30 | + * |
|
| 31 | + * @param int|string $flags Flags |
|
| 32 | + * @param int $width The number of flags. If width is larger than number of |
|
| 33 | + * bits in $flags, zeroes are prepended to flag field. |
|
| 34 | + */ |
|
| 35 | + public function __construct($flags, int $width) |
|
| 36 | + { |
|
| 37 | + if (!$width) { |
|
| 38 | + $this->_flags = ""; |
|
| 39 | + } else { |
|
| 40 | + // calculate number of unused bits in last octet |
|
| 41 | + $last_octet_bits = $width % 8; |
|
| 42 | + $unused_bits = $last_octet_bits ? 8 - $last_octet_bits : 0; |
|
| 43 | + $num = gmp_init($flags); |
|
| 44 | + // mask bits outside bitfield width |
|
| 45 | + $mask = gmp_sub(gmp_init(1) << $width, 1); |
|
| 46 | + $num &= $mask; |
|
| 47 | + // shift towards MSB if needed |
|
| 48 | + $data = gmp_export($num << $unused_bits, 1, |
|
| 49 | + GMP_MSW_FIRST | GMP_BIG_ENDIAN); |
|
| 50 | + $octets = unpack("C*", $data); |
|
| 51 | + $bits = count($octets) * 8; |
|
| 52 | + // pad with zeroes |
|
| 53 | + while ($bits < $width) { |
|
| 54 | + array_unshift($octets, 0); |
|
| 55 | + $bits += 8; |
|
| 56 | + } |
|
| 57 | + $this->_flags = pack("C*", ...$octets); |
|
| 58 | + } |
|
| 59 | + $this->_width = $width; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * Initialize from BitString. |
|
| 64 | - * |
|
| 65 | - * @param BitString $bs |
|
| 66 | - * @param int $width |
|
| 67 | - * @return self |
|
| 68 | - */ |
|
| 69 | - public static function fromBitString(BitString $bs, int $width): self |
|
| 70 | - { |
|
| 71 | - $num_bits = $bs->numBits(); |
|
| 72 | - $num = gmp_import($bs->string(), 1, GMP_MSW_FIRST | GMP_BIG_ENDIAN); |
|
| 73 | - $num >>= $bs->unusedBits(); |
|
| 74 | - if ($num_bits < $width) { |
|
| 75 | - $num <<= ($width - $num_bits); |
|
| 76 | - } |
|
| 77 | - return new self(gmp_strval($num, 10), $width); |
|
| 78 | - } |
|
| 62 | + /** |
|
| 63 | + * Initialize from BitString. |
|
| 64 | + * |
|
| 65 | + * @param BitString $bs |
|
| 66 | + * @param int $width |
|
| 67 | + * @return self |
|
| 68 | + */ |
|
| 69 | + public static function fromBitString(BitString $bs, int $width): self |
|
| 70 | + { |
|
| 71 | + $num_bits = $bs->numBits(); |
|
| 72 | + $num = gmp_import($bs->string(), 1, GMP_MSW_FIRST | GMP_BIG_ENDIAN); |
|
| 73 | + $num >>= $bs->unusedBits(); |
|
| 74 | + if ($num_bits < $width) { |
|
| 75 | + $num <<= ($width - $num_bits); |
|
| 76 | + } |
|
| 77 | + return new self(gmp_strval($num, 10), $width); |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * Check whether a bit at given index is set. |
|
| 82 | - * Index 0 is the leftmost bit. |
|
| 83 | - * |
|
| 84 | - * @param int $idx |
|
| 85 | - * @throws \OutOfBoundsException |
|
| 86 | - * @return bool |
|
| 87 | - */ |
|
| 88 | - public function test(int $idx): bool |
|
| 89 | - { |
|
| 90 | - if ($idx >= $this->_width) { |
|
| 91 | - throw new \OutOfBoundsException("Index is out of bounds."); |
|
| 92 | - } |
|
| 93 | - // octet index |
|
| 94 | - $oi = (int) floor($idx / 8); |
|
| 95 | - $byte = $this->_flags[$oi]; |
|
| 96 | - // bit index |
|
| 97 | - $bi = $idx % 8; |
|
| 98 | - // index 0 is the most significant bit in byte |
|
| 99 | - $mask = 0x01 << (7 - $bi); |
|
| 100 | - return (ord($byte) & $mask) > 0; |
|
| 101 | - } |
|
| 80 | + /** |
|
| 81 | + * Check whether a bit at given index is set. |
|
| 82 | + * Index 0 is the leftmost bit. |
|
| 83 | + * |
|
| 84 | + * @param int $idx |
|
| 85 | + * @throws \OutOfBoundsException |
|
| 86 | + * @return bool |
|
| 87 | + */ |
|
| 88 | + public function test(int $idx): bool |
|
| 89 | + { |
|
| 90 | + if ($idx >= $this->_width) { |
|
| 91 | + throw new \OutOfBoundsException("Index is out of bounds."); |
|
| 92 | + } |
|
| 93 | + // octet index |
|
| 94 | + $oi = (int) floor($idx / 8); |
|
| 95 | + $byte = $this->_flags[$oi]; |
|
| 96 | + // bit index |
|
| 97 | + $bi = $idx % 8; |
|
| 98 | + // index 0 is the most significant bit in byte |
|
| 99 | + $mask = 0x01 << (7 - $bi); |
|
| 100 | + return (ord($byte) & $mask) > 0; |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - /** |
|
| 104 | - * Get flags as an octet string. |
|
| 105 | - * Zeroes are appended to the last octet if width is not divisible by 8. |
|
| 106 | - * |
|
| 107 | - * @return string |
|
| 108 | - */ |
|
| 109 | - public function string(): string |
|
| 110 | - { |
|
| 111 | - return $this->_flags; |
|
| 112 | - } |
|
| 103 | + /** |
|
| 104 | + * Get flags as an octet string. |
|
| 105 | + * Zeroes are appended to the last octet if width is not divisible by 8. |
|
| 106 | + * |
|
| 107 | + * @return string |
|
| 108 | + */ |
|
| 109 | + public function string(): string |
|
| 110 | + { |
|
| 111 | + return $this->_flags; |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - /** |
|
| 115 | - * Get flags as a base 10 integer. |
|
| 116 | - * |
|
| 117 | - * @return string Integer as a string |
|
| 118 | - */ |
|
| 119 | - public function number(): string |
|
| 120 | - { |
|
| 121 | - $num = gmp_import($this->_flags, 1, GMP_MSW_FIRST | GMP_BIG_ENDIAN); |
|
| 122 | - $last_octet_bits = $this->_width % 8; |
|
| 123 | - $unused_bits = $last_octet_bits ? 8 - $last_octet_bits : 0; |
|
| 124 | - $num >>= $unused_bits; |
|
| 125 | - return gmp_strval($num, 10); |
|
| 126 | - } |
|
| 114 | + /** |
|
| 115 | + * Get flags as a base 10 integer. |
|
| 116 | + * |
|
| 117 | + * @return string Integer as a string |
|
| 118 | + */ |
|
| 119 | + public function number(): string |
|
| 120 | + { |
|
| 121 | + $num = gmp_import($this->_flags, 1, GMP_MSW_FIRST | GMP_BIG_ENDIAN); |
|
| 122 | + $last_octet_bits = $this->_width % 8; |
|
| 123 | + $unused_bits = $last_octet_bits ? 8 - $last_octet_bits : 0; |
|
| 124 | + $num >>= $unused_bits; |
|
| 125 | + return gmp_strval($num, 10); |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | - /** |
|
| 129 | - * Get flags as an integer. |
|
| 130 | - * |
|
| 131 | - * @return int |
|
| 132 | - */ |
|
| 133 | - public function intNumber(): int |
|
| 134 | - { |
|
| 135 | - $num = new BigInt($this->number()); |
|
| 136 | - return $num->intVal(); |
|
| 137 | - } |
|
| 128 | + /** |
|
| 129 | + * Get flags as an integer. |
|
| 130 | + * |
|
| 131 | + * @return int |
|
| 132 | + */ |
|
| 133 | + public function intNumber(): int |
|
| 134 | + { |
|
| 135 | + $num = new BigInt($this->number()); |
|
| 136 | + return $num->intVal(); |
|
| 137 | + } |
|
| 138 | 138 | |
| 139 | - /** |
|
| 140 | - * Get flags as a BitString. |
|
| 141 | - * Unused bits are set accordingly. Trailing zeroes are not stripped. |
|
| 142 | - * |
|
| 143 | - * @return BitString |
|
| 144 | - */ |
|
| 145 | - public function bitString(): BitString |
|
| 146 | - { |
|
| 147 | - $last_octet_bits = $this->_width % 8; |
|
| 148 | - $unused_bits = $last_octet_bits ? 8 - $last_octet_bits : 0; |
|
| 149 | - return new BitString($this->_flags, $unused_bits); |
|
| 150 | - } |
|
| 139 | + /** |
|
| 140 | + * Get flags as a BitString. |
|
| 141 | + * Unused bits are set accordingly. Trailing zeroes are not stripped. |
|
| 142 | + * |
|
| 143 | + * @return BitString |
|
| 144 | + */ |
|
| 145 | + public function bitString(): BitString |
|
| 146 | + { |
|
| 147 | + $last_octet_bits = $this->_width % 8; |
|
| 148 | + $unused_bits = $last_octet_bits ? 8 - $last_octet_bits : 0; |
|
| 149 | + return new BitString($this->_flags, $unused_bits); |
|
| 150 | + } |
|
| 151 | 151 | } |
@@ -14,82 +14,82 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class DERData extends Element |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * DER encoded data. |
|
| 19 | - * |
|
| 20 | - * @var string $_der |
|
| 21 | - */ |
|
| 22 | - protected $_der; |
|
| 17 | + /** |
|
| 18 | + * DER encoded data. |
|
| 19 | + * |
|
| 20 | + * @var string $_der |
|
| 21 | + */ |
|
| 22 | + protected $_der; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Identifier of the underlying type. |
|
| 26 | - * |
|
| 27 | - * @var Identifier $_identifier |
|
| 28 | - */ |
|
| 29 | - protected $_identifier; |
|
| 24 | + /** |
|
| 25 | + * Identifier of the underlying type. |
|
| 26 | + * |
|
| 27 | + * @var Identifier $_identifier |
|
| 28 | + */ |
|
| 29 | + protected $_identifier; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Offset to the content in DER data. |
|
| 33 | - * |
|
| 34 | - * @var int $_contentOffset |
|
| 35 | - */ |
|
| 36 | - protected $_contentOffset = 0; |
|
| 31 | + /** |
|
| 32 | + * Offset to the content in DER data. |
|
| 33 | + * |
|
| 34 | + * @var int $_contentOffset |
|
| 35 | + */ |
|
| 36 | + protected $_contentOffset = 0; |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Constructor. |
|
| 40 | - * |
|
| 41 | - * @param string $data DER encoded data |
|
| 42 | - * @throws \ASN1\Exception\DecodeException If data does not adhere to DER |
|
| 43 | - */ |
|
| 44 | - public function __construct(string $data) |
|
| 45 | - { |
|
| 46 | - $this->_identifier = Identifier::fromDER($data, $this->_contentOffset); |
|
| 47 | - Length::expectFromDER($data, $this->_contentOffset); |
|
| 48 | - $this->_der = $data; |
|
| 49 | - $this->_typeTag = $this->_identifier->intTag(); |
|
| 50 | - } |
|
| 38 | + /** |
|
| 39 | + * Constructor. |
|
| 40 | + * |
|
| 41 | + * @param string $data DER encoded data |
|
| 42 | + * @throws \ASN1\Exception\DecodeException If data does not adhere to DER |
|
| 43 | + */ |
|
| 44 | + public function __construct(string $data) |
|
| 45 | + { |
|
| 46 | + $this->_identifier = Identifier::fromDER($data, $this->_contentOffset); |
|
| 47 | + Length::expectFromDER($data, $this->_contentOffset); |
|
| 48 | + $this->_der = $data; |
|
| 49 | + $this->_typeTag = $this->_identifier->intTag(); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * |
|
| 54 | - * @see \ASN1\Element::typeClass() |
|
| 55 | - * @return int |
|
| 56 | - */ |
|
| 57 | - public function typeClass(): int |
|
| 58 | - { |
|
| 59 | - return $this->_identifier->typeClass(); |
|
| 60 | - } |
|
| 52 | + /** |
|
| 53 | + * |
|
| 54 | + * @see \ASN1\Element::typeClass() |
|
| 55 | + * @return int |
|
| 56 | + */ |
|
| 57 | + public function typeClass(): int |
|
| 58 | + { |
|
| 59 | + return $this->_identifier->typeClass(); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * |
|
| 64 | - * @see \ASN1\Element::isConstructed() |
|
| 65 | - * @return bool |
|
| 66 | - */ |
|
| 67 | - public function isConstructed(): bool |
|
| 68 | - { |
|
| 69 | - return $this->_identifier->isConstructed(); |
|
| 70 | - } |
|
| 62 | + /** |
|
| 63 | + * |
|
| 64 | + * @see \ASN1\Element::isConstructed() |
|
| 65 | + * @return bool |
|
| 66 | + */ |
|
| 67 | + public function isConstructed(): bool |
|
| 68 | + { |
|
| 69 | + return $this->_identifier->isConstructed(); |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * |
|
| 74 | - * @see \ASN1\Element::_encodedContentDER() |
|
| 75 | - * @return string |
|
| 76 | - */ |
|
| 77 | - protected function _encodedContentDER(): string |
|
| 78 | - { |
|
| 79 | - // if there's no content payload |
|
| 80 | - if (strlen($this->_der) == $this->_contentOffset) { |
|
| 81 | - return ""; |
|
| 82 | - } |
|
| 83 | - return substr($this->_der, $this->_contentOffset); |
|
| 84 | - } |
|
| 72 | + /** |
|
| 73 | + * |
|
| 74 | + * @see \ASN1\Element::_encodedContentDER() |
|
| 75 | + * @return string |
|
| 76 | + */ |
|
| 77 | + protected function _encodedContentDER(): string |
|
| 78 | + { |
|
| 79 | + // if there's no content payload |
|
| 80 | + if (strlen($this->_der) == $this->_contentOffset) { |
|
| 81 | + return ""; |
|
| 82 | + } |
|
| 83 | + return substr($this->_der, $this->_contentOffset); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * |
|
| 88 | - * @see \ASN1\Element::toDER() |
|
| 89 | - * @return string |
|
| 90 | - */ |
|
| 91 | - public function toDER(): string |
|
| 92 | - { |
|
| 93 | - return $this->_der; |
|
| 94 | - } |
|
| 86 | + /** |
|
| 87 | + * |
|
| 88 | + * @see \ASN1\Element::toDER() |
|
| 89 | + * @return string |
|
| 90 | + */ |
|
| 91 | + public function toDER(): string |
|
| 92 | + { |
|
| 93 | + return $this->_der; |
|
| 94 | + } |
|
| 95 | 95 | } |
@@ -13,13 +13,13 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | interface ImplicitTagging extends ElementBase |
| 15 | 15 | { |
| 16 | - /** |
|
| 17 | - * Get implicitly tagged wrapped element. |
|
| 18 | - * |
|
| 19 | - * @param int $tag Tag of the element |
|
| 20 | - * @param int $class Expected type class of the element |
|
| 21 | - * @throws \UnexpectedValueException If expectation fails |
|
| 22 | - * @return \ASN1\Type\UnspecifiedType |
|
| 23 | - */ |
|
| 24 | - public function implicit(int $tag, int $class = Identifier::CLASS_UNIVERSAL): UnspecifiedType; |
|
| 16 | + /** |
|
| 17 | + * Get implicitly tagged wrapped element. |
|
| 18 | + * |
|
| 19 | + * @param int $tag Tag of the element |
|
| 20 | + * @param int $class Expected type class of the element |
|
| 21 | + * @throws \UnexpectedValueException If expectation fails |
|
| 22 | + * @return \ASN1\Type\UnspecifiedType |
|
| 23 | + */ |
|
| 24 | + public function implicit(int $tag, int $class = Identifier::CLASS_UNIVERSAL): UnspecifiedType; |
|
| 25 | 25 | } |
@@ -20,106 +20,106 @@ |
||
| 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 = $identifier->intTag(); |
|
| 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 = $identifier->intTag(); |
|
| 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)->intLength(); |
|
| 91 | - return substr($this->_data, $idx, $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)->intLength(); |
|
| 91 | + return substr($this->_data, $idx, $length); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * |
|
| 96 | - * {@inheritdoc} |
|
| 97 | - * @see \ASN1\Type\Tagged\ImplicitTagging::implicit() |
|
| 98 | - * @return UnspecifiedType |
|
| 99 | - */ |
|
| 100 | - public function implicit(int $tag, int $class = Identifier::CLASS_UNIVERSAL): UnspecifiedType |
|
| 101 | - { |
|
| 102 | - $identifier = $this->_identifier->withClass($class)->withTag($tag); |
|
| 103 | - $cls = self::_determineImplClass($identifier); |
|
| 104 | - $idx = $this->_offset; |
|
| 105 | - /** @var \ASN1\Feature\ElementBase $element */ |
|
| 106 | - $element = $cls::_decodeFromDER($identifier, $this->_data, $idx); |
|
| 107 | - return $element->asUnspecified(); |
|
| 108 | - } |
|
| 94 | + /** |
|
| 95 | + * |
|
| 96 | + * {@inheritdoc} |
|
| 97 | + * @see \ASN1\Type\Tagged\ImplicitTagging::implicit() |
|
| 98 | + * @return UnspecifiedType |
|
| 99 | + */ |
|
| 100 | + public function implicit(int $tag, int $class = Identifier::CLASS_UNIVERSAL): UnspecifiedType |
|
| 101 | + { |
|
| 102 | + $identifier = $this->_identifier->withClass($class)->withTag($tag); |
|
| 103 | + $cls = self::_determineImplClass($identifier); |
|
| 104 | + $idx = $this->_offset; |
|
| 105 | + /** @var \ASN1\Feature\ElementBase $element */ |
|
| 106 | + $element = $cls::_decodeFromDER($identifier, $this->_data, $idx); |
|
| 107 | + return $element->asUnspecified(); |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - /** |
|
| 111 | - * |
|
| 112 | - * @see \ASN1\Type\Tagged\ExplicitTagging::explicit() |
|
| 113 | - * @return UnspecifiedType |
|
| 114 | - */ |
|
| 115 | - public function explicit($expectedTag = null): UnspecifiedType |
|
| 116 | - { |
|
| 117 | - $idx = $this->_offset; |
|
| 118 | - Length::expectFromDER($this->_data, $idx); |
|
| 119 | - $element = Element::fromDER($this->_data, $idx); |
|
| 120 | - if (isset($expectedTag)) { |
|
| 121 | - $element->expectType($expectedTag); |
|
| 122 | - } |
|
| 123 | - return $element->asUnspecified(); |
|
| 124 | - } |
|
| 110 | + /** |
|
| 111 | + * |
|
| 112 | + * @see \ASN1\Type\Tagged\ExplicitTagging::explicit() |
|
| 113 | + * @return UnspecifiedType |
|
| 114 | + */ |
|
| 115 | + public function explicit($expectedTag = null): UnspecifiedType |
|
| 116 | + { |
|
| 117 | + $idx = $this->_offset; |
|
| 118 | + Length::expectFromDER($this->_data, $idx); |
|
| 119 | + $element = Element::fromDER($this->_data, $idx); |
|
| 120 | + if (isset($expectedTag)) { |
|
| 121 | + $element->expectType($expectedTag); |
|
| 122 | + } |
|
| 123 | + return $element->asUnspecified(); |
|
| 124 | + } |
|
| 125 | 125 | } |
@@ -17,58 +17,58 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class ImplicitlyTaggedType extends TaggedTypeWrap implements ImplicitTagging |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * Constructor. |
|
| 22 | - * |
|
| 23 | - * @param int $tag Tag number |
|
| 24 | - * @param Element $element Wrapped element |
|
| 25 | - * @param int $class Type class |
|
| 26 | - */ |
|
| 27 | - public function __construct(int $tag, Element $element, |
|
| 28 | - int $class = Identifier::CLASS_CONTEXT_SPECIFIC) |
|
| 29 | - { |
|
| 30 | - $this->_typeTag = $tag; |
|
| 31 | - $this->_element = $element; |
|
| 32 | - $this->_class = $class; |
|
| 33 | - } |
|
| 20 | + /** |
|
| 21 | + * Constructor. |
|
| 22 | + * |
|
| 23 | + * @param int $tag Tag number |
|
| 24 | + * @param Element $element Wrapped element |
|
| 25 | + * @param int $class Type class |
|
| 26 | + */ |
|
| 27 | + public function __construct(int $tag, Element $element, |
|
| 28 | + int $class = Identifier::CLASS_CONTEXT_SPECIFIC) |
|
| 29 | + { |
|
| 30 | + $this->_typeTag = $tag; |
|
| 31 | + $this->_element = $element; |
|
| 32 | + $this->_class = $class; |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * |
|
| 37 | - * @see \ASN1\Element::isConstructed() |
|
| 38 | - * @return bool |
|
| 39 | - */ |
|
| 40 | - public function isConstructed(): bool |
|
| 41 | - { |
|
| 42 | - // depends on the underlying type |
|
| 43 | - return $this->_element->isConstructed(); |
|
| 44 | - } |
|
| 35 | + /** |
|
| 36 | + * |
|
| 37 | + * @see \ASN1\Element::isConstructed() |
|
| 38 | + * @return bool |
|
| 39 | + */ |
|
| 40 | + public function isConstructed(): bool |
|
| 41 | + { |
|
| 42 | + // depends on the underlying type |
|
| 43 | + return $this->_element->isConstructed(); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * |
|
| 48 | - * @see \ASN1\Element::_encodedContentDER() |
|
| 49 | - * @return string |
|
| 50 | - */ |
|
| 51 | - protected function _encodedContentDER(): string |
|
| 52 | - { |
|
| 53 | - // get only the content of the wrapped element. |
|
| 54 | - return $this->_element->_encodedContentDER(); |
|
| 55 | - } |
|
| 46 | + /** |
|
| 47 | + * |
|
| 48 | + * @see \ASN1\Element::_encodedContentDER() |
|
| 49 | + * @return string |
|
| 50 | + */ |
|
| 51 | + protected function _encodedContentDER(): string |
|
| 52 | + { |
|
| 53 | + // get only the content of the wrapped element. |
|
| 54 | + return $this->_element->_encodedContentDER(); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * |
|
| 59 | - * {@inheritdoc} |
|
| 60 | - * @see \ASN1\Type\Tagged\ImplicitTagging::implicit() |
|
| 61 | - * @return UnspecifiedType |
|
| 62 | - */ |
|
| 63 | - public function implicit(int $tag, int $class = Identifier::CLASS_UNIVERSAL): UnspecifiedType |
|
| 64 | - { |
|
| 65 | - $this->_element->expectType($tag); |
|
| 66 | - if ($this->_element->typeClass() != $class) { |
|
| 67 | - throw new \UnexpectedValueException( |
|
| 68 | - sprintf("Type class %s expected, got %s.", |
|
| 69 | - Identifier::classToName($class), |
|
| 70 | - Identifier::classToName($this->_element->typeClass()))); |
|
| 71 | - } |
|
| 72 | - return $this->_element->asUnspecified(); |
|
| 73 | - } |
|
| 57 | + /** |
|
| 58 | + * |
|
| 59 | + * {@inheritdoc} |
|
| 60 | + * @see \ASN1\Type\Tagged\ImplicitTagging::implicit() |
|
| 61 | + * @return UnspecifiedType |
|
| 62 | + */ |
|
| 63 | + public function implicit(int $tag, int $class = Identifier::CLASS_UNIVERSAL): UnspecifiedType |
|
| 64 | + { |
|
| 65 | + $this->_element->expectType($tag); |
|
| 66 | + if ($this->_element->typeClass() != $class) { |
|
| 67 | + throw new \UnexpectedValueException( |
|
| 68 | + sprintf("Type class %s expected, got %s.", |
|
| 69 | + Identifier::classToName($class), |
|
| 70 | + Identifier::classToName($this->_element->typeClass()))); |
|
| 71 | + } |
|
| 72 | + return $this->_element->asUnspecified(); |
|
| 73 | + } |
|
| 74 | 74 | } |
@@ -16,53 +16,53 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class ExplicitlyTaggedType extends TaggedTypeWrap implements ExplicitTagging |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * Constructor. |
|
| 21 | - * |
|
| 22 | - * @param int $tag Tag number |
|
| 23 | - * @param Element $element Wrapped element |
|
| 24 | - * @param int $class Type class |
|
| 25 | - */ |
|
| 26 | - public function __construct(int $tag, Element $element, |
|
| 27 | - int $class = Identifier::CLASS_CONTEXT_SPECIFIC) |
|
| 28 | - { |
|
| 29 | - $this->_typeTag = $tag; |
|
| 30 | - $this->_element = $element; |
|
| 31 | - $this->_class = $class; |
|
| 32 | - } |
|
| 19 | + /** |
|
| 20 | + * Constructor. |
|
| 21 | + * |
|
| 22 | + * @param int $tag Tag number |
|
| 23 | + * @param Element $element Wrapped element |
|
| 24 | + * @param int $class Type class |
|
| 25 | + */ |
|
| 26 | + public function __construct(int $tag, Element $element, |
|
| 27 | + int $class = Identifier::CLASS_CONTEXT_SPECIFIC) |
|
| 28 | + { |
|
| 29 | + $this->_typeTag = $tag; |
|
| 30 | + $this->_element = $element; |
|
| 31 | + $this->_class = $class; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * |
|
| 36 | - * @see \ASN1\Element::isConstructed() |
|
| 37 | - * @return bool |
|
| 38 | - */ |
|
| 39 | - public function isConstructed(): bool |
|
| 40 | - { |
|
| 41 | - return true; |
|
| 42 | - } |
|
| 34 | + /** |
|
| 35 | + * |
|
| 36 | + * @see \ASN1\Element::isConstructed() |
|
| 37 | + * @return bool |
|
| 38 | + */ |
|
| 39 | + public function isConstructed(): bool |
|
| 40 | + { |
|
| 41 | + return true; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * |
|
| 46 | - * @see \ASN1\Element::_encodedContentDER() |
|
| 47 | - * @return string |
|
| 48 | - */ |
|
| 49 | - protected function _encodedContentDER(): string |
|
| 50 | - { |
|
| 51 | - // get the full encoding of the wrapped element |
|
| 52 | - return $this->_element->toDER(); |
|
| 53 | - } |
|
| 44 | + /** |
|
| 45 | + * |
|
| 46 | + * @see \ASN1\Element::_encodedContentDER() |
|
| 47 | + * @return string |
|
| 48 | + */ |
|
| 49 | + protected function _encodedContentDER(): string |
|
| 50 | + { |
|
| 51 | + // get the full encoding of the wrapped element |
|
| 52 | + return $this->_element->toDER(); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * |
|
| 57 | - * {@inheritdoc} |
|
| 58 | - * @see \ASN1\Type\Tagged\ExplicitTagging::explicit() |
|
| 59 | - * @return UnspecifiedType |
|
| 60 | - */ |
|
| 61 | - public function explicit($expectedTag = null): UnspecifiedType |
|
| 62 | - { |
|
| 63 | - if (isset($expectedTag)) { |
|
| 64 | - $this->_element->expectType($expectedTag); |
|
| 65 | - } |
|
| 66 | - return $this->_element->asUnspecified(); |
|
| 67 | - } |
|
| 55 | + /** |
|
| 56 | + * |
|
| 57 | + * {@inheritdoc} |
|
| 58 | + * @see \ASN1\Type\Tagged\ExplicitTagging::explicit() |
|
| 59 | + * @return UnspecifiedType |
|
| 60 | + */ |
|
| 61 | + public function explicit($expectedTag = null): UnspecifiedType |
|
| 62 | + { |
|
| 63 | + if (isset($expectedTag)) { |
|
| 64 | + $this->_element->expectType($expectedTag); |
|
| 65 | + } |
|
| 66 | + return $this->_element->asUnspecified(); |
|
| 67 | + } |
|
| 68 | 68 | } |
@@ -11,27 +11,27 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | abstract class TaggedTypeWrap extends TaggedType |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * Wrapped element. |
|
| 16 | - * |
|
| 17 | - * @var \ASN1\Element $_element |
|
| 18 | - */ |
|
| 19 | - protected $_element; |
|
| 14 | + /** |
|
| 15 | + * Wrapped element. |
|
| 16 | + * |
|
| 17 | + * @var \ASN1\Element $_element |
|
| 18 | + */ |
|
| 19 | + protected $_element; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Type class. |
|
| 23 | - * |
|
| 24 | - * @var int |
|
| 25 | - */ |
|
| 26 | - protected $_class; |
|
| 21 | + /** |
|
| 22 | + * Type class. |
|
| 23 | + * |
|
| 24 | + * @var int |
|
| 25 | + */ |
|
| 26 | + protected $_class; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * |
|
| 30 | - * @see \ASN1\Element::typeClass() |
|
| 31 | - * @return int |
|
| 32 | - */ |
|
| 33 | - public function typeClass(): int |
|
| 34 | - { |
|
| 35 | - return $this->_class; |
|
| 36 | - } |
|
| 28 | + /** |
|
| 29 | + * |
|
| 30 | + * @see \ASN1\Element::typeClass() |
|
| 31 | + * @return int |
|
| 32 | + */ |
|
| 33 | + public function typeClass(): int |
|
| 34 | + { |
|
| 35 | + return $this->_class; |
|
| 36 | + } |
|
| 37 | 37 | } |
@@ -13,17 +13,17 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class ApplicationType extends DERTaggedType |
| 15 | 15 | { |
| 16 | - /** |
|
| 17 | - * |
|
| 18 | - * {@inheritdoc} |
|
| 19 | - */ |
|
| 20 | - protected static function _decodeFromDER(Identifier $identifier, string $data, |
|
| 21 | - int &$offset): ElementBase |
|
| 22 | - { |
|
| 23 | - $idx = $offset; |
|
| 24 | - $type = new self($identifier, $data, $idx); |
|
| 25 | - $length = Length::expectFromDER($data, $idx)->intLength(); |
|
| 26 | - $offset = $idx + $length; |
|
| 27 | - return $type; |
|
| 28 | - } |
|
| 16 | + /** |
|
| 17 | + * |
|
| 18 | + * {@inheritdoc} |
|
| 19 | + */ |
|
| 20 | + protected static function _decodeFromDER(Identifier $identifier, string $data, |
|
| 21 | + int &$offset): ElementBase |
|
| 22 | + { |
|
| 23 | + $idx = $offset; |
|
| 24 | + $type = new self($identifier, $data, $idx); |
|
| 25 | + $length = Length::expectFromDER($data, $idx)->intLength(); |
|
| 26 | + $offset = $idx + $length; |
|
| 27 | + return $type; |
|
| 28 | + } |
|
| 29 | 29 | } |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | * {@inheritdoc} |
| 19 | 19 | */ |
| 20 | 20 | protected static function _decodeFromDER(Identifier $identifier, string $data, |
| 21 | - int &$offset): ElementBase |
|
| 21 | + int & $offset): ElementBase |
|
| 22 | 22 | { |
| 23 | 23 | $idx = $offset; |
| 24 | 24 | $type = new self($identifier, $data, $idx); |