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

Method NewContext

engine/engine.go:61–77  ·  view source on GitHub ↗

NewContext creates a new execution context for the active engine and returns an error if the execution context failed to initialize at any point. This corresponds to PHP's RINIT (request init) phase.

()

Source from the content-addressed store, hash-verified

59// an error if the execution context failed to initialize at any point. This
60// corresponds to PHP's RINIT (request init) phase.
61func (e *Engine) NewContext() (*Context, error) {
62 ptr, err := C.context_new()
63 if err != nil {
64 return nil, fmt.Errorf("Failed to initialize context for PHP engine")
65 }
66
67 ctx := &Context{
68 Header: make(http.Header),
69 context: ptr,
70 values: make([]*Value, 0),
71 }
72
73 // Store reference to context, using pointer as key.
74 e.contexts[ptr] = ctx
75
76 return ctx, nil
77}
78
79// Define registers a PHP class for the name passed, using function fn as
80// constructor for individual object instances as needed by the PHP context.

Callers 15

TestContextNewFunction · 0.80
TestContextExecFunction · 0.80
TestContextEvalFunction · 0.80
TestContextHeaderFunction · 0.80
TestContextLogFunction · 0.80
TestContextBindFunction · 0.80
TestContextDestroyFunction · 0.80
TestReceiverDefineFunction · 0.80
TestReceiverDestroyFunction · 0.80
TestEngineNewContextFunction · 0.80
TestValueNewFunction · 0.80
TestValueNewInvalidFunction · 0.80

Calls

no outgoing calls

Tested by 15

TestContextNewFunction · 0.64
TestContextExecFunction · 0.64
TestContextEvalFunction · 0.64
TestContextHeaderFunction · 0.64
TestContextLogFunction · 0.64
TestContextBindFunction · 0.64
TestContextDestroyFunction · 0.64
TestReceiverDefineFunction · 0.64
TestReceiverDestroyFunction · 0.64
TestEngineNewContextFunction · 0.64
TestValueNewFunction · 0.64
TestValueNewInvalidFunction · 0.64