concat() 공개 정적인 메소드

The type of the generated instance depends on which class this method is called on, for example Name\FullyQualified::concat() will yield a Name\FullyQualified instance. If one of the arguments is null, a new instance of the other name will be returned. If both arguments are null, null will be returned. As such, writing Name::concat($namespace, $shortName) where $namespace is a Name node or null will work as expected.
public static concat ( string | array | self | null $name1, string | array | self | null $name2, array $attributes = [] ) : static | null
$name1 string | array | self | null The first name
$name2 string | array | self | null The second name
$attributes array Attributes to assign to concatenated name
리턴 static | null Concatenated name
 protected function addAlias(Stmt\UseUse $use, $type, Name $prefix = null)
 {
     parent::addAlias($use, $type, $prefix);
     if ($type == Stmt\Use_::TYPE_NORMAL) {
         // Add prefix for group uses
         $name = strval($prefix ? Name::concat($prefix, $use->name) : $use->name);
         $this->classAliases[$use->alias] = $name;
     }
 }
예제 #2
0
 protected function addNamespacedName(Node $node)
 {
     if (null !== $this->namespace) {
         $node->namespacedName = Name::concat($this->namespace, $node->name);
     } else {
         $node->namespacedName = new Name($node->name);
     }
 }
예제 #3
0
 protected function parseExpr_FuncCall(Expr\FuncCall $expr)
 {
     $args = $this->parseExprList($expr->args, self::MODE_READ);
     $name = $this->parseExprNode($expr->name);
     if ($this->currentNamespace && $expr->name instanceof Node\Name && $expr->name->isUnqualified()) {
         $op = new Op\Expr\NsFuncCall($name, $this->parseExprNode(Node\Name::concat($this->currentNamespace, $expr->name)), $args, $this->mapAttributes($expr));
     } else {
         $op = new Op\Expr\FuncCall($name, $args, $this->mapAttributes($expr));
     }
     if ($name instanceof Operand\Literal) {
         static $assertionFunctions = ['is_array' => 'array', 'is_bool' => 'bool', 'is_callable' => 'callable', 'is_double' => 'float', 'is_float' => 'float', 'is_int' => 'int', 'is_integer' => 'int', 'is_long' => 'int', 'is_null' => 'null', 'is_numeric' => 'numeric', 'is_object' => 'object', 'is_real' => 'float', 'is_string' => 'string', 'is_resource' => 'resource'];
         $lname = strtolower($name->value);
         if (isset($assertionFunctions[$lname])) {
             $op->result->addAssertion($args[0], new Assertion\TypeAssertion(new Operand\Literal($assertionFunctions[$lname])));
         }
     }
     return $op;
 }
 public function enterNode(Node $node)
 {
     if ($node instanceof UseUse) {
         $node->name = Name::concat($this->prefix, $node->name);
     }
 }
예제 #5
0
 protected function addAlias(Stmt\UseUse $use, $type, Name $prefix = null)
 {
     // Add prefix for group uses
     $name = $prefix ? Name::concat($prefix, $use->name) : $use->name;
     // Type is determined either by individual element or whole use declaration
     $type |= $use->type;
     // Constant names are case sensitive, everything else case insensitive
     if ($type === Stmt\Use_::TYPE_CONSTANT) {
         $aliasName = $use->alias;
     } else {
         $aliasName = strtolower($use->alias);
     }
     if (isset($this->aliases[$type][$aliasName])) {
         $typeStringMap = array(Stmt\Use_::TYPE_NORMAL => '', Stmt\Use_::TYPE_FUNCTION => 'function ', Stmt\Use_::TYPE_CONSTANT => 'const ');
         throw new Error(sprintf('Cannot use %s%s as %s because the name is already in use', $typeStringMap[$type], $name, $use->alias), $use->getLine());
     }
     $this->aliases[$type][$aliasName] = $name;
 }
예제 #6
0
 protected function addNamespacedName(Node $node) {
     $node->namespacedName = Name::concat($this->namespace, $node->name);
 }
 public function enterNode(Node $node)
 {
     if ($node instanceof FullyQualified) {
         return new Name(Name::concat($this->prefix, (string) $node));
     }
 }
 public function enterNode(Node $node)
 {
     if ($node instanceof Namespace_ && null !== $node->name) {
         $node->name = Name::concat($this->prefix, $node->name);
     }
 }