Skip to content

Commit

Permalink
2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Shira-3749 committed Sep 20, 2018
1 parent fcbbb69 commit df2bd9f
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 29 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ matrix:
- INSTALL_COMMAND="composer install"
- MAIN_COMMAND="composer tests"

allow_failures:
- php: nightly

fast_finish: true

install: ${INSTALL_COMMAND}

script: ${MAIN_COMMAND}
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
#########

2.0.1
*****

- fixed PHP version requirement to PHP 7.1+
- relaxed PHPDoc annotations of value-related ``Enum`` methods


2.0.0
*****

Expand Down
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Emulated enumeration objects in PHP.
The interface is similar to `SplEnum <http://php.net/manual/en/class.splenum.php>`_
but doesn't require any PHP extensions and provides more functionality.

.. image:: https://travis-ci.org/kuria/enum.svg?branch=master
:target: https://travis-ci.org/kuria/enum
.. image:: https://travis-ci.com/kuria/enum.svg?branch=master
:target: https://travis-ci.com/kuria/enum

.. contents::

Expand All @@ -26,7 +26,7 @@ Features
Requirements
************

- PHP 7.0+
- PHP 7.1+

Usage
*****
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"keywords": ["enum", "enumeration"],
"license": "MIT",
"require": {
"php": ">=7.0"
"php": ">=7.1"
},
"require-dev": {
"kuria/dev-meta": "^0.4.0"
"kuria/dev-meta": "^0.5"
},
"autoload": {
"psr-4": {
Expand Down
22 changes: 1 addition & 21 deletions src/Enum.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,13 @@ abstract class Enum implements EnumInterface
/** @var string */
private $key;

/** @var string|int|null */
/** @var mixed */
private $value;

/**
* Internal constructor
*
* The key and value are assumed to be valid.
*
* @param string|int|null $value
*/
protected function __construct(string $key, $value)
{
Expand Down Expand Up @@ -128,7 +126,6 @@ static function fromKey(string $key)
/**
* Get instance for the given value
*
* @param string|int|null $value
* @return static
*/
static function fromValue($value)
Expand All @@ -148,8 +145,6 @@ static function hasKey(string $key): bool

/**
* Check if the given value exists in this enum
*
* @param string|int|null $value
*/
static function hasValue($value): bool
{
Expand All @@ -160,7 +155,6 @@ static function hasValue($value): bool

/**
* @throws InvalidKeyException
* @return string|int|null
*/
static function findValueByKey(string $key)
{
Expand All @@ -170,7 +164,6 @@ static function findValueByKey(string $key)
}

/**
* @param string|int|null $value
* @throws InvalidValueException
*/
static function findKeyByValue($value): string
Expand All @@ -190,9 +183,6 @@ static function getKeys(): array
return array_keys(self::$keyToValueMap[static::class]);
}

/**
* @return string[]|int[]|null[]
*/
static function getValues(): array
{
self::ensureKeyToValueMapLoaded();
Expand Down Expand Up @@ -233,9 +223,6 @@ function getKey(): string
return $this->key;
}

/**
* @return string|int|null
*/
function getValue()
{
return $this->value;
Expand All @@ -246,9 +233,6 @@ function is(string $key): bool
return $this->key === $key;
}

/**
* @param string|int|null $value
*/
function equals($value): bool
{
self::ensureValueToKeyMapLoaded();
Expand All @@ -272,7 +256,6 @@ static function ensureKeyExists(string $key)
}

/**
* @param string|int|null $value
* @throws InvalidValueException if the value does not exist
*/
static function ensureValueExists($value)
Expand Down Expand Up @@ -372,9 +355,6 @@ private static function determineKeyToValueMap(): array
return $keyToValueMap;
}

/**
* @param string|int|null $value
*/
private static function dumpValue($value): string
{
if (is_string($value)) {
Expand Down
5 changes: 2 additions & 3 deletions tests/EnumTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@

namespace Kuria\Enum;

use Kuria\DevMeta\Test;
use Kuria\Enum\Exception\DuplicateValueException;
use Kuria\Enum\Exception\InvalidKeyException;
use Kuria\Enum\Exception\InvalidValueException;
use Kuria\Enum\TestSubject\DuplicateCoercedIntEnum;
use Kuria\Enum\TestSubject\DuplicateCoercedNullEnum;
use Kuria\Enum\TestSubject\DuplicateCoercedValuesEnum;
use Kuria\Enum\TestSubject\DuplicateValuesEnum;
use Kuria\Enum\TestSubject\IntNullEnum;
use Kuria\Enum\TestSubject\StringEnum;
use Kuria\Enum\TestSubject\TestEnum;
use PHPUnit\Framework\TestCase;

class EnumTest extends TestCase
class EnumTest extends Test
{
/**
* @dataProvider provideKeyValue
Expand Down

0 comments on commit df2bd9f

Please sign in to comment.