@@ -74,20 +74,20 @@ public function traverse(array $nodes, ExecutionContextInterface $context)
74
74
}
75
75
}
76
76
77
- $ traversal = new Traversal ( $ context );
77
+ $ nodeQueue = new \ SplQueue ( );
78
78
79
79
foreach ($ nodes as $ node ) {
80
- $ traversal -> nodeQueue ->enqueue ($ node );
80
+ $ nodeQueue ->enqueue ($ node );
81
81
82
- while (!$ traversal -> nodeQueue ->isEmpty ()) {
83
- $ node = $ traversal -> nodeQueue ->dequeue ();
82
+ while (!$ nodeQueue ->isEmpty ()) {
83
+ $ node = $ nodeQueue ->dequeue ();
84
84
85
85
if ($ node instanceof ClassNode) {
86
- $ this ->traverseClassNode ($ node , $ traversal );
86
+ $ this ->traverseClassNode ($ node , $ nodeQueue , $ context );
87
87
} elseif ($ node instanceof CollectionNode) {
88
- $ this ->traverseCollectionNode ($ node , $ traversal );
88
+ $ this ->traverseCollectionNode ($ node , $ nodeQueue , $ context );
89
89
} else {
90
- $ this ->traverseNode ($ node , $ traversal );
90
+ $ this ->traverseNode ($ node , $ nodeQueue , $ context );
91
91
}
92
92
}
93
93
}
@@ -113,7 +113,7 @@ private function visit(Node $node, ExecutionContextInterface $context)
113
113
return true ;
114
114
}
115
115
116
- private function traverseNode (Node $ node , Traversal $ traversal )
116
+ private function traverseNode (Node $ node , \ SplQueue $ nodeQueue , ExecutionContextInterface $ context )
117
117
{
118
118
// Visitors have two possibilities to influence the traversal:
119
119
//
@@ -122,7 +122,7 @@ private function traverseNode(Node $node, Traversal $traversal)
122
122
// 2. If a visitor's visit() method removes a group from the node,
123
123
// that group will be skipped in the subtree of that node.
124
124
125
- if (false === $ this ->visit ($ node , $ traversal -> context )) {
125
+ if (false === $ this ->visit ($ node , $ context )) {
126
126
return ;
127
127
}
128
128
@@ -147,7 +147,7 @@ private function traverseNode(Node $node, Traversal $traversal)
147
147
// Arrays are always traversed, independent of the specified
148
148
// traversal strategy
149
149
// (BC with Symfony < 2.5)
150
- $ traversal -> nodeQueue ->enqueue (new CollectionNode (
150
+ $ nodeQueue ->enqueue (new CollectionNode (
151
151
$ node ->value ,
152
152
$ node ->propertyPath ,
153
153
$ cascadedGroups ,
@@ -167,7 +167,7 @@ private function traverseNode(Node $node, Traversal $traversal)
167
167
$ node ->propertyPath ,
168
168
$ cascadedGroups ,
169
169
$ traversalStrategy ,
170
- $ traversal
170
+ $ nodeQueue
171
171
);
172
172
173
173
return ;
@@ -184,7 +184,7 @@ private function traverseNode(Node $node, Traversal $traversal)
184
184
}
185
185
186
186
// If TRAVERSE, the constructor will fail if we have no Traversable
187
- $ traversal -> nodeQueue ->enqueue (new CollectionNode (
187
+ $ nodeQueue ->enqueue (new CollectionNode (
188
188
$ node ->value ,
189
189
$ node ->propertyPath ,
190
190
$ cascadedGroups ,
@@ -193,7 +193,7 @@ private function traverseNode(Node $node, Traversal $traversal)
193
193
));
194
194
}
195
195
196
- private function traverseClassNode (ClassNode $ node , Traversal $ traversal )
196
+ private function traverseClassNode (ClassNode $ node , \ SplQueue $ nodeQueue , ExecutionContextInterface $ context )
197
197
{
198
198
// Visitors have two possibilities to influence the traversal:
199
199
//
@@ -202,7 +202,7 @@ private function traverseClassNode(ClassNode $node, Traversal $traversal)
202
202
// 2. If a visitor's visit() method removes a group from the node,
203
203
// that group will be skipped in the subtree of that node.
204
204
205
- if (false === $ this ->visit ($ node , $ traversal -> context )) {
205
+ if (false === $ this ->visit ($ node , $ context )) {
206
206
return ;
207
207
}
208
208
@@ -212,7 +212,7 @@ private function traverseClassNode(ClassNode $node, Traversal $traversal)
212
212
213
213
foreach ($ node ->metadata ->getConstrainedProperties () as $ propertyName ) {
214
214
foreach ($ node ->metadata ->getPropertyMetadata ($ propertyName ) as $ propertyMetadata ) {
215
- $ traversal -> nodeQueue ->enqueue (new PropertyNode (
215
+ $ nodeQueue ->enqueue (new PropertyNode (
216
216
$ node ->value ,
217
217
$ propertyMetadata ->getPropertyValue ($ node ->value ),
218
218
$ propertyMetadata ,
@@ -246,7 +246,7 @@ private function traverseClassNode(ClassNode $node, Traversal $traversal)
246
246
}
247
247
248
248
// If TRAVERSE, the constructor will fail if we have no Traversable
249
- $ traversal -> nodeQueue ->enqueue (new CollectionNode (
249
+ $ nodeQueue ->enqueue (new CollectionNode (
250
250
$ node ->value ,
251
251
$ node ->propertyPath ,
252
252
$ node ->groups ,
@@ -255,7 +255,7 @@ private function traverseClassNode(ClassNode $node, Traversal $traversal)
255
255
));
256
256
}
257
257
258
- private function traverseCollectionNode (CollectionNode $ node , Traversal $ traversal )
258
+ private function traverseCollectionNode (CollectionNode $ node , \ SplQueue $ nodeQueue , ExecutionContextInterface $ context )
259
259
{
260
260
// Visitors have two possibilities to influence the traversal:
261
261
//
@@ -264,7 +264,7 @@ private function traverseCollectionNode(CollectionNode $node, Traversal $travers
264
264
// 2. If a visitor's visit() method removes a group from the node,
265
265
// that group will be skipped in the subtree of that node.
266
266
267
- if (false === $ this ->visit ($ node , $ traversal -> context )) {
267
+ if (false === $ this ->visit ($ node , $ context )) {
268
268
return ;
269
269
}
270
270
@@ -285,7 +285,7 @@ private function traverseCollectionNode(CollectionNode $node, Traversal $travers
285
285
// Arrays are always cascaded, independent of the specified
286
286
// traversal strategy
287
287
// (BC with Symfony < 2.5)
288
- $ traversal -> nodeQueue ->enqueue (new CollectionNode (
288
+ $ nodeQueue ->enqueue (new CollectionNode (
289
289
$ value ,
290
290
$ node ->propertyPath .'[ ' .$ key .'] ' ,
291
291
$ node ->groups ,
@@ -304,13 +304,13 @@ private function traverseCollectionNode(CollectionNode $node, Traversal $travers
304
304
$ node ->propertyPath .'[ ' .$ key .'] ' ,
305
305
$ node ->groups ,
306
306
$ traversalStrategy ,
307
- $ traversal
307
+ $ nodeQueue
308
308
);
309
309
}
310
310
}
311
311
}
312
312
313
- private function cascadeObject ($ object , $ propertyPath , array $ groups , $ traversalStrategy , Traversal $ traversal )
313
+ private function cascadeObject ($ object , $ propertyPath , array $ groups , $ traversalStrategy , \ SplQueue $ nodeQueue )
314
314
{
315
315
try {
316
316
$ classMetadata = $ this ->metadataFactory ->getMetadataFor ($ object );
@@ -319,7 +319,7 @@ private function cascadeObject($object, $propertyPath, array $groups, $traversal
319
319
// error
320
320
}
321
321
322
- $ traversal -> nodeQueue ->enqueue (new ClassNode (
322
+ $ nodeQueue ->enqueue (new ClassNode (
323
323
$ object ,
324
324
$ classMetadata ,
325
325
$ propertyPath ,
@@ -338,7 +338,7 @@ private function cascadeObject($object, $propertyPath, array $groups, $traversal
338
338
throw $ e ;
339
339
}
340
340
341
- $ traversal -> nodeQueue ->enqueue (new CollectionNode (
341
+ $ nodeQueue ->enqueue (new CollectionNode (
342
342
$ object ,
343
343
$ propertyPath ,
344
344
$ groups ,
0 commit comments