{"modulePath":"github.com/wudi/php-parser","version":"v0.1.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package testutils\n\n## Constants\n\n```go\nconst (\n\tCategoryBasic       = \"basic\"\n\tCategoryExpressions = \"expressions\"\n\tCategoryStatements  = \"statements\"\n\tCategoryClasses     = \"classes\"\n\tCategoryFunctions   = \"functions\"\n\tCategoryControlFlow = \"control_flow\"\n\tCategoryErrors      = \"errors\"\n\tCategoryPHP8        = \"php8\"\n\tCategoryPHP81       = \"php81\"\n\tCategoryPHP82       = \"php82\"\n\tCategoryPHP83       = \"php83\"\n\tCategoryPHP84       = \"php84\"\n)\n```\nTestCategory 测试分类常量\n\n```go\nconst (\n\tTagSmoke        = \"smoke\"\n\tTagRegression   = \"regression\"\n\tTagSlow         = \"slow\"\n\tTagExperimental = \"experimental\"\n\tTagBenchmark    = \"benchmark\"\n\tTagIntegration  = \"integration\"\n\tTagUnit         = \"unit\"\n\tTagError        = \"error\"\n)\n```\nTestTags 测试标签常量\n\n## Variables\n\n```go\nvar CreateDefaultParserFactory func() ParserFactory\n```\nCreateDefaultParserFactory 创建默认解析器工厂的辅助函数 这个函数需要在parser包中实现\n\n```go\nvar DefaultGlobalConfig = \u0026GlobalConfig{\n\tDefaultStrictMode: true,\n\tEnableDebug:       false,\n\tTestDataDir:       \"testdata\",\n\tGoldenFileDir:     \"testdata/golden\",\n\tBenchmarkEnabled:  true,\n\tCoverageEnabled:   true,\n}\n```\nDefaultGlobalConfig 默认全局配置\n\n## Functions\n\n```go\nfunc CheckParserErrors(t *testing.T, p ParserInterface)\n```\nCheckParserErrors 检查解析器错误 - 从原有代码迁移\n\n```go\nfunc DebugParser(t *testing.T, source string, parserFactory ParserFactory)\n```\nDebugParser 调试解析器，输出详细信息\n\n```go\nfunc ExpectNoErrors() func(*TestContext)\n```\nExpectNoErrors 验证无解析错误\n\n```go\nfunc ExpectProgram(expectedBodyLen int) func(*TestContext)\n```\nExpectProgram 验证程序体长度\n\n```go\nfunc IsTestEnabled(tags []string) bool\n```\nIsTestEnabled 检查测试是否启用\n\n```go\nfunc MustCreateParser(source string) (ParserInterface, *TestContext)\n```\nMustCreateParser 必须创建解析器，失败则panic\n\n```go\nfunc QuickClass(name, body string) string\n```\nQuickClass 快速创建类的PHP源码\n\n```go\nfunc QuickFunction(name, params, body string) string\n```\nQuickFunction 快速创建函数的PHP源码\n\n```go\nfunc QuickPHP(code string) string\n```\nQuickPHP 快速创建简单PHP源码的辅助函数\n\n```go\nfunc SetDefaultParserFactory(factory ParserFactory)\n```\nSetDefaultParserFactory 设置默认解析器工厂\n\n```go\nfunc SetGlobalConfig(config *GlobalConfig)\n```\nSetGlobalConfig 设置全局配置\n\n```go\nfunc ValidateClassConstant(expectedName string, expectedVisibility string) func(*ast.ClassExpression, *testing.T)\n```\nValidateClassConstant 创建类常量验证器\n\n```go\nfunc ValidateClassMethod(expectedName, expectedVisibility string) func(*ast.ClassExpression, *testing.T)\n```\nValidateClassMethod 创建类方法验证器\n\n```go\nfunc ValidateNumberArg(expectedValue string) func(ast.Node, *testing.T)\n```\nValidateNumberArg 创建数字参数验证器\n\n```go\nfunc ValidateProperty(expectedName string, expectedVisibility string) func(*ast.ClassExpression, *testing.T)\n```\nValidateProperty 创建类属性验证器\n\n```go\nfunc ValidateStringArg(expectedValue, expectedRaw string) func(ast.Node, *testing.T)\n```\nValidateStringArg 创建字符串参数验证器\n\n## Types\n\n```go\ntype ASTAssertions struct {\n\t// contains filtered or unexported fields\n}\n```\nASTAssertions 提供AST特定的断言\n\n```go\nfunc NewASTAssertions(t *testing.T) *ASTAssertions\n```\nNewASTAssertions 创建AST断言工具\n\n```go\nfunc (a *ASTAssertions) AssertArray(node ast.Node, expectedElementCount int) *ast.ArrayExpression\n```\nAssertArray 断言数组表达式\n\n```go\nfunc (a *ASTAssertions) AssertAssignment(node ast.Node, expectedOperator string) *ast.AssignmentExpression\n```\nAssertAssignment 断言赋值表达式\n\n```go\nfunc (a *ASTAssertions) AssertBinaryExpression(node ast.Node, expectedOperator string) *ast.BinaryExpression\n```\nAssertBinaryExpression 断言二元表达式\n\n```go\nfunc (a *ASTAssertions) AssertCallExpression(expr ast.Expression) *ast.CallExpression\n```\nAssertCallExpression 断言函数调用表达式\n\n```go\nfunc (a *ASTAssertions) AssertCatchClausesCount(tryStmt *ast.TryStatement, expectedCount int)\n```\nAssertCatchClausesCount 断言catch子句数量\n\n```go\nfunc (a *ASTAssertions) AssertClass(node ast.Node, expectedName string) *ast.ClassExpression\n```\nAssertClass 断言类表达式\n\n```go\nfunc (a *ASTAssertions) AssertEchoStatement(stmt ast.Statement, expectedArgCount int) *ast.EchoStatement\n```\nAssertEchoStatement 断言echo语句\n\n```go\nfunc (a *ASTAssertions) AssertExpressionStatement(stmt ast.Statement) *ast.ExpressionStatement\n```\nAssertExpressionStatement 断言表达式语句\n\n```go\nfunc (a *ASTAssertions) AssertFullyQualifiedCall(callExpr *ast.CallExpression, expectedName string)\n```\nAssertFullyQualifiedCall 断言完全限定的函数调用\n\n```go\nfunc (a *ASTAssertions) AssertFunctionBody(funcDecl *ast.FunctionDeclaration, expectedStatements int)\n```\nAssertFunctionBody 断言函数体\n\n```go\nfunc (a *ASTAssertions) AssertFunctionDeclaration(stmt ast.Statement, expectedName string) *ast.FunctionDeclaration\n```\nAssertFunctionDeclaration 断言函数声明\n\n```go\nfunc (a *ASTAssertions) AssertGlobalNamespaceStatement(stmt ast.Statement) *ast.NamespaceStatement\n```\nAssertGlobalNamespaceStatement 断言全局namespace语句\n\n```go\nfunc (a *ASTAssertions) AssertIdentifier(node ast.Node, expectedName string) *ast.IdentifierNode\n```\nAssertIdentifier 断言标识符节点\n\n```go\nfunc (a *ASTAssertions) AssertMatchExpression(expr ast.Expression) *ast.MatchExpression\n```\nAssertMatchExpression 断言Match表达式\n\n```go\nfunc (a *ASTAssertions) AssertMethodCall(node ast.Node, expectedObject, expectedMethod string) *ast.MethodCallExpression\n```\nAssertMethodCall 断言方法调用\n\n```go\nfunc (a *ASTAssertions) AssertNamespaceStatement(stmt ast.Statement, expectedName string) *ast.NamespaceStatement\n```\nAssertNamespaceStatement 断言namespace语句\n\n```go\nfunc (a *ASTAssertions) AssertNumberLiteral(node ast.Node, expectedValue string) *ast.NumberLiteral\n```\nAssertNumberLiteral 断言数字字面量\n\n```go\nfunc (a *ASTAssertions) AssertProgramBody(program *ast.Program, expectedLength int) []ast.Statement\n```\nAssertProgramBody 断言程序体\n\n```go\nfunc (a *ASTAssertions) AssertReturnStatement(stmt ast.Statement) *ast.ReturnStatement\n```\nAssertReturnStatement 断言return语句\n\n```go\nfunc (a *ASTAssertions) AssertStringLiteral(node ast.Node, expectedValue, expectedRaw string) *ast.StringLiteral\n```\nAssertStringLiteral 断言字符串字面量\n\n```go\nfunc (a *ASTAssertions) AssertTernaryExpression(node ast.Node) *ast.TernaryExpression\n```\nAssertTernaryExpression 断言三元表达式\n\n```go\nfunc (a *ASTAssertions) AssertTraitDeclaration(stmt ast.Statement, expectedName string) *ast.TraitDeclaration\n```\nAssertTraitDeclaration 断言Trait声明\n\n```go\nfunc (a *ASTAssertions) AssertTryBlockEmpty(tryStmt *ast.TryStatement)\n```\nAssertTryBlockEmpty 断言try块为空\n\n```go\nfunc (a *ASTAssertions) AssertTryBlockStatements(tryStmt *ast.TryStatement, expectedCount int)\n```\nAssertTryBlockStatements 断言try块中的语句数量\n\n```go\nfunc (a *ASTAssertions) AssertTryStatement(stmt ast.Statement) *ast.TryStatement\n```\nAssertTryStatement 断言try语句\n\n```go\nfunc (a *ASTAssertions) AssertVariable(node ast.Node, expectedName string) *ast.Variable\n```\nAssertVariable 断言变量节点\n\n```go\ntype ArrayElement struct {\n\tKey       string // 数组键，空则为索引数组\n\tValue     string // 数组值\n\tIsNumeric bool   // 是否为数值\n}\n```\nArrayElement 表示数组元素\n\n```go\ntype BenchmarkBuilder struct {\n\t// contains filtered or unexported fields\n}\n```\nBenchmarkBuilder 性能测试构建器\n\n```go\nfunc NewBenchmarkBuilder(name string, parserFactory ParserFactory) *BenchmarkBuilder\n```\nNewBenchmarkBuilder 创建性能测试构建器\n\n```go\nfunc (b *BenchmarkBuilder) Add(name, source string) *BenchmarkBuilder\n```\nAdd 添加性能测试\n\n```go\nfunc (b *BenchmarkBuilder) Run(bench *testing.B)\n```\nRun 运行性能测试\n\n```go\ntype BenchmarkCase struct {\n\tName   string\n\tSource string\n}\n```\nBenchmarkCase 性能测试用例\n\n```go\ntype CatchClause struct {\n\tExceptionType string\n\tVariableName  string\n\tBodyValidator ValidationFunc\n}\n```\n类型定义\n\n```go\nfunc ValidateCatchClause(exceptionType, varName string, bodyValidator ValidationFunc) CatchClause\n```\nValidateCatchClause 创建catch子句验证器\n\n```go\ntype EnumCase struct {\n\tName  string\n\tValue string\n}\n```\nEnumCase 表示枚举常量\n\n```go\ntype ErrorTestBuilder struct {\n\t// contains filtered or unexported fields\n}\n```\nErrorTestBuilder 错误测试构建器\n\n```go\nfunc NewErrorTestBuilder(parserFactory ParserFactory) *ErrorTestBuilder\n```\nNewErrorTestBuilder 创建错误测试构建器\n\n```go\nfunc (b *ErrorTestBuilder) ExpectError(t *testing.T, source string, expectedErrorSubstring string)\n```\nExpectError 验证解析错误\n\n```go\nfunc (b *ErrorTestBuilder) ExpectNoError(t *testing.T, source string)\n```\nExpectNoError 验证无解析错误\n\n```go\nfunc (b *ErrorTestBuilder) ExpectRecovery(t *testing.T, source string, expectedStatementCount int)\n```\nExpectRecovery 验证错误恢复（有错误但仍能解析部分内容）\n\n```go\ntype ErrorTestCase struct {\n\tName         string\n\tSource       string\n\tExpectError  bool\n\tErrorKeyword string\n\tRecoverCount int // 错误恢复时期望的语句数量\n}\n```\nErrorTestCase 错误测试用例\n\n```go\ntype ErrorTestSuite struct {\n\t// contains filtered or unexported fields\n}\n```\nErrorTestSuite 错误测试套件\n\n```go\nfunc NewErrorTestSuite(name string, parserFactory ParserFactory) *ErrorTestSuite\n```\nNewErrorTestSuite 创建错误测试套件\n\n```go\nfunc (s *ErrorTestSuite) Add(testCase ErrorTestCase) *ErrorTestSuite\n```\nAdd 添加错误测试用例\n\n```go\nfunc (s *ErrorTestSuite) AddError(name, source, errorKeyword string) *ErrorTestSuite\n```\nAddError 添加期望错误的测试\n\n```go\nfunc (s *ErrorTestSuite) AddRecovery(name, source string, recoverCount int) *ErrorTestSuite\n```\nAddRecovery 添加错误恢复测试\n\n```go\nfunc (s *ErrorTestSuite) AddSuccess(name, source string) *ErrorTestSuite\n```\nAddSuccess 添加期望成功的测试\n\n```go\nfunc (s *ErrorTestSuite) Run(t *testing.T)\n```\nRun 运行错误测试套件\n\n```go\ntype GlobalConfig struct {\n\tDefaultStrictMode bool\n\tEnableDebug       bool\n\tTestDataDir       string\n\tGoldenFileDir     string\n\tBenchmarkEnabled  bool\n\tCoverageEnabled   bool\n}\n```\nGlobalConfig 全局测试配置\n\n```go\nfunc GetGlobalConfig() *GlobalConfig\n```\nGetGlobalConfig 获取全局配置\n\n```go\ntype InterpolationPart struct {\n\tText      string // 字符串文本\n\tVariable  string // 变量名\n\tHasBraces bool   // 是否有花括号\n}\n```\nInterpolationPart 表示插值部分\n\n```go\ntype MatchArm struct {\n\tCondition  string\n\tConditions []string // 用于多条件\n\tValue      string\n\tIsDefault  bool\n}\n```\nMatchArm 表示match表达式的分支\n\n```go\ntype PHPSourceBuilder struct {\n\t// contains filtered or unexported fields\n}\n```\nPHPSourceBuilder PHP源码构建器\n\n```go\nfunc NewPHPSource() *PHPSourceBuilder\n```\nNewPHPSource 创建PHP源码构建器\n\n```go\nfunc (b *PHPSourceBuilder) Add(code string) *PHPSourceBuilder\n```\nAdd 添加PHP代码\n\n```go\nfunc (b *PHPSourceBuilder) AddClass(name, body string) *PHPSourceBuilder\n```\nAddClass 添加类定义\n\n```go\nfunc (b *PHPSourceBuilder) AddEcho(args ...string) *PHPSourceBuilder\n```\nAddEcho 添加echo语句\n\n```go\nfunc (b *PHPSourceBuilder) AddFor(init, condition, increment, body string) *PHPSourceBuilder\n```\nAddFor 添加for语句\n\n```go\nfunc (b *PHPSourceBuilder) AddFunction(name string, params []string, body string) *PHPSourceBuilder\n```\nAddFunction 添加函数定义\n\n```go\nfunc (b *PHPSourceBuilder) AddIf(condition, body string) *PHPSourceBuilder\n```\nAddIf 添加if语句\n\n```go\nfunc (b *PHPSourceBuilder) AddLine(code string) *PHPSourceBuilder\n```\nAddLine 添加一行PHP代码\n\n```go\nfunc (b *PHPSourceBuilder) AddTryCatch(tryBody, catchVar, catchBody string) *PHPSourceBuilder\n```\nAddTryCatch 添加try-catch语句\n\n```go\nfunc (b *PHPSourceBuilder) AddVariable(name, value string) *PHPSourceBuilder\n```\nAddVariable 添加变量赋值\n\n```go\nfunc (b *PHPSourceBuilder) AddWhile(condition, body string) *PHPSourceBuilder\n```\nAddWhile 添加while语句\n\n```go\nfunc (b *PHPSourceBuilder) Build() string\n```\nBuild 构建最终的PHP源码\n\n```go\nfunc (b *PHPSourceBuilder) String() string\n```\nString 实现Stringer接口\n\n```go\ntype ParserFactory func(*lexer.Lexer) ParserInterface\n```\nParserFactory 解析器工厂函数类型\n\n```go\nvar DefaultParserFactory ParserFactory\n```\nDefaultParserFactory 默认解析器工厂函数类型 该函数需要在parser包中实现，避免循环依赖\n\n```go\ntype ParserInterface interface {\n\tParseProgram() *ast.Program\n\tErrors() []string\n}\n```\nParserInterface 定义解析器接口以避免循环依赖\n\n```go\ntype ParserTestBuilder struct {\n\t// contains filtered or unexported fields\n}\n```\nParserTestBuilder 解析器测试构建器\n\n```go\nfunc NewParserTestBuilder(parserFactory ParserFactory) *ParserTestBuilder\n```\nNewParserTestBuilder 创建解析器测试构建器 parserFactory 参数用于创建解析器实例\n\n```go\nfunc NewQuickTestBuilder(factory ParserFactory) *ParserTestBuilder\n```\nNewQuickTestBuilder 创建快速测试构建器（用于parser包内部）\n\n```go\nfunc NewTestBuilder() *ParserTestBuilder\n```\nNewTestBuilder 创建带默认解析器工厂的测试构建器 使用前需要在parser包中设置DefaultParserFactory\n\n```go\nfunc (b *ParserTestBuilder) Test(t *testing.T, source string, validator func(*TestContext))\n```\nTest 执行测试\n\n```go\nfunc (b *ParserTestBuilder) TestTableDriven(t *testing.T, tests []struct {\n\tName      string\n\tSource    string\n\tValidator func(*TestContext)\n})\n```\nTestTableDriven 执行表驱动测试\n\n```go\nfunc (b *ParserTestBuilder) WithConfig(config *TestConfig) *ParserTestBuilder\n```\nWithConfig 设置测试配置\n\n```go\nfunc (b *ParserTestBuilder) WithSetup(setup func(*TestContext)) *ParserTestBuilder\n```\nWithSetup 添加设置函数\n\n```go\nfunc (b *ParserTestBuilder) WithStrictMode(strict bool) *ParserTestBuilder\n```\nWithStrictMode 设置严格模式\n\n```go\ntype ParserTester struct {\n\t// contains filtered or unexported fields\n}\n```\nParserTester 解析器测试器，用于快速测试\n\n```go\nfunc NewParserTester(t *testing.T, parserFactory ParserFactory) *ParserTester\n```\nNewParserTester 创建解析器测试器\n\n```go\nfunc (pt *ParserTester) Quick(source string, validator ValidationFunc)\n```\nQuick 快速测试\n\n```go\nfunc (pt *ParserTester) QuickError(source, errorKeyword string)\n```\nQuickError 快速测试错误\n\n```go\nfunc (pt *ParserTester) QuickString(varName, value, raw string)\n```\nQuickString 快速测试字符串赋值\n\n```go\nfunc (pt *ParserTester) QuickSuccess(source string)\n```\nQuickSuccess 快速测试成功解析\n\n```go\nfunc (pt *ParserTester) QuickVariable(varName, value string)\n```\nQuickVariable 快速测试变量赋值\n\n```go\ntype StringInterpolation struct {\n\tParts []InterpolationPart\n}\n```\nStringInterpolation 表示字符串插值\n\n```go\ntype SwitchCase struct {\n\tValue      string\n\tValidators []ValidationFunc\n\tIsDefault  bool\n}\n```\n\n```go\nfunc ValidateDefaultCase(validators ...ValidationFunc) SwitchCase\n```\nValidateDefaultCase 创建default case验证器\n\n```go\nfunc ValidateSwitchCase(value string, validators ...ValidationFunc) SwitchCase\n```\nValidateSwitchCase 创建switch case验证器\n\n```go\ntype TestCase struct {\n\tName      string\n\tSource    string\n\tValidator ValidationFunc\n\tSkip      bool\n\tOnly      bool\n\tTags      []string\n}\n```\nTestCase 标准测试用例结构\n\n```go\ntype TestConfig struct {\n\tStrictMode  bool // 严格模式：解析错误时失败测试\n\tValidateAST bool // 验证AST结构\n}\n```\nTestConfig 测试配置选项\n\n```go\ntype TestContext struct {\n\tT       *testing.T\n\tParser  ParserInterface\n\tLexer   *lexer.Lexer\n\tProgram *ast.Program\n\tConfig  *TestConfig\n}\n```\nTestContext 提供测试上下文和工具\n\n```go\ntype TestDataItem struct {\n\tName        string\n\tSource      string\n\tExpectedAST interface{} // 可以是任何期望的AST结构表示\n\tTags        []string\n\tSkip        bool\n}\n```\nTestDataItem 测试数据项\n\n```go\ntype TestDataset struct {\n\tName  string\n\tItems []TestDataItem\n}\n```\nTestDataset 测试数据集\n\n```go\ntype TestSuiteBuilder struct {\n\t// contains filtered or unexported fields\n}\n```\nTestSuiteBuilder 测试套件构建器\n\n```go\nfunc NewTestSuiteBuilder(name string, parserFactory ParserFactory) *TestSuiteBuilder\n```\nNewTestSuiteBuilder 创建测试套件构建器\n\n```go\nfunc (b *TestSuiteBuilder) Add(testCase TestCase) *TestSuiteBuilder\n```\nAdd 添加测试用例\n\n```go\nfunc (b *TestSuiteBuilder) AddClass(name, className, classBody string, validators ...func(*ast.ClassExpression, *testing.T)) *TestSuiteBuilder\n```\nAddClass 添加类测试\n\n```go\nfunc (b *TestSuiteBuilder) AddControlFlow(name, flowType, source string, validators ...func(ast.Statement, *testing.T)) *TestSuiteBuilder\n```\nAddControlFlow 添加控制流测试\n\n```go\nfunc (b *TestSuiteBuilder) AddEcho(name string, args []string, validators ...func(ast.Node, *testing.T)) *TestSuiteBuilder\n```\nAddEcho 添加echo测试\n\n```go\nfunc (b *TestSuiteBuilder) AddFunction(name, funcName string, params []string, validators ...func(*ast.FunctionDeclaration, *testing.T)) *TestSuiteBuilder\n```\nAddFunction 添加函数测试\n\n```go\nfunc (b *TestSuiteBuilder) AddSimple(name, source string, validator ValidationFunc) *TestSuiteBuilder\n```\nAddSimple 添加简单测试用例\n\n```go\nfunc (b *TestSuiteBuilder) AddStringAssignment(name, varName, value, raw string) *TestSuiteBuilder\n```\nAddStringAssignment 添加字符串赋值测试\n\n```go\nfunc (b *TestSuiteBuilder) AddVariableAssignment(name, varName, valueSource string) *TestSuiteBuilder\n```\nAddVariableAssignment 添加变量赋值测试\n\n```go\nfunc (b *TestSuiteBuilder) Only(testName string) *TestSuiteBuilder\n```\nOnly 仅运行特定测试\n\n```go\nfunc (b *TestSuiteBuilder) Run(t *testing.T)\n```\nRun 执行测试套件\n\n```go\nfunc (b *TestSuiteBuilder) Skip(testName string) *TestSuiteBuilder\n```\nSkip 标记跳过测试\n\n```go\nfunc (b *TestSuiteBuilder) WithConfig(config *TestConfig) *TestSuiteBuilder\n```\nWithConfig 设置配置\n\n```go\ntype TypedParam struct {\n\tName string\n\tType string\n}\n```\nTypedParam 表示带类型的参数\n\n```go\ntype ValidationFunc func(*TestContext)\n```\nValidationFunc 验证函数类型\n\n```go\nfunc ValidateAbstractClass(className string) ValidationFunc\n```\nValidateAbstractClass 验证abstract类\n\n```go\nfunc ValidateAbstractClassInExpressionStatement(className string) ValidationFunc\n```\nValidateAbstractClassInExpressionStatement 验证abstract类在表达式语句中\n\n```go\nfunc ValidateAdditionAssignment(varName string) ValidationFunc\n```\nValidateAdditionAssignment 验证加法赋值 (+=)\n\n```go\nfunc ValidateAnonymousFunctionAssignment(varName string, bodyValidator ValidationFunc) ValidationFunc\n```\nValidateAnonymousFunctionAssignment 验证匿名函数赋值\n\n```go\nfunc ValidateAnonymousFunctionWithParams(varName string, params []string, bodyValidator ValidationFunc) ValidationFunc\n```\nValidateAnonymousFunctionWithParams 验证带参数的匿名函数\n\n```go\nfunc ValidateArrayAccess(varName, arrayVar, index string) ValidationFunc\n```\nValidateArrayAccess 验证数组访问\n\n```go\nfunc ValidateArrayAssignment(varName string, elements []ArrayElement) ValidationFunc\n```\nValidateArrayAssignment 验证数组赋值\n\n```go\nfunc ValidateArrowFunctionAssignment(varName string, params []string, bodyValidator ValidationFunc) ValidationFunc\n```\nValidateArrowFunctionAssignment 验证箭头函数赋值\n\n```go\nfunc ValidateAssignment(varName, operator string) ValidationFunc\n```\nValidateAssignment 验证赋值表达式，支持指定操作符\n\n```go\nfunc ValidateAssignmentExpression(varName, value string) ValidationFunc\n```\nValidateAssignmentExpression 创建赋值验证器\n\n```go\nfunc ValidateAssignmentOperation(varName, operator, valueVar string) ValidationFunc\n```\nValidateAssignmentOperation 验证赋值操作\n\n```go\nfunc ValidateBackedEnum(enumName, backingType string, cases []EnumCase) ValidationFunc\n```\nValidateBackedEnum 验证带值的枚举 (简化版本)\n\n```go\nfunc ValidateBasicAssignment(varName string) ValidationFunc\n```\nValidateBasicAssignment 验证基础赋值 (=)\n\n```go\nfunc ValidateBinaryAssignment(varName, leftVar, operator, rightVar string) ValidationFunc\n```\nValidateBinaryAssignment 验证二元表达式赋值\n\n```go\nfunc ValidateBinaryExpression(leftVar, operator, rightValue string) ValidationFunc\n```\nValidateBinaryExpression 创建二元表达式验证器\n\n```go\nfunc ValidateBinaryOperation(operator string, leftValidator, rightValidator func(ast.Node, *testing.T)) ValidationFunc\n```\nValidateBinaryOperation 验证二元运算表达式\n\n```go\nfunc ValidateBitwiseAndAssignment(varName string) ValidationFunc\n```\nValidateBitwiseAndAssignment 验证按位与赋值 (\u0026=)\n\n```go\nfunc ValidateBitwiseOrAssignment(varName string) ValidationFunc\n```\nValidateBitwiseOrAssignment 验证按位或赋值 (|=)\n\n```go\nfunc ValidateBitwiseXorAssignment(varName string) ValidationFunc\n```\nValidateBitwiseXorAssignment 验证按位异或赋值 (^=)\n\n```go\nfunc ValidateBreakStatement() ValidationFunc\n```\nValidateBreakStatement 创建break语句验证器\n\n```go\nfunc ValidateChainedArrayAccess(varName, arrayVar string, indices []string) ValidationFunc\n```\nValidateChainedArrayAccess 验证链式数组访问\n\n```go\nfunc ValidateChainedStaticCall(varName, className, firstMethod string, firstArgs []string, secondMethod string) ValidationFunc\n```\nValidateChainedStaticCall 验证链式静态调用 (简化版本)\n\n```go\nfunc ValidateClass(expectedName string, validators ...func(*ast.ClassExpression, *testing.T)) ValidationFunc\n```\nValidateClass 验证类声明\n\n```go\nfunc ValidateClassDeclaration(className, parentClass string, interfaces []string, memberValidator ValidationFunc) ValidationFunc\n```\nValidateClassDeclaration 验证类声明\n\n```go\nfunc ValidateClassInExpressionStatement(className string) ValidationFunc\n```\nValidateClassInExpressionStatement 验证表达式语句中的类声明\n\n```go\nfunc ValidateClassWithInheritance(className, parentClass string, memberValidator ValidationFunc) ValidationFunc\n```\nValidateClassWithInheritance 验证带继承的类\n\n```go\nfunc ValidateClassWithInterfaces(className string, interfaces []string) ValidationFunc\n```\nValidateClassWithInterfaces 验证实现接口的类\n\n```go\nfunc ValidateClosureWithUse(varName string, params []string, useVars []string, bodyValidator ValidationFunc) ValidationFunc\n```\nValidateClosureWithUse 验证带use的闭包\n\n```go\nfunc ValidateCoalesceAssignment(varName string) ValidationFunc\n```\nValidateCoalesceAssignment 验证null合并赋值 (??=)\n\n```go\nfunc ValidateCoalesceExpression(varName, leftVar, rightVar string) ValidationFunc\n```\nValidateCoalesceExpression 验证null合并表达式\n\n```go\nfunc ValidateConcatenationAssignment(varName string) ValidationFunc\n```\nValidateConcatenationAssignment 验证字符串连接赋值 (.=)\n\n```go\nfunc ValidateControlFlow(expectedType string, validators ...func(ast.Statement, *testing.T)) ValidationFunc\n```\nValidateControlFlow 验证控制流语句\n\n```go\nfunc ValidateDivisionAssignment(varName string) ValidationFunc\n```\nValidateDivisionAssignment 验证除法赋值 (/=)\n\n```go\nfunc ValidateEcho(expectedArgCount int, argValidators ...func(ast.Node, *testing.T)) ValidationFunc\n```\nValidateEcho 验证echo语句\n\n```go\nfunc ValidateEchoArgs(args []string) ValidationFunc\n```\nValidateEchoArgs 创建echo语句验证器\n\n```go\nfunc ValidateEchoVariable(varName string) ValidationFunc\n```\nValidateEchoVariable 创建echo变量验证器\n\n```go\nfunc ValidateEnumDeclaration(enumName, backingType string, cases []string) ValidationFunc\n```\nValidateEnumDeclaration 验证枚举声明 (简化版本)\n\n```go\nfunc ValidateErrorMessage(expectedKeywords ...string) ValidationFunc\n```\nValidateErrorMessage 创建错误消息验证函数\n\n```go\nfunc ValidateFinalClass(className string) ValidationFunc\n```\nValidateFinalClass 验证final类\n\n```go\nfunc ValidateFinalClassInExpressionStatement(className string) ValidationFunc\n```\nValidateFinalClassInExpressionStatement 验证final类在表达式语句中\n\n```go\nfunc ValidateForStatement(initValidator, testValidator, updateValidator, bodyValidator ValidationFunc) ValidationFunc\n```\nValidateForStatement 验证for语句\n\n```go\nfunc ValidateForeachStatement(iterableVar, keyVar, valueVar string, bodyValidators ...ValidationFunc) ValidationFunc\n```\nValidateForeachStatement 验证foreach语句\n\n```go\nfunc ValidateFunction(expectedName string, expectedParamCount int, validators ...func(*ast.FunctionDeclaration, *testing.T)) ValidationFunc\n```\nValidateFunction 验证函数声明\n\n```go\nfunc ValidateFunctionCall(funcName string, args ...string) ValidationFunc\n```\nValidateFunctionCall 创建函数调用验证器\n\n```go\nfunc ValidateFunctionDeclaration(funcName string, params []string, returnType string, bodyValidator ValidationFunc) ValidationFunc\n```\nValidateFunctionDeclaration 验证函数声明\n\n```go\nfunc ValidateFunctionWithIntersectionType(funcName, intersectionType, paramName string, bodyValidator ValidationFunc) ValidationFunc\n```\nValidateFunctionWithIntersectionType 验证交集类型函数 (简化版本)\n\n```go\nfunc ValidateFunctionWithNullableUnionType(funcName, nullableUnionType string, bodyValidator ValidationFunc) ValidationFunc\n```\nValidateFunctionWithNullableUnionType 验证可空联合类型函数 (简化版本)\n\n```go\nfunc ValidateFunctionWithParameters(funcName string, params []string, bodyValidator ValidationFunc) ValidationFunc\n```\nValidateFunctionWithParameters 验证带参数的函数\n\n```go\nfunc ValidateFunctionWithReturnType(funcName string, returnType string, bodyValidator ValidationFunc) ValidationFunc\n```\nValidateFunctionWithReturnType 验证带返回类型的函数\n\n```go\nfunc ValidateFunctionWithUnionType(funcName, unionType, paramName string, bodyValidator ValidationFunc) ValidationFunc\n```\nValidateFunctionWithUnionType 验证联合类型函数 (简化版本)\n\n```go\nfunc ValidateHeredocAssignment(varName, expectedValue string) ValidationFunc\n```\nValidateHeredocAssignment 验证Heredoc赋值\n\n```go\nfunc ValidateIfElseStatement(testValidator ValidationFunc, consequentValidator ValidationFunc, alternateValidator ValidationFunc) ValidationFunc\n```\nValidateIfElseStatement 验证if-else语句\n\n```go\nfunc ValidateIfStatement(testValidator ValidationFunc, consequentValidators ...ValidationFunc) ValidationFunc\n```\nValidateIfStatement 验证if语句\n\n```go\nfunc ValidateInstanceofExpression(varName, objectVar, className string) ValidationFunc\n```\nValidateInstanceofExpression 验证instanceof表达式\n\n```go\nfunc ValidateInterpolatedStringAssignment(varName string, interpolation StringInterpolation) ValidationFunc\n```\nValidateInterpolatedStringAssignment 验证插值字符串赋值\n\n```go\nfunc ValidateLeftShiftAssignment(varName string) ValidationFunc\n```\nValidateLeftShiftAssignment 验证左移赋值 (\\\u003c\\\u003c=)\n\n```go\nfunc ValidateMatchExpression(varName, matchVar string, arms []MatchArm) ValidationFunc\n```\nValidateMatchExpression 验证match表达式 (简化版本)\n\n```go\nfunc ValidateMatchWithMultipleConditions(varName, matchVar string, arms []MatchArm) ValidationFunc\n```\nValidateMatchWithMultipleConditions 验证多条件match表达式 (简化版本)\n\n```go\nfunc ValidateModuloAssignment(varName string) ValidationFunc\n```\nValidateModuloAssignment 验证模运算赋值 (%=)\n\n```go\nfunc ValidateMultiplicationAssignment(varName string) ValidationFunc\n```\nValidateMultiplicationAssignment 验证乘法赋值 (\\*=)\n\n```go\nfunc ValidateNoErrors() ValidationFunc\n```\nValidateNoErrors 验证无错误的验证函数\n\n```go\nfunc ValidateNowdocAssignment(varName, expectedValue string) ValidationFunc\n```\nValidateNowdocAssignment 验证Nowdoc赋值\n\n```go\nfunc ValidatePostfixAssignment(varName, operandVar, operator string) ValidationFunc\n```\nValidatePostfixAssignment 验证后缀表达式赋值\n\n```go\nfunc ValidatePostfixExpression(varName, operator string) ValidationFunc\n```\nValidatePostfixExpression 创建后缀表达式验证器\n\n```go\nfunc ValidatePowerAssignment(varName string) ValidationFunc\n```\nValidatePowerAssignment 验证幂运算赋值 (\\*\\*=)\n\n```go\nfunc ValidatePrefixExpression(varName, operandVar, operator string) ValidationFunc\n```\nValidatePrefixExpression 验证前缀表达式\n\n```go\nfunc ValidatePropertyDeclaration(visibility, varName, typeName, defaultValue string) ValidationFunc\n```\nValidatePropertyDeclaration 验证属性声明\n\n```go\nfunc ValidateReturnBinaryExpression(leftVar, operator, rightVar string) ValidationFunc\n```\nValidateReturnBinaryExpression 验证return二元表达式\n\n```go\nfunc ValidateReturnNull() ValidationFunc\n```\nValidateReturnNull 验证return null\n\n```go\nfunc ValidateReturnStatement(expectedValue string) ValidationFunc\n```\nValidateReturnStatement 验证return语句\n\n```go\nfunc ValidateReturnVariable(varName string) ValidationFunc\n```\nValidateReturnVariable 验证return变量\n\n```go\nfunc ValidateRightShiftAssignment(varName string) ValidationFunc\n```\nValidateRightShiftAssignment 验证右移赋值 (\u003e\u003e=)\n\n```go\nfunc ValidateStaticConstantAccess(varName, className, constantName string) ValidationFunc\n```\nValidateStaticConstantAccess 验证静态常量访问\n\n```go\nfunc ValidateStaticMethodCall(varName, className, methodName string, args []string) ValidationFunc\n```\nValidateStaticMethodCall 验证静态方法调用\n\n```go\nfunc ValidateStaticPropertyAccess(varName, className, propertyName string) ValidationFunc\n```\nValidateStaticPropertyAccess 验证静态属性访问\n\n```go\nfunc ValidateStringAssignment(varName, expectedValue, expectedRaw string) ValidationFunc\n```\nValidateStringAssignment 创建字符串赋值验证函数\n\n```go\nfunc ValidateSubtractionAssignment(varName string) ValidationFunc\n```\nValidateSubtractionAssignment 验证减法赋值 (-=)\n\n```go\nfunc ValidateSwitchStatement(discriminantVar string, cases []SwitchCase) ValidationFunc\n```\nValidateSwitchStatement 验证switch语句\n\n```go\nfunc ValidateTernaryExpression(varName, conditionVar, trueVar, falseVar string) ValidationFunc\n```\nValidateTernaryExpression 验证三元表达式\n\n```go\nfunc ValidateTryCatchFinallyStatement(tryValidator ValidationFunc, catchValidator CatchClause, finallyValidator ValidationFunc) ValidationFunc\n```\nValidateTryCatchFinallyStatement 验证try-catch-finally语句\n\n```go\nfunc ValidateTryCatchStatement(tryValidator ValidationFunc, catchValidator CatchClause) ValidationFunc\n```\nValidateTryCatchStatement 验证try-catch语句\n\n```go\nfunc ValidateTryMultipleCatchStatement(tryValidator ValidationFunc, catchValidators []CatchClause) ValidationFunc\n```\nValidateTryMultipleCatchStatement 验证多个catch子句的try语句\n\n```go\nfunc ValidateTypedArrowFunction(varName string, params []TypedParam, returnType string, bodyValidator ValidationFunc) ValidationFunc\n```\nValidateTypedArrowFunction 验证带类型的箭头函数\n\n```go\nfunc ValidateTypedFunction(funcName string, params []TypedParam, bodyValidator ValidationFunc) ValidationFunc\n```\nValidateTypedFunction 验证带类型参数的函数\n\n```go\nfunc ValidateVariable(name string) ValidationFunc\n```\nValidateVariable 创建变量验证函数\n\n```go\nfunc ValidateVariableAssignment(varName string) ValidationFunc\n```\nValidateVariableAssignment 验证变量赋值的别名，避免与已有函数冲突\n\n```go\nfunc ValidateVariableExpression(varName string) ValidationFunc\n```\nValidateVariable 创建变量验证器\n\n```go\nfunc ValidateWhileStatement(testValidator ValidationFunc, bodyValidators ...ValidationFunc) ValidationFunc\n```\nValidateWhileStatement 验证while语句\n\n","path":"github.com/wudi/php-parser/parser/testutils","name":"testutils","synopsis":"","isRedistributable":true}
