Versions in this module Expand all Collapse all v0 v0.1.0 Sep 3, 2025 Changes in this version + const CategoryBasic + const CategoryClasses + const CategoryControlFlow + const CategoryErrors + const CategoryExpressions + const CategoryFunctions + const CategoryPHP8 + const CategoryPHP81 + const CategoryPHP82 + const CategoryPHP83 + const CategoryPHP84 + const CategoryStatements + const TagBenchmark + const TagError + const TagExperimental + const TagIntegration + const TagRegression + const TagSlow + const TagSmoke + const TagUnit + var CreateDefaultParserFactory func() ParserFactory + var DefaultGlobalConfig = &GlobalConfig + func CheckParserErrors(t *testing.T, p ParserInterface) + func DebugParser(t *testing.T, source string, parserFactory ParserFactory) + func ExpectNoErrors() func(*TestContext) + func ExpectProgram(expectedBodyLen int) func(*TestContext) + func IsTestEnabled(tags []string) bool + func MustCreateParser(source string) (ParserInterface, *TestContext) + func QuickClass(name, body string) string + func QuickFunction(name, params, body string) string + func QuickPHP(code string) string + func SetDefaultParserFactory(factory ParserFactory) + func SetGlobalConfig(config *GlobalConfig) + func ValidateClassConstant(expectedName string, expectedVisibility string) func(*ast.ClassExpression, *testing.T) + func ValidateClassMethod(expectedName, expectedVisibility string) func(*ast.ClassExpression, *testing.T) + func ValidateNumberArg(expectedValue string) func(ast.Node, *testing.T) + func ValidateProperty(expectedName string, expectedVisibility string) func(*ast.ClassExpression, *testing.T) + func ValidateStringArg(expectedValue, expectedRaw string) func(ast.Node, *testing.T) + type ASTAssertions struct + func NewASTAssertions(t *testing.T) *ASTAssertions + func (a *ASTAssertions) AssertArray(node ast.Node, expectedElementCount int) *ast.ArrayExpression + func (a *ASTAssertions) AssertAssignment(node ast.Node, expectedOperator string) *ast.AssignmentExpression + func (a *ASTAssertions) AssertBinaryExpression(node ast.Node, expectedOperator string) *ast.BinaryExpression + func (a *ASTAssertions) AssertCallExpression(expr ast.Expression) *ast.CallExpression + func (a *ASTAssertions) AssertCatchClausesCount(tryStmt *ast.TryStatement, expectedCount int) + func (a *ASTAssertions) AssertClass(node ast.Node, expectedName string) *ast.ClassExpression + func (a *ASTAssertions) AssertEchoStatement(stmt ast.Statement, expectedArgCount int) *ast.EchoStatement + func (a *ASTAssertions) AssertExpressionStatement(stmt ast.Statement) *ast.ExpressionStatement + func (a *ASTAssertions) AssertFullyQualifiedCall(callExpr *ast.CallExpression, expectedName string) + func (a *ASTAssertions) AssertFunctionBody(funcDecl *ast.FunctionDeclaration, expectedStatements int) + func (a *ASTAssertions) AssertFunctionDeclaration(stmt ast.Statement, expectedName string) *ast.FunctionDeclaration + func (a *ASTAssertions) AssertGlobalNamespaceStatement(stmt ast.Statement) *ast.NamespaceStatement + func (a *ASTAssertions) AssertIdentifier(node ast.Node, expectedName string) *ast.IdentifierNode + func (a *ASTAssertions) AssertMatchExpression(expr ast.Expression) *ast.MatchExpression + func (a *ASTAssertions) AssertMethodCall(node ast.Node, expectedObject, expectedMethod string) *ast.MethodCallExpression + func (a *ASTAssertions) AssertNamespaceStatement(stmt ast.Statement, expectedName string) *ast.NamespaceStatement + func (a *ASTAssertions) AssertNumberLiteral(node ast.Node, expectedValue string) *ast.NumberLiteral + func (a *ASTAssertions) AssertProgramBody(program *ast.Program, expectedLength int) []ast.Statement + func (a *ASTAssertions) AssertReturnStatement(stmt ast.Statement) *ast.ReturnStatement + func (a *ASTAssertions) AssertStringLiteral(node ast.Node, expectedValue, expectedRaw string) *ast.StringLiteral + func (a *ASTAssertions) AssertTernaryExpression(node ast.Node) *ast.TernaryExpression + func (a *ASTAssertions) AssertTraitDeclaration(stmt ast.Statement, expectedName string) *ast.TraitDeclaration + func (a *ASTAssertions) AssertTryBlockEmpty(tryStmt *ast.TryStatement) + func (a *ASTAssertions) AssertTryBlockStatements(tryStmt *ast.TryStatement, expectedCount int) + func (a *ASTAssertions) AssertTryStatement(stmt ast.Statement) *ast.TryStatement + func (a *ASTAssertions) AssertVariable(node ast.Node, expectedName string) *ast.Variable + type ArrayElement struct + IsNumeric bool + Key string + Value string + type BenchmarkBuilder struct + func NewBenchmarkBuilder(name string, parserFactory ParserFactory) *BenchmarkBuilder + func (b *BenchmarkBuilder) Add(name, source string) *BenchmarkBuilder + func (b *BenchmarkBuilder) Run(bench *testing.B) + type BenchmarkCase struct + Name string + Source string + type CatchClause struct + BodyValidator ValidationFunc + ExceptionType string + VariableName string + func ValidateCatchClause(exceptionType, varName string, bodyValidator ValidationFunc) CatchClause + type EnumCase struct + Name string + Value string + type ErrorTestBuilder struct + func NewErrorTestBuilder(parserFactory ParserFactory) *ErrorTestBuilder + func (b *ErrorTestBuilder) ExpectError(t *testing.T, source string, expectedErrorSubstring string) + func (b *ErrorTestBuilder) ExpectNoError(t *testing.T, source string) + func (b *ErrorTestBuilder) ExpectRecovery(t *testing.T, source string, expectedStatementCount int) + type ErrorTestCase struct + ErrorKeyword string + ExpectError bool + Name string + RecoverCount int + Source string + type ErrorTestSuite struct + func NewErrorTestSuite(name string, parserFactory ParserFactory) *ErrorTestSuite + func (s *ErrorTestSuite) Add(testCase ErrorTestCase) *ErrorTestSuite + func (s *ErrorTestSuite) AddError(name, source, errorKeyword string) *ErrorTestSuite + func (s *ErrorTestSuite) AddRecovery(name, source string, recoverCount int) *ErrorTestSuite + func (s *ErrorTestSuite) AddSuccess(name, source string) *ErrorTestSuite + func (s *ErrorTestSuite) Run(t *testing.T) + type GlobalConfig struct + BenchmarkEnabled bool + CoverageEnabled bool + DefaultStrictMode bool + EnableDebug bool + GoldenFileDir string + TestDataDir string + func GetGlobalConfig() *GlobalConfig + type InterpolationPart struct + HasBraces bool + Text string + Variable string + type MatchArm struct + Condition string + Conditions []string + IsDefault bool + Value string + type PHPSourceBuilder struct + func NewPHPSource() *PHPSourceBuilder + func (b *PHPSourceBuilder) Add(code string) *PHPSourceBuilder + func (b *PHPSourceBuilder) AddClass(name, body string) *PHPSourceBuilder + func (b *PHPSourceBuilder) AddEcho(args ...string) *PHPSourceBuilder + func (b *PHPSourceBuilder) AddFor(init, condition, increment, body string) *PHPSourceBuilder + func (b *PHPSourceBuilder) AddFunction(name string, params []string, body string) *PHPSourceBuilder + func (b *PHPSourceBuilder) AddIf(condition, body string) *PHPSourceBuilder + func (b *PHPSourceBuilder) AddLine(code string) *PHPSourceBuilder + func (b *PHPSourceBuilder) AddTryCatch(tryBody, catchVar, catchBody string) *PHPSourceBuilder + func (b *PHPSourceBuilder) AddVariable(name, value string) *PHPSourceBuilder + func (b *PHPSourceBuilder) AddWhile(condition, body string) *PHPSourceBuilder + func (b *PHPSourceBuilder) Build() string + func (b *PHPSourceBuilder) String() string + type ParserFactory func(*lexer.Lexer) ParserInterface + var DefaultParserFactory ParserFactory + type ParserInterface interface + Errors func() []string + ParseProgram func() *ast.Program + type ParserTestBuilder struct + func NewParserTestBuilder(parserFactory ParserFactory) *ParserTestBuilder + func NewQuickTestBuilder(factory ParserFactory) *ParserTestBuilder + func NewTestBuilder() *ParserTestBuilder + func (b *ParserTestBuilder) Test(t *testing.T, source string, validator func(*TestContext)) + func (b *ParserTestBuilder) TestTableDriven(t *testing.T, tests []struct{ ... }) + func (b *ParserTestBuilder) WithConfig(config *TestConfig) *ParserTestBuilder + func (b *ParserTestBuilder) WithSetup(setup func(*TestContext)) *ParserTestBuilder + func (b *ParserTestBuilder) WithStrictMode(strict bool) *ParserTestBuilder + type ParserTester struct + func NewParserTester(t *testing.T, parserFactory ParserFactory) *ParserTester + func (pt *ParserTester) Quick(source string, validator ValidationFunc) + func (pt *ParserTester) QuickError(source, errorKeyword string) + func (pt *ParserTester) QuickString(varName, value, raw string) + func (pt *ParserTester) QuickSuccess(source string) + func (pt *ParserTester) QuickVariable(varName, value string) + type StringInterpolation struct + Parts []InterpolationPart + type SwitchCase struct + IsDefault bool + Validators []ValidationFunc + Value string + func ValidateDefaultCase(validators ...ValidationFunc) SwitchCase + func ValidateSwitchCase(value string, validators ...ValidationFunc) SwitchCase + type TestCase struct + Name string + Only bool + Skip bool + Source string + Tags []string + Validator ValidationFunc + type TestConfig struct + StrictMode bool + ValidateAST bool + type TestContext struct + Config *TestConfig + Lexer *lexer.Lexer + Parser ParserInterface + Program *ast.Program + T *testing.T + type TestDataItem struct + ExpectedAST interface{} + Name string + Skip bool + Source string + Tags []string + type TestDataset struct + Items []TestDataItem + Name string + type TestSuiteBuilder struct + func NewTestSuiteBuilder(name string, parserFactory ParserFactory) *TestSuiteBuilder + func (b *TestSuiteBuilder) Add(testCase TestCase) *TestSuiteBuilder + func (b *TestSuiteBuilder) AddClass(name, className, classBody string, ...) *TestSuiteBuilder + func (b *TestSuiteBuilder) AddControlFlow(name, flowType, source string, validators ...func(ast.Statement, *testing.T)) *TestSuiteBuilder + func (b *TestSuiteBuilder) AddEcho(name string, args []string, validators ...func(ast.Node, *testing.T)) *TestSuiteBuilder + func (b *TestSuiteBuilder) AddFunction(name, funcName string, params []string, ...) *TestSuiteBuilder + func (b *TestSuiteBuilder) AddSimple(name, source string, validator ValidationFunc) *TestSuiteBuilder + func (b *TestSuiteBuilder) AddStringAssignment(name, varName, value, raw string) *TestSuiteBuilder + func (b *TestSuiteBuilder) AddVariableAssignment(name, varName, valueSource string) *TestSuiteBuilder + func (b *TestSuiteBuilder) Only(testName string) *TestSuiteBuilder + func (b *TestSuiteBuilder) Run(t *testing.T) + func (b *TestSuiteBuilder) Skip(testName string) *TestSuiteBuilder + func (b *TestSuiteBuilder) WithConfig(config *TestConfig) *TestSuiteBuilder + type TypedParam struct + Name string + Type string + type ValidationFunc func(*TestContext) + func ValidateAbstractClass(className string) ValidationFunc + func ValidateAbstractClassInExpressionStatement(className string) ValidationFunc + func ValidateAdditionAssignment(varName string) ValidationFunc + func ValidateAnonymousFunctionAssignment(varName string, bodyValidator ValidationFunc) ValidationFunc + func ValidateAnonymousFunctionWithParams(varName string, params []string, bodyValidator ValidationFunc) ValidationFunc + func ValidateArrayAccess(varName, arrayVar, index string) ValidationFunc + func ValidateArrayAssignment(varName string, elements []ArrayElement) ValidationFunc + func ValidateArrowFunctionAssignment(varName string, params []string, bodyValidator ValidationFunc) ValidationFunc + func ValidateAssignment(varName, operator string) ValidationFunc + func ValidateAssignmentExpression(varName, value string) ValidationFunc + func ValidateAssignmentOperation(varName, operator, valueVar string) ValidationFunc + func ValidateBackedEnum(enumName, backingType string, cases []EnumCase) ValidationFunc + func ValidateBasicAssignment(varName string) ValidationFunc + func ValidateBinaryAssignment(varName, leftVar, operator, rightVar string) ValidationFunc + func ValidateBinaryExpression(leftVar, operator, rightValue string) ValidationFunc + func ValidateBinaryOperation(operator string, leftValidator, rightValidator func(ast.Node, *testing.T)) ValidationFunc + func ValidateBitwiseAndAssignment(varName string) ValidationFunc + func ValidateBitwiseOrAssignment(varName string) ValidationFunc + func ValidateBitwiseXorAssignment(varName string) ValidationFunc + func ValidateBreakStatement() ValidationFunc + func ValidateChainedArrayAccess(varName, arrayVar string, indices []string) ValidationFunc + func ValidateChainedStaticCall(varName, className, firstMethod string, firstArgs []string, ...) ValidationFunc + func ValidateClass(expectedName string, validators ...func(*ast.ClassExpression, *testing.T)) ValidationFunc + func ValidateClassDeclaration(className, parentClass string, interfaces []string, ...) ValidationFunc + func ValidateClassInExpressionStatement(className string) ValidationFunc + func ValidateClassWithInheritance(className, parentClass string, memberValidator ValidationFunc) ValidationFunc + func ValidateClassWithInterfaces(className string, interfaces []string) ValidationFunc + func ValidateClosureWithUse(varName string, params []string, useVars []string, ...) ValidationFunc + func ValidateCoalesceAssignment(varName string) ValidationFunc + func ValidateCoalesceExpression(varName, leftVar, rightVar string) ValidationFunc + func ValidateConcatenationAssignment(varName string) ValidationFunc + func ValidateControlFlow(expectedType string, validators ...func(ast.Statement, *testing.T)) ValidationFunc + func ValidateDivisionAssignment(varName string) ValidationFunc + func ValidateEcho(expectedArgCount int, argValidators ...func(ast.Node, *testing.T)) ValidationFunc + func ValidateEchoArgs(args []string) ValidationFunc + func ValidateEchoVariable(varName string) ValidationFunc + func ValidateEnumDeclaration(enumName, backingType string, cases []string) ValidationFunc + func ValidateErrorMessage(expectedKeywords ...string) ValidationFunc + func ValidateFinalClass(className string) ValidationFunc + func ValidateFinalClassInExpressionStatement(className string) ValidationFunc + func ValidateForStatement(initValidator, testValidator, updateValidator, bodyValidator ValidationFunc) ValidationFunc + func ValidateForeachStatement(iterableVar, keyVar, valueVar string, bodyValidators ...ValidationFunc) ValidationFunc + func ValidateFunction(expectedName string, expectedParamCount int, ...) ValidationFunc + func ValidateFunctionCall(funcName string, args ...string) ValidationFunc + func ValidateFunctionDeclaration(funcName string, params []string, returnType string, ...) ValidationFunc + func ValidateFunctionWithIntersectionType(funcName, intersectionType, paramName string, bodyValidator ValidationFunc) ValidationFunc + func ValidateFunctionWithNullableUnionType(funcName, nullableUnionType string, bodyValidator ValidationFunc) ValidationFunc + func ValidateFunctionWithParameters(funcName string, params []string, bodyValidator ValidationFunc) ValidationFunc + func ValidateFunctionWithReturnType(funcName string, returnType string, bodyValidator ValidationFunc) ValidationFunc + func ValidateFunctionWithUnionType(funcName, unionType, paramName string, bodyValidator ValidationFunc) ValidationFunc + func ValidateHeredocAssignment(varName, expectedValue string) ValidationFunc + func ValidateIfElseStatement(testValidator ValidationFunc, consequentValidator ValidationFunc, ...) ValidationFunc + func ValidateIfStatement(testValidator ValidationFunc, consequentValidators ...ValidationFunc) ValidationFunc + func ValidateInstanceofExpression(varName, objectVar, className string) ValidationFunc + func ValidateInterpolatedStringAssignment(varName string, interpolation StringInterpolation) ValidationFunc + func ValidateLeftShiftAssignment(varName string) ValidationFunc + func ValidateMatchExpression(varName, matchVar string, arms []MatchArm) ValidationFunc + func ValidateMatchWithMultipleConditions(varName, matchVar string, arms []MatchArm) ValidationFunc + func ValidateModuloAssignment(varName string) ValidationFunc + func ValidateMultiplicationAssignment(varName string) ValidationFunc + func ValidateNoErrors() ValidationFunc + func ValidateNowdocAssignment(varName, expectedValue string) ValidationFunc + func ValidatePostfixAssignment(varName, operandVar, operator string) ValidationFunc + func ValidatePostfixExpression(varName, operator string) ValidationFunc + func ValidatePowerAssignment(varName string) ValidationFunc + func ValidatePrefixExpression(varName, operandVar, operator string) ValidationFunc + func ValidatePropertyDeclaration(visibility, varName, typeName, defaultValue string) ValidationFunc + func ValidateReturnBinaryExpression(leftVar, operator, rightVar string) ValidationFunc + func ValidateReturnNull() ValidationFunc + func ValidateReturnStatement(expectedValue string) ValidationFunc + func ValidateReturnVariable(varName string) ValidationFunc + func ValidateRightShiftAssignment(varName string) ValidationFunc + func ValidateStaticConstantAccess(varName, className, constantName string) ValidationFunc + func ValidateStaticMethodCall(varName, className, methodName string, args []string) ValidationFunc + func ValidateStaticPropertyAccess(varName, className, propertyName string) ValidationFunc + func ValidateStringAssignment(varName, expectedValue, expectedRaw string) ValidationFunc + func ValidateSubtractionAssignment(varName string) ValidationFunc + func ValidateSwitchStatement(discriminantVar string, cases []SwitchCase) ValidationFunc + func ValidateTernaryExpression(varName, conditionVar, trueVar, falseVar string) ValidationFunc + func ValidateTryCatchFinallyStatement(tryValidator ValidationFunc, catchValidator CatchClause, ...) ValidationFunc + func ValidateTryCatchStatement(tryValidator ValidationFunc, catchValidator CatchClause) ValidationFunc + func ValidateTryMultipleCatchStatement(tryValidator ValidationFunc, catchValidators []CatchClause) ValidationFunc + func ValidateTypedArrowFunction(varName string, params []TypedParam, returnType string, ...) ValidationFunc + func ValidateTypedFunction(funcName string, params []TypedParam, bodyValidator ValidationFunc) ValidationFunc + func ValidateVariable(name string) ValidationFunc + func ValidateVariableAssignment(varName string) ValidationFunc + func ValidateVariableExpression(varName string) ValidationFunc + func ValidateWhileStatement(testValidator ValidationFunc, bodyValidators ...ValidationFunc) ValidationFunc