lib/Doctrine/DBAL/DriverManager.php
private static function parseDatabaseUrl(array $params) : array
    {
        if (! isset($params['url'])) {
            return $params;
        }

        // (pdo_)?sqlite3?:///... => (pdo_)?sqlite3?://localhost/... or else the URL will be invalid
        $url = preg_replace('#^((?:pdo_)?sqlite3?):///#', '$1://localhost/', $params['url']);
        assert(is_string($url));

        $url = parse_url($url);

        if ($url === false) {
            throw new DBALException('Malformed parameter "url".');
        }

        $url = array_map('rawurldecode', $url);

        // If we have a connection URL, we have to unset the default PDO instance connection parameter (if any)
        // as we cannot merge connection details from the URL into the PDO instance (URL takes precedence).
        unset($params['pdo']);

        $params = self::parseDatabaseUrlScheme($url, $params);

        if (isset($url['host'])) {
            $params['host'] = $url['host'];
        }
        if (isset($url['port'])) {
            $params['port'] = $url['port'];
        }
        if (isset($url['user'])) {
            $params['user'] = $url['user'];
        }
        if (isset($url['pass'])) {
            $params['password'] = $url['pass'];
        }

        $params = self::parseDatabaseUrlPath($url, $params);
        $params = self::parseDatabaseUrlQuery($url, $params);

        return $params;
    }
private static function parseDatabaseUrl(array $params) : array
    {
        if (! isset($params['url'])) {
            return $params;
        }

        // (pdo_)?sqlite3?:///... => (pdo_)?sqlite3?://localhost/... or else the URL will be invalid
        $url = preg_replace('#^((?:pdo_)?sqlite3?):///#', '$1://localhost/', $params['url']);
        assert(is_string($url));

        $url = parse_url($url);

        if ($url === false) {
            throw new DBALException('Malformed parameter "url".');
        }

        $url = array_map('rawurldecode', $url);

        // If we have a connection URL, we have to unset the default PDO instance connection parameter (if any)
        // as we cannot merge connection details from the URL into the PDO instance (URL takes precedence).
        unset($params['pdo']);

        $params = self::parseDatabaseUrlScheme($url, $params);

        if (isset($url['host'])) {
            $params['host'] = $url['host'];
        }
        if (isset($url['port'])) {
            $params['port'] = $url['port'];
        }
        if (isset($url['user'])) {
            $params['user'] = $url['user'];
        }
        if (isset($url['pass'])) {
            $params['password'] = $url['pass'];
        }

        $params = self::parseDatabaseUrlPath($url, $params);
        $params = self::parseDatabaseUrlQuery($url, $params);

        return $params;
    }
private static function parseDatabaseUrl ( array $ params ) : array { if ( ! isset ( $ params [ 'url' ] ) ) { return $ params ; } // (pdo_)?sqlite3?:///... => (pdo_)?sqlite3?://localhost/... or else the URL will be invalid $ url = preg_replace ( '#^((?:pdo_)?sqlite3?):///#' , '$1://localhost/' , $ params [ 'url' ] ) ; assert ( is_string ( $ url ) ) ; $ url = parse_url ( $ url ) ; if ( $ url === false ) { throw new DBALException ( 'Malformed parameter "url".' ) ; } $ url = array_map ( 'rawurldecode' , $ url ) ; // If we have a connection URL, we have to unset the default PDO instance connection parameter (if any) // as we cannot merge connection details from the URL into the PDO instance (URL takes precedence). unset ( $ params [ 'pdo' ] ) ; $ params = self :: parseDatabaseUrlScheme ( $ url , $ params ) ; if ( isset ( $ url [ 'host' ] ) ) { $ params [ 'host' ] = $ url [ 'host' ] ; } if ( isset ( $ url [ 'port' ] ) ) { $ params [ 'port' ] = $ url [ 'port' ] ; } if ( isset ( $ url [ 'user' ] ) ) { $ params [ 'user' ] = $ url [ 'user' ] ; } if ( isset ( $ url [ 'pass' ] ) ) { $ params [ 'password' ] = $ url [ 'pass' ] ; } $ params = self :: parseDatabaseUrlPath ( $ url , $ params ) ; $ params = self :: parseDatabaseUrlQuery ( $ url , $ params ) ; return $ params ; }
Extracts parts from a database URL, if present, and returns an
updated list of parameters.

@param mixed[] $params The list of parameters.

@return mixed[] A modified list of parameters with info from a database
URL extracted into indidivual parameter parts.

@throws DBALException
Extracts parts from a database URL if present and returns an updated list of parameters .