Skip to content

Commit

Permalink
DatasetInterface: clarify behavior of offsetGet() and offsetExists()
Browse files Browse the repository at this point in the history
  • Loading branch information
zozlak committed Nov 1, 2022
1 parent 3778a33 commit 1d7645c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/rdfInterface/DatasetInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ public function forEach(callable $fn,
* - 0. This is a shorthand syntax for checking if the dataset is empty.
* The main use case is enabling the `$dataset[0] ?? $defaultQuad` syntax
* for "unpacking" a dataset containing one or zero quads.
* Passing any other integer value must throw an \OutOfBoundsException
*
* @param QuadCompareInterface|callable|int<0, 0> $offset
* @return bool
Expand All @@ -213,10 +214,11 @@ public function offsetExists(mixed $offset): bool;
* thrown.
* - 0. Returns any quad (or throws \OutOfBoundsException it a dataset is
* empty).
* The main use case is enabling the `$dataset[0] ?? $defaultQuad` syntax
* for "unpacking" a dataset containing one or zero quads.
* As quads within a dataset don't have order, it makes no sense to access
* them using integer offsets. Still it's nice to have a simple syntax
* for returning any quad. This is particularly useful for unpacking
* a quad from a dataset which should contain only a single quad.
* them using other integer offsets and an attempt of doing so must
* throw an \OutOfBoundsException.
*
* @param QuadCompareInterface|callable|int<0, 0> $offset
* @return QuadInterface
Expand Down

0 comments on commit 1d7645c

Please sign in to comment.