Skip to content

Commit

Permalink
Deprecate well known types - move to gdbots/pbj (#8)
Browse files Browse the repository at this point in the history
* wip, deprecating identifier, geopoint and microtime classes as they are moving to pbj

* mark well known types as deprecated here as they are moving to gdbots/pbj.  removes their unit tests as well.
  • Loading branch information
gdbrown authored Aug 14, 2016
1 parent fdceb7a commit 04647ee
Show file tree
Hide file tree
Showing 17 changed files with 69 additions and 281 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG-1.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
This changelog references the relevant changes done in 1.x versions.


## v1.1.0
* Marked these classes as deprecated as they will be removed in 2.x.
* BigNumber
* GeoPoint
* Microtime
* Identifiers\*
* Moved `ext-bcmath`, `moontoast/math`, `ramsey/uuid` in `composer.json` to __require-dev__.
If you're not on `gdbots/pbj-php` 1.1.x or later you'll need to require these in your own project.


## v1.0.1
* Remove __final__ from classes in anticipation of moving to "WellKnown" types in `gdbots/pbj` library.
* BigNumber
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"type": "library",
"license": "Apache-2.0",
"require": {
"php": ">=5.6",
"ext-bcmath": "*",
"moontoast/math": "~1.1",
"ramsey/uuid": "~3.1"
"php": ">=5.6"
},
"require-dev": {
"phpunit/phpunit": "~4.3"
"phpunit/phpunit": "~4.3",
"ext-bcmath": "*",
"moontoast/math": "~1.1",
"ramsey/uuid": "~3.5"
},
"autoload": {
"psr-4": {
Expand All @@ -24,7 +24,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
"dev-master": "1.1.x-dev"
}
}
}
15 changes: 15 additions & 0 deletions src/Common/BigNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,23 @@

namespace Gdbots\Common;

/**
* @deprecated Use "Gdbots\Pbj\WellKnown\BigNumber" from "gdbots/pbj" 1.1.x or later instead.
*/
class BigNumber extends \Moontoast\Math\BigNumber implements \JsonSerializable
{
/**
* BigNumber constructor.
*
* @param mixed $number
* @param null $scale
*/
public function __construct($number, $scale = null)
{
@trigger_error(sprintf('"%s" is deprecated. Use "Gdbots\Pbj\WellKnown\BigNumber" from "gdbots/pbj" 1.1.x or later instead.', __CLASS__), E_USER_DEPRECATED);
parent::__construct($number, $scale);
}

/**
* @return string
*/
Expand Down
4 changes: 4 additions & 0 deletions src/Common/GeoPoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
/**
* Represents a GeoJson Point value.
* @link http://geojson.org/geojson-spec.html#point
*
* @deprecated Use "Gdbots\Pbj\WellKnown\GeoPoint" from "gdbots/pbj" 1.1.x or later instead.
*/
class GeoPoint implements FromArray, ToArray, \JsonSerializable
{
Expand All @@ -22,6 +24,8 @@ class GeoPoint implements FromArray, ToArray, \JsonSerializable
*/
public function __construct($lat, $lon)
{
@trigger_error(sprintf('"%s" is deprecated. Use "Gdbots\Pbj\WellKnown\GeoPoint" from "gdbots/pbj" 1.1.x or later instead.', __CLASS__), E_USER_DEPRECATED);

$this->latitude = (float) $lat;
$this->longitude = (float) $lon;

Expand Down
7 changes: 6 additions & 1 deletion src/Common/Microtime.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
* 10 digits (unix timestamp) concatenated with 6 microsecond digits.
*
* @link http://php.net/manual/en/function.microtime.php
*
* @deprecated Use "Gdbots\Pbj\WellKnown\Microtime" from "gdbots/pbj" 1.1.x or later instead.
*/
class Microtime implements \JsonSerializable
{
Expand All @@ -29,7 +31,10 @@ class Microtime implements \JsonSerializable
/**
* Private constructor to ensure static methods are used.
*/
private function __construct() {}
private function __construct()
{
@trigger_error(sprintf('"%s" is deprecated. Use "Gdbots\Pbj\WellKnown\Microtime" from "gdbots/pbj" 1.1.x or later instead.', __CLASS__), E_USER_DEPRECATED);
}

/**
* Create a new object using the current microtime.
Expand Down
5 changes: 5 additions & 0 deletions src/Identifiers/DatedSlugIdentifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
use Gdbots\Common\Util\SlugUtils;
use Gdbots\Common\Util\StringUtils;

/**
* @deprecated Use "Gdbots\Pbj\WellKnown\DatedSlugIdentifier" from "gdbots/pbj" 1.1.x or later instead.
*/
abstract class DatedSlugIdentifier implements Identifier, \JsonSerializable
{
/** @var string */
Expand All @@ -16,6 +19,8 @@ abstract class DatedSlugIdentifier implements Identifier, \JsonSerializable
*/
protected function __construct($slug)
{
@trigger_error(sprintf('"%s" is deprecated. Use "Gdbots\Pbj\WellKnown\DatedSlugIdentifier" from "gdbots/pbj" 1.1.x or later instead.', __CLASS__), E_USER_DEPRECATED);

if (!is_string($slug)) {
throw new \InvalidArgumentException(
sprintf('String expected but got [%s].', StringUtils::varToString($slug))
Expand Down
3 changes: 3 additions & 0 deletions src/Identifiers/GeneratesIdentifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace Gdbots\Identifiers;

/**
* @deprecated Use "Gdbots\Pbj\WellKnown\GeneratesIdentifier" from "gdbots/pbj" 1.1.x or later instead.
*/
interface GeneratesIdentifier
{
/**
Expand Down
3 changes: 3 additions & 0 deletions src/Identifiers/Identifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace Gdbots\Identifiers;

/**
* @deprecated Use "Gdbots\Pbj\WellKnown\Identifier" from "gdbots/pbj" 1.1.x or later instead.
*/
interface Identifier
{
/**
Expand Down
5 changes: 5 additions & 0 deletions src/Identifiers/SlugIdentifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
use Gdbots\Common\Util\SlugUtils;
use Gdbots\Common\Util\StringUtils;

/**
* @deprecated Use "Gdbots\Pbj\WellKnown\SlugIdentifier" from "gdbots/pbj" 1.1.x or later instead.
*/
abstract class SlugIdentifier implements Identifier, \JsonSerializable
{
/** @var string */
Expand All @@ -16,6 +19,8 @@ abstract class SlugIdentifier implements Identifier, \JsonSerializable
*/
protected function __construct($slug)
{
@trigger_error(sprintf('"%s" is deprecated. Use "Gdbots\Pbj\WellKnown\SlugIdentifier" from "gdbots/pbj" 1.1.x or later instead.', __CLASS__), E_USER_DEPRECATED);

if (!is_string($slug)) {
throw new \InvalidArgumentException(
sprintf('String expected but got [%s].', StringUtils::varToString($slug))
Expand Down
5 changes: 5 additions & 0 deletions src/Identifiers/StringIdentifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

use Gdbots\Common\Util\StringUtils;

/**
* @deprecated Use "Gdbots\Pbj\WellKnown\StringIdentifier" from "gdbots/pbj" 1.1.x or later instead.
*/
abstract class StringIdentifier implements Identifier, \JsonSerializable
{
/** @var string */
Expand All @@ -15,6 +18,8 @@ abstract class StringIdentifier implements Identifier, \JsonSerializable
*/
protected function __construct($string)
{
@trigger_error(sprintf('"%s" is deprecated. Use "Gdbots\Pbj\WellKnown\StringIdentifier" from "gdbots/pbj" 1.1.x or later instead.', __CLASS__), E_USER_DEPRECATED);

if (!is_string($string)) {
throw new \InvalidArgumentException(
sprintf('String expected but got [%s].', StringUtils::varToString($string))
Expand Down
3 changes: 3 additions & 0 deletions src/Identifiers/TimeUuidIdentifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;

/**
* @deprecated Use "Gdbots\Pbj\WellKnown\TimeUuidIdentifier" from "gdbots/pbj" 1.1.x or later instead.
*/
class TimeUuidIdentifier extends UuidIdentifier
{
/**
Expand Down
4 changes: 4 additions & 0 deletions src/Identifiers/UuidIdentifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;

/**
* @deprecated Use "Gdbots\Pbj\WellKnown\UuidIdentifier" from "gdbots/pbj" 1.1.x or later instead.
*/
class UuidIdentifier implements Identifier, GeneratesIdentifier, \JsonSerializable
{
/** @var UuidInterface */
Expand All @@ -15,6 +18,7 @@ class UuidIdentifier implements Identifier, GeneratesIdentifier, \JsonSerializab
*/
protected function __construct(UuidInterface $uuid)
{
@trigger_error(sprintf('"%s" is deprecated. Use "Gdbots\Pbj\WellKnown\[Time]UuidIdentifier" from "gdbots/pbj" 1.1.x or later instead.', __CLASS__), E_USER_DEPRECATED);
$this->uuid = $uuid;
}

Expand Down
116 changes: 0 additions & 116 deletions tests/Common/MicrotimeTest.php

This file was deleted.

48 changes: 0 additions & 48 deletions tests/Identifiers/DatedSlugIdentifierTest.php

This file was deleted.

Loading

0 comments on commit 04647ee

Please sign in to comment.