Copied!

This class defines helpers used in the implementation of builders. Don't use it directly.

  • internal
CloneableFinalInstantiable
Methods
public static addClassModifier(int $existingModifiers, int $modifierToSet) : int
 

Adds a modifier and returns new modifier bitmask.

  • return int New modifiers
public static addModifier(int $modifiers, int $modifier) : int
 

Adds a modifier and returns new modifier bitmask.

  • param int $modifiers Existing modifiers
  • param int $modifier Modifier to set
  • return int New modifiers
public static normalizeAttribute( $attribute) : PhpParser\Node\AttributeGroup
 

Normalizes a attribute: Converts attribute to the Attribute Group if needed.

  • param \Node\Attribute|\Node\AttributeGroup $attribute
  • return \Node\AttributeGroup The Attribute Group
public static normalizeDocComment( $docComment) : PhpParser\Comment\Doc
 

Normalizes a doc comment: Converts plain strings to PhpParser\Comment\Doc.

  • param \Comment\Doc|string $docComment The doc comment to normalize
  • return \Comment\Doc The normalized doc comment
public static normalizeIdentifier( $name) : PhpParser\Node\Identifier
 

Normalizes strings to Identifier.

  • param string|\Identifier $name The identifier to normalize
  • return \Identifier The normalized identifier
public static normalizeIdentifierOrExpr( $name)
 

Normalizes strings to Identifier, also allowing expressions.

  • param string|\Identifier|\Expr $name The identifier to normalize
  • return \Identifier|\Expr The normalized identifier or expression
public static normalizeName( $name) : PhpParser\Node\Name
 

Normalizes a name: Converts string names to Name nodes.

  • param \Name|string $name The name to normalize
  • return \Name The normalized name
public static normalizeNameOrExpr( $name)
 

Normalizes a name: Converts string names to Name nodes, while also allowing expressions.

  • param \Expr|\Name|string $name The name to normalize
  • return \Name|\Expr The normalized name or expression
public static normalizeNode( $node) : PhpParser\Node
 

Normalizes a node: Converts builder objects to nodes.

  • param \Node|\Builder $node The node to normalize
  • return \Node The normalized node
public static normalizeStmt( $node) : PhpParser\Node\Stmt
 

Normalizes a node to a statement.

Expressions are wrapped in a Stmt\Expression node.

  • param \Node|\Builder $node The node to normalize
  • return \Stmt The normalized statement node
public static normalizeType( $type)
 

Normalizes a type: Converts plain-text type names into proper AST representation.

In particular, builtin types become Identifiers, custom types become Names and nullables are wrapped in NullableType nodes.

  • param string|\Name|\Identifier|\ComplexType $type The type to normalize
  • return \Name|\Identifier|\ComplexType The normalized type
public static normalizeValue( $value) : PhpParser\Node\Expr
 

Normalizes a value: Converts nulls, booleans, integers, floats, strings and arrays into their respective nodes

  • param \Node\Expr|bool|null|int|float|string|array|\UnitEnum $value The value to normalize
  • return \Expr The normalized value
Methods
public static addClassModifier(int $existingModifiers, int $modifierToSet) : int
 

Adds a modifier and returns new modifier bitmask.

  • return int New modifiers
public static addModifier(int $modifiers, int $modifier) : int
 

Adds a modifier and returns new modifier bitmask.

  • param int $modifiers Existing modifiers
  • param int $modifier Modifier to set
  • return int New modifiers
public static normalizeAttribute( $attribute) : PhpParser\Node\AttributeGroup
 

Normalizes a attribute: Converts attribute to the Attribute Group if needed.

  • param \Node\Attribute|\Node\AttributeGroup $attribute
  • return \Node\AttributeGroup The Attribute Group
public static normalizeDocComment( $docComment) : PhpParser\Comment\Doc
 

Normalizes a doc comment: Converts plain strings to PhpParser\Comment\Doc.

  • param \Comment\Doc|string $docComment The doc comment to normalize
  • return \Comment\Doc The normalized doc comment
public static normalizeIdentifier( $name) : PhpParser\Node\Identifier
 

Normalizes strings to Identifier.

  • param string|\Identifier $name The identifier to normalize
  • return \Identifier The normalized identifier
public static normalizeIdentifierOrExpr( $name)
 

Normalizes strings to Identifier, also allowing expressions.

  • param string|\Identifier|\Expr $name The identifier to normalize
  • return \Identifier|\Expr The normalized identifier or expression
public static normalizeName( $name) : PhpParser\Node\Name
 

Normalizes a name: Converts string names to Name nodes.

  • param \Name|string $name The name to normalize
  • return \Name The normalized name
public static normalizeNameOrExpr( $name)
 

Normalizes a name: Converts string names to Name nodes, while also allowing expressions.

  • param \Expr|\Name|string $name The name to normalize
  • return \Name|\Expr The normalized name or expression
public static normalizeNode( $node) : PhpParser\Node
 

Normalizes a node: Converts builder objects to nodes.

  • param \Node|\Builder $node The node to normalize
  • return \Node The normalized node
public static normalizeStmt( $node) : PhpParser\Node\Stmt
 

Normalizes a node to a statement.

Expressions are wrapped in a Stmt\Expression node.

  • param \Node|\Builder $node The node to normalize
  • return \Stmt The normalized statement node
public static normalizeType( $type)
 

Normalizes a type: Converts plain-text type names into proper AST representation.

In particular, builtin types become Identifiers, custom types become Names and nullables are wrapped in NullableType nodes.

  • param string|\Name|\Identifier|\ComplexType $type The type to normalize
  • return \Name|\Identifier|\ComplexType The normalized type
public static normalizeValue( $value) : PhpParser\Node\Expr
 

Normalizes a value: Converts nulls, booleans, integers, floats, strings and arrays into their respective nodes

  • param \Node\Expr|bool|null|int|float|string|array|\UnitEnum $value The value to normalize
  • return \Expr The normalized value
© 2025 Bruce Wells
Search Namespaces \ Classes
Configuration