protected function addAlias(Stmt\UseUse $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], $use->name, $use->alias), $use->getLine()); } $this->aliases[$type][$aliasName] = $use->name; }
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; }