@@ -74,20 +74,20 @@ public function traverse(array $nodes, ExecutionContextInterface $context)
7474 }
7575 }
7676
77- $ traversal = new Traversal ( $ context );
77+ $ nodeQueue = new \ SplQueue ( );
7878
7979 foreach ($ nodes as $ node ) {
80- $ traversal -> nodeQueue ->enqueue ($ node );
80+ $ nodeQueue ->enqueue ($ node );
8181
82- while (!$ traversal -> nodeQueue ->isEmpty ()) {
83- $ node = $ traversal -> nodeQueue ->dequeue ();
82+ while (!$ nodeQueue ->isEmpty ()) {
83+ $ node = $ nodeQueue ->dequeue ();
8484
8585 if ($ node instanceof ClassNode) {
86- $ this ->traverseClassNode ($ node , $ traversal );
86+ $ this ->traverseClassNode ($ node , $ nodeQueue , $ context );
8787 } elseif ($ node instanceof CollectionNode) {
88- $ this ->traverseCollectionNode ($ node , $ traversal );
88+ $ this ->traverseCollectionNode ($ node , $ nodeQueue , $ context );
8989 } else {
90- $ this ->traverseNode ($ node , $ traversal );
90+ $ this ->traverseNode ($ node , $ nodeQueue , $ context );
9191 }
9292 }
9393 }
@@ -113,7 +113,7 @@ private function visit(Node $node, ExecutionContextInterface $context)
113113 return true ;
114114 }
115115
116- private function traverseNode (Node $ node , Traversal $ traversal )
116+ private function traverseNode (Node $ node , \ SplQueue $ nodeQueue , ExecutionContextInterface $ context )
117117 {
118118 // Visitors have two possibilities to influence the traversal:
119119 //
@@ -122,7 +122,7 @@ private function traverseNode(Node $node, Traversal $traversal)
122122 // 2. If a visitor's visit() method removes a group from the node,
123123 // that group will be skipped in the subtree of that node.
124124
125- if (false === $ this ->visit ($ node , $ traversal -> context )) {
125+ if (false === $ this ->visit ($ node , $ context )) {
126126 return ;
127127 }
128128
@@ -147,7 +147,7 @@ private function traverseNode(Node $node, Traversal $traversal)
147147 // Arrays are always traversed, independent of the specified
148148 // traversal strategy
149149 // (BC with Symfony < 2.5)
150- $ traversal -> nodeQueue ->enqueue (new CollectionNode (
150+ $ nodeQueue ->enqueue (new CollectionNode (
151151 $ node ->value ,
152152 $ node ->propertyPath ,
153153 $ cascadedGroups ,
@@ -167,7 +167,7 @@ private function traverseNode(Node $node, Traversal $traversal)
167167 $ node ->propertyPath ,
168168 $ cascadedGroups ,
169169 $ traversalStrategy ,
170- $ traversal
170+ $ nodeQueue
171171 );
172172
173173 return ;
@@ -184,7 +184,7 @@ private function traverseNode(Node $node, Traversal $traversal)
184184 }
185185
186186 // If TRAVERSE, the constructor will fail if we have no Traversable
187- $ traversal -> nodeQueue ->enqueue (new CollectionNode (
187+ $ nodeQueue ->enqueue (new CollectionNode (
188188 $ node ->value ,
189189 $ node ->propertyPath ,
190190 $ cascadedGroups ,
@@ -193,7 +193,7 @@ private function traverseNode(Node $node, Traversal $traversal)
193193 ));
194194 }
195195
196- private function traverseClassNode (ClassNode $ node , Traversal $ traversal )
196+ private function traverseClassNode (ClassNode $ node , \ SplQueue $ nodeQueue , ExecutionContextInterface $ context )
197197 {
198198 // Visitors have two possibilities to influence the traversal:
199199 //
@@ -202,7 +202,7 @@ private function traverseClassNode(ClassNode $node, Traversal $traversal)
202202 // 2. If a visitor's visit() method removes a group from the node,
203203 // that group will be skipped in the subtree of that node.
204204
205- if (false === $ this ->visit ($ node , $ traversal -> context )) {
205+ if (false === $ this ->visit ($ node , $ context )) {
206206 return ;
207207 }
208208
@@ -212,7 +212,7 @@ private function traverseClassNode(ClassNode $node, Traversal $traversal)
212212
213213 foreach ($ node ->metadata ->getConstrainedProperties () as $ propertyName ) {
214214 foreach ($ node ->metadata ->getPropertyMetadata ($ propertyName ) as $ propertyMetadata ) {
215- $ traversal -> nodeQueue ->enqueue (new PropertyNode (
215+ $ nodeQueue ->enqueue (new PropertyNode (
216216 $ node ->value ,
217217 $ propertyMetadata ->getPropertyValue ($ node ->value ),
218218 $ propertyMetadata ,
@@ -246,7 +246,7 @@ private function traverseClassNode(ClassNode $node, Traversal $traversal)
246246 }
247247
248248 // If TRAVERSE, the constructor will fail if we have no Traversable
249- $ traversal -> nodeQueue ->enqueue (new CollectionNode (
249+ $ nodeQueue ->enqueue (new CollectionNode (
250250 $ node ->value ,
251251 $ node ->propertyPath ,
252252 $ node ->groups ,
@@ -255,7 +255,7 @@ private function traverseClassNode(ClassNode $node, Traversal $traversal)
255255 ));
256256 }
257257
258- private function traverseCollectionNode (CollectionNode $ node , Traversal $ traversal )
258+ private function traverseCollectionNode (CollectionNode $ node , \ SplQueue $ nodeQueue , ExecutionContextInterface $ context )
259259 {
260260 // Visitors have two possibilities to influence the traversal:
261261 //
@@ -264,7 +264,7 @@ private function traverseCollectionNode(CollectionNode $node, Traversal $travers
264264 // 2. If a visitor's visit() method removes a group from the node,
265265 // that group will be skipped in the subtree of that node.
266266
267- if (false === $ this ->visit ($ node , $ traversal -> context )) {
267+ if (false === $ this ->visit ($ node , $ context )) {
268268 return ;
269269 }
270270
@@ -285,7 +285,7 @@ private function traverseCollectionNode(CollectionNode $node, Traversal $travers
285285 // Arrays are always cascaded, independent of the specified
286286 // traversal strategy
287287 // (BC with Symfony < 2.5)
288- $ traversal -> nodeQueue ->enqueue (new CollectionNode (
288+ $ nodeQueue ->enqueue (new CollectionNode (
289289 $ value ,
290290 $ node ->propertyPath .'[ ' .$ key .'] ' ,
291291 $ node ->groups ,
@@ -304,13 +304,13 @@ private function traverseCollectionNode(CollectionNode $node, Traversal $travers
304304 $ node ->propertyPath .'[ ' .$ key .'] ' ,
305305 $ node ->groups ,
306306 $ traversalStrategy ,
307- $ traversal
307+ $ nodeQueue
308308 );
309309 }
310310 }
311311 }
312312
313- private function cascadeObject ($ object , $ propertyPath , array $ groups , $ traversalStrategy , Traversal $ traversal )
313+ private function cascadeObject ($ object , $ propertyPath , array $ groups , $ traversalStrategy , \ SplQueue $ nodeQueue )
314314 {
315315 try {
316316 $ classMetadata = $ this ->metadataFactory ->getMetadataFor ($ object );
@@ -319,7 +319,7 @@ private function cascadeObject($object, $propertyPath, array $groups, $traversal
319319 // error
320320 }
321321
322- $ traversal -> nodeQueue ->enqueue (new ClassNode (
322+ $ nodeQueue ->enqueue (new ClassNode (
323323 $ object ,
324324 $ classMetadata ,
325325 $ propertyPath ,
@@ -338,7 +338,7 @@ private function cascadeObject($object, $propertyPath, array $groups, $traversal
338338 throw $ e ;
339339 }
340340
341- $ traversal -> nodeQueue ->enqueue (new CollectionNode (
341+ $ nodeQueue ->enqueue (new CollectionNode (
342342 $ object ,
343343 $ propertyPath ,
344344 $ groups ,
0 commit comments