From 45aa5540d5d08f5fe24d08b97d17a5466dd3cf71 Mon Sep 17 00:00:00 2001 From: Bilge Date: Mon, 25 Nov 2024 20:37:23 +0000 Subject: [PATCH] Added PHP 8.4 compatibility. BC: Changed DataType from AbstractEnumeration -> native enum. --- .github/workflows/Tests.yaml | 1 + README.md | 2 +- composer.json | 3 +-- src/DataType.php | 26 +++++++------------------- src/Strategy/Type.php | 2 +- test/Functional/DocumentationTest.php | 2 +- test/Unit/Mapper/Strategy/TypeTest.php | 2 +- 7 files changed, 13 insertions(+), 25 deletions(-) diff --git a/.github/workflows/Tests.yaml b/.github/workflows/Tests.yaml index 765443a..f2947d8 100644 --- a/.github/workflows/Tests.yaml +++ b/.github/workflows/Tests.yaml @@ -18,6 +18,7 @@ jobs: - 8.1 - 8.2 - 8.3 + - 8.4 dependencies: - hi - lo diff --git a/README.md b/README.md index 88ca6c3..2b1497e 100644 --- a/README.md +++ b/README.md @@ -897,7 +897,7 @@ Type(DataType $type, Strategy $strategy) #### Example ```php -(new Mapper)->map(['foo' => 123], new Type(DataType::STRING(), new Copy('foo'))); +(new Mapper)->map(['foo' => 123], new Type(DataType::String, new Copy('foo'))); ``` > '123' diff --git a/composer.json b/composer.json index 3f71ac6..028a282 100644 --- a/composer.json +++ b/composer.json @@ -10,8 +10,7 @@ "license": "LGPL-3.0", "require": { "php": "^8.1", - "scriptfusion/array-walker": "^1", - "eloquent/enumeration": "^5|^6" + "scriptfusion/array-walker": "^1" }, "require-dev": { "scriptfusion/static-class": "^1", diff --git a/src/DataType.php b/src/DataType.php index 7755bfc..d25e934 100644 --- a/src/DataType.php +++ b/src/DataType.php @@ -1,24 +1,12 @@ type"); + settype($data, $this->type->name); return $data; } diff --git a/test/Functional/DocumentationTest.php b/test/Functional/DocumentationTest.php index 5870969..37fe934 100644 --- a/test/Functional/DocumentationTest.php +++ b/test/Functional/DocumentationTest.php @@ -390,7 +390,7 @@ public function testType() { self::assertSame( '123', - (new Mapper)->map(['foo' => 123], new Type(DataType::STRING(), new Copy('foo'))) + (new Mapper)->map(['foo' => 123], new Type(DataType::String, new Copy('foo'))) ); } diff --git a/test/Unit/Mapper/Strategy/TypeTest.php b/test/Unit/Mapper/Strategy/TypeTest.php index d363c89..243aeab 100644 --- a/test/Unit/Mapper/Strategy/TypeTest.php +++ b/test/Unit/Mapper/Strategy/TypeTest.php @@ -14,7 +14,7 @@ final class TypeTest extends TestCase public function test() { - $type = new Type(DataType::INTEGER(), \Mockery::mock(Strategy::class)); + $type = new Type(DataType::Integer, \Mockery::mock(Strategy::class)); $type->setMapper(MockFactory::mockMapper('123')); self::assertSame(123, $type([]));