@@ -107,18 +107,18 @@ private function addObject($object): int
107107 return $ object_id ;
108108 }
109109
110- private function marshal (Context $ ctx , mixed $ data ): string
110+ private function marshal (Context $ ctx , mixed $ data ): mixed
111111 {
112112 if (is_object ($ data ) or is_resource ($ data )) {
113113 $ object_id = $ this ->addObject ($ data );
114- return RemoteObject::serialize ($ object_id , $ ctx ->getCoroutineId (), $ ctx ->getClientId ());
114+ return RemoteObject::marshal ($ object_id , $ ctx ->getCoroutineId (), $ ctx ->getClientId ());
115115 }
116116 if (is_array ($ data )) {
117117 foreach ($ data as $ key => $ value ) {
118118 $ data [$ key ] = $ this ->marshal ($ ctx , $ value );
119119 }
120120 }
121- return serialize ( $ data) ;
121+ return $ data ;
122122 }
123123
124124 private function unmarshal ($ data ): mixed
@@ -169,7 +169,7 @@ private function _call_function(Context $ctx): void
169169 throw new Exception ("function[ {$ fn }] not found " );
170170 }
171171 $ result = $ fn (...$ args );
172- $ ctx ->end (['code ' => 0 , 'result ' => $ this ->marshal ($ ctx , $ result )]);
172+ $ ctx ->end (['code ' => 0 , 'result ' => serialize ( $ this ->marshal ($ ctx , $ result) )]);
173173 }
174174
175175 /**
@@ -192,7 +192,7 @@ private function _call_method(Context $ctx): void
192192 throw new Exception ("method[ {$ class }:: {$ method }] not found " );
193193 }
194194 $ result = $ obj ->{$ method }(...$ args );
195- $ ctx ->end (['code ' => 0 , 'result ' => $ this ->marshal ($ ctx , $ result )]);
195+ $ ctx ->end (['code ' => 0 , 'result ' => serialize ( $ this ->marshal ($ ctx , $ result) )]);
196196 }
197197
198198 /**
@@ -207,7 +207,7 @@ private function _read_property(Context $ctx): void
207207 }
208208 $ obj = $ this ->objects [$ object_id ];
209209 $ result = $ obj ->{$ property };
210- $ ctx ->end (['code ' => 0 , 'property ' => $ this ->marshal ($ ctx , $ result )]);
210+ $ ctx ->end (['code ' => 0 , 'property ' => serialize ( $ this ->marshal ($ ctx , $ result) )]);
211211 }
212212
213213 /**
@@ -258,7 +258,7 @@ private function _offset_get(Context $ctx): void
258258 }
259259 $ obj = $ this ->objects [$ object_id ];
260260 $ result = $ obj ->{$ offset };
261- $ ctx ->end (['code ' => 0 , 'value ' => $ this ->marshal ($ ctx , $ result )]);
261+ $ ctx ->end (['code ' => 0 , 'value ' => serialize ( $ this ->marshal ($ ctx , $ result) )]);
262262 }
263263
264264 private function _offset_set (Context $ ctx ): void
@@ -295,6 +295,6 @@ private function _offset_exists(Context $ctx): void
295295 }
296296 $ obj = $ this ->objects [$ object_id ];
297297 $ result = isset ($ obj ->{$ offset });
298- $ ctx ->end (['code ' => 0 , 'value ' => $ this ->marshal ($ ctx , $ result )]);
298+ $ ctx ->end (['code ' => 0 , 'value ' => serialize ( $ this ->marshal ($ ctx , $ result) )]);
299299 }
300300}
0 commit comments