Escapes SQL identifiers

@param $Identifier The identifier to escape.
@param $instance The db instance used to send the query.
@return The escaped identifier.
@see SQLAdapter::escapeIdentifier()
@deprecated

Escapes the given string as an SQL identifier.
502691
public static function doEscapeIdentifier($Identifier, $instance=null) {
		self::prepareInstance($instance);
		return self::$instances[$instance]->escapeIdentifier($Identifier);
	}
285282
function quoteIdentifier( $identifier ) {

        $delimiter = $this->identifierDelimiter;

        if ( empty( $delimiter ) ) return $identifier;

        $identifier = explode( ".", $identifier );

        $identifier = array_map(
            function( $part ) use ( $delimiter ) { return $delimiter . str_replace( $delimiter, $delimiter.$delimiter, $part ) . $delimiter; },
            $identifier
        );

        return implode( ".", $identifier );

    }
1327783
protected function replace($content, $instance){
        foreach( $this->placeholders as $key => $desc ){
            $fill = $this->fill($key, $instance);
            if( $fill && false !== strpos($content, '%'.$key.'%') ){
                $content = str_replace("%{$key}%", $fill, $content);
            }
        }
        return $content;
    }
1248615
public function resolveParamName($identifier)
    {
        if (!isset($this->paramNames[$identifier])) {
            return $identifier;
        }

        return $this->paramNames[$identifier];
    }
282887
public function quoteIdent($identifier)
	{
		if (\is_array($identifier))
		{
			return array_map([$this, __METHOD__], $identifier);
		}

		// Handle comma-separated identifiers
		if (strpos($identifier, ',') !== FALSE)
		{
			$parts = array_map('mb_trim', explode(',', $identifier));
			$parts = array_map([$this, __METHOD__], $parts);
			$identifier = implode(',', $parts);
		}

		// Split each identifier by the period
		$hiers = explode('.', $identifier);
		$hiers = array_map('mb_trim', $hiers);

		// Re-compile the string
		$raw = implode('.', array_map([$this, '_quote'], $hiers));

		// Fix functions
		$funcs = [];
		preg_match_all("#{$this->escapeCharOpen}([a-zA-Z0-9_]+(\((.*?)\))){$this->escapeCharClose}#iu", $raw, $funcs, PREG_SET_ORDER);
		foreach($funcs as $f)
		{
			// Unquote the function
			$raw = str_replace($f[0], $f[1], $raw);

			// Quote the inside identifiers
			$raw = str_replace($f[3], $this->quoteIdent($f[3]), $raw);
		}

		return $raw;
	}
325570
private function getInstanceCode(Instance $instance) : Code
    {
        $node = ($this->normalizer)($instance->value);

        return new Code(new Node\Stmt\Return_($node), false);
    }
1254040
public function quoteIdentifier($identifier)
    {
        $identifier = trim($identifier);

        if ($identifier === '*') {
            return '*';
        }

        if ($identifier === '') {
            return '';
        }

        // string
        if (preg_match('/^[\w-]+$/', $identifier)) {
            return $this->startQuote . $identifier . $this->endQuote;
        }

        // string.string
        if (preg_match('/^[\w-]+\.[^ \*]*$/', $identifier)) {
            $items = explode('.', $identifier);

            return $this->startQuote . implode($this->endQuote . '.' . $this->startQuote, $items) . $this->endQuote;
        }

        // string.*
        if (preg_match('/^[\w-]+\.\*$/', $identifier)) {
            return $this->startQuote . str_replace('.*', $this->endQuote . '.*', $identifier);
        }

        return $identifier;
    }
1115295
public static function get($identifier = 'default')
    {
        if (!array_key_exists($identifier, self::$instances)) {
            self::$instances[$identifier] = static::create();
        }

        return self::$instances[$identifier];
    }
828462
public static function setIdentifierName(string $identifier): void
    {
        if (empty($identifier)) {
            throw new InvalidArgumentException("Identifier shouldn't be empty.");
        } elseif (\in_array($identifier, ['password'])) {
            throw new InvalidArgumentException("Identifier [{$identifier}] is not allowed!");
        }

        static::$identifier = $identifier;
    }
1244737
public function getContentTypeName(string $identifier): string
    {
        try {
            $contentType = $this->loadContentType($identifier);

            return $contentType->getName() ?? '';
        } catch (Throwable $t) {
            return '';
        }
    }
969762
public function quoteIdentifier(string $identifier): string
    {
        // switch statement for DB type
        switch ($this->connect['type']) {
            case 'mysql':
                return '`' . str_replace('`', '``', $identifier) . '`';
            case 'postgresql':
            case 'sqlite':
            default:
                return '"' . str_replace('"', '\\' . '"', $identifier) . '"';
        }
    }
918620
private static void doAppendEscapedIdentifier(Appendable sbuf, String value) throws SQLException {
    try {
      sbuf.append('"');

      for (int i = 0; i < value.length(); ++i) {
        char ch = value.charAt(i);
        if (ch == '\0') {
          throw new PSQLException(GT.tr("Zero bytes may not occur in identifiers."),
              PSQLState.INVALID_PARAMETER_VALUE);
        }
        if (ch == '"') {
          sbuf.append(ch);
        }
        sbuf.append(ch);
      }

      sbuf.append('"');
    } catch (IOException e) {
      throw new PSQLException(GT.tr("No IOException expected from StringBuffer or StringBuilder"),
          PSQLState.UNEXPECTED_ERROR, e);
    }
  }
186618
function generateMappingCode( $identifier )
    {
        if ( !is_array( $identifier ) )
            $identifier = array( $identifier );
        $table = $this->expandInheritance( $identifier );

        // We allow all characters for now
        $allowedRanges = array();
        $simpleTable = $this->generateSimpleMappingTable( $table, $allowedRanges );
        ksort( $simpleTable );
        return $simpleTable;
    }
871711
public function escape($identifier): string {
        if ($identifier instanceof Literal) {
            return $identifier->getValue($this);
        }
        return '`'.str_replace('`', '``', $identifier).'`';
    }
289606
public function parseIdentifier(ObjectIdentifier $identifier)
    {
        $info = parent::parseIdentifier($identifier);

        $path  = $identifier->path;

        //Allow locating default classes if $path is empty.
        if(empty($path))
        {
            $info['path']    = $info['file'];
            $info['file']    = '';
            $info['package'] = '';
        }
        else
        {
            $package = array_shift($path);

            $info['path']    = StringInflector::implode($path);
            $info['package'] = ucfirst($package);
        }

        //Make an exception for 'view' and 'module' types
        if(in_array($info['package'], array('View','Module')) && !in_array('behavior', $path)) {
            $info['path'] = '';
        }

        return $info;
    }
518648
protected function quoteOneIdentifier($identifier)
    {
        $parts = explode('.', $identifier);
        $parts = array_map([$this, 'quoteIdentifierSection'], $parts);

        return implode('.', $parts);
    }
1243124
static function instance( $identifier = false )
    {
        if ( $identifier === false )
        {
            $fileINI = eZINI::instance( 'file.ini' );
            $identifier = $fileINI->variable( 'BinaryFileSettings', 'Handler' );
        }
        $instance =& $GLOBALS['eZBinaryFileHandlerInstance-' . $identifier];
        if ( !isset( $instance ) )
        {
            $optionArray = array( 'iniFile'     => 'file.ini',
                                  'iniSection'  => 'BinaryFileSettings',
                                  'iniVariable' => 'Handler'  );

            $options = new ezpExtensionOptions( $optionArray );

            $instance = eZExtension::getHandlerClass( $options );

            if( $instance === false )
            {
                eZDebug::writeError( "Could not find binary file handler '$identifier'", __METHOD__ );
            }
        }
        return $instance;
    }