diff --git a/composer.json b/composer.json index 9883403c..ae1a6027 100644 --- a/composer.json +++ b/composer.json @@ -31,8 +31,12 @@ "symfony/filesystem": "^5.4 || ^6.0 || ^7.0", "symfony/framework-bundle": "*", "symfony/http-kernel": "^5.4 || ^6.0 || ^7.0", + "symfony/property-access": "^5.4 || ^6.0 || ^7.0", "symfony/serializer": "*", + "symfony/stopwatch": "^7.0", + "symfony/twig-bundle": "^5.4 || ^6.0 || ^7.0", "symfony/uid": "^5.4 || ^6.0 || ^7.0", + "symfony/web-profiler-bundle": "^5.4 || ^6.0 || ^7.0", "symfony/yaml": "^5.4 || ^6.0 || ^7.0" }, "suggest": { diff --git a/src/AutoMapper.php b/src/AutoMapper.php index 4eb045fe..d30bfb9a 100644 --- a/src/AutoMapper.php +++ b/src/AutoMapper.php @@ -86,15 +86,6 @@ public function getMapper(string $source, string $target): MapperInterface return $this->mapperRegistry[$className]; } - /** - * @template Source of object - * @template Target of object - * - * @param Source|array $source - * @param class-string|'array'|array|Target $target - * - * @return ($target is class-string|Target ? Target|null : array|null) - */ public function map(array|object $source, string|array|object $target, array $context = []): array|object|null { $sourceType = $targetType = null; diff --git a/src/AutoMapperInterface.php b/src/AutoMapperInterface.php index dec19bb5..f8e05f76 100644 --- a/src/AutoMapperInterface.php +++ b/src/AutoMapperInterface.php @@ -12,13 +12,14 @@ interface AutoMapperInterface { /** - * Maps data from a source to a target. + * @template Source of object + * @template Target of object * - * @param array|object $source Any data object, which may be an object or an array - * @param 'array'|class-string|array|object $target To which type of data, or data, the source should be mapped - * @param array $context Mapper context + * @param Source|array $source + * @param class-string|'array'|array|Target $target + * @param array $context * - * @return array|object|null The mapped object + * @return ($target is class-string|Target ? Target|null : array|null) */ public function map(array|object $source, string|array|object $target, array $context = []): array|object|null; } diff --git a/src/Normalizer/AutoMapperNormalizer.php b/src/Normalizer/AutoMapperNormalizer.php index a97729a3..2b064a6b 100644 --- a/src/Normalizer/AutoMapperNormalizer.php +++ b/src/Normalizer/AutoMapperNormalizer.php @@ -39,6 +39,13 @@ public function normalize(mixed $object, string $format = null, array $context = return $this->autoMapper->map($object, 'array', $this->createAutoMapperContext($context)); } + /** + * @template T of object + * + * @param class-string $type + * + * @return T|null + */ public function denormalize(mixed $data, string $type, string $format = null, array $context = []): mixed { return $this->autoMapper->map($data, $type, $this->createAutoMapperContext($context)); diff --git a/tests/Bundle/Resources/App/AppKernel.php b/tests/Bundle/Resources/App/AppKernel.php index 96489294..44ddd041 100644 --- a/tests/Bundle/Resources/App/AppKernel.php +++ b/tests/Bundle/Resources/App/AppKernel.php @@ -4,32 +4,13 @@ namespace AutoMapper\Tests\Bundle\Resources\App; -use AutoMapper\Symfony\Bundle\AutoMapperBundle; -use Symfony\Bundle\FrameworkBundle\FrameworkBundle; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; -use Symfony\Component\Config\Loader\LoaderInterface; -use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Kernel; class AppKernel extends Kernel { use MicroKernelTrait; - public function registerBundles(): array - { - $bundles = [ - new FrameworkBundle(), - new AutoMapperBundle(), - ]; - - return $bundles; - } - - protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void - { - $loader->load(__DIR__ . '/config.yml'); - } - public function getProjectDir(): string { return __DIR__ . '/..'; diff --git a/tests/Bundle/Resources/App/Controller/HomeController.php b/tests/Bundle/Resources/App/Controller/HomeController.php new file mode 100644 index 00000000..9bd9a06d --- /dev/null +++ b/tests/Bundle/Resources/App/Controller/HomeController.php @@ -0,0 +1,42 @@ +query->has('serializer')) { + $output[] = $this->serializer->normalize($data, 'json'); + } else { + $output[] = $this->autoMapper->map($data, 'array'); + } + } + + return new JsonResponse($output); + } +} diff --git a/tests/Bundle/Fixtures/Address.php b/tests/Bundle/Resources/App/Entity/Address.php similarity index 78% rename from tests/Bundle/Fixtures/Address.php rename to tests/Bundle/Resources/App/Entity/Address.php index a2757ec5..63038d4e 100644 --- a/tests/Bundle/Fixtures/Address.php +++ b/tests/Bundle/Resources/App/Entity/Address.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace AutoMapper\Tests\Bundle\Fixtures; +namespace AutoMapper\Tests\Bundle\Resources\App\Entity; class Address { diff --git a/tests/Bundle/Fixtures/AddressDTO.php b/tests/Bundle/Resources/App/Entity/AddressDTO.php similarity index 66% rename from tests/Bundle/Fixtures/AddressDTO.php rename to tests/Bundle/Resources/App/Entity/AddressDTO.php index ba5afda3..26922fee 100644 --- a/tests/Bundle/Fixtures/AddressDTO.php +++ b/tests/Bundle/Resources/App/Entity/AddressDTO.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace AutoMapper\Tests\Bundle\Fixtures; +namespace AutoMapper\Tests\Bundle\Resources\App\Entity; class AddressDTO { diff --git a/tests/Bundle/Fixtures/BaseUser.php b/tests/Bundle/Resources/App/Entity/BaseUser.php similarity index 95% rename from tests/Bundle/Fixtures/BaseUser.php rename to tests/Bundle/Resources/App/Entity/BaseUser.php index 7eddbcaf..b80d8660 100644 --- a/tests/Bundle/Fixtures/BaseUser.php +++ b/tests/Bundle/Resources/App/Entity/BaseUser.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace AutoMapper\Tests\Bundle\Fixtures; +namespace AutoMapper\Tests\Bundle\Resources\App\Entity; class BaseUser { diff --git a/tests/Bundle/Fixtures/Cat.php b/tests/Bundle/Resources/App/Entity/Cat.php similarity index 51% rename from tests/Bundle/Fixtures/Cat.php rename to tests/Bundle/Resources/App/Entity/Cat.php index e2a464f5..8df49948 100644 --- a/tests/Bundle/Fixtures/Cat.php +++ b/tests/Bundle/Resources/App/Entity/Cat.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace AutoMapper\Tests\Bundle\Fixtures; +namespace AutoMapper\Tests\Bundle\Resources\App\Entity; class Cat extends Pet { diff --git a/tests/Bundle/Fixtures/ClassWithMapToContextAttribute.php b/tests/Bundle/Resources/App/Entity/ClassWithMapToContextAttribute.php similarity index 93% rename from tests/Bundle/Fixtures/ClassWithMapToContextAttribute.php rename to tests/Bundle/Resources/App/Entity/ClassWithMapToContextAttribute.php index d62970fa..873610d1 100644 --- a/tests/Bundle/Fixtures/ClassWithMapToContextAttribute.php +++ b/tests/Bundle/Resources/App/Entity/ClassWithMapToContextAttribute.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace AutoMapper\Tests\Bundle\Fixtures; +namespace AutoMapper\Tests\Bundle\Resources\App\Entity; use AutoMapper\Attribute\MapToContext; diff --git a/tests/Bundle/Fixtures/ClassWithPrivateProperty.php b/tests/Bundle/Resources/App/Entity/ClassWithPrivateProperty.php similarity index 79% rename from tests/Bundle/Fixtures/ClassWithPrivateProperty.php rename to tests/Bundle/Resources/App/Entity/ClassWithPrivateProperty.php index 43ddb4c9..57bd7266 100644 --- a/tests/Bundle/Fixtures/ClassWithPrivateProperty.php +++ b/tests/Bundle/Resources/App/Entity/ClassWithPrivateProperty.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace AutoMapper\Tests\Bundle\Fixtures; +namespace AutoMapper\Tests\Bundle\Resources\App\Entity; class ClassWithPrivateProperty { diff --git a/tests/Bundle/Fixtures/DTOWithEnum.php b/tests/Bundle/Resources/App/Entity/DTOWithEnum.php similarity index 67% rename from tests/Bundle/Fixtures/DTOWithEnum.php rename to tests/Bundle/Resources/App/Entity/DTOWithEnum.php index a1ba3298..43d2abf8 100644 --- a/tests/Bundle/Fixtures/DTOWithEnum.php +++ b/tests/Bundle/Resources/App/Entity/DTOWithEnum.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace AutoMapper\Tests\Bundle\Fixtures; +namespace AutoMapper\Tests\Bundle\Resources\App\Entity; final class DTOWithEnum { diff --git a/tests/Bundle/Fixtures/Dog.php b/tests/Bundle/Resources/App/Entity/Dog.php similarity index 51% rename from tests/Bundle/Fixtures/Dog.php rename to tests/Bundle/Resources/App/Entity/Dog.php index 75e91ecc..328ae353 100644 --- a/tests/Bundle/Fixtures/Dog.php +++ b/tests/Bundle/Resources/App/Entity/Dog.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace AutoMapper\Tests\Bundle\Fixtures; +namespace AutoMapper\Tests\Bundle\Resources\App\Entity; class Dog extends Pet { diff --git a/tests/Bundle/Fixtures/FooMapTo.php b/tests/Bundle/Resources/App/Entity/FooMapTo.php similarity index 97% rename from tests/Bundle/Fixtures/FooMapTo.php rename to tests/Bundle/Resources/App/Entity/FooMapTo.php index 746e4972..2482ac8e 100644 --- a/tests/Bundle/Fixtures/FooMapTo.php +++ b/tests/Bundle/Resources/App/Entity/FooMapTo.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace AutoMapper\Tests\Bundle\Fixtures; +namespace AutoMapper\Tests\Bundle\Resources\App\Entity; use AutoMapper\Attribute\MapTo; use AutoMapper\Tests\Fixtures\MapTo\Bar; diff --git a/tests/Bundle/Fixtures/NestedObject.php b/tests/Bundle/Resources/App/Entity/NestedObject.php similarity index 58% rename from tests/Bundle/Fixtures/NestedObject.php rename to tests/Bundle/Resources/App/Entity/NestedObject.php index fa9ce44b..ddcd414c 100644 --- a/tests/Bundle/Fixtures/NestedObject.php +++ b/tests/Bundle/Resources/App/Entity/NestedObject.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace AutoMapper\Tests\Bundle\Fixtures; +namespace AutoMapper\Tests\Bundle\Resources\App\Entity; class NestedObject { diff --git a/tests/Bundle/Fixtures/Order.php b/tests/Bundle/Resources/App/Entity/Order.php similarity index 72% rename from tests/Bundle/Fixtures/Order.php rename to tests/Bundle/Resources/App/Entity/Order.php index 0b12de0a..b64a12a2 100644 --- a/tests/Bundle/Fixtures/Order.php +++ b/tests/Bundle/Resources/App/Entity/Order.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace AutoMapper\Tests\Bundle\Fixtures; +namespace AutoMapper\Tests\Bundle\Resources\App\Entity; use Money\Money; diff --git a/tests/Bundle/Fixtures/Pet.php b/tests/Bundle/Resources/App/Entity/Pet.php similarity index 83% rename from tests/Bundle/Fixtures/Pet.php rename to tests/Bundle/Resources/App/Entity/Pet.php index a139ba1c..d5f076b8 100644 --- a/tests/Bundle/Fixtures/Pet.php +++ b/tests/Bundle/Resources/App/Entity/Pet.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace AutoMapper\Tests\Bundle\Fixtures; +namespace AutoMapper\Tests\Bundle\Resources\App\Entity; use Symfony\Component\Serializer\Annotation\DiscriminatorMap; diff --git a/tests/Bundle/Fixtures/SomeEnum.php b/tests/Bundle/Resources/App/Entity/SomeEnum.php similarity index 59% rename from tests/Bundle/Fixtures/SomeEnum.php rename to tests/Bundle/Resources/App/Entity/SomeEnum.php index 96bc97a2..a4276bea 100644 --- a/tests/Bundle/Fixtures/SomeEnum.php +++ b/tests/Bundle/Resources/App/Entity/SomeEnum.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace AutoMapper\Tests\Bundle\Fixtures; +namespace AutoMapper\Tests\Bundle\Resources\App\Entity; enum SomeEnum: string { diff --git a/tests/Bundle/Fixtures/User.php b/tests/Bundle/Resources/App/Entity/User.php similarity index 77% rename from tests/Bundle/Fixtures/User.php rename to tests/Bundle/Resources/App/Entity/User.php index db2f5a9e..4f94472b 100644 --- a/tests/Bundle/Fixtures/User.php +++ b/tests/Bundle/Resources/App/Entity/User.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace AutoMapper\Tests\Bundle\Fixtures; +namespace AutoMapper\Tests\Bundle\Resources\App\Entity; class User extends BaseUser { diff --git a/tests/Bundle/Fixtures/UserDTO.php b/tests/Bundle/Resources/App/Entity/UserDTO.php similarity index 93% rename from tests/Bundle/Fixtures/UserDTO.php rename to tests/Bundle/Resources/App/Entity/UserDTO.php index 18c58829..50a903c0 100644 --- a/tests/Bundle/Fixtures/UserDTO.php +++ b/tests/Bundle/Resources/App/Entity/UserDTO.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace AutoMapper\Tests\Bundle\Fixtures; +namespace AutoMapper\Tests\Bundle\Resources\App\Entity; class UserDTO { diff --git a/tests/Bundle/Resources/App/Service/YearOfBirthTransformer.php b/tests/Bundle/Resources/App/Service/YearOfBirthTransformer.php index aabe916a..8a6cf511 100644 --- a/tests/Bundle/Resources/App/Service/YearOfBirthTransformer.php +++ b/tests/Bundle/Resources/App/Service/YearOfBirthTransformer.php @@ -8,8 +8,8 @@ use AutoMapper\Metadata\SourcePropertyMetadata; use AutoMapper\Metadata\TargetPropertyMetadata; use AutoMapper\Metadata\TypesMatching; -use AutoMapper\Tests\Bundle\Fixtures\User; -use AutoMapper\Tests\Bundle\Fixtures\UserDTO; +use AutoMapper\Tests\Bundle\Resources\App\Entity\User; +use AutoMapper\Tests\Bundle\Resources\App\Entity\UserDTO; use AutoMapper\Transformer\PropertyTransformer\PropertyTransformerInterface; use AutoMapper\Transformer\PropertyTransformer\PropertyTransformerSupportInterface; diff --git a/tests/Bundle/Resources/App/config.yml b/tests/Bundle/Resources/App/config.yml deleted file mode 100644 index 514f52e8..00000000 --- a/tests/Bundle/Resources/App/config.yml +++ /dev/null @@ -1,22 +0,0 @@ -framework: - secret: jane-automapper - property_info: ~ - test: ~ - -automapper: - normalizer: true - name_converter: AutoMapper\Tests\Bundle\Resources\App\Service\IdNameConverter - map_private_properties: true - warmup: - - { source: 'AutoMapper\Tests\Bundle\Fixtures\NestedObject', target: 'array' } - -services: - _defaults: - autoconfigure: true - autowire: true - - AutoMapper\Tests\Bundle\Resources\App\Service\FooService: ~ - AutoMapper\Tests\Bundle\Resources\App\Service\YearOfBirthTransformer: ~ - dummy_app.year_of_birth_transformer: - class: AutoMapper\Tests\Bundle\Resources\App\Service\YearOfBirthTransformer - AutoMapper\Tests\Bundle\Resources\App\Service\IdNameConverter: ~ diff --git a/tests/Bundle/Resources/config/bundles.php b/tests/Bundle/Resources/config/bundles.php new file mode 100644 index 00000000..62f3575f --- /dev/null +++ b/tests/Bundle/Resources/config/bundles.php @@ -0,0 +1,10 @@ + ['all' => true], + Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], + AutoMapper\Symfony\Bundle\AutoMapperBundle::class => ['all' => true], + Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true], +]; diff --git a/tests/Bundle/Resources/config/packages/automapper.yaml b/tests/Bundle/Resources/config/packages/automapper.yaml new file mode 100644 index 00000000..9a637de6 --- /dev/null +++ b/tests/Bundle/Resources/config/packages/automapper.yaml @@ -0,0 +1,7 @@ +automapper: + normalizer: false + name_converter: AutoMapper\Tests\Bundle\Resources\App\Service\IdNameConverter + map_private_properties: false + check_attributes: false + warmup: + - { source: 'AutoMapper\Tests\Bundle\Resources\App\Entity\NestedObject', target: 'array' } \ No newline at end of file diff --git a/tests/Bundle/Resources/config/packages/framework.yaml b/tests/Bundle/Resources/config/packages/framework.yaml new file mode 100644 index 00000000..9cef6b9d --- /dev/null +++ b/tests/Bundle/Resources/config/packages/framework.yaml @@ -0,0 +1,13 @@ +framework: + secret: automapper + property_info: ~ + test: ~ + serializer: + enabled: true + profiler: + only_exceptions: false + collect_serializer_data: true + +web_profiler: + toolbar: true + intercept_redirects: false diff --git a/tests/Bundle/Resources/config/routes.yaml b/tests/Bundle/Resources/config/routes.yaml new file mode 100644 index 00000000..f02091cd --- /dev/null +++ b/tests/Bundle/Resources/config/routes.yaml @@ -0,0 +1,13 @@ +controllers: + resource: + path: ../App/Controller/ + namespace: AutoMapper\Tests\Bundle\Resources\App\Controller + type: attribute + +web_profiler_wdt: + resource: '@WebProfilerBundle/Resources/config/routing/wdt.xml' + prefix: /_wdt + +web_profiler_profiler: + resource: '@WebProfilerBundle/Resources/config/routing/profiler.xml' + prefix: /_profiler diff --git a/tests/Bundle/Resources/config/services.yaml b/tests/Bundle/Resources/config/services.yaml new file mode 100644 index 00000000..dc277e73 --- /dev/null +++ b/tests/Bundle/Resources/config/services.yaml @@ -0,0 +1,8 @@ +services: + _defaults: + autoconfigure: true + autowire: true + + AutoMapper\Tests\Bundle\Resources\App\: + resource: '../App/*' + exclude: '../App/{Entity,AppKernel.php}' diff --git a/tests/Bundle/Resources/public/index.php b/tests/Bundle/Resources/public/index.php new file mode 100644 index 00000000..bc4a01ff --- /dev/null +++ b/tests/Bundle/Resources/public/index.php @@ -0,0 +1,16 @@ +handle($request); +$response->send(); +$kernel->terminate($request, $response); diff --git a/tests/Bundle/ServiceInstantiationTest.php b/tests/Bundle/ServiceInstantiationTest.php index 6aeab1a3..d148d840 100644 --- a/tests/Bundle/ServiceInstantiationTest.php +++ b/tests/Bundle/ServiceInstantiationTest.php @@ -6,14 +6,14 @@ use AutoMapper\AutoMapperInterface; use AutoMapper\MapperContext; -use AutoMapper\Tests\Bundle\Fixtures\AddressDTO; -use AutoMapper\Tests\Bundle\Fixtures\ClassWithMapToContextAttribute; -use AutoMapper\Tests\Bundle\Fixtures\ClassWithPrivateProperty; -use AutoMapper\Tests\Bundle\Fixtures\DTOWithEnum; -use AutoMapper\Tests\Bundle\Fixtures\FooMapTo; -use AutoMapper\Tests\Bundle\Fixtures\SomeEnum; -use AutoMapper\Tests\Bundle\Fixtures\User; -use AutoMapper\Tests\Bundle\Fixtures\UserDTO; +use AutoMapper\Tests\Bundle\Resources\App\Entity\AddressDTO; +use AutoMapper\Tests\Bundle\Resources\App\Entity\ClassWithMapToContextAttribute; +use AutoMapper\Tests\Bundle\Resources\App\Entity\ClassWithPrivateProperty; +use AutoMapper\Tests\Bundle\Resources\App\Entity\DTOWithEnum; +use AutoMapper\Tests\Bundle\Resources\App\Entity\FooMapTo; +use AutoMapper\Tests\Bundle\Resources\App\Entity\SomeEnum; +use AutoMapper\Tests\Bundle\Resources\App\Entity\User; +use AutoMapper\Tests\Bundle\Resources\App\Entity\UserDTO; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\Filesystem\Filesystem; @@ -24,6 +24,7 @@ protected function setUp(): void static::$class = null; $_SERVER['KERNEL_DIR'] = __DIR__ . '/Resources/App'; $_SERVER['KERNEL_CLASS'] = 'AutoMapper\Tests\Bundle\Resources\App\AppKernel'; + $_SERVER['APP_DEBUG'] = false; (new Filesystem())->remove(__DIR__ . '/Resources/var/cache/test'); } @@ -37,13 +38,13 @@ public function testWarmup(): void { static::bootKernel(); - self::assertFileExists(__DIR__ . '/Resources/var/cache/test/automapper/Symfony_Mapper_AutoMapper_Tests_Bundle_Fixtures_NestedObject_array.php'); - self::assertFileExists(__DIR__ . '/Resources/var/cache/test/automapper/Symfony_Mapper_AutoMapper_Tests_Bundle_Fixtures_User_array.php'); - self::assertFileExists(__DIR__ . '/Resources/var/cache/test/automapper/Symfony_Mapper_AutoMapper_Tests_Bundle_Fixtures_AddressDTO_array.php'); + self::assertFileExists(__DIR__ . '/Resources/var/cache/test/automapper/Symfony_Mapper_AutoMapper_Tests_Bundle_Resources_App_Entity_NestedObject_array.php'); + self::assertFileExists(__DIR__ . '/Resources/var/cache/test/automapper/Symfony_Mapper_AutoMapper_Tests_Bundle_Resources_App_Entity_User_array.php'); + self::assertFileExists(__DIR__ . '/Resources/var/cache/test/automapper/Symfony_Mapper_AutoMapper_Tests_Bundle_Resources_App_Entity_AddressDTO_array.php'); - self::assertInstanceOf(\Symfony_Mapper_AutoMapper_Tests_Bundle_Fixtures_NestedObject_array::class, new \Symfony_Mapper_AutoMapper_Tests_Bundle_Fixtures_NestedObject_array()); - self::assertInstanceOf(\Symfony_Mapper_AutoMapper_Tests_Bundle_Fixtures_User_array::class, new \Symfony_Mapper_AutoMapper_Tests_Bundle_Fixtures_User_array()); - self::assertInstanceOf(\Symfony_Mapper_AutoMapper_Tests_Bundle_Fixtures_AddressDTO_array::class, new \Symfony_Mapper_AutoMapper_Tests_Bundle_Fixtures_AddressDTO_array()); + self::assertInstanceOf(\Symfony_Mapper_AutoMapper_Tests_Bundle_Resources_App_Entity_NestedObject_array::class, new \Symfony_Mapper_AutoMapper_Tests_Bundle_Resources_App_Entity_NestedObject_array()); + self::assertInstanceOf(\Symfony_Mapper_AutoMapper_Tests_Bundle_Resources_App_Entity_User_array::class, new \Symfony_Mapper_AutoMapper_Tests_Bundle_Resources_App_Entity_User_array()); + self::assertInstanceOf(\Symfony_Mapper_AutoMapper_Tests_Bundle_Resources_App_Entity_AddressDTO_array::class, new \Symfony_Mapper_AutoMapper_Tests_Bundle_Resources_App_Entity_AddressDTO_array()); } public function testAutoMapper(): void @@ -93,8 +94,8 @@ public function testDiscriminator(): void 'type' => 'cat', ]; - $pet = $autoMapper->map($data, Fixtures\Pet::class); - self::assertInstanceOf(Fixtures\Cat::class, $pet); + $pet = $autoMapper->map($data, Resources\App\Entity\Pet::class); + self::assertInstanceOf(Resources\App\Entity\Cat::class, $pet); } public function testItCanMapEnums(): void diff --git a/tools/php-cs-fixer/.php-cs-fixer.php b/tools/php-cs-fixer/.php-cs-fixer.php index fcce3f37..bbc9f7be 100644 --- a/tools/php-cs-fixer/.php-cs-fixer.php +++ b/tools/php-cs-fixer/.php-cs-fixer.php @@ -1,10 +1,9 @@ exclude(__DIR__ . '/../../tests/cache') - ->exclude(__DIR__ . '/../../tests/Bundle/Resources/var') ->in(__DIR__ . '/../../src') ->in(__DIR__ . '/../../tests') + ->exclude(['cache', 'Bundle/Resources/var']) ; return (new PhpCsFixer\Config()) diff --git a/tools/phpstan/phpstan-baseline.neon b/tools/phpstan/phpstan-baseline.neon index 0ef11d8e..dbc9a1a9 100644 --- a/tools/phpstan/phpstan-baseline.neon +++ b/tools/phpstan/phpstan-baseline.neon @@ -1,35 +1,11 @@ parameters: ignoreErrors: - - - message: "#^Method AutoMapper\\\\AutoMapper\\:\\:map\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: ../../src/AutoMapper.php - message: "#^Parameter \\#1 \\$loader of class Symfony\\\\Component\\\\Serializer\\\\Mapping\\\\Factory\\\\ClassMetadataFactory constructor expects Symfony\\\\Component\\\\Serializer\\\\Mapping\\\\Loader\\\\LoaderInterface, Symfony\\\\Component\\\\Serializer\\\\Mapping\\\\Loader\\\\AnnotationLoader\\|Symfony\\\\Component\\\\Serializer\\\\Mapping\\\\Loader\\\\AttributeLoader given\\.$#" count: 1 path: ../../src/AutoMapper.php - - - message: "#^Method AutoMapper\\\\AutoMapperInterface\\:\\:map\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: ../../src/AutoMapperInterface.php - - - - message: "#^Method AutoMapper\\\\AutoMapperInterface\\:\\:map\\(\\) has parameter \\$source with no value type specified in iterable type array\\.$#" - count: 1 - path: ../../src/AutoMapperInterface.php - - - - message: "#^Method AutoMapper\\\\AutoMapperInterface\\:\\:map\\(\\) has parameter \\$target with no value type specified in iterable type array\\.$#" - count: 1 - path: ../../src/AutoMapperInterface.php - - - - message: "#^Method AutoMapper\\\\AutoMapperInterface\\:\\:map\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: ../../src/AutoMapperInterface.php - - message: "#^Property AutoMapper\\\\GeneratedMapper\\:\\:\\$cachedTarget has no type specified\\.$#" count: 1 @@ -250,11 +226,6 @@ parameters: count: 1 path: ../../src/Normalizer/AutoMapperNormalizer.php - - - message: "#^Method AutoMapper\\\\Normalizer\\\\AutoMapperNormalizer\\:\\:normalize\\(\\) should return array\\|ArrayObject\\|bool\\|float\\|int\\|string\\|null but returns array\\|object\\|null\\.$#" - count: 1 - path: ../../src/Normalizer/AutoMapperNormalizer.php - - message: "#^Method AutoMapper\\\\Normalizer\\\\AutoMapperNormalizer\\:\\:supportsDenormalization\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" count: 1 @@ -270,11 +241,6 @@ parameters: count: 2 path: ../../src/Normalizer/AutoMapperNormalizer.php - - - message: "#^Parameter \\#2 \\$target of method AutoMapper\\\\AutoMapperInterface\\:\\:map\\(\\) expects 'array'\\|array\\|class\\-string\\|object, string given\\.$#" - count: 1 - path: ../../src/Normalizer/AutoMapperNormalizer.php - - message: "#^Parameter \\#1 \\$expr of class PhpParser\\\\Node\\\\Stmt\\\\Expression constructor expects PhpParser\\\\Node\\\\Expr, PhpParser\\\\Node\\\\Expr\\|null given\\.$#" count: 1