phpctx

package
v0.0.0-...-60f1d27 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2025 License: BSD-3-Clause Imports: 29 Imported by: 15

Documentation

Index

Constants

View Source
const (
	BufferWrite = 0
	BufferStart = 1 << iota
	BufferClean
	BufferFlush
	BufferFinal
	BufferCleanable
	BufferFlushable
	BufferRemovable
)
View Source
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

Variables

View Source
var Compile func(parent phpv.Context, t *tokenizer.Lexer) (phpv.Runnable, error)
View Source
var PHP_OUTPUT_HANDLER_STDFLAGS = phpv.ZInt(BufferCleanable | BufferFlushable | BufferRemovable)

> const

Functions

func HasExt

func HasExt(name string) bool

func NewBufContext

func NewBufContext(ctx phpv.Context, b io.Writer) phpv.Context

func ParseQueryToArray

func ParseQueryToArray(ctx phpv.Context, q string, a *phpv.ZArray) error

ParseQueryToArray will parse a given query string into a ZArray with PHP parsing rules

func RegisterExt

func RegisterExt(e *Ext)

func WithConfig

func WithConfig(parent phpv.Context, name phpv.ZString, v *phpv.ZVal) phpv.Context

Types

type BufContext

type BufContext struct {
	phpv.Context
	// contains filtered or unexported fields
}

func (*BufContext) Write

func (b *BufContext) Write(d []byte) (int, error)

type Buffer

type Buffer struct {
	ImplicitFlush bool
	ChunkSize     int
	CB            phpv.Callable
	// contains filtered or unexported fields
}

func (*Buffer) Clean

func (b *Buffer) Clean()

func (*Buffer) Close

func (b *Buffer) Close() error

func (*Buffer) Flush

func (b *Buffer) Flush() error

func (*Buffer) Get

func (b *Buffer) Get() []byte

func (*Buffer) Level

func (b *Buffer) Level() int

func (*Buffer) Write

func (b *Buffer) Write(d []byte) (int, error)

type Ext

type Ext struct {
	Name      string
	Version   string
	Functions map[string]*ExtFunction
	Constants map[phpv.ZString]phpv.Val
	Classes   []*phpobj.ZClass
}

func GetExt

func GetExt(name string) *Ext

type ExtFunction

type ExtFunction struct {
	phpv.CallableVal

	Func func(ctx phpv.Context, args []*phpv.ZVal) (*phpv.ZVal, error)
	Args []*ExtFunctionArg
	// contains filtered or unexported fields
}

func (*ExtFunction) Call

func (e *ExtFunction) Call(ctx phpv.Context, args []*phpv.ZVal) (*phpv.ZVal, error)

func (*ExtFunction) Name

func (e *ExtFunction) Name() string

type ExtFunctionArg

type ExtFunctionArg struct {
	ArgName  string // without the $ sign
	Ref      bool
	Optional bool // is this argument optional?
}

type Flusher

type Flusher interface {
	Flush() error
}

type FuncContext

type FuncContext struct {
	phpv.Context

	Args []*phpv.ZVal
	// contains filtered or unexported fields
}

func (*FuncContext) AsVal

func (c *FuncContext) AsVal(ctx phpv.Context, t phpv.ZType) (phpv.Val, error)

func (*FuncContext) Class

func (c *FuncContext) Class() phpv.ZClass

func (*FuncContext) Count

func (c *FuncContext) Count(ctx phpv.Context) phpv.ZInt

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) Errorf

func (ctx *FuncContext) Errorf(format string, a ...any) 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) GetType

func (c *FuncContext) GetType() phpv.ZType

func (*FuncContext) NewIterator

func (c *FuncContext) NewIterator() phpv.ZIterator

func (*FuncContext) Notice

func (ctx *FuncContext) Notice(format string, a ...any) error

func (*FuncContext) OffsetCheck

func (c *FuncContext) OffsetCheck(ctx phpv.Context, name phpv.Val) (*phpv.ZVal, bool, error)

func (*FuncContext) OffsetExists

func (c *FuncContext) OffsetExists(ctx phpv.Context, name phpv.Val) (bool, error)

func (*FuncContext) OffsetGet

func (c *FuncContext) OffsetGet(ctx phpv.Context, name phpv.Val) (*phpv.ZVal, error)

func (*FuncContext) OffsetSet

func (c *FuncContext) OffsetSet(ctx phpv.Context, name phpv.Val, v *phpv.ZVal) error

func (*FuncContext) OffsetUnset

func (c *FuncContext) OffsetUnset(ctx phpv.Context, name phpv.Val) error

func (*FuncContext) Parent

func (ctx *FuncContext) Parent(n int) phpv.Context

func (*FuncContext) This

func (c *FuncContext) This() phpv.ZObject

func (*FuncContext) Warn

func (ctx *FuncContext) Warn(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

	DefaultStreamContext *stream.Context
	// contains filtered or unexported fields
}

func NewGlobal

func NewGlobal(ctx context.Context, p *Process, config phpv.IniConfig) *Global

func NewGlobalReq

func NewGlobalReq(req *http.Request, p *Process, config phpv.IniConfig) *Global

func (*Global) AppendBuffer

func (g *Global) AppendBuffer() *Buffer

func (*Global) Argv

func (g *Global) Argv() []string

func (*Global) Buffer

func (g *Global) Buffer() *Buffer

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) CallZVal

func (c *Global) CallZVal(ctx phpv.Context, f phpv.Callable, args []*phpv.ZVal, optionalThis ...phpv.ZObject) (*phpv.ZVal, error)

func (*Global) Chdir

func (g *Global) Chdir(d phpv.ZString) error

func (*Global) Class

func (g *Global) Class() phpv.ZClass

func (*Global) Close

func (g *Global) Close() error

func (*Global) ConstantGet

func (g *Global) ConstantGet(name phpv.ZString) (phpv.Val, bool)

func (*Global) ConstantSet

func (g *Global) ConstantSet(k phpv.ZString, v phpv.Val) bool

func (*Global) Count

func (c *Global) Count(ctx phpv.Context) phpv.ZInt

func (*Global) Deadline

func (g *Global) Deadline() (time.Time, bool)

func (*Global) Deprecated

func (g *Global) Deprecated(format string, a ...any) error

func (*Global) DoString

func (c *Global) DoString(ctx phpv.Context, strCode phpv.ZString) (*phpv.ZVal, error)

func (*Global) Error

func (g *Global) Error(err error, t ...phpv.PhpErrorType) error

func (*Global) Errorf

func (g *Global) Errorf(format string, a ...any) error

func (*Global) Exists

func (g *Global) Exists(fn phpv.ZString) (bool, error)

func (*Global) Flush

func (g *Global) Flush()

func (*Global) Func

func (g *Global) Func() phpv.FuncContext

func (*Global) FuncError

func (g *Global) FuncError(err error, t ...phpv.PhpErrorType) error

func (*Global) FuncErrorf

func (g *Global) FuncErrorf(format string, a ...any) error

func (*Global) GetClass

func (g *Global) GetClass(ctx phpv.Context, name phpv.ZString, autoload bool) (phpv.ZClass, error)

func (*Global) GetConfig

func (g *Global) GetConfig(name phpv.ZString, def *phpv.ZVal) *phpv.ZVal

func (*Global) GetDefinedFunctions

func (g *Global) GetDefinedFunctions(ctx phpv.Context, excludeDisabled bool) (*phpv.ZArray, error)

func (*Global) GetFuncName

func (g *Global) GetFuncName() string

func (*Global) GetFunction

func (g *Global) GetFunction(ctx phpv.Context, name phpv.ZString) (phpv.Callable, error)

func (*Global) GetGlobalConfig

func (g *Global) GetGlobalConfig(name phpv.ZString, def *phpv.ZVal) *phpv.ZVal

func (*Global) GetLoadedExtensions

func (g *Global) GetLoadedExtensions() []string

func (*Global) GetScriptFile

func (g *Global) GetScriptFile() phpv.ZString

func (*Global) GetStackTrace

func (g *Global) GetStackTrace(ctx phpv.Context) []*phpv.StackTraceEntry

func (*Global) GetUserErrorHandler

func (g *Global) GetUserErrorHandler() (phpv.Callable, phpv.PhpErrorType)

func (*Global) Getenv

func (g *Global) Getenv(key string) (string, bool)

func (*Global) Getwd

func (g *Global) Getwd() phpv.ZString

func (*Global) Global

func (g *Global) Global() phpv.GlobalContext

func (*Global) HeaderContext

func (g *Global) HeaderContext() *phpv.HeaderContext

func (*Global) Include

func (c *Global) Include(ctx phpv.Context, fn phpv.ZString) (*phpv.ZVal, error)

func (*Global) IncludeOnce

func (c *Global) IncludeOnce(ctx phpv.Context, fn phpv.ZString) (*phpv.ZVal, error)

func (*Global) IterateConfig

func (g *Global) IterateConfig() iter.Seq2[string, phpv.IniValue]

func (*Global) Loc

func (g *Global) Loc() *phpv.Loc

func (*Global) LogError

func (g *Global) LogError(err *phpv.PhpError, optionArg ...logopt.Data)

func (*Global) MemAlloc

func (g *Global) MemAlloc(ctx phpv.Context, s uint64) error

func (*Global) NewIterator

func (c *Global) NewIterator() phpv.ZIterator

func (*Global) NextResourceID

func (g *Global) NextResourceID() int

func (*Global) Notice

func (g *Global) Notice(format string, a ...any) error

func (*Global) OffsetCheck

func (c *Global) OffsetCheck(ctx phpv.Context, name phpv.Val) (*phpv.ZVal, bool, error)

func (*Global) OffsetExists

func (c *Global) OffsetExists(ctx phpv.Context, name phpv.Val) (bool, error)

func (*Global) OffsetGet

func (c *Global) OffsetGet(ctx phpv.Context, name phpv.Val) (*phpv.ZVal, error)

func (*Global) OffsetSet

func (c *Global) OffsetSet(ctx phpv.Context, name phpv.Val, v *phpv.ZVal) error

func (*Global) OffsetUnset

func (c *Global) OffsetUnset(ctx phpv.Context, name phpv.Val) error

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) Parent

func (c *Global) Parent(n int) phpv.Context

func (*Global) Random

func (g *Global) Random() *random.State

func (*Global) RegisterClass

func (g *Global) RegisterClass(name phpv.ZString, c phpv.ZClass) error

func (*Global) RegisterFunction

func (g *Global) RegisterFunction(name phpv.ZString, f phpv.Callable) error

func (*Global) RegisterLazyClass

func (g *Global) RegisterLazyClass(name phpv.ZString, r phpv.Runnables, p int)

func (*Global) RegisterLazyFunc

func (g *Global) RegisterLazyFunc(name phpv.ZString, r phpv.Runnables, p int)

func (*Global) RegisterShutdownFunction

func (g *Global) RegisterShutdownFunction(f phpv.Callable)

func (*Global) Require

func (c *Global) Require(ctx phpv.Context, fn phpv.ZString) (*phpv.ZVal, error)

func (*Global) RequireOnce

func (c *Global) RequireOnce(ctx phpv.Context, fn phpv.ZString) (*phpv.ZVal, error)

func (*Global) ResetDeadline

func (g *Global) ResetDeadline()

func (*Global) RestoreConfig

func (g *Global) RestoreConfig(name phpv.ZString)

func (*Global) RunFile

func (g *Global) RunFile(fn string) error

func (*Global) SetDeadline

func (g *Global) SetDeadline(t time.Time)

func (*Global) SetLocalConfig

func (g *Global) SetLocalConfig(name phpv.ZString, value *phpv.ZVal) (*phpv.ZVal, bool)

func (*Global) SetOutput

func (g *Global) SetOutput(w io.Writer)

func (*Global) SetUserErrorHandler

func (g *Global) SetUserErrorHandler(handler phpv.Callable, filter phpv.PhpErrorType)

func (*Global) Setenv

func (g *Global) Setenv(key, value string) error

func (*Global) ShownDeprecated

func (g *Global) ShownDeprecated(key string) bool

func (*Global) This

func (g *Global) This() phpv.ZObject

func (*Global) Tick

func (g *Global) Tick(ctx phpv.Context, l *phpv.Loc) error

func (*Global) Unsetenv

func (g *Global) Unsetenv(key string) error

func (*Global) Warn

func (g *Global) Warn(format string, a ...any) error

func (*Global) WarnDeprecated

func (g *Global) WarnDeprecated() error

func (*Global) Write

func (g *Global) Write(v []byte) (int, error)

func (*Global) WriteErr

func (g *Global) WriteErr(v []byte) (int, error)

type MemMgr

type MemMgr struct {
	// contains filtered or unexported fields
}

func NewMemMgr

func NewMemMgr(limit uint64) *MemMgr

func (*MemMgr) Alloc

func (m *MemMgr) Alloc(ctx phpv.Context, s uint64) error

func (*MemMgr) Copy

func (m *MemMgr) Copy(dst io.Writer, src io.Reader) (written int64, err error)

type OpenContext

type OpenContext int

type Process

type Process struct {
	ScriptFilename string
	Argv           []string
	Options        *ProcessOptions
	// contains filtered or unexported fields
}

func NewProcess

func NewProcess(sapi string) *Process

NewProcess instanciates a new instance of Process, which represents a running PHP process.

func (*Process) CommandLine

func (p *Process) CommandLine(args []string) error

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

func (p *Process) Handler(docroot string, iniCfg phpv.IniConfig) http.Handler

Hander returns a http.Handler object suitable for use with golang standard http servers and similar.

func (*Process) SetConstant

func (p *Process) SetConstant(name, value phpv.ZString)

SetConstant sets a global constant, typically used to set PHP_SAPI.

type ProcessOptions

type ProcessOptions struct {
	RunCode    string
	NoIniFile  bool
	IniFile    string
	IniEntries map[string]string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL