Skip to content

Commit

Permalink
Merge pull request #46 from karriereat/feature/php8
Browse files Browse the repository at this point in the history
Add support for PHP 8
  • Loading branch information
fetzi authored Nov 2, 2021
2 parents 3ee234c + a763151 commit 93b5ed6
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [7.4]
php: [7.4, 8.0]

runs-on: ubuntu-latest
name: PHP@${{ matrix.php }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [7.3, 7.4]
php: [7.3, 7.4, 8.0]

runs-on: ubuntu-latest
name: PHP@${{ matrix.php }}
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [4.1.0] - 2021-10-20
### Added
- Support for PHP 8

## [4.0.3] - 2020-11-30
### Fixed
- To strict param type in `transform` method
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
}
},
"require": {
"php": ">=7.3",
"php": "^7.3 | ^8.0",
"php-di/phpdoc-reader": "^2.1"
},
"require-dev": {
Expand Down
4 changes: 2 additions & 2 deletions tests/Bindings/AliasBindingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class AliasBindingTest extends TestCase
{
/** @test */
public function it_aliases_a_field()
public function itAliasesAField()
{
$binding = new AliasBinding('firstname', 'first-name');
$person = new Person();
Expand All @@ -23,7 +23,7 @@ public function it_aliases_a_field()
}

/** @test */
public function it_skips_a_not_available_field()
public function itSkipsANotAvailableField()
{
$binding = new AliasBinding('lastname', 'lastname');
$person = new Person();
Expand Down
4 changes: 2 additions & 2 deletions tests/Bindings/ArrayBindingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class ArrayBindingTest extends TestCase
{
/** @test */
public function it_binds_an_array()
public function itBindsAnArray()
{
$binding = new ArrayBinding('address', 'addresses', Address::class);
$person = new Person();
Expand Down Expand Up @@ -42,7 +42,7 @@ public function it_binds_an_array()
}

/** @test */
public function it_skips_a_not_available_field()
public function itSkipsANotAvailableField()
{
$binding = new ArrayBinding('address', 'addresses', Address::class);
$person = new Person();
Expand Down
4 changes: 2 additions & 2 deletions tests/Bindings/CallbackBindingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class CallbackBindingTest extends TestCase
{
/** @test */
public function it_binds_with_a_callback()
public function itBindsWithACallback()
{
$binding = new CallbackBinding('firstname', function () {
return 'Jane';
Expand All @@ -25,7 +25,7 @@ public function it_binds_with_a_callback()
}

/** @test */
public function it_always_validates_to_true()
public function itAlwaysValidatesToTrue()
{
$binding = new CallbackBinding('firstname', function () {
return 'Jane';
Expand Down
18 changes: 9 additions & 9 deletions tests/Bindings/DateTimeBindingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,52 +12,52 @@
class DateTimeBindingTest extends TestCase
{
/** @test */
public function it_validates_successfully()
public function itValidatesSuccessfully()
{
$binding = new DateTimeBinding('date', 'date');

$this->assertTrue($binding->validate(['date' => '2020-01-01T12:00:00+00:00']));
}

/** @test */
public function it_fails_on_validation_of_a_required_property_with_an_invalid_date_format()
public function itFailsOnValidationOfARequiredPropertyWithAnInvalidDateFormat()
{
$binding = new DateTimeBinding('date', 'date', true);

$this->assertFalse($binding->validate(['date' => 'invalid']));
}

/** @test */
public function it_fails_on_validation_of_a_not_required_property_with_an_invalid_date_format()
public function itFailsOnValidationOfANotRequiredPropertyWithAnInvalidDateFormat()
{
$binding = new DateTimeBinding('date', 'date', false);

$this->assertFalse($binding->validate(['date' => 'invalid']));
}

/** @test */
public function it_fails_on_validation_for_a_not_set_field_that_is_required()
public function itFailsOnValidationForANotSetFieldThatIsRequired()
{
$binding = new DateTimeBinding('date', 'date', true);
$this->assertFalse($binding->validate([]));
}

/** @test */
public function it_succeeds_on_validation_for_a_not_set_field_that_is_not_required()
public function itSucceedsOnValidationForANotSetFieldThatIsNotRequired()
{
$binding = new DateTimeBinding('date', 'date', false);
$this->assertTrue($binding->validate([]));
}

/** @test */
public function it_succeeds_on_validation_for_an_empty_field_that_is_not_required()
public function itSucceedsOnValidationForAnEmptyFieldThatIsNotRequired()
{
$binding = new DateTimeBinding('date', 'date', false);
$this->assertTrue($binding->validate(['date' => '']));
}

/** @test */
public function it_binds_an_atom_datetime()
public function itBindsAnAtomDatetime()
{
$binding = new DateTimeBinding('date', 'date');
$person = new Person();
Expand All @@ -71,7 +71,7 @@ public function it_binds_an_atom_datetime()
}

/** @test */
public function it_ignores_an_empty_datetime_value()
public function itIgnoresAnEmptyDatetimeValue()
{
$binding = new DateTimeBinding('date', 'date');
$person = new Person();
Expand All @@ -83,7 +83,7 @@ public function it_ignores_an_empty_datetime_value()
}

/** @test */
public function it_ignores_an_invalid_datetime_value()
public function itIgnoresAnInvalidDatetimeValue()
{
$binding = new DateTimeBinding('date', 'date');
$person = new Person();
Expand Down
4 changes: 2 additions & 2 deletions tests/Bindings/FieldBindingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class FieldBindingTest extends TestCase
{
/** @test */
public function it_binds_a_field_to_a_class_instance()
public function itBindsAFieldToAClassInstance()
{
$binding = new FieldBinding('address', 'address', Address::class);
$person = new Person();
Expand All @@ -27,7 +27,7 @@ public function it_binds_a_field_to_a_class_instance()
}

/** @test */
public function it_ignores_a_not_defined_field()
public function itIgnoresANotDefinedField()
{
$binding = new FieldBinding('address', 'address', Address::class);
$person = new Person();
Expand Down
6 changes: 3 additions & 3 deletions tests/Bindings/RawBindingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class RawBindingTest extends TestCase
{
/** @test */
public function it_sets_a_raw_value()
public function itSetsARawValue()
{
$binding = new RawBinding('firstname');
$person = new Person();
Expand All @@ -23,7 +23,7 @@ public function it_sets_a_raw_value()
}

/** @test */
public function it_ignores_a_not_existing_property()
public function itIgnoresANotExistingProperty()
{
$binding = new RawBinding('firstname');
$person = new Person();
Expand All @@ -35,7 +35,7 @@ public function it_ignores_a_not_existing_property()
}

/** @test */
public function it_always_validates_to_true()
public function itAlwaysValidatesToTrue()
{
$binding = new RawBinding('firstname');

Expand Down
12 changes: 6 additions & 6 deletions tests/ClassBindingsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class ClassBindingsTest extends TestCase
{
/** @test */
public function it_registers_a_binding()
public function itRegistersABinding()
{
$classBindings = new ClassBindings(new JsonDecoder());

Expand All @@ -27,7 +27,7 @@ public function it_registers_a_binding()
}

/** @test */
public function it_registers_a_callback_binding()
public function itRegistersACallbackBinding()
{
$classBindings = new ClassBindings(new JsonDecoder());

Expand All @@ -41,7 +41,7 @@ public function it_registers_a_callback_binding()
}

/** @test */
public function it_fails_to_register_a_not_compatible_binding_class()
public function itFailsToRegisterANotCompatibleBindingClass()
{
$classBindings = new ClassBindings(new JsonDecoder());

Expand All @@ -51,7 +51,7 @@ public function it_fails_to_register_a_not_compatible_binding_class()
}

/** @test */
public function it_throws_an_exception_if_binding_validation_fails()
public function itThrowsAnExceptionIfBindingValidationFails()
{
$classBindings = new ClassBindings(new JsonDecoder());

Expand All @@ -72,7 +72,7 @@ public function bind($jsonDecoder, $jsonData, $property)
}

/** @test */
public function it_executes_callback_bindings_when_property_name_is_contained_in_json_fields()
public function itExecutesCallbackBindingsWhenPropertyNameIsContainedInJsonFields()
{
$classBindings = new ClassBindings(new JsonDecoder());
$classBindings->register(new CallbackBinding('firstname', function ($data) {
Expand All @@ -85,7 +85,7 @@ public function it_executes_callback_bindings_when_property_name_is_contained_in
}

/** @test */
public function it_executes_callback_bindings_when_property_name_is_not_contained_in_json_fields()
public function itExecutesCallbackBindingsWhenPropertyNameIsNotContainedInJsonFields()
{
$classBindings = new ClassBindings(new JsonDecoder());
$classBindings->register(new CallbackBinding('somePropertyName', function () {
Expand Down
24 changes: 12 additions & 12 deletions tests/JsonDecoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class JsonDecoderTest extends TestCase
{
/** @test */
public function it_fails_for_an_invalid_json_input()
public function itFailsForAnInvalidJsonInput()
{
$jsonDecoder = new JsonDecoder();

Expand All @@ -29,7 +29,7 @@ public function it_fails_for_an_invalid_json_input()
}

/** @test */
public function it_is_able_to_decode_json_without_a_transformer()
public function itIsAbleToDecodeJsonWithoutATransformer()
{
$jsonDecoder = new JsonDecoder();

Expand All @@ -44,7 +44,7 @@ public function it_is_able_to_decode_json_without_a_transformer()
}

/** @test */
public function it_is_able_to_decode_json_with_a_transformer()
public function itIsAbleToDecodeJsonWithATransformer()
{
$jsonDecoder = new JsonDecoder();
$jsonDecoder->register(new class() implements Transformer {
Expand Down Expand Up @@ -74,7 +74,7 @@ public function transforms()
}

/** @test */
public function it_is_able_to_decode_json_with_a_more_complex_transformer()
public function itIsAbleToDecodeJsonWithAMoreComplexTransformer()
{
$jsonDecoder = new JsonDecoder();
$jsonDecoder->register(new class() implements Transformer {
Expand Down Expand Up @@ -106,7 +106,7 @@ public function transforms()
}

/** @test */
public function it_decodes_multiple_instances_of_a_type()
public function itDecodesMultipleInstancesOfAType()
{
$jsonDecoder = new JsonDecoder();
$persons = $jsonDecoder->decodeMultiple(file_get_contents(__DIR__ . '/data/persons.json'), Person::class);
Expand All @@ -118,7 +118,7 @@ public function it_decodes_multiple_instances_of_a_type()
}

/** @test */
public function it_handles_empty_json_strings_gracefully()
public function itHandlesEmptyJsonStringsGracefully()
{
$jsonDecoder = new JsonDecoder();

Expand All @@ -145,7 +145,7 @@ public function transforms()
}

/** @test */
public function it_decodes_an_object_with_a_root_key()
public function itDecodesAnObjectWithARootKey()
{
$jsonDecoder = new JsonDecoder();

Expand All @@ -157,7 +157,7 @@ public function it_decodes_an_object_with_a_root_key()
}

/** @test */
public function it_decodes_multiple_objects_with_a_root_key()
public function itDecodesMultipleObjectsWithARootKey()
{
$jsonDecoder = new JsonDecoder();

Expand All @@ -171,7 +171,7 @@ public function it_decodes_multiple_objects_with_a_root_key()
}

/** @test */
public function it_fails_for_not_existing_root_key()
public function itFailsForNotExistingRootKey()
{
$this->expectException(NotExistingRootException::class);

Expand All @@ -180,7 +180,7 @@ public function it_fails_for_not_existing_root_key()
}

/** @test */
public function it_scans_a_class_and_generates_a_transformer()
public function itScansAClassAndGeneratesATransformer()
{
$jsonDecoder = new JsonDecoder();
$jsonDecoder->scanAndRegister(Person::class);
Expand All @@ -199,7 +199,7 @@ public function it_scans_a_class_and_generates_a_transformer()
}

/** @test */
public function it_can_auto_case_from_snake_to_camel()
public function itCanAutoCaseFromSnakeToCamel()
{
$jsonDecoder = new JsonDecoder(true);

Expand All @@ -212,7 +212,7 @@ public function it_can_auto_case_from_snake_to_camel()
}

/** @test */
public function it_can_auto_case_from_kebap_to_camel()
public function itCanAutoCaseFromKebapToCamel()
{
$jsonDecoder = new JsonDecoder(true);

Expand Down
Loading

0 comments on commit 93b5ed6

Please sign in to comment.