diff --git a/src/Decoder.php b/src/Decoder.php index ad44c33..21fc555 100644 --- a/src/Decoder.php +++ b/src/Decoder.php @@ -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; diff --git a/src/IndefiniteLengthListObject.php b/src/IndefiniteLengthListObject.php index d86958e..c503697 100644 --- a/src/IndefiniteLengthListObject.php +++ b/src/IndefiniteLengthListObject.php @@ -23,6 +23,7 @@ use IteratorAggregate; /** + * @phpstan-implements ArrayAccess * @phpstan-implements IteratorAggregate * @final */ @@ -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); diff --git a/src/IndefiniteLengthMapObject.php b/src/IndefiniteLengthMapObject.php index 4a52b35..d5eea5e 100644 --- a/src/IndefiniteLengthMapObject.php +++ b/src/IndefiniteLengthMapObject.php @@ -23,6 +23,7 @@ use IteratorAggregate; /** + * @phpstan-implements ArrayAccess * @phpstan-implements IteratorAggregate * @final */ @@ -165,17 +166,11 @@ 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); @@ -183,7 +178,7 @@ public function offsetGet($offset): MapItem 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) { diff --git a/src/ListObject.php b/src/ListObject.php index 4bee838..6f55db3 100644 --- a/src/ListObject.php +++ b/src/ListObject.php @@ -23,6 +23,7 @@ use IteratorAggregate; /** + * @phpstan-implements ArrayAccess * @phpstan-implements IteratorAggregate */ class ListObject extends AbstractCBORObject implements Countable, IteratorAggregate, Normalizable, ArrayAccess @@ -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); diff --git a/src/MapObject.php b/src/MapObject.php index 3c01dd1..890585f 100644 --- a/src/MapObject.php +++ b/src/MapObject.php @@ -23,6 +23,7 @@ use IteratorAggregate; /** + * @phpstan-implements ArrayAccess * @phpstan-implements IteratorAggregate */ final class MapObject extends AbstractCBORObject implements Countable, IteratorAggregate, Normalizable, ArrayAccess @@ -151,7 +152,7 @@ public function getIterator(): Iterator } /** - * @return array + * @return array */ public function normalize(): array { @@ -177,17 +178,11 @@ 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); @@ -195,7 +190,7 @@ public function offsetGet($offset): MapItem 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) {