@@ -218,11 +218,11 @@ abstract class Element implements ElementBase
218
218
];
219
219
220
220
/**
221
- * @param bool $_indefiniteLength Whether type shall be encoded with indefinite length.
221
+ * @param bool $indefiniteLength Whether type shall be encoded with indefinite length.
222
222
*/
223
223
protected function __construct (
224
- protected int $ typeTag ,
225
- protected bool $ _indefiniteLength = false
224
+ protected readonly int $ typeTag ,
225
+ protected bool $ indefiniteLength = false
226
226
) {
227
227
}
228
228
@@ -245,7 +245,7 @@ public static function fromDER(string $data, int &$offset = null): static
245
245
// decode identifier
246
246
$ identifier = Identifier::fromDER ($ data , $ idx );
247
247
// determine class that implements type specific decoding
248
- $ cls = self ::_determineImplClass ($ identifier );
248
+ $ cls = self ::determineImplClass ($ identifier );
249
249
// decode remaining element
250
250
$ element = $ cls ::decodeFromDER ($ identifier , $ data , $ idx );
251
251
// if called in the context of a concrete class, check
@@ -271,7 +271,7 @@ public function toDER(): string
271
271
$ this ->typeTag
272
272
);
273
273
$ content = $ this ->encodedAsDER ();
274
- if ($ this ->_indefiniteLength ) {
274
+ if ($ this ->indefiniteLength ) {
275
275
$ length = Length::create (0 , true );
276
276
$ eoc = EOC ::create ();
277
277
return $ identifier ->toDER () . $ length ->toDER () . $ content . $ eoc ->toDER ();
@@ -293,16 +293,16 @@ public function isType(int $tag): bool
293
293
}
294
294
// negative tags identify an abstract pseudotype
295
295
if ($ tag < 0 ) {
296
- return $ this ->_isPseudoType ($ tag );
296
+ return $ this ->isPseudoType ($ tag );
297
297
}
298
- return $ this ->_isConcreteType ($ tag );
298
+ return $ this ->isConcreteType ($ tag );
299
299
}
300
300
301
301
public function expectType (int $ tag ): ElementBase
302
302
{
303
303
if (! $ this ->isType ($ tag )) {
304
304
throw new UnexpectedValueException (
305
- sprintf ('%s expected, got %s. ' , self ::tagToName ($ tag ), $ this ->_typeDescriptorString ())
305
+ sprintf ('%s expected, got %s. ' , self ::tagToName ($ tag ), $ this ->typeDescriptorString ())
306
306
);
307
307
}
308
308
return $ this ;
@@ -331,7 +331,7 @@ public function expectTagged(?int $tag = null): TaggedType
331
331
*/
332
332
public function hasIndefiniteLength (): bool
333
333
{
334
- return $ this ->_indefiniteLength ;
334
+ return $ this ->indefiniteLength ;
335
335
}
336
336
337
337
/**
@@ -342,7 +342,7 @@ public function hasIndefiniteLength(): bool
342
342
public function withIndefiniteLength (bool $ indefinite = true ): self
343
343
{
344
344
$ obj = clone $ this ;
345
- $ obj ->_indefiniteLength = $ indefinite ;
345
+ $ obj ->indefiniteLength = $ indefinite ;
346
346
return $ obj ;
347
347
}
348
348
@@ -391,11 +391,11 @@ abstract protected static function decodeFromDER(Identifier $identifier, string
391
391
*
392
392
* @return string Class name
393
393
*/
394
- protected static function _determineImplClass (Identifier $ identifier ): string
394
+ protected static function determineImplClass (Identifier $ identifier ): string
395
395
{
396
396
switch ($ identifier ->typeClass ()) {
397
397
case Identifier::CLASS_UNIVERSAL :
398
- $ cls = self ::_determineUniversalImplClass ($ identifier ->intTag ());
398
+ $ cls = self ::determineUniversalImplClass ($ identifier ->intTag ());
399
399
// constructed strings may be present in BER
400
400
if ($ identifier ->isConstructed ()
401
401
&& is_subclass_of ($ cls , StringType::class)) {
@@ -421,7 +421,7 @@ protected static function _determineImplClass(Identifier $identifier): string
421
421
*
422
422
* @return string Class name
423
423
*/
424
- protected static function _determineUniversalImplClass (int $ tag ): string
424
+ protected static function determineUniversalImplClass (int $ tag ): string
425
425
{
426
426
if (! array_key_exists ($ tag , self ::MAP_TAG_TO_CLASS )) {
427
427
throw new UnexpectedValueException ("Universal tag {$ tag } not implemented. " );
@@ -432,7 +432,7 @@ protected static function _determineUniversalImplClass(int $tag): string
432
432
/**
433
433
* Get textual description of the type for debugging purposes.
434
434
*/
435
- protected function _typeDescriptorString (): string
435
+ protected function typeDescriptorString (): string
436
436
{
437
437
if ($ this ->typeClass () === Identifier::CLASS_UNIVERSAL ) {
438
438
return self ::tagToName ($ this ->typeTag );
@@ -441,17 +441,17 @@ protected function _typeDescriptorString(): string
441
441
}
442
442
443
443
/**
444
- * Check whether the element is a concrete type of a given tag.
444
+ * Check whether the element is a concrete type of given tag.
445
445
*/
446
- private function _isConcreteType (int $ tag ): bool
446
+ private function isConcreteType (int $ tag ): bool
447
447
{
448
448
// if tag doesn't match
449
449
if ($ this ->tag () !== $ tag ) {
450
450
return false ;
451
451
}
452
452
// if type is universal check that instance is of a correct class
453
453
if ($ this ->typeClass () === Identifier::CLASS_UNIVERSAL ) {
454
- $ cls = self ::_determineUniversalImplClass ($ tag );
454
+ $ cls = self ::determineUniversalImplClass ($ tag );
455
455
if (! $ this instanceof $ cls ) {
456
456
return false ;
457
457
}
@@ -462,7 +462,7 @@ private function _isConcreteType(int $tag): bool
462
462
/**
463
463
* Check whether the element is a pseudotype.
464
464
*/
465
- private function _isPseudoType (int $ tag ): bool
465
+ private function isPseudoType (int $ tag ): bool
466
466
{
467
467
return match ($ tag ) {
468
468
self ::TYPE_STRING => $ this instanceof StringType,
0 commit comments