Documentation
¶
Overview ¶
Package phpast provides shared PHP AST traversal utilities for test framework parsers.
Index ¶
- Constants
- func ExtendsTestCase(node *sitter.Node, source []byte) bool
- func GetAttributeName(attr *sitter.Node, source []byte) string
- func GetAttributes(node *sitter.Node) []*sitter.Node
- func GetClassName(node *sitter.Node, source []byte) string
- func GetDeclarationList(node *sitter.Node) *sitter.Node
- func GetMethodName(node *sitter.Node, source []byte) string
- func HasSkipAttribute(attrs []*sitter.Node, source []byte) (bool, string)
- func HasTestAnnotation(comment string) bool
- func HasTestAttribute(attrs []*sitter.Node, source []byte) bool
- func IsPHPTestFileName(filename string) bool
Constants ¶
const ( NodeClassDeclaration = "class_declaration" NodeMethodDeclaration = "method_declaration" NodeDeclarationList = "declaration_list" NodeAttributeList = "attribute_list" NodeAttributeGroup = "attribute_group" NodeAttribute = "attribute" NodeComment = "comment" NodeName = "name" NodeVisibilityModifier = "visibility_modifier" NodeQualifiedName = "qualified_name" NodeNamespaceUse = "namespace_use_declaration" NodeBaseClause = "base_clause" )
PHP AST node types.
Variables ¶
This section is empty.
Functions ¶
func ExtendsTestCase ¶
ExtendsTestCase checks if a class extends a TestCase base class. Matches: TestCase, BaseTestCase, *TestCase, *Test (suffix match for indirect inheritance) Does NOT match: TestCaseHelper, TestHelper (not valid test base class suffix)
func GetAttributeName ¶
GetAttributeName extracts the attribute name (e.g., "Test" from #[Test]).
func GetAttributes ¶
GetAttributes extracts PHP 8 attribute nodes from a method declaration.
func GetClassName ¶
GetClassName extracts the class name from a class_declaration node.
func GetDeclarationList ¶
GetDeclarationList returns the declaration_list (class body) from a class_declaration.
func GetMethodName ¶
GetMethodName extracts the method name from a method_declaration node.
func HasSkipAttribute ¶
HasSkipAttribute checks if a method has skip-related attributes.
func HasTestAnnotation ¶
HasTestAnnotation checks if a docblock contains @test annotation.
func HasTestAttribute ¶
HasTestAttribute checks if a method has #[Test] attribute (PHP 8+).
func IsPHPTestFileName ¶
IsPHPTestFileName checks if the filename follows PHPUnit test naming conventions.
Types ¶
This section is empty.