MCPcopy Index your code
hub / github.com/php/frankenphp / goValue

Function goValue

types.go:269–364  ·  view source on GitHub ↗
(zval *C.zval)

Source from the content-addressed store, hash-verified

267}
268
269func goValue[T any](zval *C.zval) (res T, err error) {
270 var (
271 resAny any
272 resZero T
273 )
274 t := C.zval_get_type(zval)
275
276 switch t {
277 case C.IS_NULL:
278 resAny = any(nil)
279 case C.IS_FALSE:
280 resAny = any(false)
281 case C.IS_TRUE:
282 resAny = any(true)
283 case C.IS_LONG:
284 v, err := extractZvalValue(zval, C.IS_LONG)
285 if err != nil {
286 return resZero, err
287 }
288
289 if v != nil {
290 resAny = any(int64(*(*C.zend_long)(v)))
291
292 break
293 }
294
295 resAny = any(int64(0))
296 case C.IS_DOUBLE:
297 v, err := extractZvalValue(zval, C.IS_DOUBLE)
298 if err != nil {
299 return resZero, err
300 }
301
302 if v != nil {
303 resAny = any(float64(*(*C.double)(v)))
304
305 break
306 }
307
308 resAny = any(float64(0))
309 case C.IS_STRING:
310 v, err := extractZvalValue(zval, C.IS_STRING)
311 if err != nil {
312 return resZero, err
313 }
314
315 if v == nil {
316 resAny = any("")
317
318 break
319 }
320
321 resAny = any(GoString(v))
322 case C.IS_ARRAY:
323 v, err := extractZvalValue(zval, C.IS_ARRAY)
324 if err != nil {
325 return resZero, err
326 }

Callers

nothing calls this directly

Calls 4

extractZvalValueFunction · 0.85
GoStringFunction · 0.85
htIsPackedFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected