Skip to content

Commit

Permalink
Allow constructing integer types from the factory method with string …
Browse files Browse the repository at this point in the history
…integers. The integer type already allows it, as that's how ints of arbitrary size over the PHP int max are represented.
  • Loading branch information
ChadSikorra committed Oct 13, 2024
1 parent aea7159 commit ee834c4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/FreeDSx/Asn1/Asn1.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ public static function sequenceOf(AbstractType ...$types): SequenceOfType
}

/**
* @param int $int
* @param int|string $int
* @return IntegerType
*/
public static function integer(int $int): IntegerType
public static function integer($int): IntegerType
{
return new IntegerType($int);
}
Expand Down
6 changes: 6 additions & 0 deletions tests/spec/FreeDSx/Asn1/Asn1Spec.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ public function it_should_construct_an_integer_type()
$this::integer(1)->shouldBeLike(new IntegerType(1));
}

public function it_should_construct_an_integer_type_from_a_numeric_string(): void
{
$this::integer('99999999999999999')
->shouldBeLike(new IntegerType('99999999999999999'));
}

public function it_should_construct_an_enumerated_type()
{
$this::enumerated(1)->shouldBeLike(new EnumeratedType(1));
Expand Down

0 comments on commit ee834c4

Please sign in to comment.