protected function parseConnectionParams($params, $defaults = [])
    {
        // Handle host shortcut
        if (is_string($params)) {
            $params = ['host' => $params];
        }

        // Convert keys from Bolt
        $replacements = [
            'databasename' => 'dbname',
            'username'     => 'user',
        ];
        foreach ($replacements as $old => $new) {
            if (isset($params[$old])) {
                $params[$new] = $params[$old];
                unset($params[$old]);
            }
        }

        // Merge in defaults
        $params = array_replace($defaults, $params);

        // Filter out invalid keys
        $validKeys = [
            'user', 'password', 'host', 'port', 'dbname', 'charset',      // common
            'path', 'memory',                                             // Qqlite
            'unix_socket', 'driverOptions', 'collate',                    // MySql
            'sslmode',                                                    // PostgreSQL
            'servicename', 'service', 'pooled', 'instancename', 'server', // Oracle
            'persistent',                                                 // SQL Anywhere
        ];
        $params = array_intersect_key($params, array_flip($validKeys));

        return $params;
    }
protected function parseConnectionParams($params, $defaults = [])
    {
        // Handle host shortcut
        if (is_string($params)) {
            $params = ['host' => $params];
        }

        // Convert keys from Bolt
        $replacements = [
            'databasename' => 'dbname',
            'username'     => 'user',
        ];
        foreach ($replacements as $old => $new) {
            if (isset($params[$old])) {
                $params[$new] = $params[$old];
                unset($params[$old]);
            }
        }

        // Merge in defaults
        $params = array_replace($defaults, $params);

        // Filter out invalid keys
        $validKeys = [
            'user', 'password', 'host', 'port', 'dbname', 'charset',      // common
            'path', 'memory',                                             // Qqlite
            'unix_socket', 'driverOptions', 'collate',                    // MySql
            'sslmode',                                                    // PostgreSQL
            'servicename', 'service', 'pooled', 'instancename', 'server', // Oracle
            'persistent',                                                 // SQL Anywhere
        ];
        $params = array_intersect_key($params, array_flip($validKeys));

        return $params;
    }
protected function parseConnectionParams ( $ params , $ defaults = [ ] ) { // Handle host shortcut if ( is_string ( $ params ) ) { $ params = [ 'host' => $ params ] ; } // Convert keys from Bolt $ replacements = [ 'databasename' => 'dbname' , 'username' => 'user' , ] ; foreach ( $ replacements as $ old => $ new ) { if ( isset ( $ params [ $ old ] ) ) { $ params [ $ new ] = $ params [ $ old ] ; unset ( $ params [ $ old ] ) ; } } // Merge in defaults $ params = array_replace ( $ defaults , $ params ) ; // Filter out invalid keys $ validKeys = [ 'user' , 'password' , 'host' , 'port' , 'dbname' , 'charset' , // common 'path' , 'memory' , // Qqlite 'unix_socket' , 'driverOptions' , 'collate' , // MySql 'sslmode' , // PostgreSQL 'servicename' , 'service' , 'pooled' , 'instancename' , 'server' , // Oracle 'persistent' , // SQL Anywhere ] ; $ params = array_intersect_key ( $ params , array_flip ( $ validKeys ) ) ; return $ params ; }
Parses params to valid connection parameters.

- Defaults are merged into the params
- Bolt keys are converted to Doctrine keys
- Invalid keys are filtered out

@param array|string $params
@param array        $defaults

@return array
Parses params to valid connection parameters .