phpdoxer

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: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrParse   = errors.New("Could not parse type out of PHPDoc")
	ErrUnknown = errors.New("No parsing rules matched the given PHPDoc")
	ErrEmpty   = errors.New("Given PHPDoc string is empty")
)

Functions

This section is empty.

Types

type BoolAccepts

type BoolAccepts uint
const (
	BoolAcceptsFalse BoolAccepts = iota
	BoolAcceptsTrue
	BoolAcceptsAll
)

type CallableParameter

type CallableParameter struct {
	Optional bool
	Variadic bool
	ByRef    bool
	Type     Type
	Name     string
}

func (*CallableParameter) String

func (c *CallableParameter) String() string

type ConditionalReturnCondition

type ConditionalReturnCondition struct {
	Left  string
	Right Type
}

func (*ConditionalReturnCondition) String

func (c *ConditionalReturnCondition) String() string

type Doc

type Doc struct {
	Top         string
	Indentation string
	Nodes       []Node
}

func ParseFullDoc

func ParseFullDoc(doc string) (*Doc, error)

Parse the doc string, keeping the leading documentation.

func (*Doc) String

func (d *Doc) String() string

Turns the doc back into a valid PHPDoc string.

NOTE: this is not intended to closely represent the input, but to produce NOTE: an output that has all the information the source had, NOTE: formatting might be slightly different.

It does try to roughly return the doc with the same indentation level as the source.

type Node

type Node interface {
	String() string
	Kind() NodeKind
	Range() (start int, end int)
	// contains filtered or unexported methods
}

func ParseDoc

func ParseDoc(doc string) ([]Node, error)

type NodeInheritDoc

type NodeInheritDoc struct {
	NodeRange
}

func (*NodeInheritDoc) Kind

func (n *NodeInheritDoc) Kind() NodeKind

func (*NodeInheritDoc) String

func (n *NodeInheritDoc) String() string

type NodeKind

type NodeKind uint
const (
	KindUnknown NodeKind = iota
	KindReturn
	KindVar
	KindParam
	KindInheritDoc
	KindSince
	KindRemoved
	KindThrows
)

type NodeParam

type NodeParam struct {
	NodeRange

	Type        Type
	Name        string
	Description string
}

func (*NodeParam) Kind

func (n *NodeParam) Kind() NodeKind

func (*NodeParam) String

func (n *NodeParam) String() string

type NodeRange

type NodeRange struct {
	StartPos int
	EndPos   int
}

func (*NodeRange) Range

func (n *NodeRange) Range() (start int, end int)

type NodeRemoved

type NodeRemoved struct {
	NodeRange

	Version     *phpversion.PHPVersion
	Description string
}

func (*NodeRemoved) Kind

func (n *NodeRemoved) Kind() NodeKind

func (*NodeRemoved) String

func (n *NodeRemoved) String() string

type NodeReturn

type NodeReturn struct {
	NodeRange

	Type        Type
	Description string
}

func (*NodeReturn) Kind

func (n *NodeReturn) Kind() NodeKind

func (*NodeReturn) String

func (n *NodeReturn) String() string

type NodeSince

type NodeSince struct {
	NodeRange

	Version     *phpversion.PHPVersion
	Description string
}

func (*NodeSince) Kind

func (n *NodeSince) Kind() NodeKind

func (*NodeSince) String

func (n *NodeSince) String() string

type NodeThrows

type NodeThrows struct {
	NodeRange

	Type        Type
	Description string
}

func (*NodeThrows) Kind

func (n *NodeThrows) Kind() NodeKind

func (*NodeThrows) String

func (n *NodeThrows) String() string

type NodeUnknown

type NodeUnknown struct {
	NodeRange

	// The string after @.
	At    string
	Value string
}

func (*NodeUnknown) Kind

func (n *NodeUnknown) Kind() NodeKind

func (*NodeUnknown) String

func (n *NodeUnknown) String() string

type NodeVar

type NodeVar struct {
	NodeRange

	Type        Type
	Description string
}

func (*NodeVar) Kind

func (n *NodeVar) Kind() NodeKind

func (*NodeVar) String

func (n *NodeVar) String() string

type StringConstraint

type StringConstraint uint
const (
	StringConstraintNone StringConstraint = iota
	StringConstraintClass
	StringConstraintCallable
	StringConstraintNumeric
	StringConstraintNonEmpty
	StringConstraintLiteral
)

type Type

type Type interface {
	String() string
	Kind() TypeKind
}

func ParseType

func ParseType(value string) (Type, error)

NOTE: const and classlike types are basically the same format, to parse those NOTE: correctly we need context of the actual project, which we don't have here. NOTE: for phpls, the internal package 'doxcontext' is there to NOTE: apply context and transform these cases.

type TypeArray

type TypeArray struct {
	KeyType  Type
	ItemType Type
	NonEmpty bool
}

func (*TypeArray) Kind

func (t *TypeArray) Kind() TypeKind

func (*TypeArray) String

func (t *TypeArray) String() string

type TypeArrayKey

type TypeArrayKey struct{}

TypeArrayKey is a hashable value (usable as an array key).

func (*TypeArrayKey) Kind

func (t *TypeArrayKey) Kind() TypeKind

func (*TypeArrayKey) String

func (t *TypeArrayKey) String() string

type TypeArrayShape

type TypeArrayShape struct {
	Values []*TypeArrayShapeValue
}

func (*TypeArrayShape) Kind

func (t *TypeArrayShape) Kind() TypeKind

func (*TypeArrayShape) String

func (t *TypeArrayShape) String() string

type TypeArrayShapeValue

type TypeArrayShapeValue struct {
	// Can be an int disguised as a string
	Key      string
	Type     Type
	Optional bool
}

func (*TypeArrayShapeValue) Kind

func (t *TypeArrayShapeValue) Kind() TypeKind

func (*TypeArrayShapeValue) String

func (t *TypeArrayShapeValue) String() string

type TypeBool

type TypeBool struct {
	Accepts BoolAccepts
}

func (*TypeBool) Kind

func (t *TypeBool) Kind() TypeKind

func (*TypeBool) String

func (t *TypeBool) String() string

type TypeCallable

type TypeCallable struct {
	Parameters []*CallableParameter
	Return     Type
}

func (*TypeCallable) Kind

func (t *TypeCallable) Kind() TypeKind

func (*TypeCallable) String

func (t *TypeCallable) String() string

type TypeClassLike

type TypeClassLike struct {
	Name           string
	FullyQualified bool
	GenericOver    []Type
}

func (*TypeClassLike) Identifier

func (t *TypeClassLike) Identifier() string

func (*TypeClassLike) Kind

func (t *TypeClassLike) Kind() TypeKind

func (*TypeClassLike) Namespace

func (t *TypeClassLike) Namespace() string

func (*TypeClassLike) String

func (t *TypeClassLike) String() string

type TypeConditionalReturn

type TypeConditionalReturn struct {
	Condition *ConditionalReturnCondition
	IfTrue    Type
	IfFalse   Type
}

func (*TypeConditionalReturn) Kind

func (t *TypeConditionalReturn) Kind() TypeKind

func (*TypeConditionalReturn) String

func (t *TypeConditionalReturn) String() string

type TypeConstant

type TypeConstant struct {
	Class *TypeClassLike
	Const string
}

func (*TypeConstant) Kind

func (t *TypeConstant) Kind() TypeKind

func (*TypeConstant) String

func (t *TypeConstant) String() string

type TypeFloat

type TypeFloat struct{}

func (*TypeFloat) Kind

func (t *TypeFloat) Kind() TypeKind

func (*TypeFloat) String

func (t *TypeFloat) String() string

type TypeFloatLiteral

type TypeFloatLiteral struct {
	Value float64
}

func (*TypeFloatLiteral) Kind

func (t *TypeFloatLiteral) Kind() TypeKind

func (*TypeFloatLiteral) String

func (t *TypeFloatLiteral) String() string

type TypeGenericTemplate

type TypeGenericTemplate struct {
	Name string
	Of   *TypeClassLike
}

NOTE: this only matches something like: T of \Exception, not T, that would be a TypeClassLike.

func (*TypeGenericTemplate) Kind

func (t *TypeGenericTemplate) Kind() TypeKind

func (*TypeGenericTemplate) String

func (t *TypeGenericTemplate) String() string

type TypeInt

type TypeInt struct {
	// Either 'min' or an int.
	Min string
	// Either 'max' or an int.
	Max string

	// Whether it is a 'positive-int'.
	HasPositiveConstraint bool
	// Whether it is a 'negative-int'.
	HasNegativeConstraint bool
}

func (*TypeInt) Kind

func (t *TypeInt) Kind() TypeKind

func (*TypeInt) String

func (t *TypeInt) String() string

type TypeIntLiteral

type TypeIntLiteral struct {
	Value int
}

func (*TypeIntLiteral) Kind

func (t *TypeIntLiteral) Kind() TypeKind

func (*TypeIntLiteral) String

func (t *TypeIntLiteral) String() string

type TypeIntMask

type TypeIntMask struct {
	Values []int
}

func (*TypeIntMask) Kind

func (t *TypeIntMask) Kind() TypeKind

func (*TypeIntMask) String

func (t *TypeIntMask) String() string

type TypeIntMaskOf

type TypeIntMaskOf struct {
	Type Type
}

func (*TypeIntMaskOf) Kind

func (t *TypeIntMaskOf) Kind() TypeKind

func (*TypeIntMaskOf) String

func (t *TypeIntMaskOf) String() string

type TypeIntersection

type TypeIntersection struct {
	Left  Type
	Right Type
}

func (*TypeIntersection) Kind

func (t *TypeIntersection) Kind() TypeKind

func (*TypeIntersection) String

func (t *TypeIntersection) String() string

type TypeIterable

type TypeIterable struct {
	// Is nil when it was created like this: 'iterable<x>'
	KeyType Type
	// Is nil when it was created like this: 'iterable'
	ItemType Type
}

func (*TypeIterable) Kind

func (t *TypeIterable) Kind() TypeKind

func (*TypeIterable) String

func (t *TypeIterable) String() string

type TypeKeyOf

type TypeKeyOf struct {
	Class *TypeClassLike
	Const string
}

func (*TypeKeyOf) Kind

func (t *TypeKeyOf) Kind() TypeKind

func (*TypeKeyOf) String

func (t *TypeKeyOf) String() string

type TypeKind

type TypeKind uint
const (
	KindMixed TypeKind = iota
	KindUnknownType
	KindNull
	KindClassLike
	KindArray
	KindIterable
	KindCallale
	KindBool
	KindFloat
	KindInt
	KindString
	KindObject
	KindNever
	KindScalar
	KindVoid
	KindArrayKey
	KindResource
	KindPrecedence
	KindUnion
	KindIntersection
	KindKeyOf
	KindValueOf
	KindArrayShape
	KindArrayShapeValue
	KindStringLiteral
	KindFloatLiteral
	KindIntLiteral
	KindConstant
	KindIntMask
	KindIntMaskOf
	KindConditionalReturn
	KindGenericTemplate
)

type TypeMixed

type TypeMixed struct{}

func (*TypeMixed) Kind

func (t *TypeMixed) Kind() TypeKind

func (*TypeMixed) String

func (t *TypeMixed) String() string

type TypeNever

type TypeNever struct{}

func (*TypeNever) Kind

func (t *TypeNever) Kind() TypeKind

func (*TypeNever) String

func (t *TypeNever) String() string

type TypeNull

type TypeNull struct{}

func (*TypeNull) Kind

func (t *TypeNull) Kind() TypeKind

func (*TypeNull) String

func (t *TypeNull) String() string

type TypeObject

type TypeObject struct{}

func (*TypeObject) Kind

func (t *TypeObject) Kind() TypeKind

func (*TypeObject) String

func (t *TypeObject) String() string

type TypePrecedence

type TypePrecedence struct {
	Type Type
}

func (*TypePrecedence) Kind

func (t *TypePrecedence) Kind() TypeKind

func (*TypePrecedence) String

func (t *TypePrecedence) String() string

type TypeResource

type TypeResource struct{}

func (*TypeResource) Kind

func (t *TypeResource) Kind() TypeKind

func (*TypeResource) String

func (t *TypeResource) String() string

type TypeScalar

type TypeScalar struct{}

Scalar is an int, float, bool or string.

func (*TypeScalar) Kind

func (t *TypeScalar) Kind() TypeKind

func (*TypeScalar) String

func (t *TypeScalar) String() string

type TypeString

type TypeString struct {
	Constraint StringConstraint

	// Can only be set when Constraint is ConstraintClass.
	GenericOver *TypeClassLike
}

func (*TypeString) Kind

func (t *TypeString) Kind() TypeKind

func (*TypeString) String

func (t *TypeString) String() string

type TypeStringLiteral

type TypeStringLiteral struct {
	Value string
}

func (*TypeStringLiteral) Kind

func (t *TypeStringLiteral) Kind() TypeKind

func (*TypeStringLiteral) String

func (t *TypeStringLiteral) String() string

type TypeUnion

type TypeUnion struct {
	Left  Type
	Right Type
}

func (*TypeUnion) Kind

func (t *TypeUnion) Kind() TypeKind

func (*TypeUnion) String

func (t *TypeUnion) String() string

type TypeUnknown

type TypeUnknown struct {
	Value string
}

func (*TypeUnknown) Kind

func (t *TypeUnknown) Kind() TypeKind

func (*TypeUnknown) String

func (t *TypeUnknown) String() string

type TypeValueOf

type TypeValueOf struct {
	Class *TypeClassLike

	// If IsEnum is true, Const is an empty string.
	Const  string
	IsEnum bool
}

func (*TypeValueOf) Kind

func (t *TypeValueOf) Kind() TypeKind

func (*TypeValueOf) String

func (t *TypeValueOf) String() string

type TypeVoid

type TypeVoid struct{}

func (*TypeVoid) Kind

func (t *TypeVoid) Kind() TypeKind

func (*TypeVoid) String

func (t *TypeVoid) String() string

Jump to

Keyboard shortcuts

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