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

[Serializer] Allow to access to the format and context in circular ref handler#27020

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

Conversation

@dunglas
Copy link
Member

@dunglasdunglas commentedApr 23, 2018
edited
Loading

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed ticketsn/a
LicenseMIT
Doc PRsymfony/symfony-docs#10318

Similar to#27017 but for circular reference handlers.

ping@meyerbaptiste

* @param object $object
* @param object $object
* @param string|null $format
* @param array $context

Choose a reason for hiding this comment

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

all these can be removed imho

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

It allows the IDE to discover those parameters. They could be dropped only when/if we'll uncomment the new parameters.

nicolas-grekas reacted with thumbs up emoji

Choose a reason for hiding this comment

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

ok, then next question for me is: how will we make these real args in 5.0?
shouldn't we throw a deprecation somehow?

Copy link
Member

Choose a reason for hiding this comment

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

do we want them to be optional in 5.x ? I would say no (otherwise you would not be able to rely on them in the handler).

so I would trigger a deprecation in case they are not provided when calling the method.

and I suggest making this method@final, as the proper way to extend the handling of circular references is to register a handler, not to extend the method in child classes.

Choose a reason for hiding this comment

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

making this method@Final

if that fits, then that's the best, as just adding the annotation will trigger a deprecation notice automatically

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

+1 for final

protectedfunctionhandleCircularReference($object/*, ?string $format = null, array $context = array()*/)
{
$format = @func_get_arg(1) ?:null;
$context = @func_get_arg(2) ?:array();

Choose a reason for hiding this comment

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

please use func_num_args instead of@

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

done

* @throws CircularReferenceException
*/
protectedfunctionhandleCircularReference($object)
protectedfunctionhandleCircularReference($object/*, ?string $format = null, array $context = array()*/)

Choose a reason for hiding this comment

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

the? should be removed
don't miss adding@final also as discussed above

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I change it, but for reference:

Typed properties cannot have a null default value, unless the type is explicitly nullable (?Type). This is in contrast to parameter types, where a null default value automatically implies a nullable type. We consider this to be a legacy behavior, which we do not wish to support for newly introduced syntax.

https://wiki.php.net/rfc/typed_properties_v2

Choose a reason for hiding this comment

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

Maybe, but same as array() vs []: we prefer consistency across branches, and not all of them support this, so it's too early to consider.

dunglas reacted with thumbs up emoji
@dunglasdunglasforce-pushed theserializer-circular-ref-extra branch fromfa5b6fd tob58cae4CompareJune 30, 2018 09:29
Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

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

LGTM, just one minor comment.

* {@class CircularReferenceException} will be thrown.
*
* @param object $object
* @final

Choose a reason for hiding this comment

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

@Final since Symfony 4.2

@dunglasdunglasforce-pushed theserializer-circular-ref-extra branch fromfc704cf to99f829eCompareJuly 3, 2018 20:18
@nicolas-grekas
Copy link
Member

Thank you@dunglas.

@nicolas-grekasnicolas-grekas merged commit99f829e intosymfony:masterJul 7, 2018
nicolas-grekas added a commit that referenced this pull requestJul 7, 2018
… in circular ref handler (dunglas)This PR was merged into the 4.2-dev branch.Discussion----------[Serializer] Allow to access to the format and context in circular ref handler| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes <!-- don't forget to update src/**/CHANGELOG.md files -->| BC breaks?    | no     <!-- seehttps://symfony.com/bc -->| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->| Fixed tickets | n/a   <!-- #-prefixed issue number(s), if any -->| License       | MIT| Doc PR        | todoSimilar to#27017 but for circular reference handlers.ping@meyerbaptisteCommits-------99f829e [Serializer] Allow to access to the format and context in circular ref handler
fabpot added a commit that referenced this pull requestSep 4, 2018
…rters (dunglas)This PR was squashed before being merged into the 4.2-dev branch (closes#27021).Discussion----------[Serializer] Allow to access extra infos in name converters| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes<!-- don't forget to update src/**/CHANGELOG.md files -->| BC breaks?    | no     <!-- seehttps://symfony.com/bc -->| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->| Fixed tickets | n/a| License       | MIT| Doc PR        | todoSimilar to#27017 and#27020 but for name converters.ping@meyerbaptisteCommits-------57fe017 [Serializer] Allow to access extra infos in name converters
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull requestSep 11, 2018
…other infos in callbacks and max depth handler (dunglas, javiereguiluz)This PR was merged into the master branch.Discussion----------[Serializer] Allow to access to the context and various other infos in callbacks and max depth handlersymfony/symfony#27020symfony/symfony#27017Commits-------672b374 Minor reword7c3e620 Fix, and document setCircularReferenceHandler's new parametersa4dad43 [Serializer] Allow to access to the context and various other infos in callbacks and max depth handler
@nicolas-grekasnicolas-grekas modified the milestones:next,4.2Nov 1, 2018
This was referencedNov 3, 2018
nicolas-grekas added a commit that referenced this pull requestJun 8, 2019
…anagi)This PR was merged into the 5.0-dev branch.Discussion----------[Serializer] Remove last deprecated/obsolete paths| Q             | A| ------------- | ---| Branch?       | master <!-- see below -->| Bug fix?      | no| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->| BC breaks?    | no     <!-- seehttps://symfony.com/bc -->| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->| Fixed tickets |#28316,#28709,#31030,#27020,#29896,16f8a13#r201060750   <!-- #-prefixed issue number(s), if any -->| License       | MIT| Doc PR        | N/A <!-- required for new features -->This should fix the last deprecations & obsolete code paths for the Serializer component.Commits-------c703b35 [Serializer] Remove last deprecated/obsolete paths
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@stofstofstof left review comments

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

4.2

Development

Successfully merging this pull request may close these issues.

4 participants

@dunglas@nicolas-grekas@stof@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp