From 3c500df96b1fec5c98b2f034e42eff16f2ab8ae8 Mon Sep 17 00:00:00 2001 From: Priyadi Iman Nurcahyo <1102197+priyadi@users.noreply.github.com> Date: Sat, 13 Jan 2024 17:42:22 +0700 Subject: [PATCH] refactor: Move `Context` to its own namespace. --- CHANGELOG.md | 1 + src/{MainTransformer => Context}/Context.php | 4 ++-- .../Exception => Context}/ContextMemberNotFoundException.php | 2 +- src/MainTransformer/MainTransformer.php | 3 ++- src/MainTransformer/MainTransformerInterface.php | 1 + src/Mapper.php | 2 +- src/MethodMapper/ClassMethodTransformer.php | 2 +- src/MethodMapper/MapFromObjectInterface.php | 2 +- src/MethodMapper/MapToObjectInterface.php | 2 +- src/MethodMapper/SubMapper.php | 2 +- src/MethodMapper/SubMapperInterface.php | 2 +- src/Transformer/ArrayToObjectTransformer.php | 2 +- src/Transformer/Contracts/TransformerInterface.php | 2 +- src/Transformer/CopyTransformer.php | 2 +- src/Transformer/DateTimeTransformer.php | 2 +- src/Transformer/NullTransformer.php | 2 +- src/Transformer/ObjectToArrayTransformer.php | 2 +- src/Transformer/ObjectToObjectTransformer.php | 2 +- src/Transformer/ObjectToStringTransformer.php | 2 +- src/Transformer/ScalarToScalarTransformer.php | 2 +- src/Transformer/StringToBackedEnumTransformer.php | 2 +- src/Transformer/TraversableToArrayAccessTransformer.php | 2 +- src/Transformer/TraversableToTraversableTransformer.php | 2 +- tests/Fixtures/MethodMapper/MoneyDto.php | 2 +- tests/Fixtures/MethodMapper/ObjectWithArrayPropertyDto.php | 2 +- .../MethodMapper/ObjectWithObjectWithScalarPropertiesDto.php | 2 +- tests/Fixtures/Transformer/MoneyToMoneyDtoTransformer.php | 2 +- 27 files changed, 29 insertions(+), 26 deletions(-) rename src/{MainTransformer => Context}/Context.php (94%) rename src/{MainTransformer/Exception => Context}/ContextMemberNotFoundException.php (91%) diff --git a/CHANGELOG.md b/CHANGELOG.md index c05c64b7..e0791764 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ * refactor: Remove `$context` from `MapperInterface` * chore: Fix static analysis issues. * refactor: Change context array to `Context` object. +* refactor: Move `Context` to its own namespace. ## 0.5.4 diff --git a/src/MainTransformer/Context.php b/src/Context/Context.php similarity index 94% rename from src/MainTransformer/Context.php rename to src/Context/Context.php index 18231b45..cb34903e 100644 --- a/src/MainTransformer/Context.php +++ b/src/Context/Context.php @@ -11,10 +11,10 @@ * that was distributed with this source code. */ -namespace Rekalogika\Mapper\MainTransformer; +namespace Rekalogika\Mapper\Context; use Rekalogika\Mapper\Exception\LogicException; -use Rekalogika\Mapper\MainTransformer\Exception\ContextMemberNotFoundException; +use Rekalogika\Mapper\Context\ContextMemberNotFoundException; /** * @immutable diff --git a/src/MainTransformer/Exception/ContextMemberNotFoundException.php b/src/Context/ContextMemberNotFoundException.php similarity index 91% rename from src/MainTransformer/Exception/ContextMemberNotFoundException.php rename to src/Context/ContextMemberNotFoundException.php index 71895ba7..164d5e6a 100644 --- a/src/MainTransformer/Exception/ContextMemberNotFoundException.php +++ b/src/Context/ContextMemberNotFoundException.php @@ -11,7 +11,7 @@ * that was distributed with this source code. */ -namespace Rekalogika\Mapper\MainTransformer\Exception; +namespace Rekalogika\Mapper\Context; use Rekalogika\Mapper\Exception\RuntimeException; diff --git a/src/MainTransformer/MainTransformer.php b/src/MainTransformer/MainTransformer.php index 406295ec..21aba2ce 100644 --- a/src/MainTransformer/MainTransformer.php +++ b/src/MainTransformer/MainTransformer.php @@ -13,8 +13,9 @@ namespace Rekalogika\Mapper\MainTransformer; +use Rekalogika\Mapper\Context\Context; use Rekalogika\Mapper\MainTransformer\Exception\CannotFindTransformerException; -use Rekalogika\Mapper\MainTransformer\Exception\ContextMemberNotFoundException; +use Rekalogika\Mapper\Context\ContextMemberNotFoundException; use Rekalogika\Mapper\MainTransformer\Exception\TransformerReturnsUnexpectedValueException; use Rekalogika\Mapper\ObjectCache\Exception\CachedTargetObjectNotFoundException; use Rekalogika\Mapper\ObjectCache\ObjectCache; diff --git a/src/MainTransformer/MainTransformerInterface.php b/src/MainTransformer/MainTransformerInterface.php index 7369950c..0be42aba 100644 --- a/src/MainTransformer/MainTransformerInterface.php +++ b/src/MainTransformer/MainTransformerInterface.php @@ -13,6 +13,7 @@ namespace Rekalogika\Mapper\MainTransformer; +use Rekalogika\Mapper\Context\Context; use Symfony\Component\PropertyInfo\Type; interface MainTransformerInterface diff --git a/src/Mapper.php b/src/Mapper.php index 17463f24..ed11421e 100644 --- a/src/Mapper.php +++ b/src/Mapper.php @@ -14,7 +14,7 @@ namespace Rekalogika\Mapper; use Rekalogika\Mapper\Exception\UnexpectedValueException; -use Rekalogika\Mapper\MainTransformer\Context; +use Rekalogika\Mapper\Context\Context; use Rekalogika\Mapper\MainTransformer\MainTransformerInterface; use Rekalogika\Mapper\Util\TypeFactory; diff --git a/src/MethodMapper/ClassMethodTransformer.php b/src/MethodMapper/ClassMethodTransformer.php index f8a155a3..2a00c969 100644 --- a/src/MethodMapper/ClassMethodTransformer.php +++ b/src/MethodMapper/ClassMethodTransformer.php @@ -14,7 +14,7 @@ namespace Rekalogika\Mapper\MethodMapper; use Rekalogika\Mapper\Exception\InvalidArgumentException; -use Rekalogika\Mapper\MainTransformer\Context; +use Rekalogika\Mapper\Context\Context; use Rekalogika\Mapper\ObjectCache\ObjectCache; use Rekalogika\Mapper\Transformer\Contracts\MainTransformerAwareInterface; use Rekalogika\Mapper\Transformer\Contracts\MainTransformerAwareTrait; diff --git a/src/MethodMapper/MapFromObjectInterface.php b/src/MethodMapper/MapFromObjectInterface.php index 244ac253..3c1032ed 100644 --- a/src/MethodMapper/MapFromObjectInterface.php +++ b/src/MethodMapper/MapFromObjectInterface.php @@ -13,7 +13,7 @@ namespace Rekalogika\Mapper\MethodMapper; -use Rekalogika\Mapper\MainTransformer\Context; +use Rekalogika\Mapper\Context\Context; interface MapFromObjectInterface { diff --git a/src/MethodMapper/MapToObjectInterface.php b/src/MethodMapper/MapToObjectInterface.php index 61a4bdb2..527ca968 100644 --- a/src/MethodMapper/MapToObjectInterface.php +++ b/src/MethodMapper/MapToObjectInterface.php @@ -13,7 +13,7 @@ namespace Rekalogika\Mapper\MethodMapper; -use Rekalogika\Mapper\MainTransformer\Context; +use Rekalogika\Mapper\Context\Context; interface MapToObjectInterface { diff --git a/src/MethodMapper/SubMapper.php b/src/MethodMapper/SubMapper.php index c5b5fb72..61408825 100644 --- a/src/MethodMapper/SubMapper.php +++ b/src/MethodMapper/SubMapper.php @@ -14,7 +14,7 @@ namespace Rekalogika\Mapper\MethodMapper; use Rekalogika\Mapper\Exception\UnexpectedValueException; -use Rekalogika\Mapper\MainTransformer\Context; +use Rekalogika\Mapper\Context\Context; use Rekalogika\Mapper\Transformer\Contracts\MainTransformerAwareInterface; use Rekalogika\Mapper\Transformer\Contracts\MainTransformerAwareTrait; use Rekalogika\Mapper\Util\TypeFactory; diff --git a/src/MethodMapper/SubMapperInterface.php b/src/MethodMapper/SubMapperInterface.php index 53498007..0bd9f66a 100644 --- a/src/MethodMapper/SubMapperInterface.php +++ b/src/MethodMapper/SubMapperInterface.php @@ -13,7 +13,7 @@ namespace Rekalogika\Mapper\MethodMapper; -use Rekalogika\Mapper\MainTransformer\Context; +use Rekalogika\Mapper\Context\Context; interface SubMapperInterface { diff --git a/src/Transformer/ArrayToObjectTransformer.php b/src/Transformer/ArrayToObjectTransformer.php index 06fbd2ca..0d5006a4 100644 --- a/src/Transformer/ArrayToObjectTransformer.php +++ b/src/Transformer/ArrayToObjectTransformer.php @@ -14,7 +14,7 @@ namespace Rekalogika\Mapper\Transformer; use Rekalogika\Mapper\Exception\InvalidArgumentException; -use Rekalogika\Mapper\MainTransformer\Context; +use Rekalogika\Mapper\Context\Context; use Rekalogika\Mapper\Transformer\Contracts\TransformerInterface; use Rekalogika\Mapper\Transformer\Contracts\TypeMapping; use Rekalogika\Mapper\Transformer\Exception\InvalidTypeInArgumentException; diff --git a/src/Transformer/Contracts/TransformerInterface.php b/src/Transformer/Contracts/TransformerInterface.php index 2c1ba407..3dd8093e 100644 --- a/src/Transformer/Contracts/TransformerInterface.php +++ b/src/Transformer/Contracts/TransformerInterface.php @@ -13,7 +13,7 @@ namespace Rekalogika\Mapper\Transformer\Contracts; -use Rekalogika\Mapper\MainTransformer\Context; +use Rekalogika\Mapper\Context\Context; use Symfony\Component\PropertyInfo\Type; interface TransformerInterface diff --git a/src/Transformer/CopyTransformer.php b/src/Transformer/CopyTransformer.php index 2c8e122c..aa0d5b4e 100644 --- a/src/Transformer/CopyTransformer.php +++ b/src/Transformer/CopyTransformer.php @@ -13,7 +13,7 @@ namespace Rekalogika\Mapper\Transformer; -use Rekalogika\Mapper\MainTransformer\Context; +use Rekalogika\Mapper\Context\Context; use Rekalogika\Mapper\Transformer\Contracts\MixedType; use Rekalogika\Mapper\Transformer\Contracts\TransformerInterface; use Rekalogika\Mapper\Transformer\Contracts\TypeMapping; diff --git a/src/Transformer/DateTimeTransformer.php b/src/Transformer/DateTimeTransformer.php index 8b089c88..0fe7ca4d 100644 --- a/src/Transformer/DateTimeTransformer.php +++ b/src/Transformer/DateTimeTransformer.php @@ -14,7 +14,7 @@ namespace Rekalogika\Mapper\Transformer; use Rekalogika\Mapper\Exception\InvalidArgumentException; -use Rekalogika\Mapper\MainTransformer\Context; +use Rekalogika\Mapper\Context\Context; use Rekalogika\Mapper\Transformer\Contracts\TransformerInterface; use Rekalogika\Mapper\Transformer\Contracts\TypeMapping; use Rekalogika\Mapper\Util\TypeCheck; diff --git a/src/Transformer/NullTransformer.php b/src/Transformer/NullTransformer.php index 090617ab..e86c7df9 100644 --- a/src/Transformer/NullTransformer.php +++ b/src/Transformer/NullTransformer.php @@ -14,7 +14,7 @@ namespace Rekalogika\Mapper\Transformer; use Rekalogika\Mapper\Exception\InvalidArgumentException; -use Rekalogika\Mapper\MainTransformer\Context; +use Rekalogika\Mapper\Context\Context; use Rekalogika\Mapper\Transformer\Contracts\TransformerInterface; use Rekalogika\Mapper\Transformer\Contracts\TypeMapping; use Rekalogika\Mapper\Util\TypeCheck; diff --git a/src/Transformer/ObjectToArrayTransformer.php b/src/Transformer/ObjectToArrayTransformer.php index 15b41e5e..df8f1ace 100644 --- a/src/Transformer/ObjectToArrayTransformer.php +++ b/src/Transformer/ObjectToArrayTransformer.php @@ -14,7 +14,7 @@ namespace Rekalogika\Mapper\Transformer; use Rekalogika\Mapper\Exception\InvalidArgumentException; -use Rekalogika\Mapper\MainTransformer\Context; +use Rekalogika\Mapper\Context\Context; use Rekalogika\Mapper\Transformer\Contracts\TransformerInterface; use Rekalogika\Mapper\Transformer\Contracts\TypeMapping; use Rekalogika\Mapper\Util\TypeFactory; diff --git a/src/Transformer/ObjectToObjectTransformer.php b/src/Transformer/ObjectToObjectTransformer.php index 3d88acc0..156b57a4 100644 --- a/src/Transformer/ObjectToObjectTransformer.php +++ b/src/Transformer/ObjectToObjectTransformer.php @@ -14,7 +14,7 @@ namespace Rekalogika\Mapper\Transformer; use Rekalogika\Mapper\Exception\InvalidArgumentException; -use Rekalogika\Mapper\MainTransformer\Context; +use Rekalogika\Mapper\Context\Context; use Rekalogika\Mapper\ObjectCache\ObjectCache; use Rekalogika\Mapper\Transformer\Contracts\MainTransformerAwareInterface; use Rekalogika\Mapper\Transformer\Contracts\MainTransformerAwareTrait; diff --git a/src/Transformer/ObjectToStringTransformer.php b/src/Transformer/ObjectToStringTransformer.php index da40c41d..eb698bd7 100644 --- a/src/Transformer/ObjectToStringTransformer.php +++ b/src/Transformer/ObjectToStringTransformer.php @@ -14,7 +14,7 @@ namespace Rekalogika\Mapper\Transformer; use Rekalogika\Mapper\Exception\InvalidArgumentException; -use Rekalogika\Mapper\MainTransformer\Context; +use Rekalogika\Mapper\Context\Context; use Rekalogika\Mapper\Transformer\Contracts\TransformerInterface; use Rekalogika\Mapper\Transformer\Contracts\TypeMapping; use Rekalogika\Mapper\Util\TypeFactory; diff --git a/src/Transformer/ScalarToScalarTransformer.php b/src/Transformer/ScalarToScalarTransformer.php index f309ea8c..f0da9203 100644 --- a/src/Transformer/ScalarToScalarTransformer.php +++ b/src/Transformer/ScalarToScalarTransformer.php @@ -14,7 +14,7 @@ namespace Rekalogika\Mapper\Transformer; use Rekalogika\Mapper\Exception\InvalidArgumentException; -use Rekalogika\Mapper\MainTransformer\Context; +use Rekalogika\Mapper\Context\Context; use Rekalogika\Mapper\Transformer\Contracts\TransformerInterface; use Rekalogika\Mapper\Transformer\Contracts\TypeMapping; use Rekalogika\Mapper\Util\TypeCheck; diff --git a/src/Transformer/StringToBackedEnumTransformer.php b/src/Transformer/StringToBackedEnumTransformer.php index 50b20960..a3db1aec 100644 --- a/src/Transformer/StringToBackedEnumTransformer.php +++ b/src/Transformer/StringToBackedEnumTransformer.php @@ -14,7 +14,7 @@ namespace Rekalogika\Mapper\Transformer; use Rekalogika\Mapper\Exception\InvalidArgumentException; -use Rekalogika\Mapper\MainTransformer\Context; +use Rekalogika\Mapper\Context\Context; use Rekalogika\Mapper\Transformer\Contracts\TransformerInterface; use Rekalogika\Mapper\Transformer\Contracts\TypeMapping; use Rekalogika\Mapper\Transformer\Exception\InvalidTypeInArgumentException; diff --git a/src/Transformer/TraversableToArrayAccessTransformer.php b/src/Transformer/TraversableToArrayAccessTransformer.php index cae63b94..d9757318 100644 --- a/src/Transformer/TraversableToArrayAccessTransformer.php +++ b/src/Transformer/TraversableToArrayAccessTransformer.php @@ -16,7 +16,7 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Rekalogika\Mapper\Exception\InvalidArgumentException; -use Rekalogika\Mapper\MainTransformer\Context; +use Rekalogika\Mapper\Context\Context; use Rekalogika\Mapper\ObjectCache\ObjectCache; use Rekalogika\Mapper\Transformer\Contracts\MainTransformerAwareInterface; use Rekalogika\Mapper\Transformer\Contracts\MainTransformerAwareTrait; diff --git a/src/Transformer/TraversableToTraversableTransformer.php b/src/Transformer/TraversableToTraversableTransformer.php index b5baff86..84762327 100644 --- a/src/Transformer/TraversableToTraversableTransformer.php +++ b/src/Transformer/TraversableToTraversableTransformer.php @@ -14,7 +14,7 @@ namespace Rekalogika\Mapper\Transformer; use Rekalogika\Mapper\Exception\InvalidArgumentException; -use Rekalogika\Mapper\MainTransformer\Context; +use Rekalogika\Mapper\Context\Context; use Rekalogika\Mapper\ObjectCache\ObjectCache; use Rekalogika\Mapper\Transformer\Contracts\MainTransformerAwareInterface; use Rekalogika\Mapper\Transformer\Contracts\MainTransformerAwareTrait; diff --git a/tests/Fixtures/MethodMapper/MoneyDto.php b/tests/Fixtures/MethodMapper/MoneyDto.php index 97ca70f3..94ff61c4 100644 --- a/tests/Fixtures/MethodMapper/MoneyDto.php +++ b/tests/Fixtures/MethodMapper/MoneyDto.php @@ -14,7 +14,7 @@ namespace Rekalogika\Mapper\Tests\Fixtures\MethodMapper; use Brick\Money\Money; -use Rekalogika\Mapper\MainTransformer\Context; +use Rekalogika\Mapper\Context\Context; use Rekalogika\Mapper\MethodMapper\MapFromObjectInterface; use Rekalogika\Mapper\MethodMapper\MapToObjectInterface; use Rekalogika\Mapper\MethodMapper\SubMapperInterface; diff --git a/tests/Fixtures/MethodMapper/ObjectWithArrayPropertyDto.php b/tests/Fixtures/MethodMapper/ObjectWithArrayPropertyDto.php index 2ea28030..ec835dce 100644 --- a/tests/Fixtures/MethodMapper/ObjectWithArrayPropertyDto.php +++ b/tests/Fixtures/MethodMapper/ObjectWithArrayPropertyDto.php @@ -13,7 +13,7 @@ namespace Rekalogika\Mapper\Tests\Fixtures\MethodMapper; -use Rekalogika\Mapper\MainTransformer\Context; +use Rekalogika\Mapper\Context\Context; use Rekalogika\Mapper\MethodMapper\MapFromObjectInterface; use Rekalogika\Mapper\MethodMapper\SubMapperInterface; use Rekalogika\Mapper\Tests\Fixtures\Scalar\ObjectWithScalarPropertiesDto; diff --git a/tests/Fixtures/MethodMapper/ObjectWithObjectWithScalarPropertiesDto.php b/tests/Fixtures/MethodMapper/ObjectWithObjectWithScalarPropertiesDto.php index ba84fa79..19e95007 100644 --- a/tests/Fixtures/MethodMapper/ObjectWithObjectWithScalarPropertiesDto.php +++ b/tests/Fixtures/MethodMapper/ObjectWithObjectWithScalarPropertiesDto.php @@ -13,7 +13,7 @@ namespace Rekalogika\Mapper\Tests\Fixtures\MethodMapper; -use Rekalogika\Mapper\MainTransformer\Context; +use Rekalogika\Mapper\Context\Context; use Rekalogika\Mapper\MethodMapper\MapFromObjectInterface; use Rekalogika\Mapper\MethodMapper\MapToObjectInterface; use Rekalogika\Mapper\MethodMapper\SubMapperInterface; diff --git a/tests/Fixtures/Transformer/MoneyToMoneyDtoTransformer.php b/tests/Fixtures/Transformer/MoneyToMoneyDtoTransformer.php index 360d38d4..c846fa17 100644 --- a/tests/Fixtures/Transformer/MoneyToMoneyDtoTransformer.php +++ b/tests/Fixtures/Transformer/MoneyToMoneyDtoTransformer.php @@ -15,7 +15,7 @@ use Brick\Money\Money; use Rekalogika\Mapper\Exception\InvalidArgumentException; -use Rekalogika\Mapper\MainTransformer\Context; +use Rekalogika\Mapper\Context\Context; use Rekalogika\Mapper\Tests\Fixtures\Money\MoneyDto; use Rekalogika\Mapper\Transformer\Contracts\TransformerInterface; use Rekalogika\Mapper\Transformer\Contracts\TypeMapping;