Documentation
¶
Index ¶
- Variables
- func GetConstValue(c ConstValue) string
- type AccessLevel
- type ClassFlags
- type ClassInfo
- type ClassParseState
- type ClassesMap
- type ConstInfo
- type ConstValue
- func (c ConstValue) GetBool() bool
- func (c ConstValue) GetFloat() float64
- func (c ConstValue) GetInt() int64
- func (c ConstValue) GetString() string
- func (c *ConstValue) GobDecode(buf []byte) error
- func (c ConstValue) GobEncode() ([]byte, error)
- func (c ConstValue) IsEqual(v ConstValue) bool
- func (c ConstValue) IsValid() bool
- func (c ConstValue) String() string
- func (c ConstValue) ToBool() (value bool, ok bool)
- func (c ConstValue) ToInt() (int64, bool)
- func (c ConstValue) ToString() (string, bool)
- type ConstValueType
- type ConstantsMap
- type DeprecationInfo
- type ElementPosition
- type FuncFlags
- type FuncInfo
- type FuncInfoOverride
- type FuncParam
- type FunctionsMap
- type FunctionsOverrideMap
- type Info
- func (i *Info) AddClassesNonLocked(filename string, m ClassesMap)
- func (i *Info) AddConstantsNonLocked(filename string, m ConstantsMap)
- func (i *Info) AddFilenameNonLocked(filename string)
- func (i *Info) AddFunctionsNonLocked(filename string, m FunctionsMap)
- func (i *Info) AddFunctionsOverridesNonLocked(filename string, m FunctionsOverrideMap)
- func (i *Info) AddToGlobalScopeNonLocked(filename string, sc *Scope)
- func (i *Info) AddTraitsNonLocked(filename string, m ClassesMap)
- func (i *Info) Clone() *Info
- func (i *Info) DeleteMetaForFileNonLocked(filename string)
- func (i *Info) FileExists(filename string) bool
- func (i *Info) FindConstants(substr string) (res []string)
- func (i *Info) FindFunctions(substr string) (res []string)
- func (i *Info) GetClass(nm string) (res ClassInfo, ok bool)
- func (i *Info) GetClassOrTrait(nm string) (res ClassInfo, ok bool)
- func (i *Info) GetConstant(nm string) (res ConstInfo, ok bool)
- func (i *Info) GetFunction(nm string) (res FuncInfo, ok bool)
- func (i *Info) GetFunctionOverride(nm string) (res FuncInfoOverride, ok bool)
- func (i *Info) GetInternalFunctionInfo(fn string) (info FuncInfo, ok bool)
- func (i *Info) GetInternalFunctionOverrideInfo(fn string) (info FuncInfoOverride, ok bool)
- func (i *Info) GetMetaForFile(filename string) (res PerFile)
- func (i *Info) GetTrait(nm string) (res ClassInfo, ok bool)
- func (i *Info) InitKphpStubs()
- func (i *Info) InitStubs()
- func (i *Info) IsIndexingComplete() bool
- func (i *Info) IsInternalClass(className string) bool
- func (i *Info) IsLoadingStubs() bool
- func (i *Info) NumClasses() int
- func (i *Info) NumConstants() int
- func (i *Info) NumFilesWithFunctions() int
- func (i *Info) NumFunctions() int
- func (i *Info) OnIndexingComplete(cb func(*Info))
- func (i *Info) SetIndexingComplete(complete bool)
- func (i *Info) SetLoadingStubs(isLoading bool)
- type OverrideProperties
- type OverrideType
- type PackageInfo
- type PerFile
- type PropertiesMap
- type PropertyFlags
- type PropertyInfo
- type Scope
- func (s *Scope) AddImplicitVar(varNode ir.Node, typ types.Map, reason string, flags VarFlags)
- func (s *Scope) AddVar(v ir.Node, typ types.Map, reason string, flags VarFlags)
- func (s *Scope) AddVarFromPHPDoc(name string, typ types.Map, reason string)
- func (s *Scope) AddVarName(name string, typ types.Map, reason string, flags VarFlags)
- func (s *Scope) Clone() *Scope
- func (s *Scope) DelVar(v ir.Node, reason string)
- func (s *Scope) DelVarName(name, reason string)
- func (s *Scope) GetVar(v ir.Node) (m *ScopeVar, ok bool)
- func (s *Scope) GetVarName(name string) (m *ScopeVar, ok bool)
- func (s *Scope) GetVarNameType(name string) (m types.Map, ok bool)
- func (s *Scope) GetVarType(v ir.Node) (m types.Map, ok bool)
- func (s *Scope) GobDecode(buf []byte) error
- func (s *Scope) GobEncode() ([]byte, error)
- func (s *Scope) GobWrite(w io.Writer) error
- func (s *Scope) HaveImplicitVar(v ir.Node) bool
- func (s *Scope) HaveImplicitVarName(name string) bool
- func (s *Scope) HaveVar(v ir.Node) bool
- func (s *Scope) HaveVarName(name string) bool
- func (s *Scope) IsInClosure() bool
- func (s *Scope) IsInInstanceMethod() bool
- func (s *Scope) Iterate(cb func(varName string, typ types.Map, flags VarFlags))
- func (s *Scope) Len() int
- func (s *Scope) MaybeHaveVar(v ir.Node) bool
- func (s *Scope) MaybeHaveVarName(name string) bool
- func (s *Scope) ReplaceVar(v ir.Node, typ types.Map, reason string, flags VarFlags)
- func (s *Scope) ReplaceVarName(name string, typ types.Map, reason string, flags VarFlags)
- func (s *Scope) SetInClosure(v bool)
- func (s *Scope) SetInInstanceMethod(v bool)
- func (s *Scope) String() string
- type ScopeVar
- type VarFlags
Constants ¶
This section is empty.
Variables ¶
var ( UnknownValue = ConstValue{Type: Undefined} TrueValue = ConstValue{Type: Bool, Value: true} FalseValue = ConstValue{Type: Bool, Value: false} )
Functions ¶
func GetConstValue ¶ added in v0.5.0
func GetConstValue(c ConstValue) string
Types ¶
type AccessLevel ¶
type AccessLevel int
const ( Public AccessLevel = iota Protected Private )
func (AccessLevel) String ¶
func (l AccessLevel) String() string
type ClassFlags ¶ added in v0.2.0
type ClassFlags uint8
const ( ClassAbstract ClassFlags = 1 << iota ClassFinal ClassShape ClassInterface )
type ClassInfo ¶
type ClassInfo struct { Pos ElementPosition Name string Flags ClassFlags Parent string ParentInterfaces []string // interfaces allow multiple inheritance Traits map[string]struct{} Interfaces map[string]struct{} Methods FunctionsMap Properties PropertiesMap // both instance and static properties are inside. Static properties have "$" prefix Constants ConstantsMap Mixins []string PackageInfo }
func (*ClassInfo) IsAbstract ¶ added in v0.2.0
func (*ClassInfo) IsInterface ¶ added in v0.4.0
type ClassParseState ¶
type ClassParseState struct { Info *Info IsTrait bool IsInterface bool Namespace string FunctionUses map[string]string Uses map[string]string CurrentFile string CurrentClass string CurrentParentClass string CurrentParentInterfaces []string // interfaces allow for multiple inheritance... CurrentFunction string // current method or function name }
TODO: rename it; it's not only class-related.
type ClassesMap ¶
type ClassesMap struct {
H map[lowercaseString]ClassInfo
}
func NewClassesMap ¶ added in v0.2.0
func NewClassesMap() ClassesMap
func (ClassesMap) Delete ¶ added in v0.2.0
func (m ClassesMap) Delete(name string)
func (ClassesMap) Len ¶ added in v0.2.0
func (m ClassesMap) Len() int
func (ClassesMap) Set ¶ added in v0.2.0
func (m ClassesMap) Set(name string, class ClassInfo)
type ConstInfo ¶ added in v0.3.0
type ConstInfo struct { Pos ElementPosition Typ types.Map AccessLevel AccessLevel Value ConstValue }
type ConstValue ¶ added in v0.3.0
type ConstValue struct { Type ConstValueType Value interface{} }
ConstValue structure is used to store the value and type of constant.
func NewBoolConst ¶ added in v0.3.0
func NewBoolConst(v bool) ConstValue
NewBoolConst returns a new constant value with the preset bool type and the passed value v.
func NewFloatConst ¶ added in v0.3.0
func NewFloatConst(v float64) ConstValue
NewFloatConst returns a new constant value with the preset float type and the passed value v.
func NewIntConst ¶ added in v0.3.0
func NewIntConst(v int64) ConstValue
NewIntConst returns a new constant value with the preset int type and the passed value v.
func NewStringConst ¶ added in v0.3.0
func NewStringConst(v string) ConstValue
NewStringConst returns a new constant value with the preset string type and the passed value v.
func (ConstValue) GetBool ¶ added in v0.3.0
func (c ConstValue) GetBool() bool
GetBool returns the value stored in c.Value cast to bool type.
Should be used with care, it can panic if the type is not equal to the required one. Usually used in places where the type has already been clearly defined and the probability of panic is 0.
func (ConstValue) GetFloat ¶ added in v0.3.0
func (c ConstValue) GetFloat() float64
GetFloat returns the value stored in c.Value cast to float type.
Should be used with care, it can panic if the type is not equal to the required one. Usually used in places where the type has already been clearly defined and the probability of panic is 0.
func (ConstValue) GetInt ¶ added in v0.3.0
func (c ConstValue) GetInt() int64
GetInt returns the value stored in c.Value cast to int type.
Should be used with care, it can panic if the type is not equal to the required one. Usually used in places where the type has already been clearly defined and the probability of panic is 0.
func (ConstValue) GetString ¶ added in v0.3.0
func (c ConstValue) GetString() string
GetString returns the value stored in c.Value cast to string type.
Should be used with care, it can panic if the type is not equal to the required one. Usually used in places where the type has already been clearly defined and the probability of panic is 0.
func (*ConstValue) GobDecode ¶ added in v0.3.0
func (c *ConstValue) GobDecode(buf []byte) error
func (ConstValue) GobEncode ¶ added in v0.3.0
func (c ConstValue) GobEncode() ([]byte, error)
func (ConstValue) IsEqual ¶ added in v0.3.0
func (c ConstValue) IsEqual(v ConstValue) bool
IsEqual checks for equality with the passed constant value.
If any of the constants are undefined, false is returned.
func (ConstValue) IsValid ¶ added in v0.3.0
func (c ConstValue) IsValid() bool
IsValid checks that the value is valid and its type is not undefined.
func (ConstValue) String ¶ added in v0.3.0
func (c ConstValue) String() string
func (ConstValue) ToBool ¶ added in v0.3.0
func (c ConstValue) ToBool() (value bool, ok bool)
ToBool converts x constant to boolean constants following PHP conversion rules. Second bool result tells whether that conversion was successful.
func (ConstValue) ToInt ¶ added in v0.3.0
func (c ConstValue) ToInt() (int64, bool)
ToInt converts x constant to int constants following PHP conversion rules. Second bool result tells whether that conversion was successful.
func (ConstValue) ToString ¶ added in v0.3.0
func (c ConstValue) ToString() (string, bool)
ToString converts x constant to string constants following PHP conversion rules. Second bool result tells whether that conversion was successful.
type ConstValueType ¶ added in v0.3.0
type ConstValueType uint8
const ( Undefined ConstValueType = iota Integer Float String Bool )
func (ConstValueType) String ¶ added in v0.3.0
func (i ConstValueType) String() string
type ConstantsMap ¶
type DeprecationInfo ¶ added in v0.5.1
type DeprecationInfo struct { Deprecated bool Removed bool Reason string Replacement string Since string RemovedReason string }
func (*DeprecationInfo) Append ¶ added in v0.5.1
func (i *DeprecationInfo) Append(other DeprecationInfo)
func (DeprecationInfo) String ¶ added in v0.5.1
func (i DeprecationInfo) String() (res string)
func (DeprecationInfo) WithDeprecationNote ¶ added in v0.5.1
func (i DeprecationInfo) WithDeprecationNote() bool
type ElementPosition ¶
type FuncInfo ¶
type FuncInfo struct { Pos ElementPosition Name string Params []FuncParam MinParamsCnt int Typ types.Map AccessLevel AccessLevel Flags FuncFlags ExitFlags int // if function has exit/die/throw, then ExitFlags will be <> 0 Internal bool DeprecationInfo }
func (*FuncInfo) IsAbstract ¶ added in v0.2.0
func (*FuncInfo) IsDeprecated ¶ added in v0.5.1
func (*FuncInfo) IsFromAnnotation ¶ added in v0.4.0
type FuncInfoOverride ¶
type FuncInfoOverride struct { OverrideType OverrideType Properties OverrideProperties ArgNum int }
FuncInfoOverride defines return type overrides based on their parameter types. For example, \array_slice($arr) returns type of element (OverrideElementType) of the ArgNum=0
type FunctionsMap ¶
type FunctionsMap struct {
H map[lowercaseString]FuncInfo
}
func NewFunctionsMap ¶ added in v0.2.0
func NewFunctionsMap() FunctionsMap
func (FunctionsMap) Delete ¶ added in v0.2.0
func (m FunctionsMap) Delete(name string)
func (FunctionsMap) Len ¶ added in v0.2.0
func (m FunctionsMap) Len() int
func (FunctionsMap) Set ¶ added in v0.2.0
func (m FunctionsMap) Set(name string, fn FuncInfo)
type FunctionsOverrideMap ¶
type FunctionsOverrideMap map[string]FuncInfoOverride
type Info ¶
Info contains meta information for all classes, functions, etc.
func (*Info) AddClassesNonLocked ¶ added in v0.4.0
func (i *Info) AddClassesNonLocked(filename string, m ClassesMap)
func (*Info) AddConstantsNonLocked ¶ added in v0.4.0
func (i *Info) AddConstantsNonLocked(filename string, m ConstantsMap)
func (*Info) AddFilenameNonLocked ¶ added in v0.4.0
func (*Info) AddFunctionsNonLocked ¶ added in v0.4.0
func (i *Info) AddFunctionsNonLocked(filename string, m FunctionsMap)
func (*Info) AddFunctionsOverridesNonLocked ¶ added in v0.4.0
func (i *Info) AddFunctionsOverridesNonLocked(filename string, m FunctionsOverrideMap)
func (*Info) AddToGlobalScopeNonLocked ¶ added in v0.4.0
func (*Info) AddTraitsNonLocked ¶ added in v0.4.0
func (i *Info) AddTraitsNonLocked(filename string, m ClassesMap)
func (*Info) DeleteMetaForFileNonLocked ¶ added in v0.4.0
func (*Info) FileExists ¶ added in v0.4.0
func (*Info) FindConstants ¶ added in v0.4.0
func (*Info) FindFunctions ¶ added in v0.4.0
func (*Info) GetClassOrTrait ¶ added in v0.4.0
func (*Info) GetConstant ¶ added in v0.4.0
func (*Info) GetFunction ¶ added in v0.4.0
func (*Info) GetFunctionOverride ¶ added in v0.4.0
func (i *Info) GetFunctionOverride(nm string) (res FuncInfoOverride, ok bool)
func (*Info) GetInternalFunctionInfo ¶ added in v0.4.0
func (*Info) GetInternalFunctionOverrideInfo ¶ added in v0.4.0
func (i *Info) GetInternalFunctionOverrideInfo(fn string) (info FuncInfoOverride, ok bool)
func (*Info) GetMetaForFile ¶ added in v0.4.0
func (*Info) InitKphpStubs ¶ added in v0.4.0
func (i *Info) InitKphpStubs()
func (*Info) IsIndexingComplete ¶ added in v0.4.0
func (*Info) IsInternalClass ¶ added in v0.4.0
func (*Info) IsLoadingStubs ¶ added in v0.4.0
IsLoadingStubs reports whether we're parsing stub files right now.
func (*Info) NumClasses ¶ added in v0.4.0
func (*Info) NumConstants ¶ added in v0.4.0
func (*Info) NumFilesWithFunctions ¶ added in v0.4.0
func (*Info) NumFunctions ¶ added in v0.4.0
func (*Info) OnIndexingComplete ¶ added in v0.4.0
func (*Info) SetIndexingComplete ¶ added in v0.4.0
func (*Info) SetLoadingStubs ¶ added in v0.4.0
SetLoadingStubs changes IsLoadingStubs() return value.
Should be only called from linter.InitStubs() function.
type OverrideProperties ¶ added in v0.4.0
type OverrideProperties int
const ( // NotNull means that the null type will be removed from the resulting type. NotNull OverrideProperties = 1 << iota // NotFalse means that the false type will be removed from the resulting type. NotFalse // ArrayOf means that the type will be converted to an array of elements of that type. ArrayOf )
type OverrideType ¶
type OverrideType int
const ( // OverrideArgType means that return type of a function is the same as the type of the argument OverrideArgType OverrideType = iota // OverrideElementType means that return type of a function is the same as the type of an element of the argument OverrideElementType // OverrideClassType means that return type of a function is the same as the type represented by the class name. OverrideClassType // OverrideNullableClassType means that return type of a function is the same as the type represented by the class name, and is also nullable. OverrideNullableClassType )
type PackageInfo ¶ added in v0.5.3
type PerFile ¶
type PerFile struct { Traits ClassesMap Classes ClassesMap Functions FunctionsMap Constants ConstantsMap }
PerFile contains all meta information about the specified file
type PropertiesMap ¶
type PropertiesMap map[string]PropertyInfo
type PropertyFlags ¶ added in v0.4.0
type PropertyFlags uint8
const ( // PropFromAnnotation is set if the property is described in the class annotation. PropFromAnnotation PropertyFlags = 1 << iota )
type PropertyInfo ¶
type PropertyInfo struct { Pos ElementPosition Typ types.Map AccessLevel AccessLevel Flags PropertyFlags }
func (*PropertyInfo) IsFromAnnotation ¶ added in v0.4.0
func (info *PropertyInfo) IsFromAnnotation() bool
type Scope ¶
type Scope struct {
// contains filtered or unexported fields
}
Scope contains variables with their types in the respective scope
func (*Scope) AddImplicitVar ¶ added in v0.4.0
AddImplicitVar adds implicit variable with specified types to scope
func (*Scope) AddVarFromPHPDoc ¶
AddVarFromPHPDoc adds variable with specified types to the scope
func (*Scope) AddVarName ¶
AddVarName adds variable with specified types to the scope
func (*Scope) DelVarName ¶
DelVarName deletes variable from the scope by it's name
func (*Scope) GetVarName ¶ added in v0.5.0
GetVarName returns variable if it exists
func (*Scope) GetVarNameType ¶
GetVarNameType returns type map for variable if it exists
func (*Scope) GetVarType ¶ added in v0.4.0
GetVarType returns type map for variable if it exists
func (*Scope) HaveImplicitVar ¶ added in v0.5.0
HaveImplicitVar checks whether or not specified implicit variable is present in the scope and that it is always defined
func (*Scope) HaveImplicitVarName ¶ added in v0.5.0
HaveImplicitVarName checks whether or not specified implicit variable is present in the scope and that it is always defined
func (*Scope) HaveVar ¶
HaveVar checks whether or not specified variable is present in the scope and that it is always defined
func (*Scope) HaveVarName ¶
HaveVarName checks whether or not specified variable is present in the scope and that it is always defined
func (*Scope) IsInClosure ¶
IsInClosure returns whether or not this scope is inside a closure and thus $this can be late-bound.
func (*Scope) IsInInstanceMethod ¶
IsInInstanceMethod returns whether or not this scope exists in instance method (and thus closures must capture $this)
func (*Scope) MaybeHaveVar ¶
MaybeHaveVar checks that variable is present in the scope (it may be not always defined)
func (*Scope) MaybeHaveVarName ¶
MaybeHaveVarName checks that variable is present in the scope (it may be not always defined)
func (*Scope) ReplaceVar ¶
ReplaceVar replaces variable with specified types to scope
func (*Scope) ReplaceVarName ¶
ReplaceVarName replaces variable with specified types to the scope
func (*Scope) SetInClosure ¶
SetInClosure updates "inClosure" flag that indicates whether or not we are inside a closure and thus late $this binding is possible.
func (*Scope) SetInInstanceMethod ¶
SetInInstanceMethod updates "inInstanceMethod" flag that indicated whether or not scope is located inside instance method and that "$this" needs to be captured
type ScopeVar ¶ added in v0.4.0
type VarFlags ¶ added in v0.3.0
type VarFlags uint8
const ( VarAlwaysDefined VarFlags VarImplicit )