-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Support WeakReferences in NodeConnectingVisitor #1057
base: master
Are you sure you want to change the base?
Conversation
I think in CloningVisitor we don't need a weak-ref because we clone the elements, right? |
if ($this->weakReferences) { | ||
$parent = \WeakReference::create($parent); | ||
} | ||
$node->setAttribute('parent', $parent); |
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.
One thing I'm wondering about here is whether we should reuse the same attribute names, or use a different one like 'weak_parent'
, to avoid having two possible types for these attributes.
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.
We could use separate attribute names, but then I would go with a separate WeakNodeConnectingVisitor class and leave NodeConnectingVisitor untouched ..?
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.
adjusted
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.
Given that the implementation themselves are pretty trivial, I'd be fine with adding separate classes as well.
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.
I am fine with the PR as is, in case you are also ok with it
closes #1055
we observed perf improvements on a similar visitor in staabm/phpstan-dba#667 (comment)