File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -81,22 +81,26 @@ private function cloneValue($value)
8181 */
8282 public function __toString ()
8383 {
84- $ tmp = $ this ->toArray ();
84+ $ tmp = $ this ->toArray (true );
8585 return json_encode ($ tmp );
8686 }
8787
8888 /**
89+ * @param bool $recursive
8990 * @return array
9091 */
91- public function toArray ()
92+ public function toArray ($ recursive = false )
9293 {
9394 $ tmp = (array ) $ this ;
95+
9496 $ tmp ['loc ' ] = [
9597 'start ' => $ this ->loc ->start ,
9698 'end ' => $ this ->loc ->end
9799 ];
98100
99- $ this ->recursiveToArray ($ tmp );
101+ if ($ recursive ) {
102+ $ this ->recursiveToArray ($ tmp );
103+ }
100104
101105 return $ tmp ;
102106 }
@@ -108,7 +112,7 @@ public function recursiveToArray(&$object)
108112 {
109113 if ($ object instanceof Node) {
110114 /** @var Node $object */
111- $ object = $ object ->toArray ();
115+ $ object = $ object ->toArray (true );
112116 } elseif (is_object ($ object )) {
113117 $ object = (array ) $ object ;
114118 } elseif (is_array ($ object )) {
You can’t perform that action at this time.
0 commit comments