Documentation
¶
Index ¶
- Constants
- Variables
- func GetConstantExtName(name string) string
- func HasExt(name string) bool
- func NewBufContext(ctx phpv.Context, b io.Writer) phpv.Context
- func ParseQueryToArray(ctx phpv.Context, q string, a *phpv.ZArray) error
- func RegisterExt(e *Ext)
- func WithConfig(parent phpv.Context, name phpv.ZString, v *phpv.ZVal) phpv.Context
- func WithFuncName(parent phpv.Context, name string) phpv.Context
- type BufContext
- type Buffer
- func (b *Buffer) CallbackName() string
- func (b *Buffer) Clean() error
- func (b *Buffer) ClearCaller()
- func (b *Buffer) Close() error
- func (b *Buffer) CloseClean() error
- func (b *Buffer) CloseWithFlags(flag int, writeOutput bool) error
- func (b *Buffer) Flush() error
- func (b *Buffer) Get() []byte
- func (b *Buffer) IsCleanable() bool
- func (b *Buffer) IsFlushable() bool
- func (b *Buffer) IsRemovable() bool
- func (b *Buffer) Level() int
- func (b *Buffer) Parent() *Buffer
- func (b *Buffer) SetCaller(ctx phpv.Context, funcName string)
- func (b *Buffer) StatusFlags() int
- func (b *Buffer) Type() int
- func (b *Buffer) Write(d []byte) (int, error)
- type ErrClassRedeclare
- type Ext
- type ExtFunction
- type ExtFunctionArg
- type Flusher
- type FuncContext
- func (c *FuncContext) AsVal(ctx phpv.Context, t phpv.ZType) (phpv.Val, error)
- func (c *FuncContext) CallSiteLoc() *phpv.Loc
- func (c *FuncContext) Callable() phpv.Callable
- func (c *FuncContext) CalledClass() phpv.ZClass
- func (c *FuncContext) Class() phpv.ZClass
- func (c *FuncContext) ClosureStaticVarKey() uintptr
- func (c *FuncContext) Count(ctx phpv.Context) phpv.ZInt
- func (ctx *FuncContext) Deprecated(format string, a ...any) error
- func (ctx *FuncContext) Error(err error, t ...phpv.PhpErrorType) error
- func (ctx *FuncContext) Errorf(format string, a ...any) error
- func (c *FuncContext) Func() phpv.FuncContext
- func (ctx *FuncContext) FuncError(err error, t ...phpv.PhpErrorType) error
- func (ctx *FuncContext) FuncErrorf(format string, a ...any) error
- func (ctx *FuncContext) GetFuncName() string
- func (ctx *FuncContext) GetFuncNameForTrace() string
- func (c *FuncContext) GetType() phpv.ZType
- func (c *FuncContext) InternalLoc() *phpv.Loc
- func (c *FuncContext) Loc() *phpv.Loc
- func (c *FuncContext) NewIterator() phpv.ZIterator
- func (ctx *FuncContext) Notice(format string, a ...any) error
- func (c *FuncContext) OffsetCheck(ctx phpv.Context, name phpv.Val) (*phpv.ZVal, bool, error)
- func (c *FuncContext) OffsetExists(ctx phpv.Context, name phpv.Val) (bool, error)
- func (c *FuncContext) OffsetGet(ctx phpv.Context, name phpv.Val) (*phpv.ZVal, error)
- func (c *FuncContext) OffsetSet(ctx phpv.Context, name phpv.Val, v *phpv.ZVal) error
- func (c *FuncContext) OffsetUnset(ctx phpv.Context, name phpv.Val) error
- func (ctx *FuncContext) Parent(n int) phpv.Context
- func (c *FuncContext) RegisterForeachRefCleanup(fn func())
- func (c *FuncContext) Release() error
- func (c *FuncContext) SetUseParentScope(v bool)
- func (c *FuncContext) SuppressCalledIn() bool
- func (c *FuncContext) This() phpv.ZObject
- func (ctx *FuncContext) UserDeprecated(format string, a ...any) error
- func (ctx *FuncContext) Warn(format string, a ...any) error
- func (ctx *FuncContext) WarnDeprecated() error
- func (c *FuncContext) ZVal() *phpv.ZVal
- type Global
- func (g *Global) AppendBuffer() *Buffer
- func (g *Global) ApplyMaxMemoryLimit()
- func (g *Global) Argv() []string
- func (g *Global) Buffer() *Buffer
- func (c *Global) Call(ctx phpv.Context, f phpv.Callable, args []phpv.Runnable, ...) (*phpv.ZVal, error)
- func (g *Global) CallDestructors()
- func (g *Global) CallTickFunctions(ctx phpv.Context) error
- func (c *Global) CallZVal(ctx phpv.Context, f phpv.Callable, args []*phpv.ZVal, ...) (*phpv.ZVal, error)
- func (c *Global) CallZValInternal(ctx phpv.Context, f phpv.Callable, args []*phpv.ZVal, ...) (*phpv.ZVal, error)
- func (c *Global) CallZValNoCalledIn(ctx phpv.Context, f phpv.Callable, args []*phpv.ZVal, ...) (*phpv.ZVal, error)
- func (g *Global) Chdir(d phpv.ZString) error
- func (g *Global) CheckOpenBasedir(ctx phpv.Context, path string, funcName string) error
- func (g *Global) Class() phpv.ZClass
- func (g *Global) CleanBuffers()
- func (g *Global) ClearAutoloadFunctions()
- func (g *Global) ClearLastCallable()
- func (g *Global) Close() error
- func (g *Global) ConstantForceSet(k phpv.ZString, v phpv.Val)
- func (g *Global) ConstantGet(name phpv.ZString) (phpv.Val, bool)
- func (g *Global) ConstantGetAttributes(k phpv.ZString) []*phpv.ZAttribute
- func (g *Global) ConstantSet(k phpv.ZString, v phpv.Val) bool
- func (g *Global) ConstantSetAttributes(k phpv.ZString, attrs []*phpv.ZAttribute)
- func (g *Global) ConsumeNoDiscardPending() bool
- func (c *Global) Count(ctx phpv.Context) phpv.ZInt
- func (g *Global) Deadline() (time.Time, bool)
- func (g *Global) Deprecated(format string, a ...any) error
- func (g *Global) DiscardBuffers()
- func (c *Global) DoString(ctx phpv.Context, strCode phpv.ZString) (*phpv.ZVal, error)
- func (g *Global) DrainTempObjects()
- func (g *Global) Error(err error, t ...phpv.PhpErrorType) error
- func (g *Global) ErrorPrefix() string
- func (g *Global) Errorf(format string, a ...any) error
- func (g *Global) Exists(fn phpv.ZString) (bool, error)
- func (g *Global) Flush()
- func (g *Global) Func() phpv.FuncContext
- func (g *Global) FuncError(err error, t ...phpv.PhpErrorType) error
- func (g *Global) FuncErrorf(format string, a ...any) error
- func (g *Global) GetAllConstants() map[phpv.ZString]phpv.Val
- func (g *Global) GetAllEnv(ctx phpv.Context) *phpv.ZArray
- func (g *Global) GetAutoloadExtensions() string
- func (g *Global) GetAutoloadFunctions() []phpv.Callable
- func (g *Global) GetClass(ctx phpv.Context, name phpv.ZString, autoload bool) (phpv.ZClass, error)
- func (g *Global) GetCompilingClass() phpv.ZClass
- func (g *Global) GetConfig(name phpv.ZString, def *phpv.ZVal) *phpv.ZVal
- func (g *Global) GetConfigEntry(name phpv.ZString) *phpv.IniValue
- func (g *Global) GetDeclaredClasses() []phpv.ZString
- func (g *Global) GetDefinedFunctions(ctx phpv.Context, excludeDisabled bool) (*phpv.ZArray, error)
- func (g *Global) GetFilterRegistry() *stream.FilterRegistry
- func (g *Global) GetFuncName() string
- func (g *Global) GetFunction(ctx phpv.Context, name phpv.ZString) (phpv.Callable, error)
- func (g *Global) GetGlobalConfig(name phpv.ZString, def *phpv.ZVal) *phpv.ZVal
- func (g *Global) GetIncludedFiles() []string
- func (g *Global) GetLoadedExtensions() []string
- func (g *Global) GetRequestBody() []byte
- func (g *Global) GetScriptFile() phpv.ZString
- func (g *Global) GetSerializeContext() interface{}
- func (g *Global) GetSerializeSeenObjects() map[phpv.ZObject]bool
- func (g *Global) GetStackTrace(ctx phpv.Context) []*phpv.StackTraceEntry
- func (g *Global) GetStdin() *stream.Stream
- func (g *Global) GetStreamHandler(scheme string) (stream.Handler, bool)
- func (g *Global) GetStreamHandlers() []string
- func (g *Global) GetStrictTypes() bool
- func (g *Global) GetUserErrorHandler() (phpv.Callable, phpv.PhpErrorType, *phpv.ZVal)
- func (g *Global) GetUserExceptionHandler() phpv.Callable
- func (g *Global) Getenv(key string) (string, bool)
- func (g *Global) Getwd() phpv.ZString
- func (g *Global) Global() phpv.GlobalContext
- func (g *Global) HandleUncaughtException(err error) error
- func (g *Global) HasStreamHandler(scheme string) bool
- func (g *Global) HasTickFunctions() bool
- func (g *Global) HeaderContext() *phpv.HeaderContext
- func (c *Global) Include(ctx phpv.Context, fn phpv.ZString) (*phpv.ZVal, error)
- func (c *Global) IncludeOnce(ctx phpv.Context, fn phpv.ZString) (*phpv.ZVal, error)
- func (g *Global) InitBaselineMemory()
- func (g *Global) IsFunctionDisabled(name phpv.ZString) bool
- func (g *Global) IsJsonEncoding(obj phpv.ZObject) bool
- func (g *Global) IsObDisabled() bool
- func (g *Global) IsUploadedFile(path string) bool
- func (g *Global) IsWithinOpenBasedir(path string) bool
- func (g *Global) IterateConfig() iter.Seq2[string, phpv.IniValue]
- func (g *Global) LastCallable() phpv.Callable
- func (g *Global) Loc() *phpv.Loc
- func (g *Global) LogError(err *phpv.PhpError, optionArg ...logopt.Data)
- func (g *Global) MarkJsonEncoding(obj phpv.ZObject) bool
- func (g *Global) MemAlloc(ctx phpv.Context, s uint64) error
- func (g *Global) MemLimit() uint64
- func (g *Global) MemMgrTracker() phpv.MemTracker
- func (g *Global) MemPeakUsage() int64
- func (g *Global) MemResetPeak()
- func (g *Global) MemUsage() int64
- func (c *Global) NewIterator() phpv.ZIterator
- func (g *Global) NextObjectID() int
- func (g *Global) NextResourceID() int
- func (g *Global) Notice(format string, a ...any) error
- func (c *Global) OffsetCheck(ctx phpv.Context, name phpv.Val) (*phpv.ZVal, bool, error)
- func (c *Global) OffsetExists(ctx phpv.Context, name phpv.Val) (bool, error)
- func (c *Global) OffsetGet(ctx phpv.Context, name phpv.Val) (*phpv.ZVal, error)
- func (c *Global) OffsetSet(ctx phpv.Context, name phpv.Val, v *phpv.ZVal) error
- func (c *Global) OffsetUnset(ctx phpv.Context, name phpv.Val) error
- func (g *Global) Open(ctx phpv.Context, fn phpv.ZString, mode phpv.ZString, useIncludePath bool, ...) (phpv.Stream, error)
- func (g *Global) OpenFile(ctx phpv.Context, path string) (io.ReadCloser, error)
- func (c *Global) Parent(n int) phpv.Context
- func (g *Global) Random() *random.State
- func (g *Global) RegisterAutoload(handler phpv.Callable, prepend bool)
- func (g *Global) RegisterClass(name phpv.ZString, c phpv.ZClass) error
- func (g *Global) RegisterDestructor(obj phpv.ZObject)
- func (g *Global) RegisterFunction(name phpv.ZString, f phpv.Callable) error
- func (g *Global) RegisterLazyClass(name phpv.ZString, r phpv.Runnables, p int)
- func (g *Global) RegisterLazyFunc(name phpv.ZString, r phpv.Runnables, p int)
- func (g *Global) RegisterShutdownFunction(f phpv.Callable)
- func (g *Global) RegisterStreamHandler(scheme string, handler stream.Handler)
- func (g *Global) RegisterTempFile(path string)
- func (g *Global) RegisterTempObject(id int, isFree func() bool)
- func (g *Global) RegisterTickFunction(cb phpv.Callable, args []*phpv.ZVal)
- func (g *Global) RegisterUploadedFile(path string)
- func (g *Global) ReinitSuperglobals()
- func (g *Global) ReleaseObjectID(id int)
- func (c *Global) Require(ctx phpv.Context, fn phpv.ZString) (*phpv.ZVal, error)
- func (c *Global) RequireOnce(ctx phpv.Context, fn phpv.ZString) (*phpv.ZVal, error)
- func (g *Global) ResetDeadline()
- func (g *Global) RestoreConfig(name phpv.ZString)
- func (g *Global) RestoreUserErrorHandler()
- func (g *Global) RestoreUserExceptionHandler()
- func (g *Global) RunFile(fn string) error
- func (g *Global) RunShutdownFunctions()
- func (g *Global) SetAutoloadExtensions(exts string)
- func (g *Global) SetCompilingClass(c phpv.ZClass)
- func (g *Global) SetDeadline(t time.Time)
- func (g *Global) SetLocalConfig(name phpv.ZString, value *phpv.ZVal) (*phpv.ZVal, bool)
- func (g *Global) SetNextCallSuppressCalledIn(v bool)
- func (g *Global) SetNoDiscardPending(v bool)
- func (g *Global) SetObDisabled()
- func (g *Global) SetOutput(w io.Writer)
- func (g *Global) SetSerializeContext(c interface{})
- func (g *Global) SetSerializeSeenObjects(m map[phpv.ZObject]bool)
- func (g *Global) SetSkipNextDynPropDeprecation(v bool)
- func (g *Global) SetStdin(r io.Reader)
- func (g *Global) SetStrictTypes(v bool)
- func (g *Global) SetUserErrorHandler(handler phpv.Callable, filter phpv.PhpErrorType, originalVal *phpv.ZVal)
- func (g *Global) SetUserExceptionHandler(handler phpv.Callable, originalVal *phpv.ZVal) *phpv.ZVal
- func (g *Global) Setenv(key, value string) error
- func (g *Global) ShownDeprecated(key string) bool
- func (g *Global) TakeSkipNextDynPropDeprecation() bool
- func (g *Global) This() phpv.ZObject
- func (g *Global) Tick(ctx phpv.Context, l *phpv.Loc) error
- func (g *Global) UnmarkJsonEncoding(obj phpv.ZObject)
- func (g *Global) UnregisterAutoload(handler phpv.Callable) bool
- func (g *Global) UnregisterAutoloadByName(name string) bool
- func (g *Global) UnregisterClass(name phpv.ZString)
- func (g *Global) UnregisterDestructor(obj phpv.ZObject)
- func (g *Global) UnregisterStreamHandler(scheme string) bool
- func (g *Global) UnregisterTickFunction(cb phpv.Callable)
- func (g *Global) UnregisterUploadedFile(path string)
- func (g *Global) Unsetenv(key string) error
- func (g *Global) UserDeprecated(format string, a ...any) error
- func (g *Global) Warn(format string, a ...any) error
- func (g *Global) WarnDeprecated() error
- func (g *Global) Write(v []byte) (int, error)
- func (g *Global) WriteErr(v []byte) (int, error)
- func (g *Global) WriteStartupWarning(msg string)
- type MemMgr
- func (m *MemMgr) Alloc(size int64) error
- func (m *MemMgr) Copy(dst io.Writer, src io.Reader) (written int64, err error)
- func (m *MemMgr) Free(size int64)
- func (m *MemMgr) Limit() int64
- func (m *MemMgr) MemAlloc(size int64) error
- func (m *MemMgr) MemFree(size int64)
- func (m *MemMgr) PeakUsage() int64
- func (m *MemMgr) ResetPeak()
- func (m *MemMgr) SetLimit(limit int64)
- func (m *MemMgr) Usage() int64
- type OpenContext
- type Process
- type ProcessOptions
Constants ¶
const ( BufferWrite = 0 BufferStart = 0x0001 BufferClean = 0x0002 BufferFlush = 0x0004 BufferFinal = 0x0008 BufferCleanable = 0x0010 BufferFlushable = 0x0020 BufferRemovable = 0x0040 // Status flags (reported by ob_get_status, not user-settable) BufferTypeUser = 0x0001 // bit 0 in type field; also set in flags for user handlers BufferStarted = 0x1000 BufferDisabled = 0x2000 BufferProcessed = 0x4000 )
const ( PHP_OUTPUT_HANDLER_START = phpv.ZInt(BufferStart) PHP_OUTPUT_HANDLER_WRITE = phpv.ZInt(BufferWrite) PHP_OUTPUT_HANDLER_FLUSH = phpv.ZInt(BufferFlush) PHP_OUTPUT_HANDLER_CLEAN = phpv.ZInt(BufferClean) PHP_OUTPUT_HANDLER_FINAL = phpv.ZInt(BufferFinal) PHP_OUTPUT_HANDLER_CONT = phpv.ZInt(BufferWrite) PHP_OUTPUT_HANDLER_END = phpv.ZInt(BufferFinal) PHP_OUTPUT_HANDLER_CLEANABLE = phpv.ZInt(BufferCleanable) PHP_OUTPUT_HANDLER_FLUSHABLE = phpv.ZInt(BufferFlushable) PHP_OUTPUT_HANDLER_REMOVABLE = phpv.ZInt(BufferRemovable) )
> const
const ( PHP_OUTPUT_HANDLER_STARTED = phpv.ZInt(BufferStarted) PHP_OUTPUT_HANDLER_DISABLED = phpv.ZInt(BufferDisabled) PHP_OUTPUT_HANDLER_PROCESSED = phpv.ZInt(BufferProcessed) )
> const
Variables ¶
var ErrOpenBasedir = &phpv.PhpError{Code: phpv.E_WARNING}
ErrOpenBasedir is returned when an open_basedir restriction blocks file access.
var PHP_OUTPUT_HANDLER_STDFLAGS = phpv.ZInt(BufferCleanable | BufferFlushable | BufferRemovable)
> const
Functions ¶
func GetConstantExtName ¶
GetConstantExtName returns the name of the extension that defines the given constant, or "" if the constant was not registered by any extension.
func ParseQueryToArray ¶
ParseQueryToArray will parse a given query string into a ZArray with PHP parsing rules
func RegisterExt ¶
func RegisterExt(e *Ext)
func WithConfig ¶
Types ¶
type BufContext ¶
type Buffer ¶
type Buffer struct {
ImplicitFlush bool
ChunkSize int
CB phpv.Callable
Flags int // capability flags (cleanable/flushable/removable)
// contains filtered or unexported fields
}
func (*Buffer) CallbackName ¶
CallbackName returns the display name of the callback for ob_get_status/ob_list_handlers.
func (*Buffer) ClearCaller ¶
func (b *Buffer) ClearCaller()
ClearCaller removes the calling function context.
func (*Buffer) CloseClean ¶
CloseClean closes and discards the buffer (ob_end_clean behavior). Invokes callback with CLEAN|FINAL, discards result, removes buffer.
func (*Buffer) CloseWithFlags ¶
CloseWithFlags closes the buffer with the given flags. If writeOutput is true, writes the callback result to the underlying writer.
func (*Buffer) IsCleanable ¶
func (*Buffer) IsFlushable ¶
func (*Buffer) IsRemovable ¶
func (*Buffer) SetCaller ¶
SetCaller stores the calling function context for deprecation warnings. The location is captured at call time so it doesn't change during callback execution.
func (*Buffer) StatusFlags ¶
StatusFlags returns the combined flags for ob_get_status reporting.
type ErrClassRedeclare ¶
type ErrClassRedeclare struct {
Kind string // "class", "interface", or "trait"
ExistingName phpv.ZString // original name of existing class
RegisterName phpv.ZString // name being registered
PrevLoc string // " (previously declared in ...)" or ""
IsAlias bool // existing name differs from registered name (class_alias case)
}
ErrClassRedeclare is returned when a class name is already registered. IsAlias indicates the existing registration was under a different name (i.e. via class_alias).
func (*ErrClassRedeclare) Error ¶
func (e *ErrClassRedeclare) Error() string
func (*ErrClassRedeclare) IsAliasConflict ¶
func (e *ErrClassRedeclare) IsAliasConflict() bool
func (*ErrClassRedeclare) RedeclareKind ¶
func (e *ErrClassRedeclare) RedeclareKind() string
func (*ErrClassRedeclare) RedeclarePrevLoc ¶
func (e *ErrClassRedeclare) RedeclarePrevLoc() string
type Ext ¶
type Ext struct {
Name string
Version string
Functions map[string]*ExtFunction
Constants map[phpv.ZString]phpv.Val
Classes []*phpobj.ZClass
// OnGlobalCreate is an optional callback invoked when a new Global context is created.
// Extensions can use it to register per-Global resources such as stream handlers.
OnGlobalCreate func(g *Global)
}
type ExtFunction ¶
type ExtFunction struct {
phpv.CallableVal
Ext string // extension name, populated by RegisterExt
Func func(ctx phpv.Context, args []*phpv.ZVal) (*phpv.ZVal, error)
Args []*ExtFunctionArg
MinArgs int // minimum required arguments (0 = no check)
MaxArgs int // maximum allowed arguments (0 = no check, -1 = variadic/unlimited)
ZeroArgs bool // if true, the function accepts exactly 0 arguments (MaxArgs=0 special case)
// contains filtered or unexported fields
}
func (*ExtFunction) GetArgs ¶
func (e *ExtFunction) GetArgs() []*phpv.FuncArg
GetArgs implements phpv.FuncGetArgs, returning cached parameter metadata. Returns nil for functions without declared Args (most built-in functions), which signals to callZValImpl that Go-side argument handling applies.
func (*ExtFunction) GetExt ¶
func (e *ExtFunction) GetExt() string
func (*ExtFunction) Name ¶
func (e *ExtFunction) Name() string
type ExtFunctionArg ¶
type FuncContext ¶
type FuncContext struct {
phpv.Context
Args []*phpv.ZVal
// contains filtered or unexported fields
}
func GetFuncContext ¶
func GetFuncContext() *FuncContext
GetFuncContext retrieves a FuncContext from the pool
func (*FuncContext) CallSiteLoc ¶
func (c *FuncContext) CallSiteLoc() *phpv.Loc
CallSiteLoc returns the frozen location (file/line) from which this function was called, as set during callZValImpl setup. This differs from Loc() which returns the current execution position in the parent context. Implements phpv.CallSiteLocProvider.
func (*FuncContext) Callable ¶
func (c *FuncContext) Callable() phpv.Callable
func (*FuncContext) CalledClass ¶
func (c *FuncContext) CalledClass() phpv.ZClass
func (*FuncContext) Class ¶
func (c *FuncContext) Class() phpv.ZClass
func (*FuncContext) ClosureStaticVarKey ¶
func (c *FuncContext) ClosureStaticVarKey() uintptr
ClosureStaticVarKey returns the per-closure-instance key for static variable storage. This implements phpv.ClosureStaticVarKeyProvider. Returns 0 when not running inside a closure instance (e.g. named functions, class methods).
func (*FuncContext) Deprecated ¶
func (ctx *FuncContext) Deprecated(format string, a ...any) error
func (*FuncContext) Error ¶
func (ctx *FuncContext) Error(err error, t ...phpv.PhpErrorType) error
func (*FuncContext) Func ¶
func (c *FuncContext) Func() phpv.FuncContext
func (*FuncContext) FuncError ¶
func (ctx *FuncContext) FuncError(err error, t ...phpv.PhpErrorType) error
func (*FuncContext) FuncErrorf ¶
func (ctx *FuncContext) FuncErrorf(format string, a ...any) error
func (*FuncContext) GetFuncName ¶
func (ctx *FuncContext) GetFuncName() string
func (*FuncContext) GetFuncNameForTrace ¶
func (ctx *FuncContext) GetFuncNameForTrace() string
GetFuncNameForTrace returns the function name using the actual method type (-> or ::) for stack traces
func (*FuncContext) GetType ¶
func (c *FuncContext) GetType() phpv.ZType
func (*FuncContext) InternalLoc ¶
func (c *FuncContext) InternalLoc() *phpv.Loc
InternalLoc returns the "internal" location (Unknown:0) for internal calls, or nil for regular calls. Used by deprecation/warning logic to report the correct location for engine-invoked callbacks.
func (*FuncContext) Loc ¶
func (c *FuncContext) Loc() *phpv.Loc
Loc returns the current source-code location. It always delegates to the parent context which tracks the current execution position via Tick(). The isInternal flag only affects stack trace formatting (showing "[internal function]"), not Loc().
func (*FuncContext) NewIterator ¶
func (c *FuncContext) NewIterator() phpv.ZIterator
func (*FuncContext) OffsetCheck ¶
func (*FuncContext) OffsetExists ¶
func (*FuncContext) OffsetUnset ¶
func (*FuncContext) RegisterForeachRefCleanup ¶
func (c *FuncContext) RegisterForeachRefCleanup(fn func())
RegisterForeachRefCleanup registers a cleanup function to be called when this function context is released, for cleaning up foreach-by-reference iterator references.
func (*FuncContext) Release ¶
func (c *FuncContext) Release() error
Release returns the FuncContext to the pool after clearing it. It returns an error if any destructor triggered during scope cleanup throws an exception.
func (*FuncContext) SetUseParentScope ¶
func (c *FuncContext) SetUseParentScope(v bool)
SetUseParentScope sets whether this FuncContext should delegate variable access (OffsetGet/OffsetSet/OffsetCheck/OffsetUnset/OffsetExists) to the parent context. Used by eval() so that variables are accessible in the calling scope while the eval FuncContext remains visible in stack traces.
func (*FuncContext) SuppressCalledIn ¶
func (c *FuncContext) SuppressCalledIn() bool
SuppressCalledIn reports whether the "called in X on line Y" suffix should be suppressed from argument-count and type error messages for this call.
func (*FuncContext) This ¶
func (c *FuncContext) This() phpv.ZObject
func (*FuncContext) UserDeprecated ¶
func (ctx *FuncContext) UserDeprecated(format string, a ...any) error
func (*FuncContext) WarnDeprecated ¶
func (ctx *FuncContext) WarnDeprecated() error
func (*FuncContext) ZVal ¶
func (c *FuncContext) ZVal() *phpv.ZVal
type Global ¶
type Global struct {
context.Context
IniConfig phpv.IniConfig
StreamFilterRegistry *stream.FilterRegistry
ImplicitFlush bool
DefaultStreamContext *stream.Context
// Last error tracked for error_get_last() / error_clear_last()
LastError *phpv.PhpError
// Serialize recursion detection across nested serialize calls
// (especially Serializable::serialize() calling serialize() internally)
SerializeSeenObjects map[phpv.ZObject]bool
// SerializeContext stores a pointer to the current outermost serializeSeen
// so that nested serialize() calls (from Serializable::serialize()) can share it.
SerializeContext interface{}
// StrictTypes tracks whether the currently executing file has declare(strict_types=1).
// This is a per-file flag that affects type coercion at call sites.
StrictTypes bool
// contains filtered or unexported fields
}
func (*Global) AppendBuffer ¶
func (*Global) ApplyMaxMemoryLimit ¶
func (g *Global) ApplyMaxMemoryLimit()
ApplyMaxMemoryLimit should be called after INI parsing to enforce max_memory_limit on the initial memory_limit value and sync the MemMgr limit.
func (*Global) Call ¶
func (c *Global) Call(ctx phpv.Context, f phpv.Callable, args []phpv.Runnable, optionalThis ...phpv.ZObject) (*phpv.ZVal, error)
perform call in new context
func (*Global) CallDestructors ¶
func (g *Global) CallDestructors()
CallDestructors calls __destruct on all remaining tracked objects. Exceptions thrown by destructors are passed to handleUncaughtException.
func (*Global) CallTickFunctions ¶
CallTickFunctions invokes all registered tick functions
func (*Global) CallZValInternal ¶
func (c *Global) CallZValInternal(ctx phpv.Context, f phpv.Callable, args []*phpv.ZVal, optionalThis ...phpv.ZObject) (*phpv.ZVal, error)
CallZValInternal is like CallZVal but marks the call as internal (e.g., from output buffer callbacks). This causes the stack trace entry to show "[internal function]" instead of the filename.
func (*Global) CallZValNoCalledIn ¶
func (c *Global) CallZValNoCalledIn(ctx phpv.Context, f phpv.Callable, args []*phpv.ZVal, optionalThis ...phpv.ZObject) (*phpv.ZVal, error)
CallZValNoCalledIn is like CallZVal but suppresses the "called in" suffix in type error messages. Used when invoking closures via __invoke method dispatch, where PHP does not append "called in" to type error messages.
func (*Global) CheckOpenBasedir ¶
CheckOpenBasedir checks if the given path is within the open_basedir restriction. Returns nil if access is allowed, or a sentinel error (ErrOpenBasedir) if restricted. A warning is emitted when access is blocked. The funcName parameter is used in the warning message (e.g. "file_exists").
func (*Global) CleanBuffers ¶
func (g *Global) CleanBuffers()
CleanBuffers discards buffered content in all active output buffers without closing them. The buffers remain active so subsequent writes (like fatal error messages) still pass through their callbacks.
func (*Global) ClearAutoloadFunctions ¶
func (g *Global) ClearAutoloadFunctions()
func (*Global) ClearLastCallable ¶
func (g *Global) ClearLastCallable()
func (*Global) ConstantForceSet ¶
ConstantForceSet sets a constant value, overwriting any existing value. Used for __COMPILER_HALT_OFFSET__ which is per-file.
func (*Global) ConstantGetAttributes ¶
func (g *Global) ConstantGetAttributes(k phpv.ZString) []*phpv.ZAttribute
func (*Global) ConstantSetAttributes ¶
func (g *Global) ConstantSetAttributes(k phpv.ZString, attrs []*phpv.ZAttribute)
func (*Global) ConsumeNoDiscardPending ¶
func (*Global) DiscardBuffers ¶
func (g *Global) DiscardBuffers()
DiscardBuffers discards all output buffer content without flushing. Used on fatal errors to prevent buffered output from leaking.
func (*Global) DrainTempObjects ¶
func (g *Global) DrainTempObjects()
DrainTempObjects checks all registered temporary objects and releases any that are still unreferenced (refcount == 0). Called at statement boundaries.
func (*Global) ErrorPrefix ¶
ErrorPrefix returns "\n" if prior output exists and didn't end with a newline, matching PHP's behavior of separating inline output from error messages. Returns "" when the error is the first output.
func (*Global) Func ¶
func (g *Global) Func() phpv.FuncContext
func (*Global) GetAllConstants ¶
GetAllConstants returns all defined constants.
func (*Global) GetAutoloadExtensions ¶
func (*Global) GetAutoloadFunctions ¶
func (*Global) GetCompilingClass ¶
func (*Global) GetConfigEntry ¶
GetConfigEntry returns the raw IniValue for a config entry, or nil if the config option doesn't exist. Unlike GetConfig, this allows callers to distinguish between "not set" and "set to empty".
func (*Global) GetDeclaredClasses ¶
func (*Global) GetDefinedFunctions ¶
func (*Global) GetFilterRegistry ¶
func (g *Global) GetFilterRegistry() *stream.FilterRegistry
GetFilterRegistry returns the per-request stream filter registry. Implements stream.FilterRegistryProvider.
func (*Global) GetFuncName ¶
func (*Global) GetFunction ¶
func (*Global) GetGlobalConfig ¶
func (*Global) GetIncludedFiles ¶
GetIncludedFiles returns a list of all included/required file paths.
func (*Global) GetLoadedExtensions ¶
func (*Global) GetRequestBody ¶
GetRequestBody returns the raw request body for php://input
func (*Global) GetScriptFile ¶
func (*Global) GetSerializeContext ¶
func (g *Global) GetSerializeContext() interface{}
GetSerializeContext returns the current serialize context (may be nil).
func (*Global) GetSerializeSeenObjects ¶
GetSerializeSeenObjects returns the current serialize object tracking map (may be nil).
func (*Global) GetStackTrace ¶
func (g *Global) GetStackTrace(ctx phpv.Context) []*phpv.StackTraceEntry
func (*Global) GetStreamHandler ¶
GetStreamHandler returns the registered stream handler for a scheme.
func (*Global) GetStreamHandlers ¶
GetStreamHandlers returns all registered stream handler scheme names.
func (*Global) GetStrictTypes ¶
GetStrictTypes returns the current strict_types flag.
func (*Global) GetUserErrorHandler ¶
func (*Global) GetUserExceptionHandler ¶
func (*Global) Global ¶
func (g *Global) Global() phpv.GlobalContext
func (*Global) HandleUncaughtException ¶
HandleUncaughtException handles an uncaught exception by calling the user exception handler if one is registered. Returns nil if the exception was handled, or the (possibly new) error if it wasn't.
PHP behavior:
- The exception handler is temporarily removed during invocation to prevent re-entrancy.
- After the handler completes (successfully or not), the handler is restored.
- If the handler throws a new exception, check if the handler registered a new handler during its execution; if so, use the new handler for the new exception (recursively).
- If no handler is available for a thrown exception, return it as-is.
func (*Global) HasStreamHandler ¶
HasStreamHandler checks if a scheme has a registered stream handler.
func (*Global) HasTickFunctions ¶
HasTickFunctions returns true if any tick functions are registered
func (*Global) HeaderContext ¶
func (g *Global) HeaderContext() *phpv.HeaderContext
func (*Global) IncludeOnce ¶
func (*Global) InitBaselineMemory ¶
func (g *Global) InitBaselineMemory()
InitBaselineMemory records the current memory usage as the baseline for this Global context, so Tick() can measure per-script usage.
func (*Global) IsFunctionDisabled ¶
IsObDisabled returns whether the OB system has been disabled. IsFunctionDisabled returns true if the named function is disabled via disable_functions INI.
func (*Global) IsJsonEncoding ¶
IsJsonEncoding reports whether the object is currently being json-encoded via JsonSerializable (without marking it).
func (*Global) IsObDisabled ¶
func (*Global) IsUploadedFile ¶
IsUploadedFile checks if the given path was registered as an uploaded file.
func (*Global) IsWithinOpenBasedir ¶
IsWithinOpenBasedir checks if the given path is within the open_basedir restriction without emitting any warnings. Returns true if access would be allowed.
func (*Global) LastCallable ¶
func (*Global) MarkJsonEncoding ¶
MarkJsonEncoding marks an object as currently being json-encoded. Returns true if the object was already being encoded (recursion detected).
func (*Global) MemMgrTracker ¶
func (g *Global) MemMgrTracker() phpv.MemTracker
MemMgr returns the memory manager, which implements phpv.MemTracker.
func (*Global) MemPeakUsage ¶
MemPeakUsage returns the peak tracked PHP memory usage in bytes.
func (*Global) MemResetPeak ¶
func (g *Global) MemResetPeak()
MemResetPeak sets peak = current tracked usage.
func (*Global) NewIterator ¶
func (*Global) NextObjectID ¶
func (*Global) NextResourceID ¶
func (*Global) OffsetCheck ¶
func (*Global) OffsetExists ¶
func (*Global) Open ¶
func (g *Global) Open(ctx phpv.Context, fn phpv.ZString, mode phpv.ZString, useIncludePath bool, streamContext ...phpv.Resource) (phpv.Stream, error)
Open opens a file using PHP stream wrappers and returns a handler to said file.
func (*Global) OpenFile ¶
OpenFile opens a file for reading through the global file access layer. This centralizes file access so it can later be scoped to an fs.FS.
func (*Global) RegisterAutoload ¶
func (*Global) RegisterClass ¶
func (*Global) RegisterDestructor ¶
func (*Global) RegisterFunction ¶
func (*Global) RegisterLazyClass ¶
func (*Global) RegisterLazyFunc ¶
func (*Global) RegisterShutdownFunction ¶
func (*Global) RegisterStreamHandler ¶
func (*Global) RegisterTempFile ¶
RegisterTempFile registers a temporary file path for cleanup when the request ends. Used for uploaded file temp files.
func (*Global) RegisterTempObject ¶
RegisterTempObject registers an object ID as a "temporary" that should be released if it has refcount 0 at the next statement boundary.
func (*Global) RegisterTickFunction ¶
RegisterTickFunction adds a tick function to be called every N statements
func (*Global) RegisterUploadedFile ¶
RegisterUploadedFile registers a file path as an uploaded file for is_uploaded_file() and move_uploaded_file() checks.
func (*Global) ReinitSuperglobals ¶
func (g *Global) ReinitSuperglobals()
ReinitSuperglobals re-initializes superglobals ($_GET, $_POST, $_SERVER, etc.) based on current INI settings. Call this after changing INI settings like variables_order or register_argc_argv that affect superglobal population.
func (*Global) ReleaseObjectID ¶
func (*Global) RequireOnce ¶
func (*Global) ResetDeadline ¶
func (g *Global) ResetDeadline()
func (*Global) RestoreConfig ¶
func (*Global) RestoreUserErrorHandler ¶
func (g *Global) RestoreUserErrorHandler()
func (*Global) RestoreUserExceptionHandler ¶
func (g *Global) RestoreUserExceptionHandler()
func (*Global) RunShutdownFunctions ¶
func (g *Global) RunShutdownFunctions()
func (*Global) SetAutoloadExtensions ¶
func (*Global) SetCompilingClass ¶
func (*Global) SetDeadline ¶
func (*Global) SetLocalConfig ¶
func (*Global) SetNextCallSuppressCalledIn ¶
func (*Global) SetNoDiscardPending ¶
func (*Global) SetObDisabled ¶
func (g *Global) SetObDisabled()
SetObDisabled marks the OB system as disabled (after re-entrant fatal error).
func (*Global) SetSerializeContext ¶
func (g *Global) SetSerializeContext(c interface{})
SetSerializeContext sets the serialize context.
func (*Global) SetSerializeSeenObjects ¶
SetSerializeSeenObjects sets the serialize object tracking map.
func (*Global) SetSkipNextDynPropDeprecation ¶
func (*Global) SetStdin ¶
SetStdin replaces the default stdin with a custom reader (useful for testing).
func (*Global) SetStrictTypes ¶
SetStrictTypes sets the strict_types flag for the current execution context.
func (*Global) SetUserErrorHandler ¶
func (*Global) SetUserExceptionHandler ¶
SetUserExceptionHandler sets the exception handler and returns the original ZVal of the previous handler (so that set_exception_handler can return it).
func (*Global) ShownDeprecated ¶
func (*Global) TakeSkipNextDynPropDeprecation ¶
func (*Global) UnmarkJsonEncoding ¶
UnmarkJsonEncoding removes the json-encoding mark from an object.
func (*Global) UnregisterAutoloadByName ¶
func (*Global) UnregisterClass ¶
func (*Global) UnregisterDestructor ¶
func (*Global) UnregisterStreamHandler ¶
func (*Global) UnregisterTickFunction ¶
UnregisterTickFunction removes a tick function by callable identity
func (*Global) UnregisterUploadedFile ¶
UnregisterUploadedFile removes a file from the uploaded files set (after move).
func (*Global) WarnDeprecated ¶
func (*Global) WriteStartupWarning ¶
WriteStartupWarning buffers a warning message emitted during request startup (before output is configured). These warnings are flushed on first Write.
type MemMgr ¶
type MemMgr struct {
// contains filtered or unexported fields
}
func (*MemMgr) Alloc ¶
Alloc tracks a new PHP-level allocation of size bytes. Returns a fatal PhpError if the allocation would exceed the memory limit.
func (*MemMgr) ResetPeak ¶
func (m *MemMgr) ResetPeak()
ResetPeak sets peak = current tracked usage.
type OpenContext ¶
type OpenContext int
type Process ¶
type Process struct {
ScriptFilename string
Argv []string
Options *ProcessOptions
// contains filtered or unexported fields
}
func NewProcess ¶
NewProcess instanciates a new instance of Process, which represents a running PHP process.
func (*Process) CommandLine ¶
CommandLine will parse arguments from the command line and configure the process accordingly. If nil is passed, then the actual command line will be parsed. In case of error, messages will be sent to stderr by default.
func (*Process) Handler ¶
Hander returns a http.Handler object suitable for use with golang standard http servers and similar.
func (*Process) SetConstant ¶
SetConstant sets a global constant, typically used to set PHP_SAPI.