You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/component/FAQ.markdown
+14
Original file line number
Diff line number
Diff line change
@@ -51,3 +51,17 @@ obtained through `$node->getAttribute('next')`.
51
51
52
52
`ParentConnectingVisitor` and `NodeConnectingVisitor` should not be used at the same time. The latter
53
53
includes the functionality of the former.
54
+
55
+
56
+
How can I limit the impact of cyclic references in the AST?
57
+
-----
58
+
59
+
NodeConnectingVisitor adds a parent reference, which introduces a cycle. This means that the AST can now only be collected by the cycle garbage collector.
60
+
This in turn can lead to performance and/or memory issues.
61
+
62
+
To break the cyclic references between AST nodes `NodeConnectingVisitor` supports a boolean `$weakReferences` constructor parameter.
63
+
When set to `true`, all attributes added by `NodeConnectingVisitor` will be wrapped into a `WeakReference` object.
64
+
65
+
After enabling this parameter, the parent node can be obtained through `$node->getAttribute('weak_parent')`,
66
+
the previous node can be obtained through `$node->getAttribute('weak_previous')`, and the next node can be
67
+
obtained through `$node->getAttribute('weak_next')`.
0 commit comments