NewValueFromPtr creates a Value type from an existing PHP value pointer.
(val unsafe.Pointer)
| 153 | |
| 154 | // NewValueFromPtr creates a Value type from an existing PHP value pointer. |
| 155 | func NewValueFromPtr(val unsafe.Pointer) (*Value, error) { |
| 156 | if val == nil { |
| 157 | return nil, fmt.Errorf("Cannot create value from 'nil' pointer") |
| 158 | } |
| 159 | |
| 160 | ptr, err := C.value_new() |
| 161 | if err != nil { |
| 162 | return nil, fmt.Errorf("Unable to create new PHP value") |
| 163 | } |
| 164 | |
| 165 | if _, err := C.value_set_zval(ptr, (*C.zval)(val)); err != nil { |
| 166 | return nil, fmt.Errorf("Unable to set PHP value from pointer") |
| 167 | } |
| 168 | |
| 169 | return &Value{value: ptr}, nil |
| 170 | } |
| 171 | |
| 172 | // Kind returns the Value's concrete kind of type. |
| 173 | func (v *Value) Kind() ValueKind { |
no outgoing calls
no test coverage detected