MCPcopy Create free account
hub / github.com/deuill/go-php / value_get_string

Function value_get_string

engine/value.c:188–215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

186}
187
188char *value_get_string(engine_value *val) {
189 zval tmp;
190 int result;
191
192 switch (val->kind) {
193 case KIND_STRING:
194 value_copy(&tmp, val->internal);
195 break;
196 case KIND_OBJECT:
197 result = zend_std_cast_object_tostring(val->internal, &tmp, IS_STRING);
198 if (result == FAILURE) {
199 ZVAL_EMPTY_STRING(&tmp);
200 }
201
202 break;
203 default:
204 value_copy(&tmp, val->internal);
205 convert_to_cstring(&tmp);
206 }
207
208 int len = Z_STRLEN(tmp) + 1;
209 char *str = malloc(len);
210 memcpy(str, Z_STRVAL(tmp), len);
211
212 zval_dtor(&tmp);
213
214 return str;
215}
216
217unsigned int value_array_size(engine_value *arr) {
218 switch (arr->kind) {

Callers

nothing calls this directly

Calls 1

value_copyFunction · 0.85

Tested by

no test coverage detected