Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[AutoMapper] New component to automatically map a source object to a target object #30248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
b5592ee
Initial commit and implementation of symfony/automapper
joelwurtz Feb 14, 2019
936bc2f
Add normalizer bridge
joelwurtz Feb 14, 2019
2ea1951
Add missing licence
joelwurtz Feb 14, 2019
d272d9c
Fix typo in interface
joelwurtz Feb 14, 2019
beb0f49
Add attribute checking option
joelwurtz Feb 15, 2019
e4c1385
Allow attribute checking to be set in factory
joelwurtz Feb 15, 2019
cf1fdf2
Add empty test classes
joelwurtz Feb 15, 2019
fc1d87d
Add automapper tests
joelwurtz Feb 19, 2019
bd387f5
Apply suggestions from @dunglas code review
dunglas Mar 25, 2019
20b7735
Add expiremental annotation where needed, add final to class that sho…
joelwurtz Mar 25, 2019
12e5d1f
Fix cs and typo
joelwurtz Mar 25, 2019
26e0c8a
Avoid too many function calls
joelwurtz Mar 25, 2019
678537a
Add interface for generator metadatas
joelwurtz Mar 25, 2019
ceeeaf1
Use array for context and provide helper class
joelwurtz Mar 26, 2019
ec97f74
Use new context construction in normalizer bridge
joelwurtz Mar 26, 2019
92784b1
Fix test case class test
joelwurtz Mar 26, 2019
eb6f638
Remove useless class
joelwurtz Mar 26, 2019
fab7135
expiremental > expiremental in 4.3
joelwurtz Mar 26, 2019
5154440
Fixing tests
Korbeil Dec 31, 2019
c688855
Added AutoMapperNormalizerTest
Korbeil Jan 3, 2020
9f16b43
Context tests
Korbeil Jan 5, 2020
ed00ec3
Add MapperGeneratorMetadataFactory tests
Korbeil Jan 5, 2020
ab82b9f
Add FromSourceMappingExtractor tests
Korbeil Jan 5, 2020
ee908a6
Add FromTargetMappingExtractor tests
Korbeil Jan 5, 2020
cd2d414
WIP PrivateReflectionExtractor tests
Korbeil Jan 6, 2020
cd85e2d
Remove internal for generated mapper
joelwurtz Jan 31, 2020
f74e22e
Fix context rebase
joelwurtz Jan 31, 2020
ee671dd
Add missing deps in dev
joelwurtz Jan 31, 2020
78ef805
Use property read / write info extractor
joelwurtz Jan 31, 2020
1e4bd5e
Fix cs
joelwurtz Jan 31, 2020
20a37df
Add tests and date time mutable / immutable transformations
joelwurtz Feb 2, 2020
af1fdf2
Fix header, expiremental in 5.1
joelwurtz Feb 2, 2020
c07edd2
Fix php version
joelwurtz Feb 2, 2020
ad190a2
Fix createFromImmutable not available in php 7.2
joelwurtz Feb 2, 2020
9c3cb23
Fix test
joelwurtz Feb 2, 2020
fecf949
Better conditions on automapper
joelwurtz Feb 3, 2020
ad0f487
Remove bad deps on rebase
joelwurtz Feb 3, 2020
5ba8171
Fix class exists
joelwurtz Feb 3, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply suggestions from @dunglas code review
Co-Authored-By: joelwurtz <jwurtz@jolicode.com>
  • Loading branch information
dunglas and joelwurtz committed Jun 20, 2020
commit bd387f58167647a65a1a8c68a30b2e3a2c4b02db
6 changes: 3 additions & 3 deletions 6 src/Symfony/Component/AutoMapper/AutoMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@
use Symfony\Component\Serializer\NameConverter\AdvancedNameConverterInterface;

/**
* An auto mapper has the role of mapping a source to a target.
* Maps a source data structure (object or array) to a target one.
*
* @author Joel Wurtz <jwurtz@jolicode.com>
*/
class AutoMapper implements AutoMapperInterface, AutoMapperRegistryInterface, MapperGeneratorMetadataRegistryInterface
final class AutoMapper implements AutoMapperInterface, AutoMapperRegistryInterface, MapperGeneratorMetadataRegistryInterface
{
private $metadatas = [];
joelwurtz marked this conversation as resolved.
Show resolved Hide resolved

Expand Down Expand Up @@ -168,7 +168,7 @@ public function map($sourceData, $targetData, Context $context = null)
*/
public function getMetadata(string $source, string $target): ?MapperGeneratorMetadataInterface
{
if (!\array_key_exists($source, $this->metadatas) || !\array_key_exists($target, $this->metadatas[$source])) {
if (!isset($this->metadatas[$source][$target])) {
if (null === $this->mapperConfigurationFactory) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion 2 src/Symfony/Component/AutoMapper/AutoMapperInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
interface AutoMapperInterface
{
/**
* Map data from a source to a target.
* Maps data from a source to a target.
*
* @param array|object $source Any data object, which may be an object or an array
* @param string|array|object $target To which type of data, or data, the source should be mapped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Symfony\Component\AutoMapper;

/**
* Allow to retrieve mapper.
* Allows to retrieve a mapper.
*
* @internal
*
Expand All @@ -21,7 +21,7 @@
interface AutoMapperRegistryInterface
{
/**
* Get a specific mapper for a source type and a target type.
* Gets a specific mapper for a source type and a target type.
*
* @param string $source Source type
* @param string $target Target type
Expand Down
2 changes: 1 addition & 1 deletion 2 src/Symfony/Component/AutoMapper/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/**
* Context for mapping.
*
* Allow to customize how is done the mapping
* Allows to customize how is done the mapping
*
* @author Joel Wurtz <jwurtz@jolicode.com>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Symfony\Component\AutoMapper\Extractor;

/**
* Extract accessor and mutator.
* Extracts accessor and mutator.
*
* @internal
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected function getGroups($class, $property): ?array
$groups = [];

foreach ($serializerClassMetadata->getAttributesMetadata() as $serializerAttributeMetadata) {
if (\count($serializerAttributeMetadata->getGroups()) > 0) {
if ($serializerAttributeMetadata->getGroups()) {
$anyGroupFound = true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Symfony\Component\AutoMapper\MapperMetadataInterface;

/**
* Extract mapping.
* Extracts mapping.
*
* @internal
*
Expand All @@ -23,19 +23,19 @@
interface MappingExtractorInterface
{
/**
* Extract properties mapped for a given source and target.
* Extracts properties mapped for a given source and target.
*
* @return PropertyMapping[]
*/
public function getPropertiesMapping(MapperMetadataInterface $mapperMetadata): array;

/**
* Extract read accessor for a given source, target and property.
* Extracts read accessor for a given source, target and property.
*/
public function getReadAccessor(string $source, string $target, string $property): ?ReadAccessor;

/**
* Extract write mutator for a given source, target and property.
* Extracts write mutator for a given source, target and property.
*/
public function getWriteMutator(string $source, string $target, string $property): ?WriteMutator;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Symfony\Component\AutoMapper\Extractor;
joelwurtz marked this conversation as resolved.
Show resolved Hide resolved

/**
* Extract accessor and mutator from reflection.
* Extracts accessor and mutator from reflection.
*
* @author Joel Wurtz <jwurtz@jolicode.com>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Symfony\Component\AutoMapper\MapperMetadataInterface;

/**
* Extract mapping between two objects, only give properties that have the same name.
* Extracts mapping between two objects, only gives properties that have the same name.
*
* @author Joel Wurtz <jwurtz@jolicode.com>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use Symfony\Component\AutoMapper\Exception\CompileException;

/**
* Write mutator tell how to write to a property.
* Writes mutator tell how to write to a property.
*
* @author Joel Wurtz <jwurtz@jolicode.com>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
namespace Symfony\Component\AutoMapper\Extractor;

/**
* Extract write mutator for property of a class.
* Extracts write mutator for property of a class.
*
* @internal
*
* @author Joel Wurtz <jwurtz@jolicode.com>
*/
interface WriteMutatorExtractorInterface
{
public function getWriteMutator(string $class, string $property, bool $allowConstruct = true): ?WriteMutator;
public function getWriteMutator(string $class, string $property, bool $allowConstructor = true): ?WriteMutator;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Symfony\Component\AutoMapper\Generator;

/**
* Allow to get a unique variable name for a scope (like a method).
* Allows to get a unique variable name for a scope (like a method).
*
* @internal
*
Expand Down
2 changes: 1 addition & 1 deletion 2 src/Symfony/Component/AutoMapper/LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2004-2019 Fabien Potencier
Copyright (c) 2019 Fabien Potencier

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Symfony\Component\AutoMapper\MapperGeneratorMetadataInterface;

/**
* Load (require) a mapping given metadata.
* Loads (require) a mapping given metadata.
*/
interface ClassLoaderInterface
{
Expand Down
2 changes: 1 addition & 1 deletion 2 src/Symfony/Component/AutoMapper/Loader/EvalLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use Symfony\Component\AutoMapper\MapperGeneratorMetadataInterface;

/**
* Use a generator and eval to requiring mapping of a class.
* Uses a generator and eval to requiring mapping of a class.
*/
class EvalLoader implements ClassLoaderInterface
{
Expand Down
2 changes: 1 addition & 1 deletion 2 src/Symfony/Component/AutoMapper/MapperMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function hasConstructor(): bool
}
}

if (0 === \count($mandatoryParameters)) {
if (!$mandatoryParameters) {
return true;
}

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.