@@ 66-78 (lines=13) @@ | ||
63 | * @return JsonWritable |
|
64 | * @throws \BadMethodCallException |
|
65 | */ |
|
66 | public function beginArray(): JsonWritable |
|
67 | { |
|
68 | if ($this->topIsObjectStart()) { |
|
69 | throw new BadMethodCallException('Cannot call beginArray() before name() during object serialization'); |
|
70 | } |
|
71 | ||
72 | $array = new JsonArray(); |
|
73 | $this->push($array); |
|
74 | $this->stack[] = $array; |
|
75 | $this->stackSize++; |
|
76 | ||
77 | return $this; |
|
78 | } |
|
79 | ||
80 | /** |
|
81 | * End writing array |
|
@@ 103-115 (lines=13) @@ | ||
100 | * @return JsonWritable |
|
101 | * @throws \BadMethodCallException |
|
102 | */ |
|
103 | public function beginObject(): JsonWritable |
|
104 | { |
|
105 | if ($this->topIsObjectStart()) { |
|
106 | throw new BadMethodCallException('Cannot call beginObject() before name() during object serialization'); |
|
107 | } |
|
108 | ||
109 | $class = new JsonObject(); |
|
110 | $this->push($class); |
|
111 | $this->stack[] = $class; |
|
112 | $this->stackSize++; |
|
113 | ||
114 | return $this; |
|
115 | } |
|
116 | ||
117 | /** |
|
118 | * End writing object |
@@ 61-73 (lines=13) @@ | ||
58 | * @return JsonWritable |
|
59 | * @throws \BadMethodCallException |
|
60 | */ |
|
61 | public function beginArray(): JsonWritable |
|
62 | { |
|
63 | if ($this->topIsObjectStart()) { |
|
64 | throw new BadMethodCallException('Cannot call beginArray() before name() during object serialization'); |
|
65 | } |
|
66 | ||
67 | $array = []; |
|
68 | $this->push($array); |
|
69 | $this->stack[] = &$array; |
|
70 | $this->stackSize++; |
|
71 | ||
72 | return $this; |
|
73 | } |
|
74 | ||
75 | /** |
|
76 | * End writing array |
|
@@ 98-110 (lines=13) @@ | ||
95 | * @return JsonWritable |
|
96 | * @throws \BadMethodCallException |
|
97 | */ |
|
98 | public function beginObject(): JsonWritable |
|
99 | { |
|
100 | if ($this->topIsObjectStart()) { |
|
101 | throw new BadMethodCallException('Cannot call beginObject() before name() during object serialization'); |
|
102 | } |
|
103 | ||
104 | $class = new stdClass(); |
|
105 | $this->push($class); |
|
106 | $this->stack[] = $class; |
|
107 | $this->stackSize++; |
|
108 | ||
109 | return $this; |
|
110 | } |
|
111 | ||
112 | /** |
|
113 | * End writing object |