From 0fa7079d7acb0e4540eeb900c7ee5dc94a00504e Mon Sep 17 00:00:00 2001 From: Jeff Date: Fri, 15 Nov 2013 13:46:53 -0200 Subject: [PATCH 1/2] verify if offset exists --- lib/Everyman/Neo4j/Query/ResultSet.php | 8 +- lib/Everyman/Neo4j/Query/ResultSet.php~ | 104 ++++++++++++++++++++++++ 2 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 lib/Everyman/Neo4j/Query/ResultSet.php~ diff --git a/lib/Everyman/Neo4j/Query/ResultSet.php b/lib/Everyman/Neo4j/Query/ResultSet.php index 062e3b0..ac9b428 100644 --- a/lib/Everyman/Neo4j/Query/ResultSet.php +++ b/lib/Everyman/Neo4j/Query/ResultSet.php @@ -50,10 +50,14 @@ public function offsetExists($offset) public function offsetGet($offset) { - if (!isset($this->rows[$offset])) { + if (! isset($this->rows[$offset])) { + if (isset($this->data[$offset])) { $this->rows[$offset] = new Row($this->client, $this->columns, $this->data[$offset]); + } else { + return null; + } } - return $this->rows[$offset]; + return $this->rows[$offset]; } public function offsetSet($offset, $value) diff --git a/lib/Everyman/Neo4j/Query/ResultSet.php~ b/lib/Everyman/Neo4j/Query/ResultSet.php~ new file mode 100644 index 0000000..062e3b0 --- /dev/null +++ b/lib/Everyman/Neo4j/Query/ResultSet.php~ @@ -0,0 +1,104 @@ +client = $client; + if (is_array($result) && array_key_exists('data', $result)) { + $this->data = $result['data']; + $this->columns = $result['columns']; + } + } + + /** + * Return the list of column names + * + * @return array + */ + public function getColumns() + { + return $this->columns; + } + + // ArrayAccess API + + public function offsetExists($offset) + { + return isset($this->data[$offset]); + } + + public function offsetGet($offset) + { + if (!isset($this->rows[$offset])) { + $this->rows[$offset] = new Row($this->client, $this->columns, $this->data[$offset]); + } + return $this->rows[$offset]; + } + + public function offsetSet($offset, $value) + { + throw new \BadMethodCallException("You cannot modify a query result."); + } + + public function offsetUnset($offset) + { + throw new \BadMethodCallException("You cannot modify a query result."); + } + + + // Countable API + + public function count() + { + return count($this->data); + } + + + // Iterator API + + public function rewind() + { + $this->position = 0; + } + + public function current() + { + return $this[$this->position]; + } + + public function key() + { + return $this->position; + } + + public function next() + { + ++$this->position; + } + + public function valid() + { + return isset($this->data[$this->position]); + } +} From d22a59999824dc12f2b3b91991cff9ed91fc1f5a Mon Sep 17 00:00:00 2001 From: Jeff Date: Fri, 15 Nov 2013 13:47:22 -0200 Subject: [PATCH 2/2] verify if offset exists --- lib/Everyman/Neo4j/Query/ResultSet.php~ | 104 ------------------------ 1 file changed, 104 deletions(-) delete mode 100644 lib/Everyman/Neo4j/Query/ResultSet.php~ diff --git a/lib/Everyman/Neo4j/Query/ResultSet.php~ b/lib/Everyman/Neo4j/Query/ResultSet.php~ deleted file mode 100644 index 062e3b0..0000000 --- a/lib/Everyman/Neo4j/Query/ResultSet.php~ +++ /dev/null @@ -1,104 +0,0 @@ -client = $client; - if (is_array($result) && array_key_exists('data', $result)) { - $this->data = $result['data']; - $this->columns = $result['columns']; - } - } - - /** - * Return the list of column names - * - * @return array - */ - public function getColumns() - { - return $this->columns; - } - - // ArrayAccess API - - public function offsetExists($offset) - { - return isset($this->data[$offset]); - } - - public function offsetGet($offset) - { - if (!isset($this->rows[$offset])) { - $this->rows[$offset] = new Row($this->client, $this->columns, $this->data[$offset]); - } - return $this->rows[$offset]; - } - - public function offsetSet($offset, $value) - { - throw new \BadMethodCallException("You cannot modify a query result."); - } - - public function offsetUnset($offset) - { - throw new \BadMethodCallException("You cannot modify a query result."); - } - - - // Countable API - - public function count() - { - return count($this->data); - } - - - // Iterator API - - public function rewind() - { - $this->position = 0; - } - - public function current() - { - return $this[$this->position]; - } - - public function key() - { - return $this->position; - } - - public function next() - { - ++$this->position; - } - - public function valid() - { - return isset($this->data[$this->position]); - } -}