Documentation ¶
Index ¶
- func ContainsTag(value []byte) bool
- func IsPHPDoc(doc string) bool
- func IsPHPDocToken(t *token.Token) bool
- func IsSuspicious(value []byte) bool
- type Comment
- type CommentPart
- type ExprKind
- type ExprShape
- type PackageCommentPart
- type RawCommentPart
- type Type
- type TypeCommentPart
- type TypeExpr
- type TypeParser
- type TypeVarCommentPart
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContainsTag ¶ added in v0.4.0
ContainsTag checks if /* */ comments contain annotations, which may mean that it is phpdoc, but there is a mistake when there is one asterisk instead of two at the beginning of a comment.
func IsPHPDocToken ¶ added in v0.4.0
IsPHPDocToken checks if the token is a doc comment
func IsSuspicious ¶ added in v0.4.0
IsSuspicious checks that phpdoc starts with /* but has tags inside it.
Types ¶
type Comment ¶ added in v0.4.0
type Comment struct { Raw string Parsed []CommentPart Inherit bool // Comment contains @inheritdoc marker. }
func Parse ¶
func Parse(parser *TypeParser, doc string) Comment
Parse returns parsed doc comment with interesting parts (ones that start "* @")
type CommentPart ¶
type ExprKind ¶ added in v0.3.0
type ExprKind uint8
const ( // ExprInvalid represents "failed to parse" type expression. ExprInvalid ExprKind = iota // ExprUnknown is a garbage-prefixed type expression. // Examples: `-int` `@@\Foo[]` // Args[0] - a valid expression that follows invalid prefix ExprUnknown // ExprName is a type that is identified by its name. // Examples: `int` `\Foo\Bar` `$this` ExprName // ExprSpecialName is a special name-like type node. // Examples: `*` `...` ExprSpecialName // ExprInt is a digit-only type expression. // Examples: `0` `10` ExprInt // ExprKeyVal is `key:val` type. // Examples: `name: string` `id:int` // Args[0] - key expression (left) // Args[1] - val expression (right) ExprKeyVal // ExprMemberType is access to member. // Examples: `\Foo::SOME_CONSTANT` `\Foo::$a` // Args[0] - class type expression (left) // Args[1] - member name expression (right) ExprMemberType // ExprArray is `elem[]` or `[]elem` type. // Examples: `int[]` `(int|float)[]` `int[` // Args[0] - array element type // ShapeArrayPrefix: `[]T` // // Note: may miss second `]`. ExprArray // ExprParen is `(expr)` type. // Examples: `(int)` `(\Foo\Bar[])` `(int` // Args[0] - enclosed type // // Note: may miss closing `)`. ExprParen // ExprNullable is `?expr` type. // Examples: `?int` `?\Foo` // Args[0] - nullable element type ExprNullable // ExprOptional is `expr?` type. // Examples: `k?: int` // Args[0] - optional element type ExprOptional // ExprNot is `!expr` type. // Examples: `!int` `!(int|float)` // Args[0] - negated element type // // Note: only valid for phpgrep type filters. ExprNot // ExprUnion is `x|y` type. // Examples: `T1|T2` `int|float[]|false` // Args - type variants ExprUnion // ExprInter is `x&y` type. // Examples: `T1&T2` `I1&I2&I3` ExprInter // ExprGeneric is a parametrized `expr<T,...>` type. // Examples: `\Collection<T>` `Either<int[], false>` `Bad<int` // Args[0] - parametrized type // Args[1:] - type parameters // ShapeGenericParen: `T(X,Y)` // ShapeGenericBrace: `T{X,Y}` // // Note: may miss closing `>`. ExprGeneric // ExprTypedCallable is a parametrized `callable(A,...):B` type. // Examples: `callable():void` `callable(int, int) : float` // Args[0] - return type // Args[1:] - argument types ExprTypedCallable // ExprLiteral is a single quoted string value. // Examples: `'a'` `'abc'` `'!'` ExprLiteral )
type PackageCommentPart ¶ added in v0.5.3
type PackageCommentPart struct { PackageName string // contains filtered or unexported fields }
func (*PackageCommentPart) Line ¶ added in v0.5.3
func (c *PackageCommentPart) Line() int
func (*PackageCommentPart) Name ¶ added in v0.5.3
func (c *PackageCommentPart) Name() string
type RawCommentPart ¶ added in v0.3.0
type RawCommentPart struct { Params []string // {"something", "bla-bla-bla"} in example above ParamsText string // "something bla-bla-bla" in example above // contains filtered or unexported fields }
func (*RawCommentPart) Line ¶ added in v0.3.0
func (c *RawCommentPart) Line() int
func (*RawCommentPart) Name ¶ added in v0.3.0
func (c *RawCommentPart) Name() string
type TypeCommentPart ¶ added in v0.3.0
func (*TypeCommentPart) Line ¶ added in v0.3.0
func (c *TypeCommentPart) Line() int
func (*TypeCommentPart) Name ¶ added in v0.3.0
func (c *TypeCommentPart) Name() string
type TypeExpr ¶ added in v0.2.0
type TypeParser ¶ added in v0.2.0
type TypeParser struct {
// contains filtered or unexported fields
}
func NewTypeParser ¶ added in v0.3.0
func NewTypeParser() *TypeParser
func (*TypeParser) Parse ¶ added in v0.3.0
func (p *TypeParser) Parse(s string) Type
type TypeVarCommentPart ¶ added in v0.3.0
type TypeVarCommentPart struct { VarIsFirst bool Var string Type Type Rest string // contains filtered or unexported fields }
func (*TypeVarCommentPart) Line ¶ added in v0.3.0
func (c *TypeVarCommentPart) Line() int
func (*TypeVarCommentPart) Name ¶ added in v0.3.0
func (c *TypeVarCommentPart) Name() string
Click to show internal directories.
Click to hide internal directories.