jadell / neo4jphp

PHP wrapper of the Neo4j REST interface
Other
532 stars 137 forks source link

Issue #136: Wrong data value returned in Row in case of non-existent index #157

Closed androa closed 6 years ago

androa commented 10 years ago

When using a non-existing array offset to get from the Row, array_search will return false. This will be typecasted into a int and offset 0 will be returned instead of the requested.

This fixes so if array_search() returns false, offsetGet() also returns false.

The existing testcases did not detect this bug since they used isset() for the non-existing keys, resulting in the usage of offsetExists(), not offsetGet().

jadell commented 9 years ago

Sorry it's taken almost a year to get back on this!

According to http://php.net/manual/en/arrayobject.offsetget.php, offsetGet should return null if the specified index doesn't exist, not false. This mirrors the existing array behavior if you reference an undefined index:

    $a = array();
    $b = $a['foo'];
    var_dump($b); // null

As soon as the change is made, I'll merge it. Can you make the modification, or do you want me to do it?