Skip to content

Commit

Permalink
Stan errors fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Spomky committed Sep 30, 2021
1 parent 08594e6 commit e458dc5
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/Decoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ private function processInfinite(Stream $stream, int $mt, bool $breakable): CBOR
case CBORObject::MAJOR_TYPE_MAP: //5
$object = IndefiniteLengthMapObject::create();
while (!($it = $this->process($stream, true)) instanceof OtherObject\BreakObject) {
$object->append($it, $this->process($stream, false));
$object->add($it, $this->process($stream, false));
}

return $object;
Expand Down
4 changes: 1 addition & 3 deletions src/IndefiniteLengthListObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use IteratorAggregate;

/**
* @phpstan-implements ArrayAccess<int, CBORObject>
* @phpstan-implements IteratorAggregate<int, CBORObject>
* @final
*/
Expand Down Expand Up @@ -141,9 +142,6 @@ public function offsetExists($offset): bool
return $this->has($offset);
}

/**
* @param int $offset
*/
public function offsetGet($offset): CBORObject
{
return $this->get($offset);
Expand Down
9 changes: 2 additions & 7 deletions src/IndefiniteLengthMapObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use IteratorAggregate;

/**
* @phpstan-implements ArrayAccess<int, MapItem>
* @phpstan-implements IteratorAggregate<int, MapItem>
* @final
*/
Expand Down Expand Up @@ -165,25 +166,19 @@ public function getNormalizedData(bool $ignoreTags = false): array
return $this->normalize();
}

/**
* @param int|string $offset
*/
public function offsetExists($offset): bool
{
return $this->has($offset);
}

/**
* @param int|string $offset
*/
public function offsetGet($offset): MapItem
{
return $this->get($offset);
}

public function offsetSet($offset, $value): void
{
if (!$offset instanceof CBORObject && !$offset instanceof Normalizable) {
if (!$offset instanceof CBORObject) {
throw new InvalidArgumentException('Invalid key');
}
if (!$value instanceof CBORObject) {
Expand Down
4 changes: 1 addition & 3 deletions src/ListObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use IteratorAggregate;

/**
* @phpstan-implements ArrayAccess<int, CBORObject>
* @phpstan-implements IteratorAggregate<int, CBORObject>
*/
class ListObject extends AbstractCBORObject implements Countable, IteratorAggregate, Normalizable, ArrayAccess
Expand Down Expand Up @@ -161,9 +162,6 @@ public function offsetExists($offset): bool
return $this->has($offset);
}

/**
* @param int $offset
*/
public function offsetGet($offset): CBORObject
{
return $this->get($offset);
Expand Down
11 changes: 3 additions & 8 deletions src/MapObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use IteratorAggregate;

/**
* @phpstan-implements ArrayAccess<int, MapItem>
* @phpstan-implements IteratorAggregate<int, MapItem>
*/
final class MapObject extends AbstractCBORObject implements Countable, IteratorAggregate, Normalizable, ArrayAccess
Expand Down Expand Up @@ -151,7 +152,7 @@ public function getIterator(): Iterator
}

/**
* @return array<mixed, mixed>
* @return array<int|string, mixed>
*/
public function normalize(): array
{
Expand All @@ -177,25 +178,19 @@ public function getNormalizedData(bool $ignoreTags = false): array
return $this->normalize();
}

/**
* @param int|string $offset
*/
public function offsetExists($offset): bool
{
return $this->has($offset);
}

/**
* @param int|string $offset
*/
public function offsetGet($offset): MapItem
{
return $this->get($offset);
}

public function offsetSet($offset, $value): void
{
if (!$offset instanceof CBORObject && !$offset instanceof Normalizable) {
if (!$offset instanceof CBORObject) {
throw new InvalidArgumentException('Invalid key');
}
if (!$value instanceof CBORObject) {
Expand Down

0 comments on commit e458dc5

Please sign in to comment.