phpv

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: 17 Imported by: 14

Documentation

Overview

Package phpv contains all required types and interfaces for storing Goro values, context or compiled PHP code.

Index

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 Compare

func Compare(ctx Context, a, b *ZVal) (int, error)

func CompareArray

func CompareArray(ctx Context, aa, ba *ZArray) (int, error)

func CompareObject

func CompareObject(ctx Context, ao, bo ZObject) (int, error)

func DebugDump

func DebugDump(v Runnable) string

func Equals

func Equals(ctx Context, a, b *ZVal) (bool, error)

func Every

func Every(ctx Context, array *ZArray, predicate func(*ZVal) bool) bool

func ExitError

func ExitError(retcode ZInt) error

func FilterExitError

func FilterExitError(err error) error

func GetGoDebugTrace

func GetGoDebugTrace() []byte

func IsExit

func IsExit(err error) bool

func IsNull

func IsNull(val Val) bool

func StrictEquals

func StrictEquals(ctx Context, a, b *ZVal) (bool, error)

func UnwrapError

func UnwrapError(err error) error

Types

type AttrStream

type AttrStream interface {
	Attr(v interface{}) interface{}
}

type BoundedCallable

type BoundedCallable struct {
	Callable
	This ZObject
	Args []*ZVal
}

func Bind

func Bind(fn Callable, this ZObject, args ...*ZVal) *BoundedCallable

type Callable

type Callable interface {
	Val
	Name() string
	Call(ctx Context, args []*ZVal) (*ZVal, error)
}

type CallableVal

type CallableVal struct{}

Used to make struct Callables satisfy the Val interface

func (CallableVal) AsVal

func (c CallableVal) AsVal(ctx Context, t ZType) (Val, error)

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 Cloneable

type Cloneable interface {
	Clone() any
}

type Compilable

type Compilable interface {
	Compile(ctx Context) error
}

type CompileDelayed

type CompileDelayed struct {
	V Runnable
}

func (*CompileDelayed) AsVal

func (c *CompileDelayed) AsVal(ctx Context, t ZType) (Val, error)

func (*CompileDelayed) GetType

func (c *CompileDelayed) GetType() ZType

func (*CompileDelayed) Run

func (c *CompileDelayed) Run(ctx Context) (*ZVal, error)

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 FuncArg

type FuncArg struct {
	VarName      ZString
	Ref          bool
	Required     bool
	DefaultValue Val
	Hint         *TypeHint
}

type FuncContext

type FuncContext interface {
	Context
}

type FuncGetArgs

type FuncGetArgs interface {
	GetArgs() []*FuncArg
}

type FuncUse

type FuncUse struct {
	VarName ZString
	Value   *ZVal
}

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 HeaderSender

type HeaderSender func(headers http.Header, statusCode int) 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 IniValue struct {
	// values that are set in system php.ini or others
	Global *ZVal

	// values that are set by the user script,
	// using ini_set() or .htacess, or
	// user .ini files
	Local *ZVal
}

func (*IniValue) Get

func (iv *IniValue) Get() *ZVal

func (*IniValue) GetString

func (iv *IniValue) GetString(ctx Context) ZString

type Loc

type Loc struct {
	Filename   string
	Line, Char int
}

func (*Loc) Dump

func (l *Loc) Dump(w io.Writer) error

func (*Loc) Error

func (l *Loc) Error(ctx Context, e error, codeArg ...PhpErrorType) *PhpError

func (*Loc) Errorf

func (l *Loc) Errorf(ctx Context, code PhpErrorType, f string, arg ...interface{}) *PhpError

func (*Loc) Loc

func (l *Loc) Loc() *Loc

func (*Loc) Run

func (l *Loc) Run(ctx Context) (*ZVal, error)

func (*Loc) String

func (l *Loc) String() string

type MethodCallable

type MethodCallable struct {
	Callable
	Class  ZClass
	Static bool
}

func BindClass

func BindClass(fn Callable, class ZClass, static bool) *MethodCallable

type PhpError

type PhpError struct {
	Err      error
	FuncName string
	Code     PhpErrorType
	Loc      *Loc

	PhpStackTrace StackTrace
	GoStackTrace  []byte
}

func (*PhpError) CanBeUserHandled

func (e *PhpError) CanBeUserHandled() bool

func (*PhpError) Error

func (e *PhpError) Error() string

func (*PhpError) IsExit

func (e *PhpError) IsExit() bool

func (*PhpError) IsNonFatal

func (e *PhpError) IsNonFatal() bool

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 PhpExit

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

func (*PhpExit) Dump

func (e *PhpExit) Dump(w io.Writer) error

func (*PhpExit) Error

func (e *PhpExit) Error() string

func (*PhpExit) Loc

func (e *PhpExit) Loc() *Loc

func (*PhpExit) Run

func (e *PhpExit) Run(ctx Context) (*ZVal, error)

type Resource

type Resource interface {
	Val
	GetResourceType() ResourceType
	GetResourceID() int
}

type ResourceType

type ResourceType int

func (ResourceType) String

func (rs ResourceType) String() string

type RunNull

type RunNull struct{}

func (RunNull) Dump

func (r RunNull) Dump(w io.Writer) error

func (RunNull) Run

func (r RunNull) Run(ctx Context) (*ZVal, error)

type Runnable

type Runnable interface {
	Run(Context) (*ZVal, error)
	Dump(io.Writer) error
}

type RunnableChild

type RunnableChild interface {
	Runnable
	GetParentNode() Runnable
	SetParentNode(Runnable)
}

type Runnables

type Runnables []Runnable

func (Runnables) Dump

func (r Runnables) Dump(w io.Writer) error

func (Runnables) DumpWith

func (r Runnables) DumpWith(w io.Writer, sep []byte) error

func (Runnables) Run

func (r Runnables) Run(ctx Context) (l *ZVal, err error)

type StackTrace

type StackTrace []*StackTraceEntry

func (StackTrace) String

func (st StackTrace) String() ZString

type StackTraceEntry

type StackTraceEntry struct {
	FuncName   string
	Filename   string
	ClassName  string
	MethodType string
	Line       int
	Args       []*ZVal
}

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

func ParseTypeHint(s ZString) *TypeHint

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 Writable

type Writable interface {
	WriteValue(ctx Context, value *ZVal) error
}

type ZArray

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

func NewZArray

func NewZArray() *ZArray

func (*ZArray) AsVal

func (a *ZArray) AsVal(ctx Context, t ZType) (Val, error)

func (*ZArray) ByteArrayKeys

func (a *ZArray) ByteArrayKeys(ctx Context) [][]byte

func (*ZArray) Clear

func (a *ZArray) Clear(ctx Context) error

func (*ZArray) Count

func (a *ZArray) Count(ctx Context) ZInt

func (*ZArray) Dup

func (a *ZArray) Dup() *ZArray

func (*ZArray) Empty

func (a *ZArray) Empty(ctx Context) error

Similar to Clear, but still allows iteration over deleted items

func (*ZArray) Equals

func (a *ZArray) Equals(ctx Context, b *ZArray) bool

func (*ZArray) GetType

func (a *ZArray) GetType() ZType

func (*ZArray) HasStringKeys

func (a *ZArray) HasStringKeys() bool

func (*ZArray) HashTable

func (a *ZArray) HashTable() *ZHashTable

func (*ZArray) IntKeys

func (a *ZArray) IntKeys(ctx Context) []ZInt

func (*ZArray) Iterate

func (a *ZArray) Iterate(ctx Context) iter.Seq2[*ZVal, *ZVal]

func (*ZArray) MainIterator

func (a *ZArray) MainIterator() ZIterator

func (*ZArray) MergeArray

func (a *ZArray) MergeArray(b *ZArray) error

func (*ZArray) MergeTable

func (a *ZArray) MergeTable(h *ZHashTable) error

func (*ZArray) NewIterator

func (a *ZArray) NewIterator() ZIterator

func (*ZArray) OffsetAt

func (a *ZArray) OffsetAt(ctx Context, index int) (*ZVal, *ZVal, error)

func (*ZArray) OffsetCheck

func (a *ZArray) OffsetCheck(ctx Context, key Val) (*ZVal, bool, error)

func (*ZArray) OffsetContains

func (a *ZArray) OffsetContains(ctx Context, val Val) (bool, error)

func (*ZArray) OffsetExists

func (a *ZArray) OffsetExists(ctx Context, key Val) (bool, error)

func (*ZArray) OffsetGet

func (a *ZArray) OffsetGet(ctx Context, key Val) (*ZVal, error)

func (*ZArray) OffsetKeyAt

func (a *ZArray) OffsetKeyAt(ctx Context, index int) (*ZVal, error)

func (*ZArray) OffsetSet

func (a *ZArray) OffsetSet(ctx Context, key Val, value *ZVal) error

func (*ZArray) OffsetUnset

func (a *ZArray) OffsetUnset(ctx Context, key Val) error

func (*ZArray) Reset

func (a *ZArray) Reset(ctx Context)

func (*ZArray) String

func (a *ZArray) String() string

func (*ZArray) StringKeys

func (a *ZArray) StringKeys(ctx Context) []ZString

func (*ZArray) Value

func (a *ZArray) Value() Val

func (*ZArray) ZVal

func (a *ZArray) ZVal() *ZVal

type ZArrayAccess

type ZArrayAccess interface {
	OffsetGet(ctx Context, key Val) (*ZVal, error)
	OffsetSet(ctx Context, key Val, value *ZVal) error
	OffsetUnset(ctx Context, key Val) error
	OffsetExists(ctx Context, key Val) (bool, error)
	OffsetCheck(ctx Context, key Val) (*ZVal, bool, error)
}

type ZBool

type ZBool bool

func (ZBool) AsVal

func (z ZBool) AsVal(ctx Context, t ZType) (Val, error)

func (ZBool) GetType

func (z ZBool) GetType() ZType

func (ZBool) String

func (z ZBool) String() string

func (ZBool) Value

func (z ZBool) Value() Val

func (ZBool) ZVal

func (z ZBool) ZVal() *ZVal

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 ZClassHandlers struct {
	Constructor  *ZClassMethod
	HandleInvoke func(ctx Context, o ZObject, args []Runnable) (*ZVal, error)
}

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 ZClosure

type ZClosure interface {
	FuncGetArgs
	Callable
	Runnable

	GetClass() ZClass
}

type ZCountable

type ZCountable interface {
	Count(ctx Context) ZInt
}

type ZFloat

type ZFloat float64

func (ZFloat) AsVal

func (z ZFloat) AsVal(ctx Context, t ZType) (Val, error)

func (ZFloat) GetType

func (z ZFloat) GetType() ZType

func (ZFloat) String

func (v ZFloat) String() string

func (ZFloat) Value

func (v ZFloat) Value() Val

func (ZFloat) ZVal

func (z ZFloat) ZVal() *ZVal

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

func (z *ZHashTable) SetInt(k ZInt, v *ZVal) error

func (*ZHashTable) SetString

func (z *ZHashTable) SetString(k ZString, v *ZVal) error

func (*ZHashTable) UnsetInt

func (z *ZHashTable) UnsetInt(k ZInt) error

func (*ZHashTable) UnsetString

func (z *ZHashTable) UnsetString(k ZString) error

type ZInt

type ZInt int64

func (ZInt) AsVal

func (z ZInt) AsVal(ctx Context, t ZType) (Val, error)

func (ZInt) GetType

func (z ZInt) GetType() ZType

func (ZInt) String

func (v ZInt) String() string

func (ZInt) Value

func (v ZInt) Value() Val

func (ZInt) ZVal

func (z ZInt) ZVal() *ZVal

type ZIterable

type ZIterable interface {
	NewIterator() ZIterator
}

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 ZNull

type ZNull struct{}

scalar stuff

func (ZNull) AsVal

func (z ZNull) AsVal(ctx Context, t ZType) (Val, error)

func (ZNull) GetType

func (z ZNull) GetType() ZType

func (ZNull) String

func (v ZNull) String() string

func (ZNull) Value

func (z ZNull) Value() Val

func (ZNull) ZVal

func (z ZNull) 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 ZObjectAccess interface {
	ObjectGet(ctx Context, key Val) (*ZVal, error)
	ObjectSet(ctx Context, key Val, value *ZVal) error
}

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

func (z ZString) AsNumeric() (Val, error)

func (ZString) AsVal

func (z ZString) AsVal(ctx Context, t ZType) (Val, error)

func (ZString) ContainsInvalidNumeric

func (z ZString) ContainsInvalidNumeric() bool

func (ZString) GetType

func (z ZString) GetType() ZType

func (ZString) IsNumeric

func (s ZString) IsNumeric() bool

func (ZString) LooksInt

func (s ZString) LooksInt() bool

func (ZString) String

func (v ZString) String() string

func (ZString) ToLower

func (s ZString) ToLower() ZString

func (ZString) ToUpper

func (s ZString) ToUpper() ZString

func (ZString) Value

func (v ZString) Value() Val

func (ZString) ZVal

func (z ZString) ZVal() *ZVal

type ZStringArray

type ZStringArray struct {
	*ZString
}

func (ZStringArray) OffsetCheck

func (z ZStringArray) OffsetCheck(ctx Context, key Val) (*ZVal, bool, error)

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 ZType

type ZType int
const (
	ZtNull ZType = iota
	ZtBool
	ZtInt
	ZtFloat
	ZtString
	ZtArray
	ZtObject
	ZtResource
	ZtCallable
)

func (ZType) String

func (zt ZType) String() string

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 MakeZVal

func MakeZVal(v Val) *ZVal

func NewZVal

func NewZVal(v Val) *ZVal

func ZStr

func ZStr(s string) *ZVal

func (*ZVal) Array

func (z *ZVal) Array() ZArrayAccess

func (*ZVal) As

func (z *ZVal) As(ctx Context, t ZType) (*ZVal, error)

func (*ZVal) AsArray

func (z *ZVal) AsArray(ctx Context) *ZArray

func (*ZVal) AsBool

func (z *ZVal) AsBool(ctx Context) ZBool

func (*ZVal) AsFloat

func (z *ZVal) AsFloat(ctx Context) ZFloat

func (*ZVal) AsInt

func (z *ZVal) AsInt(ctx Context) ZInt

func (*ZVal) AsNumeric

func (z *ZVal) AsNumeric(ctx Context) (*ZVal, error)

func (*ZVal) AsObject

func (z *ZVal) AsObject(ctx Context) ZObject

func (*ZVal) AsString

func (z *ZVal) AsString(ctx Context) ZString

func (*ZVal) AsVal

func (z *ZVal) AsVal(ctx Context, t ZType) (Val, error)

func (*ZVal) CastTo

func (z *ZVal) CastTo(ctx Context, t ZType) error

func (*ZVal) Dup

func (z *ZVal) Dup() *ZVal

func (*ZVal) GetName

func (z *ZVal) GetName() ZString

func (*ZVal) GetType

func (z *ZVal) GetType() ZType

func (*ZVal) HashTable

func (z *ZVal) HashTable() *ZHashTable

func (*ZVal) IsNull

func (z *ZVal) IsNull() bool

func (*ZVal) IsRef

func (z *ZVal) IsRef() bool

func (*ZVal) NewIterator

func (z *ZVal) NewIterator() ZIterator

func (*ZVal) Nude

func (z *ZVal) Nude() *ZVal

Returns actual zval, dropping status of reference

func (*ZVal) Ref

func (z *ZVal) Ref() *ZVal

Ref returns a reference to this zval while making it itself a ref

func (*ZVal) Set

func (z *ZVal) Set(nz *ZVal)

func (*ZVal) String

func (z *ZVal) String() string

func (*ZVal) Value

func (z *ZVal) Value() Val

func (*ZVal) ZVal

func (z *ZVal) ZVal() *ZVal

ZVal will make a copy of a given zval without actually copying memory

Jump to

Keyboard shortcuts

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