Documentation
¶
Overview ¶
Package phpv contains all required types and interfaces for storing Goro values, context or compiled PHP code.
Index ¶
- Constants
- Variables
- func Compare(ctx Context, a, b *ZVal) (int, error)
- func CompareArray(ctx Context, aa, ba *ZArray) (int, error)
- func CompareObject(ctx Context, ao, bo ZObject) (int, error)
- func DebugDump(v Runnable) string
- func Equals(ctx Context, a, b *ZVal) (bool, error)
- func Every(ctx Context, array *ZArray, predicate func(*ZVal) bool) bool
- func ExitError(retcode ZInt) error
- func FilterExitError(err error) error
- func GetGoDebugTrace() []byte
- func IsExit(err error) bool
- func IsNull(val Val) bool
- func StrictEquals(ctx Context, a, b *ZVal) (bool, error)
- func UnwrapError(err error) error
- type AttrStream
- type BoundedCallable
- type Callable
- type CallableVal
- type Cloneable
- type Compilable
- type CompileDelayed
- type Context
- type FuncArg
- type FuncContext
- type FuncGetArgs
- type FuncUse
- type GlobalContext
- type HeaderContext
- type HeaderSender
- type IniConfig
- type IniValue
- type Loc
- func (l *Loc) Dump(w io.Writer) error
- func (l *Loc) Error(ctx Context, e error, codeArg ...PhpErrorType) *PhpError
- func (l *Loc) Errorf(ctx Context, code PhpErrorType, f string, arg ...interface{}) *PhpError
- func (l *Loc) Loc() *Loc
- func (l *Loc) Run(ctx Context) (*ZVal, error)
- func (l *Loc) String() string
- type MethodCallable
- type PhpError
- type PhpErrorType
- type PhpExit
- type Resource
- type ResourceType
- type RunNull
- type Runnable
- type RunnableChild
- type Runnables
- type StackTrace
- type StackTraceEntry
- type Stream
- type TypeHint
- type Val
- type Writable
- type ZArray
- func (a *ZArray) AsVal(ctx Context, t ZType) (Val, error)
- func (a *ZArray) ByteArrayKeys(ctx Context) [][]byte
- func (a *ZArray) Clear(ctx Context) error
- func (a *ZArray) Count(ctx Context) ZInt
- func (a *ZArray) Dup() *ZArray
- func (a *ZArray) Empty(ctx Context) error
- func (a *ZArray) Equals(ctx Context, b *ZArray) bool
- func (a *ZArray) GetType() ZType
- func (a *ZArray) HasStringKeys() bool
- func (a *ZArray) HashTable() *ZHashTable
- func (a *ZArray) IntKeys(ctx Context) []ZInt
- func (a *ZArray) Iterate(ctx Context) iter.Seq2[*ZVal, *ZVal]
- func (a *ZArray) MainIterator() ZIterator
- func (a *ZArray) MergeArray(b *ZArray) error
- func (a *ZArray) MergeTable(h *ZHashTable) error
- func (a *ZArray) NewIterator() ZIterator
- func (a *ZArray) OffsetAt(ctx Context, index int) (*ZVal, *ZVal, error)
- func (a *ZArray) OffsetCheck(ctx Context, key Val) (*ZVal, bool, error)
- func (a *ZArray) OffsetContains(ctx Context, val Val) (bool, error)
- func (a *ZArray) OffsetExists(ctx Context, key Val) (bool, error)
- func (a *ZArray) OffsetGet(ctx Context, key Val) (*ZVal, error)
- func (a *ZArray) OffsetKeyAt(ctx Context, index int) (*ZVal, error)
- func (a *ZArray) OffsetSet(ctx Context, key Val, value *ZVal) error
- func (a *ZArray) OffsetUnset(ctx Context, key Val) error
- func (a *ZArray) Reset(ctx Context)
- func (a *ZArray) String() string
- func (a *ZArray) StringKeys(ctx Context) []ZString
- func (a *ZArray) Value() Val
- func (a *ZArray) ZVal() *ZVal
- type ZArrayAccess
- type ZBool
- type ZClass
- type ZClassAttr
- type ZClassHandlers
- type ZClassMethod
- type ZClassProp
- type ZClassType
- type ZClosure
- type ZCountable
- type ZFloat
- type ZHashTable
- func (z *ZHashTable) Append(v *ZVal) error
- func (z *ZHashTable) Array() *ZArray
- func (z *ZHashTable) Clear()
- func (z *ZHashTable) Count() ZInt
- func (z *ZHashTable) Dup() *ZHashTable
- func (z *ZHashTable) Empty()
- func (z *ZHashTable) GetInt(k ZInt) *ZVal
- func (z *ZHashTable) GetString(k ZString) *ZVal
- func (z *ZHashTable) GetStringB(k ZString) (*ZVal, bool)
- func (z *ZHashTable) HasInt(k ZInt) bool
- func (z *ZHashTable) HasString(k ZString) bool
- func (z ZHashTable) HasStringKeys() bool
- func (z *ZHashTable) MergeTable(b *ZHashTable) error
- func (z *ZHashTable) NewIterator() ZIterator
- func (z *ZHashTable) ResetIntKeys()
- func (z *ZHashTable) SetInt(k ZInt, v *ZVal) error
- func (z *ZHashTable) SetString(k ZString, v *ZVal) error
- func (z *ZHashTable) UnsetInt(k ZInt) error
- func (z *ZHashTable) UnsetString(k ZString) error
- type ZInt
- type ZIterable
- type ZIterator
- type ZNull
- type ZObject
- type ZObjectAccess
- type ZObjectAttr
- type ZString
- func (z ZString) Array() ZStringArray
- func (z ZString) AsNumeric() (Val, error)
- func (z ZString) AsVal(ctx Context, t ZType) (Val, error)
- func (z ZString) ContainsInvalidNumeric() bool
- func (z ZString) GetType() ZType
- func (s ZString) IsNumeric() bool
- func (s ZString) LooksInt() bool
- func (v ZString) String() string
- func (s ZString) ToLower() ZString
- func (s ZString) ToUpper() ZString
- func (v ZString) Value() Val
- func (z ZString) ZVal() *ZVal
- type ZStringArray
- func (z ZStringArray) OffsetCheck(ctx Context, key Val) (*ZVal, bool, error)
- func (z ZStringArray) OffsetExists(ctx Context, key Val) (bool, error)
- func (z ZStringArray) OffsetGet(ctx Context, key Val) (*ZVal, error)
- func (z ZStringArray) OffsetSet(ctx Context, key Val, value *ZVal) error
- func (z ZStringArray) OffsetUnset(ctx Context, key Val) error
- func (z ZStringArray) String() ZString
- type ZType
- type ZVal
- func (z *ZVal) Array() ZArrayAccess
- func (z *ZVal) As(ctx Context, t ZType) (*ZVal, error)
- func (z *ZVal) AsArray(ctx Context) *ZArray
- func (z *ZVal) AsBool(ctx Context) ZBool
- func (z *ZVal) AsFloat(ctx Context) ZFloat
- func (z *ZVal) AsInt(ctx Context) ZInt
- func (z *ZVal) AsNumeric(ctx Context) (*ZVal, error)
- func (z *ZVal) AsObject(ctx Context) ZObject
- func (z *ZVal) AsString(ctx Context) ZString
- func (z *ZVal) AsVal(ctx Context, t ZType) (Val, error)
- func (z *ZVal) CastTo(ctx Context, t ZType) error
- func (z *ZVal) Dup() *ZVal
- func (z *ZVal) GetName() ZString
- func (z *ZVal) GetType() ZType
- func (z *ZVal) HashTable() *ZHashTable
- func (z *ZVal) IsNull() bool
- func (z *ZVal) IsRef() bool
- func (z *ZVal) NewIterator() ZIterator
- func (z *ZVal) Nude() *ZVal
- func (z *ZVal) Ref() *ZVal
- func (z *ZVal) Set(nz *ZVal)
- func (z *ZVal) String() string
- func (z *ZVal) Value() Val
- func (z *ZVal) ZVal() *ZVal
Constants ¶
View Source
const ( // would use 1 << iota but those values come from php, so making them constants is more appropriate ZClassStatic ZClassAttr = 0x001 ZClassAbstract = 0x002 ZClassImplAbstract = 0x008 // an abstract method which has been implemented ZClassImplicitAbstract = 0x010 // for classes ZClassExplicitAbstract = 0x020 // for classes ZClassFinal = 0x040 // class attribute (not method) ZClassTrait = 0x80 ZClassAnon = 0x100 ZClassAnonBound = 0x200 ZClassInherited = 0x400 ZClassTypeImplicitAbstract ZClassType = 0x10 ZClassTypeExplicitAbstract = 0x20 ZClassTypeInterface = 0x40 ZClassTypeTrait = 0x80 ZClassTypeAnon = 0x100 ZAttrStatic ZObjectAttr = ZObjectAttr(ZClassStatic) ZAttrAbstract = ZObjectAttr(ZClassAbstract) ZAttrFinal = 0x004 // final method, not the same value as ZClassFinal ZAttrPublic = 0x100 ZAttrProtected = 0x200 ZAttrPrivate = 0x400 ZAttrAccess = ZAttrPublic | ZAttrProtected | ZAttrPrivate ZAttrImplicitPublic = 0x1000 // method without flag ZAttrCtor = 0x2000 ZAttrDtor = 0x4000 ZAttrUserArgInfo = 0x80 // method flag used by Closure::__invoke() ZAttrAllowStatic = 0x10000 // method flag (bc only), any method that has this flag can be used statically and non statically. ZAttrShadow = 0x20000 // shadow of parent's private method/property ZAttrDeprecated = 0x40000 // deprecation flag ZAttrClosure = 0x100000 ZAttrFakeClosure = 0x40 ZAttrGenerator = 0x800000 ZAttrViaTrampoline = 0x200000 // call through user function trampoline. e.g. __call, __callstatic ZAttrViaHandler = ZAttrViaTrampoline // call through internal function handler. e.g. Closure::invoke() ZAttrVariadic = 0x1000000 ZAttrReturnRef = 0x4000000 ZAttrUseGuard = 0x1000000 // class has magic methods __get/__set/__unset/__isset that use guards ZAttrHasTypeHints = 0x10000000 // function has typed arguments ZAttrHasReturnType = 0x40000000 // Function has a return type (or class has such non-private function) )
View Source
const ( ResourceUnknown = iota ResourceStream ResourceContext )
Variables ¶
View Source
var ZFalse = ZBool(false)
View Source
var ZNULL = ZNull{}
global NULL for easy call
View Source
var ZTrue = ZBool(true)
Functions ¶
func FilterExitError ¶
func GetGoDebugTrace ¶
func GetGoDebugTrace() []byte
func UnwrapError ¶
Types ¶
type AttrStream ¶
type AttrStream interface {
Attr(v interface{}) interface{}
}
type BoundedCallable ¶
type CallableVal ¶
type CallableVal struct{}
Used to make struct Callables satisfy the Val interface
func (CallableVal) GetType ¶
func (c CallableVal) GetType() ZType
func (CallableVal) Name ¶
func (c CallableVal) Name() string
func (CallableVal) String ¶
func (c CallableVal) String() string
func (CallableVal) Value ¶
func (c CallableVal) Value() Val
func (CallableVal) ZVal ¶
func (c CallableVal) ZVal() *ZVal
type Compilable ¶
type CompileDelayed ¶
type CompileDelayed struct {
V Runnable
}
func (*CompileDelayed) GetType ¶
func (c *CompileDelayed) GetType() ZType
func (*CompileDelayed) String ¶
func (c *CompileDelayed) String() string
func (*CompileDelayed) Value ¶
func (c *CompileDelayed) Value() Val
func (*CompileDelayed) ZVal ¶
func (c *CompileDelayed) ZVal() *ZVal
type Context ¶
type Context interface { context.Context ZArrayAccess ZCountable ZIterable io.Writer // return value of GetScriptFile will change depending on which // currently include()'d or require()'d file is running GetScriptFile() ZString Global() GlobalContext Func() FuncContext Parent(n int) Context This() ZObject Class() ZClass Loc() *Loc Tick(ctx Context, l *Loc) error MemAlloc(ctx Context, s uint64) error Errorf(format string, a ...any) error Error(err error, t ...PhpErrorType) error FuncErrorf(format string, a ...any) error FuncError(err error, t ...PhpErrorType) error // In the following functions, args can also take logopt types: // examples: // Warn("testing %d", 123, logopt.NoFuncName(true)) // Notice("note %s", "asdf", logopt.NoLoc(true)) // Notice("nope", logopt.Data{NoLoc: false}) Warn(format string, args ...any) error Notice(format string, args ...any) error Deprecated(format string, args ...any) error LogError(err *PhpError, optionArg ...logopt.Data) WarnDeprecated() error GetFuncName() string GetConfig(name ZString, def *ZVal) *ZVal GetGlobalConfig(name ZString, def *ZVal) *ZVal Call(ctx Context, f Callable, args []Runnable, this ...ZObject) (*ZVal, error) CallZVal(ctx Context, f Callable, args []*ZVal, this ...ZObject) (*ZVal, error) GetStackTrace(ctx Context) []*StackTraceEntry HeaderContext() *HeaderContext }
type FuncContext ¶
type FuncContext interface { Context }
type FuncGetArgs ¶
type FuncGetArgs interface {
GetArgs() []*FuncArg
}
type GlobalContext ¶
type GlobalContext interface { Context Flush() Argv() []string RegisterFunction(name ZString, f Callable) error GetFunction(ctx Context, name ZString) (Callable, error) RegisterShutdownFunction(f Callable) RegisterClass(name ZString, c ZClass) error GetClass(ctx Context, name ZString, autoload bool) (ZClass, error) RestoreConfig(name ZString) SetLocalConfig(name ZString, value *ZVal) (*ZVal, bool) IterateConfig() iter.Seq2[string, IniValue] ConstantSet(k ZString, v Val) bool ConstantGet(k ZString) (Val, bool) RegisterLazyFunc(name ZString, r Runnables, p int) RegisterLazyClass(name ZString, r Runnables, p int) Open(ctx Context, fn, mode ZString, useIncludePath bool, streamCtx ...Resource) (Stream, error) Exists(fn ZString) (bool, error) Chdir(d ZString) error Getwd() ZString Getenv(key string) (string, bool) Setenv(key, value string) error Unsetenv(key string) error Include(ctx Context, fn ZString) (*ZVal, error) Require(ctx Context, fn ZString) (*ZVal, error) IncludeOnce(ctx Context, fn ZString) (*ZVal, error) RequireOnce(ctx Context, fn ZString) (*ZVal, error) GetLoadedExtensions() []string Random() *random.State GetUserErrorHandler() (Callable, PhpErrorType) SetUserErrorHandler(Callable, PhpErrorType) WriteErr(p []byte) (n int, err error) ShownDeprecated(key string) bool NextResourceID() int }
type HeaderContext ¶
type HeaderContext struct { Sent bool OutputOrigin *Loc Headers http.Header Sender HeaderSender StatusCode int Callbacks []Callable }
func (*HeaderContext) Add ¶
func (hc *HeaderContext) Add(key, value string, replace bool)
func (*HeaderContext) SendHeaders ¶
func (hc *HeaderContext) SendHeaders(ctx Context) error
type IniConfig ¶
type IniConfig interface { Get(name ZString) *IniValue CanIniSet(name ZString) bool RestoreConfig(ctx Context, name ZString) SetLocal(ctx Context, name ZString, value *ZVal) *ZVal SetGlobal(ctx Context, name ZString, value *ZVal) *ZVal IterateConfig() iter.Seq2[string, IniValue] Parse(ctx Context, r io.Reader) error EvalConfigValue(ctx Context, expr ZString) (*ZVal, error) LoadDefaults(ctx Context) }
type IniValue ¶
type Loc ¶
type MethodCallable ¶
type PhpError ¶
type PhpError struct { Err error FuncName string Code PhpErrorType Loc *Loc PhpStackTrace StackTrace GoStackTrace []byte }
func (*PhpError) CanBeUserHandled ¶
func (*PhpError) IsNonFatal ¶
type PhpErrorType ¶
type PhpErrorType int
const ( E_ERROR PhpErrorType = 1 << iota E_WARNING E_PARSE E_NOTICE E_CORE_ERROR E_CORE_WARNING E_COMPILE_ERROR E_COMPILE_WARNING E_USER_ERROR E_USER_WARNING E_USER_NOTICE E_STRICT E_RECOVERABLE_ERROR E_DEPRECATED E_USER_DEPRECATED E_ALL PhpErrorType = (1 << iota) - 1 )
type Resource ¶
type Resource interface { Val GetResourceType() ResourceType GetResourceID() int }
type ResourceType ¶
type ResourceType int
func (ResourceType) String ¶
func (rs ResourceType) String() string
type RunnableChild ¶
type StackTrace ¶
type StackTrace []*StackTraceEntry
func (StackTrace) String ¶
func (st StackTrace) String() ZString
type StackTraceEntry ¶
type Stream ¶
type Stream interface { Resource Read(p []byte) (int, error) Write(p []byte) (n int, err error) Seek(offset int64, whence int) (int64, error) ReadByte() (byte, error) Close() error SetAttr(k string, v interface{}) Attr(v interface{}) interface{} Stat() (os.FileInfo, error) Flush() error Sync() error }
type TypeHint ¶
type TypeHint struct {
// contains filtered or unexported fields
}
func ParseTypeHint ¶
type Val ¶
type Val interface { GetType() ZType // GetType returns the type of the value ZVal() *ZVal // ZVal returns a ZVal pointing to this value Value() Val // Value returns the raw value, in case it was in a ZVal AsVal(ctx Context, t ZType) (Val, error) // AsVal converts the value to another type String() string // String should only be used on ZtString values }
Val is a basic value of any PHP kind: null, bool, int, float, string, array, resource or object.
type ZArray ¶
type ZArray struct {
// contains filtered or unexported fields
}
func (*ZArray) ByteArrayKeys ¶
func (*ZArray) HasStringKeys ¶
func (*ZArray) HashTable ¶
func (a *ZArray) HashTable() *ZHashTable
func (*ZArray) MainIterator ¶
func (*ZArray) MergeArray ¶
func (*ZArray) MergeTable ¶
func (a *ZArray) MergeTable(h *ZHashTable) error
func (*ZArray) NewIterator ¶
func (*ZArray) OffsetCheck ¶
func (*ZArray) StringKeys ¶
type ZArrayAccess ¶
type ZClass ¶
type ZClass interface { GetName() ZString InstanceOf(parent ZClass) bool Implements(intf ZClass) bool BaseName() ZString GetStaticProps(ctx Context) (*ZHashTable, error) GetProp(name ZString) (*ZClassProp, bool) GetMethod(name ZString) (*ZClassMethod, bool) Handlers() *ZClassHandlers GetParent() ZClass NextInstanceID() int }
type ZClassAttr ¶
type ZClassAttr int
func (ZClassAttr) Has ¶
func (a ZClassAttr) Has(c ZClassAttr) bool
func (ZClassAttr) String ¶
func (a ZClassAttr) String() string
type ZClassHandlers ¶
type ZClassMethod ¶
type ZClassMethod struct { Name ZString Modifiers ZObjectAttr Method Callable Class ZClass Empty bool }
type ZClassProp ¶
type ZClassProp struct { VarName ZString Default Val Modifiers ZObjectAttr }
type ZClassType ¶
type ZClassType int
func (ZClassType) Has ¶
func (a ZClassType) Has(c ZClassType) bool
func (ZClassType) IsInterface ¶
func (a ZClassType) IsInterface() bool
type ZCountable ¶
type ZHashTable ¶
type ZHashTable struct {
// contains filtered or unexported fields
}
func NewHashTable ¶
func NewHashTable() *ZHashTable
func (*ZHashTable) Append ¶
func (z *ZHashTable) Append(v *ZVal) error
func (*ZHashTable) Array ¶
func (z *ZHashTable) Array() *ZArray
func (*ZHashTable) Clear ¶
func (z *ZHashTable) Clear()
func (*ZHashTable) Count ¶
func (z *ZHashTable) Count() ZInt
func (*ZHashTable) Dup ¶
func (z *ZHashTable) Dup() *ZHashTable
func (*ZHashTable) Empty ¶
func (z *ZHashTable) Empty()
Similar to Clear, but doesn't set the deleted flag
func (*ZHashTable) GetInt ¶
func (z *ZHashTable) GetInt(k ZInt) *ZVal
func (*ZHashTable) GetString ¶
func (z *ZHashTable) GetString(k ZString) *ZVal
func (*ZHashTable) GetStringB ¶
func (z *ZHashTable) GetStringB(k ZString) (*ZVal, bool)
func (*ZHashTable) HasInt ¶
func (z *ZHashTable) HasInt(k ZInt) bool
func (*ZHashTable) HasString ¶
func (z *ZHashTable) HasString(k ZString) bool
func (ZHashTable) HasStringKeys ¶
func (z ZHashTable) HasStringKeys() bool
func (*ZHashTable) MergeTable ¶
func (z *ZHashTable) MergeTable(b *ZHashTable) error
func (*ZHashTable) NewIterator ¶
func (z *ZHashTable) NewIterator() ZIterator
func (*ZHashTable) ResetIntKeys ¶
func (z *ZHashTable) ResetIntKeys()
modifies all int indices such that the first one starts with zero
func (*ZHashTable) UnsetInt ¶
func (z *ZHashTable) UnsetInt(k ZInt) error
func (*ZHashTable) UnsetString ¶
func (z *ZHashTable) UnsetString(k ZString) error
type ZIterator ¶
type ZIterator interface { Current(ctx Context) (*ZVal, error) Key(ctx Context) (*ZVal, error) Next(ctx Context) (*ZVal, error) Prev(ctx Context) (*ZVal, error) Reset(ctx Context) (*ZVal, error) ResetIfEnd(ctx Context) (*ZVal, error) End(ctx Context) (*ZVal, error) Valid(ctx Context) bool Iterate(ctx Context) iter.Seq2[*ZVal, *ZVal] }
type ZObject ¶
type ZObject interface { ZObjectAccess Val GetOpaque(c ZClass) interface{} SetOpaque(c ZClass, v interface{}) GetClass() ZClass NewIterator() ZIterator HashTable() *ZHashTable Clone(ctx Context) (ZObject, error) GetParent() ZObject GetKin(className string) ZObject IterProps(ctx Context) iter.Seq[*ZClassProp] }
type ZObjectAccess ¶
type ZObjectAttr ¶
type ZObjectAttr int
func (ZObjectAttr) Access ¶
func (a ZObjectAttr) Access() ZObjectAttr
func (ZObjectAttr) Has ¶
func (a ZObjectAttr) Has(c ZObjectAttr) bool
func (ZObjectAttr) IsPrivate ¶
func (a ZObjectAttr) IsPrivate() bool
func (ZObjectAttr) IsProtected ¶
func (a ZObjectAttr) IsProtected() bool
func (ZObjectAttr) IsPublic ¶
func (a ZObjectAttr) IsPublic() bool
func (ZObjectAttr) IsStatic ¶
func (a ZObjectAttr) IsStatic() bool
type ZString ¶
type ZString string
func (ZString) Array ¶
func (z ZString) Array() ZStringArray
func (ZString) ContainsInvalidNumeric ¶
type ZStringArray ¶
type ZStringArray struct {
*ZString
}
func (ZStringArray) OffsetCheck ¶
func (ZStringArray) OffsetExists ¶
func (z ZStringArray) OffsetExists(ctx Context, key Val) (bool, error)
func (ZStringArray) OffsetGet ¶
func (z ZStringArray) OffsetGet(ctx Context, key Val) (*ZVal, error)
func (ZStringArray) OffsetSet ¶
func (z ZStringArray) OffsetSet(ctx Context, key Val, value *ZVal) error
func (ZStringArray) OffsetUnset ¶
func (z ZStringArray) OffsetUnset(ctx Context, key Val) error
func (ZStringArray) String ¶
func (z ZStringArray) String() ZString
type ZVal ¶
type ZVal struct { Name *ZString // contains filtered or unexported fields }
ZVal is a pointer to a value, that can be used as a Val, a reference, etc.
Eventually, ZVal will only be used for references.
func (*ZVal) Array ¶
func (z *ZVal) Array() ZArrayAccess
func (*ZVal) HashTable ¶
func (z *ZVal) HashTable() *ZHashTable
func (*ZVal) NewIterator ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.