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

Function my_filter

testdata/integration/callable.go:28–47  ·  view source on GitHub ↗

export_php:function my_filter(array $data, ?callable $callback): array

(arr *C.zend_array, callback *C.zval)

Source from the content-addressed store, hash-verified

26
27// export_php:function my_filter(array $data, ?callable $callback): array
28func my_filter(arr *C.zend_array, callback *C.zval) unsafe.Pointer {
29 goArray, err := frankenphp.GoPackedArray[any](unsafe.Pointer(arr))
30 if err != nil {
31 return nil
32 }
33
34 if callback == nil {
35 return unsafe.Pointer(arr)
36 }
37
38 result := make([]any, 0)
39 for _, item := range goArray {
40 callResult := frankenphp.CallPHPCallable(unsafe.Pointer(callback), []any{item})
41 if boolResult, ok := callResult.(bool); ok && boolResult {
42 result = append(result, item)
43 }
44 }
45
46 return frankenphp.PHPPackedArray[any](result)
47}
48
49// export_php:class Processor
50type Processor struct{}

Callers

nothing calls this directly

Calls 1

CallPHPCallableFunction · 0.92

Tested by

no test coverage detected