phpast

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package phpast provides shared PHP AST traversal utilities for test framework parsers.

Index

Constants

View Source
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

func ExtendsTestCase(node *sitter.Node, source []byte) bool

ExtendsTestCase checks if a class extends a TestCase base class. Matches: TestCase, BaseTestCase, *TestCase (suffix match) Does NOT match: TestCaseHelper, SomeTestCaseMixin (not suffix)

func GetAttributeName

func GetAttributeName(attr *sitter.Node, source []byte) string

GetAttributeName extracts the attribute name (e.g., "Test" from #[Test]).

func GetAttributes

func GetAttributes(node *sitter.Node) []*sitter.Node

GetAttributes extracts PHP 8 attribute nodes from a method declaration.

func GetClassName

func GetClassName(node *sitter.Node, source []byte) string

GetClassName extracts the class name from a class_declaration node.

func GetDeclarationList

func GetDeclarationList(node *sitter.Node) *sitter.Node

GetDeclarationList returns the declaration_list (class body) from a class_declaration.

func GetMethodName

func GetMethodName(node *sitter.Node, source []byte) string

GetMethodName extracts the method name from a method_declaration node.

func HasSkipAttribute

func HasSkipAttribute(attrs []*sitter.Node, source []byte) (bool, string)

HasSkipAttribute checks if a method has skip-related attributes.

func HasTestAnnotation

func HasTestAnnotation(comment string) bool

HasTestAnnotation checks if a docblock contains @test annotation.

func HasTestAttribute

func HasTestAttribute(attrs []*sitter.Node, source []byte) bool

HasTestAttribute checks if a method has #[Test] attribute (PHP 8+).

func IsPHPTestFileName

func IsPHPTestFileName(filename string) bool

IsPHPTestFileName checks if the filename follows PHPUnit test naming conventions.

Types

This section is empty.

Jump to

Keyboard shortcuts

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