-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Recursive denormalize using PropertyInfo #16143
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
Recursive denormalize using PropertyInfo #16143
Conversation
* 2.8: fix test for not configured form action attribute do not render empty form action attributes deprecated lifetime profiler option
* 2.8: [Form] made the tests compatible with 3.0
…pot) This PR was merged into the 3.0-dev branch. Discussion ---------- [HttpKernel] removed deprecated profiler storages | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Commits ------- 2925df5 [HttpKernel] removed deprecated profiler storages
…argument (fabpot) This PR was merged into the 3.0-dev branch. Discussion ---------- [HttpFoundation] removed the ParameterBag::get() deep argument | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Commits ------- 317f7b4 [HttpFoundation] removed the ParameterBag::get() deep argument
* 2.8: [Security] made tests work for 2.8 and 3.0
* 2.8: Use PHPUnit 5.0 for PHP 7 [DomCrawler] always pass base href to subcrawlers
* 2.8: fixed typo
* 2.8: Fix merge Fix appveyor.yml missing ANSICON env var [appveyor] merge test matrix in a single job [travis] Skip testing intermediate PHP versions on pull requests Conflicts: .travis.yml appveyor.yml
…uterJ) This PR was squashed before being merged into the 3.0-dev branch (closes #15904). Discussion ---------- [3.0][FrameworkBundle] Removed deprecated features | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Commits ------- fc41cf0 [3.0][FrameworkBundle] Removed deprecated features
…terJ) This PR was squashed before being merged into the 3.0-dev branch (closes #15900). Discussion ---------- [3.0][DoctrineBridge] Removed deprecated features | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Commits ------- 6dc3cf9 [3.0][DoctrineBridge] Removed deprecated features
…nd Form (fabpot) This PR was merged into the 3.0-dev branch. Discussion ---------- [Validator] removed deprecated features in Validator and Form | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Commits ------- 33f3400 [Form] removed deprecated features 582f3a3 [Form] removed deprecated FormType::getName() bfba6ca [Form] removed precision option 17cedd3 [Form] removed usage of Validator deprecated features 8fd32ba [Validator] remove the API_VERSION 2a6b629 [Validator] removed deprecated methods 925ecaf [Validator] removed deprecated features in Constraints
Conflicts: UPGRADE-2.8.md src/Symfony/Bridge/Twig/Command/LintCommand.php src/Symfony/Bundle/FrameworkBundle/Resources/config/collectors.xml src/Symfony/Bundle/FrameworkBundle/Resources/config/form_debug.xml src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/FormPassTest.php src/Symfony/Bundle/FrameworkBundle/composer.json src/Symfony/Bundle/SecurityBundle/Resources/config/collectors.xml src/Symfony/Bundle/TwigBundle/Command/DebugCommand.php src/Symfony/Bundle/TwigBundle/Tests/Controller/ExceptionControllerTest.php src/Symfony/Component/Routing/Loader/YamlFileLoader.php
…ion) This PR was merged into the 3.0-dev branch. Discussion ---------- [HttpKernel] make RequestStack parameter required | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Continuation of #14634, #8904 Commits ------- a2e154d [HttpKernel] make RequestStack parameter required for classes that need it
…ibutes (WouterJ) This PR was merged into the 3.0-dev branch. Discussion ---------- [WIP][3.0][Form] Removed usage of deprecated form tag attributes | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - WIP because it needs some adjustments after #15926 is merged Commits ------- 215fdbe Removed alias attribute usages
… (fabpot) This PR was merged into the 3.0-dev branch. Discussion ---------- [CssSelector] removed the deprecated CssSelector class | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Commits ------- 3ffa422 [CssSelector] removed the deprecated CssSelector class
* 3.0: Fix merge [Form] fix BC break introduced with prototype_data option [Ldap] Escape carriage returns in LDAP DNs. Upgrade for 2.8: ContainerAware was deprecated in favour of ContainerAwareTrait [ci skip] simplify debug error_reporting levels given php version > 5.3 Fix wrong method name mapping in UPGRADE-3.0.md Use correct height for clearer [Validator] fixed raising violations to a maximum of one
This PR was merged into the 3.1-dev branch. Discussion ---------- Fix typo in changelog | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #17084 | License | MIT | Doc PR | - Create separate PR as requested in [OptionsResolver PR](#17032) Commits ------- 6508b3d Fix typo in changelog
* Sets the {@link ClassMetadataFactoryInterface} to use. | ||
* | ||
* @param ClassMetadataFactoryInterface|null $classMetadataFactory | ||
* @param NameConverterInterface|null $nameConverter | ||
*/ | ||
public function __construct(ClassMetadataFactoryInterface $classMetadataFactory = null, NameConverterInterface $nameConverter = null) | ||
public function __construct(ClassMetadataFactoryInterface $classMetadataFactory = null, NameConverterInterface $nameConverter = null, PropertyInfoExtractor $propertyInfoExtractor = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Must type hint the PropertyInfoExtractorInterface
instead of the implementation.
@mihai-stancu I've just reopened the PR because of #16917. The cache will handled directly in the PropertyInfo Component so it's ok to use it directly. I've refactored most of the |
@dunglas i will rebase this evening, thanks! |
- Refactored PR 14844 "Denormalize with typehinting" - Now using PropertyInfo to extract type information - Updated tests - Updated composer.json
- Refactoring: - Extract method for property denormalization - Guard clauses - Avoid else/elseif - 2 indents per function - CS fix
- Fix logical fault for nullables
This PR was replaced by #17193 because it should be requested against master instead of 2.8. |
…ct class (dunglas) This PR was squashed before being merged into the 3.1-dev branch (closes #17191). Discussion ---------- [Serializer] Move the normalization logic in an abstract class | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a As suggested by @xabbuh, move all the normalization logic for objects in an abstract class. It will ease the maintenance as well as adding new features such as #17113 and #16143. I've introduced a new abstract class to avoid BC breaks in `AbstractNormalizer`. As a (good) side effect, all normalizers now benefits from the caching system introduced in #16547. Commits ------- 3bec813 [Serializer] Move the normalization logic in an abstract class
This PR was squashed before being merged into the 3.1-dev branch (closes #16917). Discussion ---------- [PropertyInfo] Cache support | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #16893 | License | MIT | Doc PR | todo Replace #16893 with several advantages: - Less complex patch - Work for all usages of PropertyInfo (even outside of the Serializer) - Avoid a circular reference between Serializer's CallMetadataFactory and PropertyInfo's SerializerExtractor - Allow @mihai-stancu's #16143 to work as-is Commits ------- 86c20df [PropertyInfo] Cache support
…ursive denormalization and hardening) (mihai-stancu, dunglas) This PR was merged into the 3.1-dev branch. Discussion ---------- [Serializer] Integrate the PropertyInfo Component (recursive denormalization and hardening) | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #16143, #17193, #14844 | License | MIT | Doc PR | todo Integrates the PropertyInfo Component in order to: * denormalize a graph of objects recursively (see tests) * harden the hydratation logic The hardening part is interesting. Considering the following example: ```php class Foo { public function setDate(\DateTimeInterface $date) { } } // initialize $normalizer $normalizer->denormalize(['date' => 1234], Foo::class); ``` Previously, a PHP error was thrown because the type passed to the setter (an int) doesn't match the one checked with the typehint. With the PropertyInfo integration, an `UnexpectedValueExcption` is throw instead. It's especially interesting for web APIs dealing with JSON documents. For instance in API Platform, previously a 500 error was thrown, but thanks to this fix a 400 HTTP code with a descriptive error message will be returned. (/cc @csarrazi @mRoca @blazarecki, it's an alternative to https://github.com/dunglas/php-to-json-schema for protecting an API). /cc @mihai-stancu Commits ------- 5194482 [Serializer] Integrate the PropertyInfo Component 6b464b0 Recursive denormalize using PropertyInfo
[2.7][Serializer] Feature using
PropertyInfo
to recursively denormalize values before calling the setter.Refactored #14844 "Denormalize with typehinting":