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

[VarDumper] show uninitialized properties#50076

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

@guillaumeVDP
Copy link
Contributor

@guillaumeVDPguillaumeVDP commentedApr 20, 2023
edited
Loading

QA
Branch?6.3
Bug fix?no
New feature?yes
Deprecations?no
TicketsFix ##50054
LicenseMIT
Doc PR-

First commit for the feature. Please review this pull request and help me doing this in a good way 🙏

I am not sure if it's good to store uninitialized properties to the attr of the stub. Any better ideas ?

Missing:

  • tests
  • updating CHANGELOG.md

@carsonbot
Copy link

Hey!

Thanks for your PR. You are targeting branch "6.3" but it seems your PR description refers to branch "6.3 for features".
Could you update the PR description or change target branch? This helps core maintainers a lot.

Cheers!

Carsonbot

@guillaumeVDPguillaumeVDP marked this pull request as draftApril 20, 2023 15:28
@guillaumeVDPguillaumeVDP marked this pull request as ready for reviewApril 20, 2023 15:36
Copy link
Member

@lyrixxlyrixx left a comment

Choose a reason for hiding this comment

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

wahoo, super good start!

guillaumeVDP reacted with hooray emoji
$stubClass =$stub->value::class;
$stub->attr['uninitialized'] = [];
foreach ($uninitializedPropsas$key =>$value) {
$rp =new \ReflectionProperty($stubClass,$key);
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a local cache for this?

$stub->attr['uninitialized'] = [];
foreach ($uninitializedPropsas$key =>$value) {
$rp =new \ReflectionProperty($stubClass,$key);
$stub->attr['uninitialized'][] = [$key =>$rp->getType()->getName()];
Copy link
Member

Choose a reason for hiding this comment

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

this is broken for any union or intersection types. Not all ReflectionType are ReflectionNamedType.

guillaumeVDP reacted with thumbs up emoji
$stub->attr['uninitialized'] = [];
foreach ($uninitializedPropsas$key =>$value) {
$rp =new \ReflectionProperty($stubClass,$key);
$stub->attr['uninitialized'][] = [$key =>$rp->getType()->getName()];
Copy link
Member

Choose a reason for hiding this comment

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

why using a list of single-item arrays with an unknown key for this$stub->attr['uninitialized'] ? why not using$stub->attr['uninitialized'][$key] = $type here ?

guillaumeVDP reacted with thumbs up emoji
}
$cursor->skipChildren =false;
// Add uninitialized properties
foreach ($item->attr["uninitialized"]as$uninitializedProperty) {
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't this be done insidedumpChildren instead ? Otherwise, things will be weird when the cursor is meant to dump without children.

guillaumeVDP reacted with thumbs up emoji
$stub->value =$v;
$stub->handle =$h;
$a =$this->castObject($stub,0 <$i);
if ($stub->value !=='') {
Copy link
Member

Choose a reason for hiding this comment

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

Does this work for nested objects or should we implement that logic incastObject ?

And I'm wondering whether this should be implemented inCaster::castObject by adding those properties as a specialUninitializedStub, so that this is donebefore any custom caster runs. This way, if a caster decides to cut a property, this would also cut it if it is uninitialized.

Choose a reason for hiding this comment

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

I agree with this. I would add this to AbstractCloner::castObject, where there is already$this->classInfo that we can use to store thoseUninitializedStub.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Ok I'll try implementing this solution. Thanks

@guillaumeVDPguillaumeVDPforce-pushed thevardumper-show-uninitialized-properties branch from7d978a0 toa4684c3CompareApril 21, 2023 08:58
@nicolas-grekasnicolas-grekas modified the milestones:6.3,6.4May 23, 2023
@nicolas-grekas
Copy link
Member

nicolas-grekas commentedJul 27, 2023
edited
Loading

I went with another approach in#51130
Thanks for pushing this forward!

fabpot added a commit that referenced this pull requestJul 30, 2023
…kas)This PR was merged into the 6.4 branch.Discussion----------[VarDumper] Dump uninitialized properties| Q             | A| ------------- | ---| Branch?       | 6.4| Bug fix?      | no| New feature?  | yes| Deprecations? | no| Tickets       |Fix#50054| License       | MIT| Doc PR        | -Replaces#50076Given this:```phpclass Foo {    private int|float $foo;    public $baz;}$f = new Foo;unset($f->baz);dump($f);```This displays:![image](https://github.com/symfony/symfony/assets/243674/00af5f8a-22ea-45ca-9ece-fec201517096)Commits-------54468db [VarDumper] Dump uninitialized properties
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@lyrixxlyrixxlyrixx left review comments

@stofstofstof left review comments

Assignees

No one assigned

Projects

None yet

Milestone

6.4

Development

Successfully merging this pull request may close these issues.

5 participants

@guillaumeVDP@carsonbot@nicolas-grekas@lyrixx@stof

[8]ページ先頭

©2009-2025 Movatter.jp