Skip to content

Releases: quintenmbusiness/PhpAstCodeGenerationHelper

1.0.2

15 Dec 00:55

Choose a tag to compare

Full Changelog: 1.0.1...1.0.2

1.0.1

13 Dec 21:48
82cb05e

Choose a tag to compare

Coverage im proved

PHP AST Code Generation Helper - Early Access v1.0

06 Dec 18:45
197e682

Choose a tag to compare

Method Summary for Release 1.0

ClassGenerationHelper

  • addClassProperty: Adds a property to a class with type, visibility, and default value.
  • setNamespace: Assigns a namespace to a class or interface and adds imports.
  • createClass: Creates a new class with the given name.
  • addClassMethod: Adds a method to a class with visibility, return type, parameters, and body.
  • extendClass: Sets a parent class for inheritance.
  • implementInterfaces: Adds one or more interfaces to a class.
  • addTraitsToClass: Adds traits to a class.
  • addConstructorToClass: Adds a constructor to a class with parameters.
  • createFullClass: Combines properties, methods, traits, and interfaces into a complete class.

BasicGenerationHelper

  • return: Creates a return statement using the given expression.
  • addVisibility: Sets the visibility of a method or property.
  • createDocComment: Generates PHPDoc comments for a method or property.
  • createArguments: Converts an array into AST-compatible arguments for method calls.
  • createArray: Converts a PHP array into an AST array node.
  • convertToAstNode: Converts a PHP value to an AST node (e.g., int, string, bool).
  • isValidDefault: Validates default values based on type.
  • generateFile: Generates a PHP file for a class, interface, or namespace.

MethodGenerationHelper

  • createMethod: Creates a method with the specified name, visibility, and return type.

TestGenerationHelper

  • createSetUpMethod: Generates a setUp method for initializing test dependencies.
  • createTestMethod: Creates a test method with a specific name and body.
  • createAssertion: Creates a PHPUnit assertion statement.
  • addTestImports: Adds PHPUnit and other imports to a test class.
  • createTestClass: Builds a complete test class with methods and optional setUp.

VariableGenerationHelper

  • assignThisVarToVar: Assigns a class property to a variable.
  • assignThisVarToThisVar: Assigns one class property to another.
  • new: Creates a new object instance.
  • assignVarToVar: Assigns one variable to another.
  • assign: Assigns one expression to another.
  • var: Creates a variable node.
  • thisVar: Fetches a property from the current instance.

PHP AST Code Generation Helper - Early Access v0.1.0

27 Nov 16:23

Choose a tag to compare

Early Access Release (v0.1.0)

This is the initial release of the PHP AST Code Generation Helper. It provides a utility library for generating PHP Abstract Syntax Tree (AST) nodes programmatically using nikic/php-parser.

🚀 Features

  • Create methods with customizable visibility and return types.
  • Generate properties with types and visibility modifiers.
  • Simplified helpers for $this->property and variable assignment.

🔧 Limitations

  • Limited functionality: This release is a preview version aimed at early adopters. Only basic method and property generation are supported.
  • Future releases will include:
    • Full class generation.
    • Additional AST helpers.
    • Enhanced support for complex types.