+ /**
+ * Creates node a for a literal value.
+ *
+ * @param Expr|bool|null|int|float|string|array $value $value
+ *
+ * @return Expr
+ */
+ public function val($value) : Expr {
+ return BuilderHelpers::normalizeValue($value);
+ }
+
+ /**
+ * Normalizes an argument list.
+ *
+ * Creates Arg nodes for all arguments and converts literal values to expressions.
+ *
+ * @param array $args List of arguments to normalize
+ *
+ * @return Arg[]
+ */
+ public function args(array $args) : array {
+ $normalizedArgs = [];
+ foreach ($args as $arg) {
+ if ($arg instanceof Arg) {
+ $normalizedArgs[] = $arg;
+ } else {
+ $normalizedArgs[] = new Arg(BuilderHelpers::normalizeValue($arg));
+ }
+ }
+ return $normalizedArgs;
+ }
+
+ /**
+ * Creates a function call node.
+ *
+ * @param string|Name|Expr $name Function name
+ * @param array $args Function arguments
+ *
+ * @return Expr\FuncCall
+ */
+ public function funcCall($name, array $args = []) : Expr\FuncCall {
+ return new Expr\FuncCall(
+ BuilderHelpers::normalizeNameOrExpr($name),
+ $this->args($args)
+ );
+ }
+
+ /**
+ * Creates a method call node.
+ *
+ * @param Expr $var Variable the method is called on
+ * @param string|Identifier|Expr $name Method name
+ * @param array $args Method arguments
+ *
+ * @return Expr\MethodCall
+ */
+ public function methodCall(Expr $var, $name, array $args = []) : Expr\MethodCall {
+ return new Expr\MethodCall(
+ $var,
+ BuilderHelpers::normalizeIdentifierOrExpr($name),
+ $this->args($args)
+ );
+ }
+
+ /**
+ * Creates a static method call node.
+ *
+ * @param string|Name|Expr $class Class name
+ * @param string|Identifier|Expr $name Method name
+ * @param array $args Method arguments
+ *
+ * @return Expr\StaticCall
+ */
+ public function staticCall($class, $name, array $args = []) : Expr\StaticCall {
+ return new Expr\StaticCall(
+ BuilderHelpers::normalizeNameOrExpr($class),
+ BuilderHelpers::normalizeIdentifierOrExpr($name),
+ $this->args($args)
+ );
+ }
+
+ /**
+ * Creates an object creation node.
+ *
+ * @param string|Name|Expr $class Class name
+ * @param array $args Constructor arguments
+ *
+ * @return Expr\New_
+ */
+ public function new($class, array $args = []) : Expr\New_ {
+ return new Expr\New_(
+ BuilderHelpers::normalizeNameOrExpr($class),
+ $this->args($args)
+ );
+ }
+
+ /**
+ * Creates a constant fetch node.
+ *
+ * @param string|Name $name Constant name
+ *
+ * @return Expr\ConstFetch
+ */
+ public function constFetch($name) : Expr\ConstFetch {
+ return new Expr\ConstFetch(BuilderHelpers::normalizeName($name));
+ }
+
+ /**
+ * Creates a class constant fetch node.
+ *
+ * @param string|Name|Expr $class Class name
+ * @param string|Identifier $name Constant name
+ *
+ * @return Expr\ClassConstFetch
+ */
+ public function classConstFetch($class, $name): Expr\ClassConstFetch {
+ return new Expr\ClassConstFetch(
+ BuilderHelpers::normalizeNameOrExpr($class),
+ BuilderHelpers::normalizeIdentifier($name)
+ );
+ }
+
+ /**
+ * Creates nested Concat nodes from a list of expressions.
+ *
+ * @param Expr|string ...$exprs Expressions or literal strings
+ *
+ * @return Concat
+ */
+ public function concat(...$exprs) : Concat {
+ $numExprs = count($exprs);
+ if ($numExprs < 2) {
+ throw new \LogicException('Expected at least two expressions');
+ }
+
+ $lastConcat = $this->normalizeStringExpr($exprs[0]);
+ for ($i = 1; $i < $numExprs; $i++) {
+ $lastConcat = new Concat($lastConcat, $this->normalizeStringExpr($exprs[$i]));
+ }
+ return $lastConcat;
+ }
+
+ /**
+ * @param string|Expr $expr
+ * @return Expr
+ */
+ private function normalizeStringExpr($expr) : Expr {
+ if ($expr instanceof Expr) {
+ return $expr;
+ }
+
+ if (\is_string($expr)) {
+ return new String_($expr);