Skip to content

Commit

Permalink
Merge pull request #55 from maxmind/greg/namespaced-jsonserializable-…
Browse files Browse the repository at this point in the history
…5.3-compat

Use proper namespace for PHP 5.3 JsonSerializable
  • Loading branch information
2shortplanks committed Sep 23, 2015
2 parents 5146f96 + 1e64073 commit 0264a53
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 17 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
CHANGELOG
=========

2.3.2 (2015-09-XX)
------------------

* `JsonSerializable` compatibility interface was moved to `GeoIp2\Compat`
rather than the global namespace to prevent autoloading issues. Reported by
Tomas Buteler. GitHub #54.
* Missing documentation for the `$postal` property was added to the
`GeoIp2\Model\City` class. Fix by Roy Sindre Norangshol. GitHub #51.
* In the Phar distribution, source files for this module no longer have their
documentation stripped, allowing IDE introspection to work properly.
Reported by Dominic Black. GitHub #52.

2.3.1 (2015-06-30)
------------------

Expand Down
13 changes: 0 additions & 13 deletions compat/JsonSerializable.php

This file was deleted.

3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
},
"autoload": {
"psr-4": {
"GeoIp2\\": "src",
"": "compat/"
"GeoIp2\\": "src"
}
}
}
27 changes: 27 additions & 0 deletions src/Compat/JsonSerializable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace GeoIp2\Compat;

// @codingStandardsIgnoreFile

/**
* This interface exists to provide backwards compatibility with PHP 5.3
*
* This should _not_ be used by any third-party code.
*
* @ignore
*/
if (interface_exists('JsonSerializable')) {
interface JSONSerializable extends \JSONSerializable
{
}
} else {
interface JsonSerializable
{
/**
* Returns data that can be serialized by json_encode
* @ignore
*/
public function jsonSerialize();
}
}
4 changes: 3 additions & 1 deletion src/Model/AbstractModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

namespace GeoIp2\Model;

use GeoIp2\Compat\JsonSerializable;

/**
* @ignore
*/
abstract class AbstractModel implements \JsonSerializable
abstract class AbstractModel implements JsonSerializable
{
protected $raw;

Expand Down
4 changes: 3 additions & 1 deletion src/Record/AbstractRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace GeoIp2\Record;

abstract class AbstractRecord implements \JsonSerializable
use GeoIp2\Compat\JsonSerializable;

abstract class AbstractRecord implements JsonSerializable
{
private $record;

Expand Down

0 comments on commit 0264a53

Please sign in to comment.