Skip to content

Commit

Permalink
Implement JsonSerializable explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
vrana committed Jan 22, 2013
1 parent bd5db46 commit a3cec36
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions NotORM.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
*/

if (!interface_exists('JsonSerializable')) {
interface JsonSerializable {
function jsonSerialize();
}
}

include_once dirname(__FILE__) . "/NotORM/Structure.php";
include_once dirname(__FILE__) . "/NotORM/Cache.php";
include_once dirname(__FILE__) . "/NotORM/Literal.php";
Expand Down
4 changes: 2 additions & 2 deletions NotORM/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/** Filtered table representation
*/
class NotORM_Result extends NotORM_Abstract implements Iterator, ArrayAccess, Countable {
class NotORM_Result extends NotORM_Abstract implements Iterator, ArrayAccess, Countable, JsonSerializable {
protected $single;
protected $select = array(), $conditions = array(), $where = array(), $parameters = array(), $order = array(), $limit = null, $offset = null, $group = "", $having = "", $lock = null;
protected $union = array(), $unionOrder = array(), $unionLimit = null, $unionOffset = null;
Expand Down Expand Up @@ -752,7 +752,7 @@ function offsetUnset($key) {
unset($this->data[$key]);
}

// JsonSerializable implementation (not explicit as it is available only since PHP 5.4)
// JsonSerializable implementation

function jsonSerialize() {
$this->execute();
Expand Down
4 changes: 2 additions & 2 deletions NotORM/Row.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/** Single row representation
*/
class NotORM_Row extends NotORM_Abstract implements IteratorAggregate, ArrayAccess, Countable {
class NotORM_Row extends NotORM_Abstract implements IteratorAggregate, ArrayAccess, Countable, JsonSerializable {
private $modified = array();
protected $row, $result;

Expand Down Expand Up @@ -177,7 +177,7 @@ function offsetUnset($key) {
unset($this->modified[$key]);
}

// JsonSerializable implementation (not explicit as it is available only since PHP 5.4)
// JsonSerializable implementation

function jsonSerialize() {
return $this->row;
Expand Down

0 comments on commit a3cec36

Please sign in to comment.