symbol

package
v0.0.0-...-e49a3f0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoParam    = errors.New("parameter has no type")
	ErrNotAMethod = errors.New("does not live on a method")
)
View Source
var ErrNoPropertyType = errors.New("property has no type declaration")
View Source
var ErrNoReturn = errors.New("node has no return type")
View Source
var ErrNoVarType = errors.New("variable has no @var node")

Functions

func NewDoxed

func NewDoxed(
	node ast.Vertex,
) *doxed

func NodeComments

func NodeComments(node ast.Vertex) []string

func TypeHintToDocType

func TypeHintToDocType(node ast.Vertex) (phpdoxer.Type, error)

TypeHintToDocType Turns a type hint node, from for example ir.FunctionStmt.ReturnType into the equivalent phpdoxer.Type.

Types

type ClassConst

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

func NewClassConst

func NewClassConst(node *ast.StmtClassConstList) *ClassConst

func (ClassConst) CanBeAccessedFrom

func (m ClassConst) CanBeAccessedFrom(p phprivacy.Privacy) bool

func (ClassConst) HasExplicitPrivacy

func (m ClassConst) HasExplicitPrivacy() bool

func (ClassConst) IsFinal

func (m ClassConst) IsFinal() bool

func (ClassConst) IsStatic

func (m ClassConst) IsStatic() bool

func (*ClassConst) Name

func (p *ClassConst) Name() string

func (*ClassConst) Node

func (p *ClassConst) Node() *ast.StmtClassConstList

func (ClassConst) Privacy

func (m ClassConst) Privacy() phprivacy.Privacy

type ClassLike

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

func NewClassLike

func NewClassLike(root rooter, node ast.Vertex) *ClassLike

func NewClassLikeFromFQN

func NewClassLikeFromFQN(r rooter, qualified *fqn.FQN) (*ClassLike, error)

func NewClassLikeFromMethod

func NewClassLikeFromMethod(root *ast.Root, method *ast.StmtClassMethod) (*ClassLike, error)

func NewClassLikeFromName

func NewClassLikeFromName(nameRoot *ast.Root, n ast.Vertex) (*ClassLike, error)

func NewClassLikeFromProperty

func NewClassLikeFromProperty(root *ast.Root, property *ast.StmtPropertyList) (*ClassLike, error)

func (ClassLike) CanBeAccessedFrom

func (m ClassLike) CanBeAccessedFrom(p phprivacy.Privacy) bool

func (*ClassLike) ConstantsIter

func (c *ClassLike) ConstantsIter() ConstantsIterFunc

func (ClassLike) Docs

func (d ClassLike) Docs() []phpdoxer.Node

func (ClassLike) Extends

func (i ClassLike) Extends() ast.Vertex

func (ClassLike) FindAllDocs

func (d ClassLike) FindAllDocs(filters ...DocFilter) (results []phpdoxer.Node)

func (*ClassLike) FindConstant

func (c *ClassLike) FindConstant(filters ...FilterFunc[*ClassConst]) *ClassConst

func (ClassLike) FindDoc

func (d ClassLike) FindDoc(filters ...DocFilter) phpdoxer.Node

func (*ClassLike) FindMember

func (c *ClassLike) FindMember(filters ...FilterFunc[Member]) Member

func (*ClassLike) FindMemberInherit

func (c *ClassLike) FindMemberInherit(filters ...FilterFunc[Member]) Member

func (*ClassLike) FindMembers

func (c *ClassLike) FindMembers(shortCircuit bool, filters ...FilterFunc[Member]) (res []Member)

TODO: also constants.

func (*ClassLike) FindMembersInherit

func (c *ClassLike) FindMembersInherit(
	shortCircuit bool,
	filters ...FilterFunc[Member],
) (res []Member)

func (*ClassLike) FindMethod

func (c *ClassLike) FindMethod(filters ...FilterFunc[*Method]) *Method

func (*ClassLike) FindMethods

func (c *ClassLike) FindMethods(shortCircuit bool, filters ...FilterFunc[*Method]) (res []*Method)

func (*ClassLike) FindProperties

func (c *ClassLike) FindProperties(
	shortCircuit bool,
	filters ...FilterFunc[*Property],
) (res []*Property)

func (*ClassLike) FindProperty

func (c *ClassLike) FindProperty(filters ...FilterFunc[*Property]) *Property

func (ClassLike) FindThrows

func (d ClassLike) FindThrows() []*phpdoxer.NodeThrows

func (ClassLike) HasExplicitPrivacy

func (m ClassLike) HasExplicitPrivacy() bool

func (ClassLike) Implements

func (i ClassLike) Implements() []ast.Vertex

func (*ClassLike) InheritsIter

func (c *ClassLike) InheritsIter() InheritsIterFunc

InheritsIter returns a generator function that generates the classes/interfaces/traits that this class/interface/trait inherits from.

The classes are generated in the same order that PHP evaluates them, so, if you have a method in the first generated class, it is overwriting any other generated classes that define that method.

This order is:

  1. Current class/trait/interface
  2. Any used traits
  3. If the class extends another 3a. Extended class 3b. Extended class's traits 3c. If the class extends another -> back to 3, otherwise 4.
  4. Any interface implementations

The generator returns true for done when there are no classes left in the chain. If there was an error generating the next class, the newClsLikeErr argument will be set.

func (ClassLike) IsFinal

func (m ClassLike) IsFinal() bool

func (ClassLike) IsStatic

func (m ClassLike) IsStatic() bool

func (*ClassLike) Kind

func (c *ClassLike) Kind() ast.Type

func (*ClassLike) MethodsIter

func (c *ClassLike) MethodsIter() MethodsIterFunc

func (*ClassLike) Name

func (c *ClassLike) Name() string

func (ClassLike) Privacy

func (m ClassLike) Privacy() phprivacy.Privacy

func (*ClassLike) PropertiesIter

func (c *ClassLike) PropertiesIter() PropertiesIterFunc

func (ClassLike) RawDocs

func (d ClassLike) RawDocs() string

func (ClassLike) Uses

func (i ClassLike) Uses() []ast.Vertex

type ConstantsIterFunc

type ConstantsIterFunc func() (method *ClassConst, done bool, genErr error)

type DocFilter

type DocFilter func(phpdoxer.Node) bool

func FilterDocKind

func FilterDocKind(kind phpdoxer.NodeKind) DocFilter

func FilterParamName

func FilterParamName(name string) DocFilter

type FilterFunc

type FilterFunc[T any] func(T) bool

func FilterCanBeAccessedFrom

func FilterCanBeAccessedFrom[T Modified](privacy phprivacy.Privacy) FilterFunc[T]

func FilterName

func FilterName[T Named](name string) FilterFunc[T]

func FilterNotPrivacy

func FilterNotPrivacy[T Modified](privacy phprivacy.Privacy) FilterFunc[T]

func FilterNotStatic

func FilterNotStatic[T Modified]() FilterFunc[T]

func FilterOverwrittenBy

func FilterOverwrittenBy[T NamedModified](m T, addDollar ...bool) FilterFunc[T]

func FilterPrefix

func FilterPrefix[T Named](prefix string) FilterFunc[T]

func FilterPrivacy

func FilterPrivacy[T Modified](privacy phprivacy.Privacy) FilterFunc[T]

func FilterStatic

func FilterStatic[T Modified]() FilterFunc[T]

type Function

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

func NewFunction

func NewFunction(root rooter, node *ast.StmtFunction) *Function

func NewFunctionFromFQN

func NewFunctionFromFQN(root rooter, qualified *fqn.FQN) (*Function, error)

func (Function) Docs

func (d Function) Docs() []phpdoxer.Node

func (Function) FindAllDocs

func (d Function) FindAllDocs(filters ...DocFilter) (results []phpdoxer.Node)

func (Function) FindDoc

func (d Function) FindDoc(filters ...DocFilter) phpdoxer.Node

func (Function) FindParameter

func (p Function) FindParameter(filters ...FilterFunc[*Parameter]) (*Parameter, error)

func (Function) FindThrows

func (d Function) FindThrows() []*phpdoxer.NodeThrows

func (*Function) Name

func (m *Function) Name() string

func (*Function) Node

func (m *Function) Node() *ast.StmtFunction

func (Function) Parameters

func (p Function) Parameters() ([]*Parameter, error)

func (Function) RawDocs

func (d Function) RawDocs() string

func (Function) Returns

func (r Function) Returns() (phpdoxer.Type, *ClassLike, error)

Returns gets the return type of this callable. Traversing through inherited methods with {@inheritdoc}.

If the node is a method, the 2nd argument is the enclosing class of the method that had the type definition on it.

func (Function) ReturnsClass

func (r Function) ReturnsClass() ([]*phpdoxer.TypeClassLike, error)

ReturnsClass resolves and unpacks the raw type returned from Returns into the classes it represents. See doxcontext.ApplyContext for more.

type InheritsIterFunc

type InheritsIterFunc func() (clsLike *ClassLike, done bool, newClsLikeErr error)

type Member

type Member interface {
	NamedModified
	Vertex() ast.Vertex
	// contains filtered or unexported methods
}

type Method

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

func NewMethod

func NewMethod(root rooter, node *ast.StmtClassMethod) *Method

func (Method) CanBeAccessedFrom

func (m Method) CanBeAccessedFrom(p phprivacy.Privacy) bool

func (Method) Docs

func (d Method) Docs() []phpdoxer.Node

func (Method) FindAllDocs

func (d Method) FindAllDocs(filters ...DocFilter) (results []phpdoxer.Node)

func (Method) FindDoc

func (d Method) FindDoc(filters ...DocFilter) phpdoxer.Node

func (Method) FindParameter

func (p Method) FindParameter(filters ...FilterFunc[*Parameter]) (*Parameter, error)

func (Method) FindThrows

func (d Method) FindThrows() []*phpdoxer.NodeThrows

func (Method) HasExplicitPrivacy

func (m Method) HasExplicitPrivacy() bool

func (Method) IsFinal

func (m Method) IsFinal() bool

func (Method) IsStatic

func (m Method) IsStatic() bool

func (*Method) Name

func (m *Method) Name() string

func (*Method) Node

func (m *Method) Node() *ast.StmtClassMethod

func (Method) Parameters

func (p Method) Parameters() ([]*Parameter, error)

func (Method) Privacy

func (m Method) Privacy() phprivacy.Privacy

func (Method) RawDocs

func (d Method) RawDocs() string

func (Method) Returns

func (r Method) Returns() (phpdoxer.Type, *ClassLike, error)

Returns gets the return type of this callable. Traversing through inherited methods with {@inheritdoc}.

If the node is a method, the 2nd argument is the enclosing class of the method that had the type definition on it.

func (Method) ReturnsClass

func (r Method) ReturnsClass() ([]*phpdoxer.TypeClassLike, error)

ReturnsClass resolves and unpacks the raw type returned from Returns into the classes it represents. See doxcontext.ApplyContext for more.

func (*Method) Vertex

func (m *Method) Vertex() ast.Vertex

type MethodsIterFunc

type MethodsIterFunc func() (method *Method, done bool, genErr error)

type Modified

type Modified interface {
	Privacy() phprivacy.Privacy
	CanBeAccessedFrom(phprivacy.Privacy) bool
	IsFinal() bool
	IsStatic() bool
}

type Named

type Named interface {
	Name() string
}

type NamedModified

type NamedModified interface {
	Named
	Modified
}

type Parameter

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

func NewParameter

func NewParameter(root rooter, funcOrMeth ast.Vertex, param *ast.Parameter) *Parameter

func (*Parameter) Name

func (p *Parameter) Name() string

func (*Parameter) Node

func (p *Parameter) Node() *ast.Parameter

func (*Parameter) Type

func (p *Parameter) Type() (phpdoxer.Type, *ClassLike, error)

Type will get the parameter's type, if Parameter.funcOrMeth is a *Method, it also checks any inherited methods for a type definition.

If the funcOrMeth is a method, the containing class of method that had a type definition is returned as the 2nd return. This is nil when the funcOrMeth is a function.

func (*Parameter) TypeClass

func (p *Parameter) TypeClass() ([]*phpdoxer.TypeClassLike, error)

TypeClass resolves and unpacks the raw type returned from Type into the classes it represents. See doxcontext.ApplyContext for more.

type PropertiesIterFunc

type PropertiesIterFunc func() (property *Property, done bool, genErr error)

type Property

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

func NewProperty

func NewProperty(cls *ClassLike, node ast.Vertex) *Property

node should either be a *ast.Parameter or *ast.StmtPropertyList. *ast.Parameter is a constructor promoted property.

func (Property) CanBeAccessedFrom

func (m Property) CanBeAccessedFrom(p phprivacy.Privacy) bool

func (*Property) ClsType

func (p *Property) ClsType() ([]*phpdoxer.TypeClassLike, error)

func (Property) Docs

func (d Property) Docs() []phpdoxer.Node

func (Property) FindAllDocs

func (d Property) FindAllDocs(filters ...DocFilter) (results []phpdoxer.Node)

func (Property) FindDoc

func (d Property) FindDoc(filters ...DocFilter) phpdoxer.Node

func (Property) FindThrows

func (d Property) FindThrows() []*phpdoxer.NodeThrows

func (Property) HasExplicitPrivacy

func (m Property) HasExplicitPrivacy() bool

func (Property) IsFinal

func (m Property) IsFinal() bool

func (Property) IsStatic

func (m Property) IsStatic() bool

func (*Property) Name

func (p *Property) Name() string

func (*Property) Node

func (p *Property) Node() ast.Vertex

func (Property) Privacy

func (m Property) Privacy() phprivacy.Privacy

func (Property) RawDocs

func (d Property) RawDocs() string

func (*Property) Type

func (p *Property) Type() (phpdoxer.Type, *ClassLike, error)

Type resolves the property's type. The 2nd return value is the enclosing class of the property node that had the type definition.

func (*Property) Vertex

func (p *Property) Vertex() ast.Vertex

Implements the Member interface.

type Variable

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

func NewVariable

func NewVariable(root rooter, node *ast.ExprVariable) *Variable

func (Variable) Docs

func (d Variable) Docs() []phpdoxer.Node

func (Variable) FindAllDocs

func (d Variable) FindAllDocs(filters ...DocFilter) (results []phpdoxer.Node)

func (Variable) FindDoc

func (d Variable) FindDoc(filters ...DocFilter) phpdoxer.Node

func (Variable) FindThrows

func (d Variable) FindThrows() []*phpdoxer.NodeThrows

func (*Variable) Name

func (v *Variable) Name() string

func (Variable) RawDocs

func (d Variable) RawDocs() string

func (*Variable) Type

func (v *Variable) Type() (phpdoxer.Type, error)

Type checks for @var comments and returns the type. NOTE: this does not check any assignment or try to be smart.

func (*Variable) TypeCls

func (v *Variable) TypeCls(currFqn *fqn.FQN) ([]*phpdoxer.TypeClassLike, error)

currFqn can be nil if the variable is not in a class.

Jump to

Keyboard shortcuts

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