Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

[PropertyInfo] Extract public properties first in ReflectionExtractor#59430

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
tBibaut wants to merge1 commit intosymfony:7.4
base:7.4
Choose a base branch
Loading
fromtBibaut:feat/reflectionextractor_property-first

Conversation

tBibaut
Copy link
Contributor

QA
Branch?7.3
Bug fix?yes/no
New feature?yes
Deprecations?yes
IssuesFix#57719
LicenseMIT

@carsonbot
Copy link

Hey!

To help keep things organized, we don't allow "Draft" pull requests. Could you please click the "ready for review" button or close this PR and open a new one when you are done?

Note that a pull request does not have to be "perfect" or "ready for merge" when you first open it. We just want it to be ready for a first review.

Cheers!

Carsonbot

@tBibauttBibautforce-pushed thefeat/reflectionextractor_property-first branch from2ee42e8 to77e76eeCompareJanuary 8, 2025 08:37
@tBibauttBibaut marked this pull request as ready for reviewJanuary 8, 2025 08:38
@carsonbotcarsonbot added this to the7.3 milestoneJan 8, 2025
@@ -987,7 +987,7 @@ private function getType(string $currentClass, string $attribute): Type|array|nu
private function getPropertyType(string $className, string $property): Type|array|null
{
if (class_exists(Type::class) && method_exists($this->propertyTypeExtractor, 'getType')) {
return $this->propertyTypeExtractor->getType($className, $property);
return $this->propertyTypeExtractor->getType($className, $property, context: ['extract_public_properties_first' => true]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I wonder if the context should instead be given by the user instead?

IMO it should be given from the normalize/denormalize context argument. Then we can leverage the default context (and update the recipe) to reduce the impact of that depreciation. WDYT?

tBibaut reacted with thumbs up emoji
@tBibauttBibautforce-pushed thefeat/reflectionextractor_property-first branch from77e76ee to406655dCompareJanuary 8, 2025 09:40
Comment on lines +211 to +213
$extractPublicPropertiesFirst = \array_key_exists('extract_public_properties_first', $context);
if (!$extractPublicPropertiesFirst) {
trigger_deprecation('symfony/property-info', '7.3', 'Not setting "extract_public_properties_first" context key is deprecated, it will default to "true" in 8.0.');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
$extractPublicPropertiesFirst =\array_key_exists('extract_public_properties_first',$context);
if (!$extractPublicPropertiesFirst) {
trigger_deprecation('symfony/property-info','7.3','Not setting "extract_public_properties_first" context key is deprecated, it will default to "true" in 8.0.');
$extractPublicPropertiesFirst =$context['extract_public_properties_first'] ??false;
if (!$extractPublicPropertiesFirst) {
trigger_deprecation('symfony/property-info','7.3','Not setting "extract_public_properties_first" context value to "true" is deprecated, it will always be considered as "true" in 8.0.');

@@ -207,6 +207,29 @@ public function getTypesFromConstructor(string $class, string $property): ?array

public function getType(string $class, string $property, array $context = []): ?Type
{
// BC layer, remove context key in 8.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Could you update theCHANGELOG.md ofPropertyInfo andUPGRADE-7.3.md as well?

{
if (class_exists(Type::class) && method_exists($this->propertyTypeExtractor, 'getType')) {
return $this->propertyTypeExtractor->getType($className, $property);
return $this->propertyTypeExtractor->getType($className, $property, $context);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Default context must be handled here

@@ -1674,6 +1674,30 @@ public function testPartialDenormalizationWithInvalidVariadicParameter()
DenormalizerInterface::COLLECT_DENORMALIZATION_ERRORS => true,
]);
}

public function testExtractPublicPropertiesFirst()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This test must be long to theAbstractObjectNormalizerTest instead.
Also, you might add a test in theReflectionExtractorTest as well.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@mtarldmtarldmtarld requested changes

@dunglasdunglasAwaiting requested review from dunglasdunglas is a code owner

Assignees
No one assigned
Projects
None yet
Milestone
7.4
Development

Successfully merging this pull request may close these issues.

ReflectionExtractor::getTypes prioritizes unreliable sources to determine the type
4 participants
@tBibaut@carsonbot@mtarld@fabpot

[8]ページ先頭

©2009-2025 Movatter.jp