2020use Symfony \Component \Validator \Group \GroupManagerInterface ;
2121use Symfony \Component \Validator \Mapping \PropertyMetadataInterface ;
2222use Symfony \Component \Validator \Node \Node ;
23- use Symfony \Component \Validator \Util \ NodeStackInterface ;
23+ use Symfony \Component \Validator \NodeVisitor \ NodeObserverInterface ;
2424use Symfony \Component \Validator \Util \PropertyPath ;
2525use Symfony \Component \Validator \Validator \ValidatorInterface ;
2626use Symfony \Component \Validator \Violation \ConstraintViolationBuilder ;
3333 *
3434 * @see ExecutionContextInterface
3535 */
36- class ExecutionContext implements ExecutionContextInterface, LegacyExecutionContextInterface, NodeStackInterface
36+ class ExecutionContext implements ExecutionContextInterface, LegacyExecutionContextInterface, NodeObserverInterface
3737{
3838 /**
3939 * @var ValidatorInterface
@@ -76,13 +76,6 @@ class ExecutionContext implements ExecutionContextInterface, LegacyExecutionCont
7676 */
7777 private $ node ;
7878
79- /**
80- * The trace of nodes from the root node to the current node.
81- *
82- * @var \SplStack
83- */
84- private $ nodeStack ;
85-
8679 /**
8780 * Creates a new execution context.
8881 *
@@ -108,49 +101,18 @@ public function __construct(ValidatorInterface $validator, $root, GroupManagerIn
108101 $ this ->translator = $ translator ;
109102 $ this ->translationDomain = $ translationDomain ;
110103 $ this ->violations = new ConstraintViolationList ();
111- $ this ->nodeStack = new \SplStack ();
112104 }
113105
114106 /**
115107 * Sets the values of the context to match the given node.
116108 *
117- * Internally, all nodes are stored on a stack and can be removed from that
118- * stack using {@link popNode()}.
119- *
120109 * @param Node $node The currently validated node
121110 */
122- public function pushNode (Node $ node )
111+ public function setCurrentNode (Node $ node )
123112 {
124- $ this ->nodeStack ->push ($ node );
125113 $ this ->node = $ node ;
126114 }
127115
128- /**
129- * Sets the values of the context to match the previous node.
130- *
131- * The current node is removed from the internal stack and returned.
132- *
133- * @return Node|null The currently validated node or null, if no node was
134- * on the stack
135- */
136- public function popNode ()
137- {
138- // Nothing to do if the stack is empty
139- if (0 === count ($ this ->nodeStack )) {
140- return null ;
141- }
142-
143- // Remove the current node from the stack
144- $ poppedNode = $ this ->nodeStack ->pop ();
145-
146- // Adjust the current node to the previous node
147- $ this ->node = count ($ this ->nodeStack ) > 0
148- ? $ this ->nodeStack ->top ()
149- : null ;
150-
151- return $ poppedNode ;
152- }
153-
154116 /**
155117 * {@inheritdoc}
156118 */
0 commit comments