Skip to content

Commit

Permalink
Merge pull request #82 from myclabs/fix-coding-style
Browse files Browse the repository at this point in the history
Fix coding style
  • Loading branch information
mnapoli authored Oct 30, 2018
2 parents 76dd4ad + d24462d commit 550d233
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ php:
- 7.0
- 7.1
- 7.2
- 7.3
- nightly

matrix:
Expand All @@ -21,7 +22,6 @@ before_script:

script:
- vendor/bin/phpunit
- vendor/bin/phpcs --standard=PSR2 ./src/

# Use Travis' new container-based infrastructure.
# See http://docs.travis-ci.com/user/migrating-from-legacy/#How-can-I-use-container-based-infrastructure%3F
Expand Down
2 changes: 1 addition & 1 deletion src/Enum.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ abstract class Enum implements \JsonSerializable
*
* @var array
*/
protected static $cache = array();
protected static $cache = [];

/**
* Creates a new value of some type
Expand Down
37 changes: 21 additions & 16 deletions tests/EnumTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,21 +166,21 @@ public function testIsValid($value, $isValid)

public function isValidProvider()
{
return array(
return [
/**
* Valid values
*/
array('foo', true),
array(42, true),
array(null, true),
array(0, true),
array('', true),
array(false, true),
['foo', true],
[42, true],
[null, true],
[0, true],
['', true],
[false, true],
/**
* Invalid values
*/
array('baz', false)
);
['baz', false]
];
}

/**
Expand Down Expand Up @@ -259,13 +259,13 @@ public function testEqualsConflictValues()
*/
public function testJsonSerialize()
{
$this->assertJsonStringEqualsJsonString('"foo"', json_encode(new EnumFixture(EnumFixture::FOO)));
$this->assertJsonStringEqualsJsonString('"bar"', json_encode(new EnumFixture(EnumFixture::BAR)));
$this->assertJsonStringEqualsJsonString('42', json_encode(new EnumFixture(EnumFixture::NUMBER)));
$this->assertJsonStringEqualsJsonString('0', json_encode(new EnumFixture(EnumFixture::PROBLEMATIC_NUMBER)));
$this->assertJsonStringEqualsJsonString('null', json_encode(new EnumFixture(EnumFixture::PROBLEMATIC_NULL)));
$this->assertJsonStringEqualsJsonString('""', json_encode(new EnumFixture(EnumFixture::PROBLEMATIC_EMPTY_STRING)));
$this->assertJsonStringEqualsJsonString('false', json_encode(new EnumFixture(EnumFixture::PROBLEMATIC_BOOLEAN_FALSE)));
$this->assertJsonEqualsJson('"foo"', json_encode(new EnumFixture(EnumFixture::FOO)));
$this->assertJsonEqualsJson('"bar"', json_encode(new EnumFixture(EnumFixture::BAR)));
$this->assertJsonEqualsJson('42', json_encode(new EnumFixture(EnumFixture::NUMBER)));
$this->assertJsonEqualsJson('0', json_encode(new EnumFixture(EnumFixture::PROBLEMATIC_NUMBER)));
$this->assertJsonEqualsJson('null', json_encode(new EnumFixture(EnumFixture::PROBLEMATIC_NULL)));
$this->assertJsonEqualsJson('""', json_encode(new EnumFixture(EnumFixture::PROBLEMATIC_EMPTY_STRING)));
$this->assertJsonEqualsJson('false', json_encode(new EnumFixture(EnumFixture::PROBLEMATIC_BOOLEAN_FALSE)));
}

public function testNullableEnum()
Expand All @@ -280,4 +280,9 @@ public function testBooleanEnum()
$this->assertFalse(EnumFixture::PROBLEMATIC_BOOLEAN_FALSE()->getValue());
$this->assertFalse((new EnumFixture(EnumFixture::PROBLEMATIC_BOOLEAN_FALSE))->jsonSerialize());
}

private function assertJsonEqualsJson($json1, $json2)
{
$this->assertJsonStringEqualsJsonString($json1, $json2);
}
}

0 comments on commit 550d233

Please sign in to comment.