repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
doctrine/dbal
lib/Doctrine/DBAL/Schema/Table.php
Table.getPrimaryKeyColumns
public function getPrimaryKeyColumns() { $primaryKey = $this->getPrimaryKey(); if ($primaryKey === null) { throw new DBALException('Table ' . $this->getName() . ' has no primary key.'); } return $primaryKey->getColumns(); }
php
public function getPrimaryKeyColumns() { $primaryKey = $this->getPrimaryKey(); if ($primaryKey === null) { throw new DBALException('Table ' . $this->getName() . ' has no primary key.'); } return $primaryKey->getColumns(); }
[ "public", "function", "getPrimaryKeyColumns", "(", ")", "{", "$", "primaryKey", "=", "$", "this", "->", "getPrimaryKey", "(", ")", ";", "if", "(", "$", "primaryKey", "===", "null", ")", "{", "throw", "new", "DBALException", "(", "'Table '", ".", "$", "this", "->", "getName", "(", ")", ".", "' has no primary key.'", ")", ";", "}", "return", "$", "primaryKey", "->", "getColumns", "(", ")", ";", "}" ]
Returns the primary key columns. @return string[] @throws DBALException
[ "Returns", "the", "primary", "key", "columns", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/Table.php#L685-L694
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/Table.php
Table.hasIndex
public function hasIndex($indexName) { $indexName = $this->normalizeIdentifier($indexName); return isset($this->_indexes[$indexName]); }
php
public function hasIndex($indexName) { $indexName = $this->normalizeIdentifier($indexName); return isset($this->_indexes[$indexName]); }
[ "public", "function", "hasIndex", "(", "$", "indexName", ")", "{", "$", "indexName", "=", "$", "this", "->", "normalizeIdentifier", "(", "$", "indexName", ")", ";", "return", "isset", "(", "$", "this", "->", "_indexes", "[", "$", "indexName", "]", ")", ";", "}" ]
Returns whether this table has an Index with the given name. @param string $indexName The index name. @return bool
[ "Returns", "whether", "this", "table", "has", "an", "Index", "with", "the", "given", "name", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/Table.php#L713-L718
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/Table.php
Table.getIndex
public function getIndex($indexName) { $indexName = $this->normalizeIdentifier($indexName); if (! $this->hasIndex($indexName)) { throw SchemaException::indexDoesNotExist($indexName, $this->_name); } return $this->_indexes[$indexName]; }
php
public function getIndex($indexName) { $indexName = $this->normalizeIdentifier($indexName); if (! $this->hasIndex($indexName)) { throw SchemaException::indexDoesNotExist($indexName, $this->_name); } return $this->_indexes[$indexName]; }
[ "public", "function", "getIndex", "(", "$", "indexName", ")", "{", "$", "indexName", "=", "$", "this", "->", "normalizeIdentifier", "(", "$", "indexName", ")", ";", "if", "(", "!", "$", "this", "->", "hasIndex", "(", "$", "indexName", ")", ")", "{", "throw", "SchemaException", "::", "indexDoesNotExist", "(", "$", "indexName", ",", "$", "this", "->", "_name", ")", ";", "}", "return", "$", "this", "->", "_indexes", "[", "$", "indexName", "]", ";", "}" ]
Returns the Index with the given name. @param string $indexName The index name. @return Index @throws SchemaException If the index does not exist.
[ "Returns", "the", "Index", "with", "the", "given", "name", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/Table.php#L729-L737
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/Sequence.php
Sequence.isAutoIncrementsFor
public function isAutoIncrementsFor(Table $table) { $primaryKey = $table->getPrimaryKey(); if ($primaryKey === null) { return false; } $pkColumns = $primaryKey->getColumns(); if (count($pkColumns) !== 1) { return false; } $column = $table->getColumn($pkColumns[0]); if (! $column->getAutoincrement()) { return false; } $sequenceName = $this->getShortestName($table->getNamespaceName()); $tableName = $table->getShortestName($table->getNamespaceName()); $tableSequenceName = sprintf('%s_%s_seq', $tableName, $column->getShortestName($table->getNamespaceName())); return $tableSequenceName === $sequenceName; }
php
public function isAutoIncrementsFor(Table $table) { $primaryKey = $table->getPrimaryKey(); if ($primaryKey === null) { return false; } $pkColumns = $primaryKey->getColumns(); if (count($pkColumns) !== 1) { return false; } $column = $table->getColumn($pkColumns[0]); if (! $column->getAutoincrement()) { return false; } $sequenceName = $this->getShortestName($table->getNamespaceName()); $tableName = $table->getShortestName($table->getNamespaceName()); $tableSequenceName = sprintf('%s_%s_seq', $tableName, $column->getShortestName($table->getNamespaceName())); return $tableSequenceName === $sequenceName; }
[ "public", "function", "isAutoIncrementsFor", "(", "Table", "$", "table", ")", "{", "$", "primaryKey", "=", "$", "table", "->", "getPrimaryKey", "(", ")", ";", "if", "(", "$", "primaryKey", "===", "null", ")", "{", "return", "false", ";", "}", "$", "pkColumns", "=", "$", "primaryKey", "->", "getColumns", "(", ")", ";", "if", "(", "count", "(", "$", "pkColumns", ")", "!==", "1", ")", "{", "return", "false", ";", "}", "$", "column", "=", "$", "table", "->", "getColumn", "(", "$", "pkColumns", "[", "0", "]", ")", ";", "if", "(", "!", "$", "column", "->", "getAutoincrement", "(", ")", ")", "{", "return", "false", ";", "}", "$", "sequenceName", "=", "$", "this", "->", "getShortestName", "(", "$", "table", "->", "getNamespaceName", "(", ")", ")", ";", "$", "tableName", "=", "$", "table", "->", "getShortestName", "(", "$", "table", "->", "getNamespaceName", "(", ")", ")", ";", "$", "tableSequenceName", "=", "sprintf", "(", "'%s_%s_seq'", ",", "$", "tableName", ",", "$", "column", "->", "getShortestName", "(", "$", "table", "->", "getNamespaceName", "(", ")", ")", ")", ";", "return", "$", "tableSequenceName", "===", "$", "sequenceName", ";", "}" ]
Checks if this sequence is an autoincrement sequence for a given table. This is used inside the comparator to not report sequences as missing, when the "from" schema implicitly creates the sequences. @return bool
[ "Checks", "if", "this", "sequence", "is", "an", "autoincrement", "sequence", "for", "a", "given", "table", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/Sequence.php#L105-L130
train
doctrine/dbal
lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php
MysqliConnection.setDriverOptions
private function setDriverOptions(array $driverOptions = []) { $supportedDriverOptions = [ MYSQLI_OPT_CONNECT_TIMEOUT, MYSQLI_OPT_LOCAL_INFILE, MYSQLI_INIT_COMMAND, MYSQLI_READ_DEFAULT_FILE, MYSQLI_READ_DEFAULT_GROUP, ]; if (defined('MYSQLI_SERVER_PUBLIC_KEY')) { $supportedDriverOptions[] = MYSQLI_SERVER_PUBLIC_KEY; } $exceptionMsg = "%s option '%s' with value '%s'"; foreach ($driverOptions as $option => $value) { if ($option === static::OPTION_FLAGS) { continue; } if (! in_array($option, $supportedDriverOptions, true)) { throw new MysqliException( sprintf($exceptionMsg, 'Unsupported', $option, $value) ); } if (@mysqli_options($this->conn, $option, $value)) { continue; } $msg = sprintf($exceptionMsg, 'Failed to set', $option, $value); $msg .= sprintf(', error: %s (%d)', mysqli_error($this->conn), mysqli_errno($this->conn)); throw new MysqliException( $msg, $this->conn->sqlstate, $this->conn->errno ); } }
php
private function setDriverOptions(array $driverOptions = []) { $supportedDriverOptions = [ MYSQLI_OPT_CONNECT_TIMEOUT, MYSQLI_OPT_LOCAL_INFILE, MYSQLI_INIT_COMMAND, MYSQLI_READ_DEFAULT_FILE, MYSQLI_READ_DEFAULT_GROUP, ]; if (defined('MYSQLI_SERVER_PUBLIC_KEY')) { $supportedDriverOptions[] = MYSQLI_SERVER_PUBLIC_KEY; } $exceptionMsg = "%s option '%s' with value '%s'"; foreach ($driverOptions as $option => $value) { if ($option === static::OPTION_FLAGS) { continue; } if (! in_array($option, $supportedDriverOptions, true)) { throw new MysqliException( sprintf($exceptionMsg, 'Unsupported', $option, $value) ); } if (@mysqli_options($this->conn, $option, $value)) { continue; } $msg = sprintf($exceptionMsg, 'Failed to set', $option, $value); $msg .= sprintf(', error: %s (%d)', mysqli_error($this->conn), mysqli_errno($this->conn)); throw new MysqliException( $msg, $this->conn->sqlstate, $this->conn->errno ); } }
[ "private", "function", "setDriverOptions", "(", "array", "$", "driverOptions", "=", "[", "]", ")", "{", "$", "supportedDriverOptions", "=", "[", "MYSQLI_OPT_CONNECT_TIMEOUT", ",", "MYSQLI_OPT_LOCAL_INFILE", ",", "MYSQLI_INIT_COMMAND", ",", "MYSQLI_READ_DEFAULT_FILE", ",", "MYSQLI_READ_DEFAULT_GROUP", ",", "]", ";", "if", "(", "defined", "(", "'MYSQLI_SERVER_PUBLIC_KEY'", ")", ")", "{", "$", "supportedDriverOptions", "[", "]", "=", "MYSQLI_SERVER_PUBLIC_KEY", ";", "}", "$", "exceptionMsg", "=", "\"%s option '%s' with value '%s'\"", ";", "foreach", "(", "$", "driverOptions", "as", "$", "option", "=>", "$", "value", ")", "{", "if", "(", "$", "option", "===", "static", "::", "OPTION_FLAGS", ")", "{", "continue", ";", "}", "if", "(", "!", "in_array", "(", "$", "option", ",", "$", "supportedDriverOptions", ",", "true", ")", ")", "{", "throw", "new", "MysqliException", "(", "sprintf", "(", "$", "exceptionMsg", ",", "'Unsupported'", ",", "$", "option", ",", "$", "value", ")", ")", ";", "}", "if", "(", "@", "mysqli_options", "(", "$", "this", "->", "conn", ",", "$", "option", ",", "$", "value", ")", ")", "{", "continue", ";", "}", "$", "msg", "=", "sprintf", "(", "$", "exceptionMsg", ",", "'Failed to set'", ",", "$", "option", ",", "$", "value", ")", ";", "$", "msg", ".=", "sprintf", "(", "', error: %s (%d)'", ",", "mysqli_error", "(", "$", "this", "->", "conn", ")", ",", "mysqli_errno", "(", "$", "this", "->", "conn", ")", ")", ";", "throw", "new", "MysqliException", "(", "$", "msg", ",", "$", "this", "->", "conn", "->", "sqlstate", ",", "$", "this", "->", "conn", "->", "errno", ")", ";", "}", "}" ]
Apply the driver options to the connection. @param mixed[] $driverOptions @throws MysqliException When one of of the options is not supported. @throws MysqliException When applying doesn't work - e.g. due to incorrect value.
[ "Apply", "the", "driver", "options", "to", "the", "connection", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php#L225-L265
train
doctrine/dbal
lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php
MysqliConnection.setSecureConnection
private function setSecureConnection(array $params) { if (! isset($params['ssl_key']) && ! isset($params['ssl_cert']) && ! isset($params['ssl_ca']) && ! isset($params['ssl_capath']) && ! isset($params['ssl_cipher']) ) { return; } $this->conn->ssl_set( $params['ssl_key'] ?? null, $params['ssl_cert'] ?? null, $params['ssl_ca'] ?? null, $params['ssl_capath'] ?? null, $params['ssl_cipher'] ?? null ); }
php
private function setSecureConnection(array $params) { if (! isset($params['ssl_key']) && ! isset($params['ssl_cert']) && ! isset($params['ssl_ca']) && ! isset($params['ssl_capath']) && ! isset($params['ssl_cipher']) ) { return; } $this->conn->ssl_set( $params['ssl_key'] ?? null, $params['ssl_cert'] ?? null, $params['ssl_ca'] ?? null, $params['ssl_capath'] ?? null, $params['ssl_cipher'] ?? null ); }
[ "private", "function", "setSecureConnection", "(", "array", "$", "params", ")", "{", "if", "(", "!", "isset", "(", "$", "params", "[", "'ssl_key'", "]", ")", "&&", "!", "isset", "(", "$", "params", "[", "'ssl_cert'", "]", ")", "&&", "!", "isset", "(", "$", "params", "[", "'ssl_ca'", "]", ")", "&&", "!", "isset", "(", "$", "params", "[", "'ssl_capath'", "]", ")", "&&", "!", "isset", "(", "$", "params", "[", "'ssl_cipher'", "]", ")", ")", "{", "return", ";", "}", "$", "this", "->", "conn", "->", "ssl_set", "(", "$", "params", "[", "'ssl_key'", "]", "??", "null", ",", "$", "params", "[", "'ssl_cert'", "]", "??", "null", ",", "$", "params", "[", "'ssl_ca'", "]", "??", "null", ",", "$", "params", "[", "'ssl_capath'", "]", "??", "null", ",", "$", "params", "[", "'ssl_cipher'", "]", "??", "null", ")", ";", "}" ]
Establish a secure connection @param mixed[] $params @throws MysqliException
[ "Establish", "a", "secure", "connection" ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php#L284-L302
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
AbstractSchemaManager.tryMethod
public function tryMethod() { $args = func_get_args(); $method = $args[0]; unset($args[0]); $args = array_values($args); $callback = [$this, $method]; assert(is_callable($callback)); try { return call_user_func_array($callback, $args); } catch (Throwable $e) { return false; } }
php
public function tryMethod() { $args = func_get_args(); $method = $args[0]; unset($args[0]); $args = array_values($args); $callback = [$this, $method]; assert(is_callable($callback)); try { return call_user_func_array($callback, $args); } catch (Throwable $e) { return false; } }
[ "public", "function", "tryMethod", "(", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "method", "=", "$", "args", "[", "0", "]", ";", "unset", "(", "$", "args", "[", "0", "]", ")", ";", "$", "args", "=", "array_values", "(", "$", "args", ")", ";", "$", "callback", "=", "[", "$", "this", ",", "$", "method", "]", ";", "assert", "(", "is_callable", "(", "$", "callback", ")", ")", ";", "try", "{", "return", "call_user_func_array", "(", "$", "callback", ",", "$", "args", ")", ";", "}", "catch", "(", "Throwable", "$", "e", ")", "{", "return", "false", ";", "}", "}" ]
Tries any method on the schema manager. Normally a method throws an exception when your DBMS doesn't support it or if an error occurs. This method allows you to try and method on your SchemaManager instance and will return false if it does not work or is not supported. <code> $result = $sm->tryMethod('dropView', 'view_name'); </code> @return mixed
[ "Tries", "any", "method", "on", "the", "schema", "manager", ".", "Normally", "a", "method", "throws", "an", "exception", "when", "your", "DBMS", "doesn", "t", "support", "it", "or", "if", "an", "error", "occurs", ".", "This", "method", "allows", "you", "to", "try", "and", "method", "on", "your", "SchemaManager", "instance", "and", "will", "return", "false", "if", "it", "does", "not", "work", "or", "is", "not", "supported", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php#L78-L93
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
AbstractSchemaManager.listDatabases
public function listDatabases() { $sql = $this->_platform->getListDatabasesSQL(); $databases = $this->_conn->fetchAll($sql); return $this->_getPortableDatabasesList($databases); }
php
public function listDatabases() { $sql = $this->_platform->getListDatabasesSQL(); $databases = $this->_conn->fetchAll($sql); return $this->_getPortableDatabasesList($databases); }
[ "public", "function", "listDatabases", "(", ")", "{", "$", "sql", "=", "$", "this", "->", "_platform", "->", "getListDatabasesSQL", "(", ")", ";", "$", "databases", "=", "$", "this", "->", "_conn", "->", "fetchAll", "(", "$", "sql", ")", ";", "return", "$", "this", "->", "_getPortableDatabasesList", "(", "$", "databases", ")", ";", "}" ]
Lists the available databases for this connection. @return string[]
[ "Lists", "the", "available", "databases", "for", "this", "connection", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php#L100-L107
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
AbstractSchemaManager.listNamespaceNames
public function listNamespaceNames() { $sql = $this->_platform->getListNamespacesSQL(); $namespaces = $this->_conn->fetchAll($sql); return $this->getPortableNamespacesList($namespaces); }
php
public function listNamespaceNames() { $sql = $this->_platform->getListNamespacesSQL(); $namespaces = $this->_conn->fetchAll($sql); return $this->getPortableNamespacesList($namespaces); }
[ "public", "function", "listNamespaceNames", "(", ")", "{", "$", "sql", "=", "$", "this", "->", "_platform", "->", "getListNamespacesSQL", "(", ")", ";", "$", "namespaces", "=", "$", "this", "->", "_conn", "->", "fetchAll", "(", "$", "sql", ")", ";", "return", "$", "this", "->", "getPortableNamespacesList", "(", "$", "namespaces", ")", ";", "}" ]
Returns a list of all namespaces in the current database. @return string[]
[ "Returns", "a", "list", "of", "all", "namespaces", "in", "the", "current", "database", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php#L114-L121
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
AbstractSchemaManager.listSequences
public function listSequences($database = null) { if ($database === null) { $database = $this->_conn->getDatabase(); } $sql = $this->_platform->getListSequencesSQL($database); $sequences = $this->_conn->fetchAll($sql); return $this->filterAssetNames($this->_getPortableSequencesList($sequences)); }
php
public function listSequences($database = null) { if ($database === null) { $database = $this->_conn->getDatabase(); } $sql = $this->_platform->getListSequencesSQL($database); $sequences = $this->_conn->fetchAll($sql); return $this->filterAssetNames($this->_getPortableSequencesList($sequences)); }
[ "public", "function", "listSequences", "(", "$", "database", "=", "null", ")", "{", "if", "(", "$", "database", "===", "null", ")", "{", "$", "database", "=", "$", "this", "->", "_conn", "->", "getDatabase", "(", ")", ";", "}", "$", "sql", "=", "$", "this", "->", "_platform", "->", "getListSequencesSQL", "(", "$", "database", ")", ";", "$", "sequences", "=", "$", "this", "->", "_conn", "->", "fetchAll", "(", "$", "sql", ")", ";", "return", "$", "this", "->", "filterAssetNames", "(", "$", "this", "->", "_getPortableSequencesList", "(", "$", "sequences", ")", ")", ";", "}" ]
Lists the available sequences for this connection. @param string|null $database @return Sequence[]
[ "Lists", "the", "available", "sequences", "for", "this", "connection", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php#L130-L140
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
AbstractSchemaManager.listTableColumns
public function listTableColumns($table, $database = null) { if (! $database) { $database = $this->_conn->getDatabase(); } $sql = $this->_platform->getListTableColumnsSQL($table, $database); $tableColumns = $this->_conn->fetchAll($sql); return $this->_getPortableTableColumnList($table, $database, $tableColumns); }
php
public function listTableColumns($table, $database = null) { if (! $database) { $database = $this->_conn->getDatabase(); } $sql = $this->_platform->getListTableColumnsSQL($table, $database); $tableColumns = $this->_conn->fetchAll($sql); return $this->_getPortableTableColumnList($table, $database, $tableColumns); }
[ "public", "function", "listTableColumns", "(", "$", "table", ",", "$", "database", "=", "null", ")", "{", "if", "(", "!", "$", "database", ")", "{", "$", "database", "=", "$", "this", "->", "_conn", "->", "getDatabase", "(", ")", ";", "}", "$", "sql", "=", "$", "this", "->", "_platform", "->", "getListTableColumnsSQL", "(", "$", "table", ",", "$", "database", ")", ";", "$", "tableColumns", "=", "$", "this", "->", "_conn", "->", "fetchAll", "(", "$", "sql", ")", ";", "return", "$", "this", "->", "_getPortableTableColumnList", "(", "$", "table", ",", "$", "database", ",", "$", "tableColumns", ")", ";", "}" ]
Lists the columns for a given table. In contrast to other libraries and to the old version of Doctrine, this column definition does try to contain the 'primary' field for the reason that it is not portable across different RDBMS. Use {@see listTableIndexes($tableName)} to retrieve the primary key of a table. We're a RDBMS specifies more details these are held in the platformDetails array. @param string $table The name of the table. @param string|null $database @return Column[]
[ "Lists", "the", "columns", "for", "a", "given", "table", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php#L157-L168
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
AbstractSchemaManager.tablesExist
public function tablesExist($tableNames) { $tableNames = array_map('strtolower', (array) $tableNames); return count($tableNames) === count(array_intersect($tableNames, array_map('strtolower', $this->listTableNames()))); }
php
public function tablesExist($tableNames) { $tableNames = array_map('strtolower', (array) $tableNames); return count($tableNames) === count(array_intersect($tableNames, array_map('strtolower', $this->listTableNames()))); }
[ "public", "function", "tablesExist", "(", "$", "tableNames", ")", "{", "$", "tableNames", "=", "array_map", "(", "'strtolower'", ",", "(", "array", ")", "$", "tableNames", ")", ";", "return", "count", "(", "$", "tableNames", ")", "===", "count", "(", "array_intersect", "(", "$", "tableNames", ",", "array_map", "(", "'strtolower'", ",", "$", "this", "->", "listTableNames", "(", ")", ")", ")", ")", ";", "}" ]
Returns true if all the given tables exist. @param string|string[] $tableNames @return bool
[ "Returns", "true", "if", "all", "the", "given", "tables", "exist", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php#L195-L200
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
AbstractSchemaManager.listTableNames
public function listTableNames() { $sql = $this->_platform->getListTablesSQL(); $tables = $this->_conn->fetchAll($sql); $tableNames = $this->_getPortableTablesList($tables); return $this->filterAssetNames($tableNames); }
php
public function listTableNames() { $sql = $this->_platform->getListTablesSQL(); $tables = $this->_conn->fetchAll($sql); $tableNames = $this->_getPortableTablesList($tables); return $this->filterAssetNames($tableNames); }
[ "public", "function", "listTableNames", "(", ")", "{", "$", "sql", "=", "$", "this", "->", "_platform", "->", "getListTablesSQL", "(", ")", ";", "$", "tables", "=", "$", "this", "->", "_conn", "->", "fetchAll", "(", "$", "sql", ")", ";", "$", "tableNames", "=", "$", "this", "->", "_getPortableTablesList", "(", "$", "tables", ")", ";", "return", "$", "this", "->", "filterAssetNames", "(", "$", "tableNames", ")", ";", "}" ]
Returns a list of all tables in the current database. @return string[]
[ "Returns", "a", "list", "of", "all", "tables", "in", "the", "current", "database", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php#L207-L215
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
AbstractSchemaManager.filterAssetNames
protected function filterAssetNames($assetNames) { $filter = $this->_conn->getConfiguration()->getSchemaAssetsFilter(); if (! $filter) { return $assetNames; } return array_values(array_filter($assetNames, $filter)); }
php
protected function filterAssetNames($assetNames) { $filter = $this->_conn->getConfiguration()->getSchemaAssetsFilter(); if (! $filter) { return $assetNames; } return array_values(array_filter($assetNames, $filter)); }
[ "protected", "function", "filterAssetNames", "(", "$", "assetNames", ")", "{", "$", "filter", "=", "$", "this", "->", "_conn", "->", "getConfiguration", "(", ")", "->", "getSchemaAssetsFilter", "(", ")", ";", "if", "(", "!", "$", "filter", ")", "{", "return", "$", "assetNames", ";", "}", "return", "array_values", "(", "array_filter", "(", "$", "assetNames", ",", "$", "filter", ")", ")", ";", "}" ]
Filters asset names if they are configured to return only a subset of all the found elements. @param mixed[] $assetNames @return mixed[]
[ "Filters", "asset", "names", "if", "they", "are", "configured", "to", "return", "only", "a", "subset", "of", "all", "the", "found", "elements", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php#L225-L233
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
AbstractSchemaManager.listViews
public function listViews() { $database = $this->_conn->getDatabase(); $sql = $this->_platform->getListViewsSQL($database); $views = $this->_conn->fetchAll($sql); return $this->_getPortableViewsList($views); }
php
public function listViews() { $database = $this->_conn->getDatabase(); $sql = $this->_platform->getListViewsSQL($database); $views = $this->_conn->fetchAll($sql); return $this->_getPortableViewsList($views); }
[ "public", "function", "listViews", "(", ")", "{", "$", "database", "=", "$", "this", "->", "_conn", "->", "getDatabase", "(", ")", ";", "$", "sql", "=", "$", "this", "->", "_platform", "->", "getListViewsSQL", "(", "$", "database", ")", ";", "$", "views", "=", "$", "this", "->", "_conn", "->", "fetchAll", "(", "$", "sql", ")", ";", "return", "$", "this", "->", "_getPortableViewsList", "(", "$", "views", ")", ";", "}" ]
Lists the views this connection has. @return View[]
[ "Lists", "the", "views", "this", "connection", "has", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php#L284-L291
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
AbstractSchemaManager.dropIndex
public function dropIndex($index, $table) { if ($index instanceof Index) { $index = $index->getQuotedName($this->_platform); } $this->_execSql($this->_platform->getDropIndexSQL($index, $table)); }
php
public function dropIndex($index, $table) { if ($index instanceof Index) { $index = $index->getQuotedName($this->_platform); } $this->_execSql($this->_platform->getDropIndexSQL($index, $table)); }
[ "public", "function", "dropIndex", "(", "$", "index", ",", "$", "table", ")", "{", "if", "(", "$", "index", "instanceof", "Index", ")", "{", "$", "index", "=", "$", "index", "->", "getQuotedName", "(", "$", "this", "->", "_platform", ")", ";", "}", "$", "this", "->", "_execSql", "(", "$", "this", "->", "_platform", "->", "getDropIndexSQL", "(", "$", "index", ",", "$", "table", ")", ")", ";", "}" ]
Drops the index from the given table. @param Index|string $index The name of the index. @param Table|string $table The name of the table. @return void
[ "Drops", "the", "index", "from", "the", "given", "table", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php#L348-L355
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
AbstractSchemaManager.dropConstraint
public function dropConstraint(Constraint $constraint, $table) { $this->_execSql($this->_platform->getDropConstraintSQL($constraint, $table)); }
php
public function dropConstraint(Constraint $constraint, $table) { $this->_execSql($this->_platform->getDropConstraintSQL($constraint, $table)); }
[ "public", "function", "dropConstraint", "(", "Constraint", "$", "constraint", ",", "$", "table", ")", "{", "$", "this", "->", "_execSql", "(", "$", "this", "->", "_platform", "->", "getDropConstraintSQL", "(", "$", "constraint", ",", "$", "table", ")", ")", ";", "}" ]
Drops the constraint from the given table. @param Table|string $table The name of the table. @return void
[ "Drops", "the", "constraint", "from", "the", "given", "table", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php#L364-L367
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
AbstractSchemaManager.dropForeignKey
public function dropForeignKey($foreignKey, $table) { $this->_execSql($this->_platform->getDropForeignKeySQL($foreignKey, $table)); }
php
public function dropForeignKey($foreignKey, $table) { $this->_execSql($this->_platform->getDropForeignKeySQL($foreignKey, $table)); }
[ "public", "function", "dropForeignKey", "(", "$", "foreignKey", ",", "$", "table", ")", "{", "$", "this", "->", "_execSql", "(", "$", "this", "->", "_platform", "->", "getDropForeignKeySQL", "(", "$", "foreignKey", ",", "$", "table", ")", ")", ";", "}" ]
Drops a foreign key from a table. @param ForeignKeyConstraint|string $foreignKey The name of the foreign key. @param Table|string $table The name of the table with the foreign key. @return void
[ "Drops", "a", "foreign", "key", "from", "a", "table", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php#L377-L380
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
AbstractSchemaManager.createConstraint
public function createConstraint(Constraint $constraint, $table) { $this->_execSql($this->_platform->getCreateConstraintSQL($constraint, $table)); }
php
public function createConstraint(Constraint $constraint, $table) { $this->_execSql($this->_platform->getCreateConstraintSQL($constraint, $table)); }
[ "public", "function", "createConstraint", "(", "Constraint", "$", "constraint", ",", "$", "table", ")", "{", "$", "this", "->", "_execSql", "(", "$", "this", "->", "_platform", "->", "getCreateConstraintSQL", "(", "$", "constraint", ",", "$", "table", ")", ")", ";", "}" ]
Creates a constraint on a table. @param Table|string $table @return void
[ "Creates", "a", "constraint", "on", "a", "table", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php#L452-L455
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
AbstractSchemaManager.createIndex
public function createIndex(Index $index, $table) { $this->_execSql($this->_platform->getCreateIndexSQL($index, $table)); }
php
public function createIndex(Index $index, $table) { $this->_execSql($this->_platform->getCreateIndexSQL($index, $table)); }
[ "public", "function", "createIndex", "(", "Index", "$", "index", ",", "$", "table", ")", "{", "$", "this", "->", "_execSql", "(", "$", "this", "->", "_platform", "->", "getCreateIndexSQL", "(", "$", "index", ",", "$", "table", ")", ")", ";", "}" ]
Creates a new index on a table. @param Table|string $table The name of the table on which the index is to be created. @return void
[ "Creates", "a", "new", "index", "on", "a", "table", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php#L464-L467
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
AbstractSchemaManager.createForeignKey
public function createForeignKey(ForeignKeyConstraint $foreignKey, $table) { $this->_execSql($this->_platform->getCreateForeignKeySQL($foreignKey, $table)); }
php
public function createForeignKey(ForeignKeyConstraint $foreignKey, $table) { $this->_execSql($this->_platform->getCreateForeignKeySQL($foreignKey, $table)); }
[ "public", "function", "createForeignKey", "(", "ForeignKeyConstraint", "$", "foreignKey", ",", "$", "table", ")", "{", "$", "this", "->", "_execSql", "(", "$", "this", "->", "_platform", "->", "getCreateForeignKeySQL", "(", "$", "foreignKey", ",", "$", "table", ")", ")", ";", "}" ]
Creates a new foreign key. @param ForeignKeyConstraint $foreignKey The ForeignKey instance. @param Table|string $table The name of the table on which the foreign key is to be created. @return void
[ "Creates", "a", "new", "foreign", "key", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php#L477-L480
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
AbstractSchemaManager.createView
public function createView(View $view) { $this->_execSql($this->_platform->getCreateViewSQL($view->getQuotedName($this->_platform), $view->getSql())); }
php
public function createView(View $view) { $this->_execSql($this->_platform->getCreateViewSQL($view->getQuotedName($this->_platform), $view->getSql())); }
[ "public", "function", "createView", "(", "View", "$", "view", ")", "{", "$", "this", "->", "_execSql", "(", "$", "this", "->", "_platform", "->", "getCreateViewSQL", "(", "$", "view", "->", "getQuotedName", "(", "$", "this", "->", "_platform", ")", ",", "$", "view", "->", "getSql", "(", ")", ")", ")", ";", "}" ]
Creates a new view. @return void
[ "Creates", "a", "new", "view", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php#L487-L490
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
AbstractSchemaManager.dropAndCreateConstraint
public function dropAndCreateConstraint(Constraint $constraint, $table) { $this->tryMethod('dropConstraint', $constraint, $table); $this->createConstraint($constraint, $table); }
php
public function dropAndCreateConstraint(Constraint $constraint, $table) { $this->tryMethod('dropConstraint', $constraint, $table); $this->createConstraint($constraint, $table); }
[ "public", "function", "dropAndCreateConstraint", "(", "Constraint", "$", "constraint", ",", "$", "table", ")", "{", "$", "this", "->", "tryMethod", "(", "'dropConstraint'", ",", "$", "constraint", ",", "$", "table", ")", ";", "$", "this", "->", "createConstraint", "(", "$", "constraint", ",", "$", "table", ")", ";", "}" ]
Drops and creates a constraint. @see dropConstraint() @see createConstraint() @param Table|string $table @return void
[ "Drops", "and", "creates", "a", "constraint", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php#L504-L508
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
AbstractSchemaManager.dropAndCreateIndex
public function dropAndCreateIndex(Index $index, $table) { $this->tryMethod('dropIndex', $index->getQuotedName($this->_platform), $table); $this->createIndex($index, $table); }
php
public function dropAndCreateIndex(Index $index, $table) { $this->tryMethod('dropIndex', $index->getQuotedName($this->_platform), $table); $this->createIndex($index, $table); }
[ "public", "function", "dropAndCreateIndex", "(", "Index", "$", "index", ",", "$", "table", ")", "{", "$", "this", "->", "tryMethod", "(", "'dropIndex'", ",", "$", "index", "->", "getQuotedName", "(", "$", "this", "->", "_platform", ")", ",", "$", "table", ")", ";", "$", "this", "->", "createIndex", "(", "$", "index", ",", "$", "table", ")", ";", "}" ]
Drops and creates a new index on a table. @param Table|string $table The name of the table on which the index is to be created. @return void
[ "Drops", "and", "creates", "a", "new", "index", "on", "a", "table", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php#L517-L521
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
AbstractSchemaManager.dropAndCreateForeignKey
public function dropAndCreateForeignKey(ForeignKeyConstraint $foreignKey, $table) { $this->tryMethod('dropForeignKey', $foreignKey, $table); $this->createForeignKey($foreignKey, $table); }
php
public function dropAndCreateForeignKey(ForeignKeyConstraint $foreignKey, $table) { $this->tryMethod('dropForeignKey', $foreignKey, $table); $this->createForeignKey($foreignKey, $table); }
[ "public", "function", "dropAndCreateForeignKey", "(", "ForeignKeyConstraint", "$", "foreignKey", ",", "$", "table", ")", "{", "$", "this", "->", "tryMethod", "(", "'dropForeignKey'", ",", "$", "foreignKey", ",", "$", "table", ")", ";", "$", "this", "->", "createForeignKey", "(", "$", "foreignKey", ",", "$", "table", ")", ";", "}" ]
Drops and creates a new foreign key. @param ForeignKeyConstraint $foreignKey An associative array that defines properties of the foreign key to be created. @param Table|string $table The name of the table on which the foreign key is to be created. @return void
[ "Drops", "and", "creates", "a", "new", "foreign", "key", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php#L531-L535
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
AbstractSchemaManager.dropAndCreateSequence
public function dropAndCreateSequence(Sequence $sequence) { $this->tryMethod('dropSequence', $sequence->getQuotedName($this->_platform)); $this->createSequence($sequence); }
php
public function dropAndCreateSequence(Sequence $sequence) { $this->tryMethod('dropSequence', $sequence->getQuotedName($this->_platform)); $this->createSequence($sequence); }
[ "public", "function", "dropAndCreateSequence", "(", "Sequence", "$", "sequence", ")", "{", "$", "this", "->", "tryMethod", "(", "'dropSequence'", ",", "$", "sequence", "->", "getQuotedName", "(", "$", "this", "->", "_platform", ")", ")", ";", "$", "this", "->", "createSequence", "(", "$", "sequence", ")", ";", "}" ]
Drops and create a new sequence. @return void @throws ConnectionException If something fails at database level.
[ "Drops", "and", "create", "a", "new", "sequence", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php#L544-L548
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
AbstractSchemaManager.dropAndCreateTable
public function dropAndCreateTable(Table $table) { $this->tryMethod('dropTable', $table->getQuotedName($this->_platform)); $this->createTable($table); }
php
public function dropAndCreateTable(Table $table) { $this->tryMethod('dropTable', $table->getQuotedName($this->_platform)); $this->createTable($table); }
[ "public", "function", "dropAndCreateTable", "(", "Table", "$", "table", ")", "{", "$", "this", "->", "tryMethod", "(", "'dropTable'", ",", "$", "table", "->", "getQuotedName", "(", "$", "this", "->", "_platform", ")", ")", ";", "$", "this", "->", "createTable", "(", "$", "table", ")", ";", "}" ]
Drops and creates a new table. @return void
[ "Drops", "and", "creates", "a", "new", "table", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php#L555-L559
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
AbstractSchemaManager.dropAndCreateView
public function dropAndCreateView(View $view) { $this->tryMethod('dropView', $view->getQuotedName($this->_platform)); $this->createView($view); }
php
public function dropAndCreateView(View $view) { $this->tryMethod('dropView', $view->getQuotedName($this->_platform)); $this->createView($view); }
[ "public", "function", "dropAndCreateView", "(", "View", "$", "view", ")", "{", "$", "this", "->", "tryMethod", "(", "'dropView'", ",", "$", "view", "->", "getQuotedName", "(", "$", "this", "->", "_platform", ")", ")", ";", "$", "this", "->", "createView", "(", "$", "view", ")", ";", "}" ]
Drops and creates a new view. @return void
[ "Drops", "and", "creates", "a", "new", "view", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php#L579-L583
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
AbstractSchemaManager.alterTable
public function alterTable(TableDiff $tableDiff) { $queries = $this->_platform->getAlterTableSQL($tableDiff); if (! is_array($queries) || ! count($queries)) { return; } foreach ($queries as $ddlQuery) { $this->_execSql($ddlQuery); } }
php
public function alterTable(TableDiff $tableDiff) { $queries = $this->_platform->getAlterTableSQL($tableDiff); if (! is_array($queries) || ! count($queries)) { return; } foreach ($queries as $ddlQuery) { $this->_execSql($ddlQuery); } }
[ "public", "function", "alterTable", "(", "TableDiff", "$", "tableDiff", ")", "{", "$", "queries", "=", "$", "this", "->", "_platform", "->", "getAlterTableSQL", "(", "$", "tableDiff", ")", ";", "if", "(", "!", "is_array", "(", "$", "queries", ")", "||", "!", "count", "(", "$", "queries", ")", ")", "{", "return", ";", "}", "foreach", "(", "$", "queries", "as", "$", "ddlQuery", ")", "{", "$", "this", "->", "_execSql", "(", "$", "ddlQuery", ")", ";", "}", "}" ]
Alters an existing tables schema. @return void
[ "Alters", "an", "existing", "tables", "schema", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php#L592-L602
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
AbstractSchemaManager.renameTable
public function renameTable($name, $newName) { $tableDiff = new TableDiff($name); $tableDiff->newName = $newName; $this->alterTable($tableDiff); }
php
public function renameTable($name, $newName) { $tableDiff = new TableDiff($name); $tableDiff->newName = $newName; $this->alterTable($tableDiff); }
[ "public", "function", "renameTable", "(", "$", "name", ",", "$", "newName", ")", "{", "$", "tableDiff", "=", "new", "TableDiff", "(", "$", "name", ")", ";", "$", "tableDiff", "->", "newName", "=", "$", "newName", ";", "$", "this", "->", "alterTable", "(", "$", "tableDiff", ")", ";", "}" ]
Renames a given table to another name. @param string $name The current name of the table. @param string $newName The new name of the table. @return void
[ "Renames", "a", "given", "table", "to", "another", "name", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php#L612-L617
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
AbstractSchemaManager._getPortableTableColumnList
protected function _getPortableTableColumnList($table, $database, $tableColumns) { $eventManager = $this->_platform->getEventManager(); $list = []; foreach ($tableColumns as $tableColumn) { $column = null; $defaultPrevented = false; if ($eventManager !== null && $eventManager->hasListeners(Events::onSchemaColumnDefinition)) { $eventArgs = new SchemaColumnDefinitionEventArgs($tableColumn, $table, $database, $this->_conn); $eventManager->dispatchEvent(Events::onSchemaColumnDefinition, $eventArgs); $defaultPrevented = $eventArgs->isDefaultPrevented(); $column = $eventArgs->getColumn(); } if (! $defaultPrevented) { $column = $this->_getPortableTableColumnDefinition($tableColumn); } if (! $column) { continue; } $name = strtolower($column->getQuotedName($this->_platform)); $list[$name] = $column; } return $list; }
php
protected function _getPortableTableColumnList($table, $database, $tableColumns) { $eventManager = $this->_platform->getEventManager(); $list = []; foreach ($tableColumns as $tableColumn) { $column = null; $defaultPrevented = false; if ($eventManager !== null && $eventManager->hasListeners(Events::onSchemaColumnDefinition)) { $eventArgs = new SchemaColumnDefinitionEventArgs($tableColumn, $table, $database, $this->_conn); $eventManager->dispatchEvent(Events::onSchemaColumnDefinition, $eventArgs); $defaultPrevented = $eventArgs->isDefaultPrevented(); $column = $eventArgs->getColumn(); } if (! $defaultPrevented) { $column = $this->_getPortableTableColumnDefinition($tableColumn); } if (! $column) { continue; } $name = strtolower($column->getQuotedName($this->_platform)); $list[$name] = $column; } return $list; }
[ "protected", "function", "_getPortableTableColumnList", "(", "$", "table", ",", "$", "database", ",", "$", "tableColumns", ")", "{", "$", "eventManager", "=", "$", "this", "->", "_platform", "->", "getEventManager", "(", ")", ";", "$", "list", "=", "[", "]", ";", "foreach", "(", "$", "tableColumns", "as", "$", "tableColumn", ")", "{", "$", "column", "=", "null", ";", "$", "defaultPrevented", "=", "false", ";", "if", "(", "$", "eventManager", "!==", "null", "&&", "$", "eventManager", "->", "hasListeners", "(", "Events", "::", "onSchemaColumnDefinition", ")", ")", "{", "$", "eventArgs", "=", "new", "SchemaColumnDefinitionEventArgs", "(", "$", "tableColumn", ",", "$", "table", ",", "$", "database", ",", "$", "this", "->", "_conn", ")", ";", "$", "eventManager", "->", "dispatchEvent", "(", "Events", "::", "onSchemaColumnDefinition", ",", "$", "eventArgs", ")", ";", "$", "defaultPrevented", "=", "$", "eventArgs", "->", "isDefaultPrevented", "(", ")", ";", "$", "column", "=", "$", "eventArgs", "->", "getColumn", "(", ")", ";", "}", "if", "(", "!", "$", "defaultPrevented", ")", "{", "$", "column", "=", "$", "this", "->", "_getPortableTableColumnDefinition", "(", "$", "tableColumn", ")", ";", "}", "if", "(", "!", "$", "column", ")", "{", "continue", ";", "}", "$", "name", "=", "strtolower", "(", "$", "column", "->", "getQuotedName", "(", "$", "this", "->", "_platform", ")", ")", ";", "$", "list", "[", "$", "name", "]", "=", "$", "column", ";", "}", "return", "$", "list", ";", "}" ]
Independent of the database the keys of the column list result are lowercased. The name of the created column instance however is kept in its case. @param string $table The name of the table. @param string $database @param mixed[][] $tableColumns @return Column[]
[ "Independent", "of", "the", "database", "the", "keys", "of", "the", "column", "list", "result", "are", "lowercased", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php#L786-L816
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
AbstractSchemaManager._getPortableTableIndexesList
protected function _getPortableTableIndexesList($tableIndexRows, $tableName = null) { $result = []; foreach ($tableIndexRows as $tableIndex) { $indexName = $keyName = $tableIndex['key_name']; if ($tableIndex['primary']) { $keyName = 'primary'; } $keyName = strtolower($keyName); if (! isset($result[$keyName])) { $options = [ 'lengths' => [], ]; if (isset($tableIndex['where'])) { $options['where'] = $tableIndex['where']; } $result[$keyName] = [ 'name' => $indexName, 'columns' => [], 'unique' => ! $tableIndex['non_unique'], 'primary' => $tableIndex['primary'], 'flags' => $tableIndex['flags'] ?? [], 'options' => $options, ]; } $result[$keyName]['columns'][] = $tableIndex['column_name']; $result[$keyName]['options']['lengths'][] = $tableIndex['length'] ?? null; } $eventManager = $this->_platform->getEventManager(); $indexes = []; foreach ($result as $indexKey => $data) { $index = null; $defaultPrevented = false; if ($eventManager !== null && $eventManager->hasListeners(Events::onSchemaIndexDefinition)) { $eventArgs = new SchemaIndexDefinitionEventArgs($data, $tableName, $this->_conn); $eventManager->dispatchEvent(Events::onSchemaIndexDefinition, $eventArgs); $defaultPrevented = $eventArgs->isDefaultPrevented(); $index = $eventArgs->getIndex(); } if (! $defaultPrevented) { $index = new Index($data['name'], $data['columns'], $data['unique'], $data['primary'], $data['flags'], $data['options']); } if (! $index) { continue; } $indexes[$indexKey] = $index; } return $indexes; }
php
protected function _getPortableTableIndexesList($tableIndexRows, $tableName = null) { $result = []; foreach ($tableIndexRows as $tableIndex) { $indexName = $keyName = $tableIndex['key_name']; if ($tableIndex['primary']) { $keyName = 'primary'; } $keyName = strtolower($keyName); if (! isset($result[$keyName])) { $options = [ 'lengths' => [], ]; if (isset($tableIndex['where'])) { $options['where'] = $tableIndex['where']; } $result[$keyName] = [ 'name' => $indexName, 'columns' => [], 'unique' => ! $tableIndex['non_unique'], 'primary' => $tableIndex['primary'], 'flags' => $tableIndex['flags'] ?? [], 'options' => $options, ]; } $result[$keyName]['columns'][] = $tableIndex['column_name']; $result[$keyName]['options']['lengths'][] = $tableIndex['length'] ?? null; } $eventManager = $this->_platform->getEventManager(); $indexes = []; foreach ($result as $indexKey => $data) { $index = null; $defaultPrevented = false; if ($eventManager !== null && $eventManager->hasListeners(Events::onSchemaIndexDefinition)) { $eventArgs = new SchemaIndexDefinitionEventArgs($data, $tableName, $this->_conn); $eventManager->dispatchEvent(Events::onSchemaIndexDefinition, $eventArgs); $defaultPrevented = $eventArgs->isDefaultPrevented(); $index = $eventArgs->getIndex(); } if (! $defaultPrevented) { $index = new Index($data['name'], $data['columns'], $data['unique'], $data['primary'], $data['flags'], $data['options']); } if (! $index) { continue; } $indexes[$indexKey] = $index; } return $indexes; }
[ "protected", "function", "_getPortableTableIndexesList", "(", "$", "tableIndexRows", ",", "$", "tableName", "=", "null", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "tableIndexRows", "as", "$", "tableIndex", ")", "{", "$", "indexName", "=", "$", "keyName", "=", "$", "tableIndex", "[", "'key_name'", "]", ";", "if", "(", "$", "tableIndex", "[", "'primary'", "]", ")", "{", "$", "keyName", "=", "'primary'", ";", "}", "$", "keyName", "=", "strtolower", "(", "$", "keyName", ")", ";", "if", "(", "!", "isset", "(", "$", "result", "[", "$", "keyName", "]", ")", ")", "{", "$", "options", "=", "[", "'lengths'", "=>", "[", "]", ",", "]", ";", "if", "(", "isset", "(", "$", "tableIndex", "[", "'where'", "]", ")", ")", "{", "$", "options", "[", "'where'", "]", "=", "$", "tableIndex", "[", "'where'", "]", ";", "}", "$", "result", "[", "$", "keyName", "]", "=", "[", "'name'", "=>", "$", "indexName", ",", "'columns'", "=>", "[", "]", ",", "'unique'", "=>", "!", "$", "tableIndex", "[", "'non_unique'", "]", ",", "'primary'", "=>", "$", "tableIndex", "[", "'primary'", "]", ",", "'flags'", "=>", "$", "tableIndex", "[", "'flags'", "]", "??", "[", "]", ",", "'options'", "=>", "$", "options", ",", "]", ";", "}", "$", "result", "[", "$", "keyName", "]", "[", "'columns'", "]", "[", "]", "=", "$", "tableIndex", "[", "'column_name'", "]", ";", "$", "result", "[", "$", "keyName", "]", "[", "'options'", "]", "[", "'lengths'", "]", "[", "]", "=", "$", "tableIndex", "[", "'length'", "]", "??", "null", ";", "}", "$", "eventManager", "=", "$", "this", "->", "_platform", "->", "getEventManager", "(", ")", ";", "$", "indexes", "=", "[", "]", ";", "foreach", "(", "$", "result", "as", "$", "indexKey", "=>", "$", "data", ")", "{", "$", "index", "=", "null", ";", "$", "defaultPrevented", "=", "false", ";", "if", "(", "$", "eventManager", "!==", "null", "&&", "$", "eventManager", "->", "hasListeners", "(", "Events", "::", "onSchemaIndexDefinition", ")", ")", "{", "$", "eventArgs", "=", "new", "SchemaIndexDefinitionEventArgs", "(", "$", "data", ",", "$", "tableName", ",", "$", "this", "->", "_conn", ")", ";", "$", "eventManager", "->", "dispatchEvent", "(", "Events", "::", "onSchemaIndexDefinition", ",", "$", "eventArgs", ")", ";", "$", "defaultPrevented", "=", "$", "eventArgs", "->", "isDefaultPrevented", "(", ")", ";", "$", "index", "=", "$", "eventArgs", "->", "getIndex", "(", ")", ";", "}", "if", "(", "!", "$", "defaultPrevented", ")", "{", "$", "index", "=", "new", "Index", "(", "$", "data", "[", "'name'", "]", ",", "$", "data", "[", "'columns'", "]", ",", "$", "data", "[", "'unique'", "]", ",", "$", "data", "[", "'primary'", "]", ",", "$", "data", "[", "'flags'", "]", ",", "$", "data", "[", "'options'", "]", ")", ";", "}", "if", "(", "!", "$", "index", ")", "{", "continue", ";", "}", "$", "indexes", "[", "$", "indexKey", "]", "=", "$", "index", ";", "}", "return", "$", "indexes", ";", "}" ]
Aggregates and groups the index results according to the required data result. @param mixed[][] $tableIndexRows @param string|null $tableName @return Index[]
[ "Aggregates", "and", "groups", "the", "index", "results", "according", "to", "the", "required", "data", "result", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php#L835-L895
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
AbstractSchemaManager.createSchema
public function createSchema() { $namespaces = []; if ($this->_platform->supportsSchemas()) { $namespaces = $this->listNamespaceNames(); } $sequences = []; if ($this->_platform->supportsSequences()) { $sequences = $this->listSequences(); } $tables = $this->listTables(); return new Schema($tables, $sequences, $this->createSchemaConfig(), $namespaces); }
php
public function createSchema() { $namespaces = []; if ($this->_platform->supportsSchemas()) { $namespaces = $this->listNamespaceNames(); } $sequences = []; if ($this->_platform->supportsSequences()) { $sequences = $this->listSequences(); } $tables = $this->listTables(); return new Schema($tables, $sequences, $this->createSchemaConfig(), $namespaces); }
[ "public", "function", "createSchema", "(", ")", "{", "$", "namespaces", "=", "[", "]", ";", "if", "(", "$", "this", "->", "_platform", "->", "supportsSchemas", "(", ")", ")", "{", "$", "namespaces", "=", "$", "this", "->", "listNamespaceNames", "(", ")", ";", "}", "$", "sequences", "=", "[", "]", ";", "if", "(", "$", "this", "->", "_platform", "->", "supportsSequences", "(", ")", ")", "{", "$", "sequences", "=", "$", "this", "->", "listSequences", "(", ")", ";", "}", "$", "tables", "=", "$", "this", "->", "listTables", "(", ")", ";", "return", "new", "Schema", "(", "$", "tables", ",", "$", "sequences", ",", "$", "this", "->", "createSchemaConfig", "(", ")", ",", "$", "namespaces", ")", ";", "}" ]
Creates a schema instance for the current database. @return Schema
[ "Creates", "a", "schema", "instance", "for", "the", "current", "database", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php#L1034-L1051
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
AbstractSchemaManager.createSchemaConfig
public function createSchemaConfig() { $schemaConfig = new SchemaConfig(); $schemaConfig->setMaxIdentifierLength($this->_platform->getMaxIdentifierLength()); $searchPaths = $this->getSchemaSearchPaths(); if (isset($searchPaths[0])) { $schemaConfig->setName($searchPaths[0]); } $params = $this->_conn->getParams(); if (! isset($params['defaultTableOptions'])) { $params['defaultTableOptions'] = []; } if (! isset($params['defaultTableOptions']['charset']) && isset($params['charset'])) { $params['defaultTableOptions']['charset'] = $params['charset']; } $schemaConfig->setDefaultTableOptions($params['defaultTableOptions']); return $schemaConfig; }
php
public function createSchemaConfig() { $schemaConfig = new SchemaConfig(); $schemaConfig->setMaxIdentifierLength($this->_platform->getMaxIdentifierLength()); $searchPaths = $this->getSchemaSearchPaths(); if (isset($searchPaths[0])) { $schemaConfig->setName($searchPaths[0]); } $params = $this->_conn->getParams(); if (! isset($params['defaultTableOptions'])) { $params['defaultTableOptions'] = []; } if (! isset($params['defaultTableOptions']['charset']) && isset($params['charset'])) { $params['defaultTableOptions']['charset'] = $params['charset']; } $schemaConfig->setDefaultTableOptions($params['defaultTableOptions']); return $schemaConfig; }
[ "public", "function", "createSchemaConfig", "(", ")", "{", "$", "schemaConfig", "=", "new", "SchemaConfig", "(", ")", ";", "$", "schemaConfig", "->", "setMaxIdentifierLength", "(", "$", "this", "->", "_platform", "->", "getMaxIdentifierLength", "(", ")", ")", ";", "$", "searchPaths", "=", "$", "this", "->", "getSchemaSearchPaths", "(", ")", ";", "if", "(", "isset", "(", "$", "searchPaths", "[", "0", "]", ")", ")", "{", "$", "schemaConfig", "->", "setName", "(", "$", "searchPaths", "[", "0", "]", ")", ";", "}", "$", "params", "=", "$", "this", "->", "_conn", "->", "getParams", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "params", "[", "'defaultTableOptions'", "]", ")", ")", "{", "$", "params", "[", "'defaultTableOptions'", "]", "=", "[", "]", ";", "}", "if", "(", "!", "isset", "(", "$", "params", "[", "'defaultTableOptions'", "]", "[", "'charset'", "]", ")", "&&", "isset", "(", "$", "params", "[", "'charset'", "]", ")", ")", "{", "$", "params", "[", "'defaultTableOptions'", "]", "[", "'charset'", "]", "=", "$", "params", "[", "'charset'", "]", ";", "}", "$", "schemaConfig", "->", "setDefaultTableOptions", "(", "$", "params", "[", "'defaultTableOptions'", "]", ")", ";", "return", "$", "schemaConfig", ";", "}" ]
Creates the configuration for this schema. @return SchemaConfig
[ "Creates", "the", "configuration", "for", "this", "schema", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php#L1058-L1078
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
AbstractSchemaManager.extractDoctrineTypeFromComment
public function extractDoctrineTypeFromComment($comment, $currentType) { if ($comment !== null && preg_match('(\(DC2Type:(((?!\)).)+)\))', $comment, $match)) { return $match[1]; } return $currentType; }
php
public function extractDoctrineTypeFromComment($comment, $currentType) { if ($comment !== null && preg_match('(\(DC2Type:(((?!\)).)+)\))', $comment, $match)) { return $match[1]; } return $currentType; }
[ "public", "function", "extractDoctrineTypeFromComment", "(", "$", "comment", ",", "$", "currentType", ")", "{", "if", "(", "$", "comment", "!==", "null", "&&", "preg_match", "(", "'(\\(DC2Type:(((?!\\)).)+)\\))'", ",", "$", "comment", ",", "$", "match", ")", ")", "{", "return", "$", "match", "[", "1", "]", ";", "}", "return", "$", "currentType", ";", "}" ]
Given a table comment this method tries to extract a typehint for Doctrine Type, or returns the type given as default. @param string|null $comment @param string $currentType @return string
[ "Given", "a", "table", "comment", "this", "method", "tries", "to", "extract", "a", "typehint", "for", "Doctrine", "Type", "or", "returns", "the", "type", "given", "as", "default", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php#L1106-L1113
train
doctrine/dbal
lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php
Driver.buildDsn
private function buildDsn($host, $port, $server, $dbname, $username = null, $password = null, array $driverOptions = []) { $host = $host ?: 'localhost'; $port = $port ?: 2638; if (! empty($server)) { $server = ';ServerName=' . $server; } return 'HOST=' . $host . ':' . $port . $server . ';DBN=' . $dbname . ';UID=' . $username . ';PWD=' . $password . ';' . implode( ';', array_map(static function ($key, $value) { return $key . '=' . $value; }, array_keys($driverOptions), $driverOptions) ); }
php
private function buildDsn($host, $port, $server, $dbname, $username = null, $password = null, array $driverOptions = []) { $host = $host ?: 'localhost'; $port = $port ?: 2638; if (! empty($server)) { $server = ';ServerName=' . $server; } return 'HOST=' . $host . ':' . $port . $server . ';DBN=' . $dbname . ';UID=' . $username . ';PWD=' . $password . ';' . implode( ';', array_map(static function ($key, $value) { return $key . '=' . $value; }, array_keys($driverOptions), $driverOptions) ); }
[ "private", "function", "buildDsn", "(", "$", "host", ",", "$", "port", ",", "$", "server", ",", "$", "dbname", ",", "$", "username", "=", "null", ",", "$", "password", "=", "null", ",", "array", "$", "driverOptions", "=", "[", "]", ")", "{", "$", "host", "=", "$", "host", "?", ":", "'localhost'", ";", "$", "port", "=", "$", "port", "?", ":", "2638", ";", "if", "(", "!", "empty", "(", "$", "server", ")", ")", "{", "$", "server", "=", "';ServerName='", ".", "$", "server", ";", "}", "return", "'HOST='", ".", "$", "host", ".", "':'", ".", "$", "port", ".", "$", "server", ".", "';DBN='", ".", "$", "dbname", ".", "';UID='", ".", "$", "username", ".", "';PWD='", ".", "$", "password", ".", "';'", ".", "implode", "(", "';'", ",", "array_map", "(", "static", "function", "(", "$", "key", ",", "$", "value", ")", "{", "return", "$", "key", ".", "'='", ".", "$", "value", ";", "}", ",", "array_keys", "(", "$", "driverOptions", ")", ",", "$", "driverOptions", ")", ")", ";", "}" ]
Build the connection string for given connection parameters and driver options. @param string $host Host address to connect to. @param int $port Port to use for the connection (default to SQL Anywhere standard port 2638). @param string $server Database server name on the host to connect to. SQL Anywhere allows multiple database server instances on the same host, therefore specifying the server instance name to use is mandatory. @param string $dbname Name of the database on the server instance to connect to. @param string $username User name to use for connection authentication. @param string $password Password to use for connection authentication. @param mixed[] $driverOptions Additional parameters to use for the connection. @return string
[ "Build", "the", "connection", "string", "for", "given", "connection", "parameters", "and", "driver", "options", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php#L64-L84
train
doctrine/dbal
lib/Doctrine/DBAL/Types/Type.php
Type.getTypesMap
public static function getTypesMap() { return array_map( static function (Type $type) : string { return get_class($type); }, self::getTypeRegistry()->getMap() ); }
php
public static function getTypesMap() { return array_map( static function (Type $type) : string { return get_class($type); }, self::getTypeRegistry()->getMap() ); }
[ "public", "static", "function", "getTypesMap", "(", ")", "{", "return", "array_map", "(", "static", "function", "(", "Type", "$", "type", ")", ":", "string", "{", "return", "get_class", "(", "$", "type", ")", ";", "}", ",", "self", "::", "getTypeRegistry", "(", ")", "->", "getMap", "(", ")", ")", ";", "}" ]
Gets the types array map which holds all registered types and the corresponding type class @return string[]
[ "Gets", "the", "types", "array", "map", "which", "holds", "all", "registered", "types", "and", "the", "corresponding", "type", "class" ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Types/Type.php#L295-L303
train
doctrine/dbal
lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php
Driver._constructPdoDsn
private function _constructPdoDsn(array $params, array $connectionOptions) { $dsn = 'sqlsrv:server='; if (isset($params['host'])) { $dsn .= $params['host']; } if (isset($params['port']) && ! empty($params['port'])) { $dsn .= ',' . $params['port']; } if (isset($params['dbname'])) { $connectionOptions['Database'] = $params['dbname']; } if (isset($params['MultipleActiveResultSets'])) { $connectionOptions['MultipleActiveResultSets'] = $params['MultipleActiveResultSets'] ? 'true' : 'false'; } return $dsn . $this->getConnectionOptionsDsn($connectionOptions); }
php
private function _constructPdoDsn(array $params, array $connectionOptions) { $dsn = 'sqlsrv:server='; if (isset($params['host'])) { $dsn .= $params['host']; } if (isset($params['port']) && ! empty($params['port'])) { $dsn .= ',' . $params['port']; } if (isset($params['dbname'])) { $connectionOptions['Database'] = $params['dbname']; } if (isset($params['MultipleActiveResultSets'])) { $connectionOptions['MultipleActiveResultSets'] = $params['MultipleActiveResultSets'] ? 'true' : 'false'; } return $dsn . $this->getConnectionOptionsDsn($connectionOptions); }
[ "private", "function", "_constructPdoDsn", "(", "array", "$", "params", ",", "array", "$", "connectionOptions", ")", "{", "$", "dsn", "=", "'sqlsrv:server='", ";", "if", "(", "isset", "(", "$", "params", "[", "'host'", "]", ")", ")", "{", "$", "dsn", ".=", "$", "params", "[", "'host'", "]", ";", "}", "if", "(", "isset", "(", "$", "params", "[", "'port'", "]", ")", "&&", "!", "empty", "(", "$", "params", "[", "'port'", "]", ")", ")", "{", "$", "dsn", ".=", "','", ".", "$", "params", "[", "'port'", "]", ";", "}", "if", "(", "isset", "(", "$", "params", "[", "'dbname'", "]", ")", ")", "{", "$", "connectionOptions", "[", "'Database'", "]", "=", "$", "params", "[", "'dbname'", "]", ";", "}", "if", "(", "isset", "(", "$", "params", "[", "'MultipleActiveResultSets'", "]", ")", ")", "{", "$", "connectionOptions", "[", "'MultipleActiveResultSets'", "]", "=", "$", "params", "[", "'MultipleActiveResultSets'", "]", "?", "'true'", ":", "'false'", ";", "}", "return", "$", "dsn", ".", "$", "this", "->", "getConnectionOptionsDsn", "(", "$", "connectionOptions", ")", ";", "}" ]
Constructs the Sqlsrv PDO DSN. @param mixed[] $params @param string[] $connectionOptions @return string The DSN.
[ "Constructs", "the", "Sqlsrv", "PDO", "DSN", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php#L45-L66
train
doctrine/dbal
lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php
Driver.getConnectionOptionsDsn
private function getConnectionOptionsDsn(array $connectionOptions) : string { $connectionOptionsDsn = ''; foreach ($connectionOptions as $paramName => $paramValue) { $connectionOptionsDsn .= sprintf(';%s=%s', $paramName, $paramValue); } return $connectionOptionsDsn; }
php
private function getConnectionOptionsDsn(array $connectionOptions) : string { $connectionOptionsDsn = ''; foreach ($connectionOptions as $paramName => $paramValue) { $connectionOptionsDsn .= sprintf(';%s=%s', $paramName, $paramValue); } return $connectionOptionsDsn; }
[ "private", "function", "getConnectionOptionsDsn", "(", "array", "$", "connectionOptions", ")", ":", "string", "{", "$", "connectionOptionsDsn", "=", "''", ";", "foreach", "(", "$", "connectionOptions", "as", "$", "paramName", "=>", "$", "paramValue", ")", "{", "$", "connectionOptionsDsn", ".=", "sprintf", "(", "';%s=%s'", ",", "$", "paramName", ",", "$", "paramValue", ")", ";", "}", "return", "$", "connectionOptionsDsn", ";", "}" ]
Converts a connection options array to the DSN @param string[] $connectionOptions
[ "Converts", "a", "connection", "options", "array", "to", "the", "DSN" ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php#L73-L82
train
doctrine/dbal
lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php
Driver._constructPdoDsn
private function _constructPdoDsn(array $params) { $dsn = 'pgsql:'; if (isset($params['host']) && $params['host'] !== '') { $dsn .= 'host=' . $params['host'] . ';'; } if (isset($params['port']) && $params['port'] !== '') { $dsn .= 'port=' . $params['port'] . ';'; } if (isset($params['dbname'])) { $dsn .= 'dbname=' . $params['dbname'] . ';'; } elseif (isset($params['default_dbname'])) { $dsn .= 'dbname=' . $params['default_dbname'] . ';'; } else { // Used for temporary connections to allow operations like dropping the database currently connected to. // Connecting without an explicit database does not work, therefore "postgres" database is used // as it is mostly present in every server setup. $dsn .= 'dbname=postgres;'; } if (isset($params['sslmode'])) { $dsn .= 'sslmode=' . $params['sslmode'] . ';'; } if (isset($params['sslrootcert'])) { $dsn .= 'sslrootcert=' . $params['sslrootcert'] . ';'; } if (isset($params['sslcert'])) { $dsn .= 'sslcert=' . $params['sslcert'] . ';'; } if (isset($params['sslkey'])) { $dsn .= 'sslkey=' . $params['sslkey'] . ';'; } if (isset($params['sslcrl'])) { $dsn .= 'sslcrl=' . $params['sslcrl'] . ';'; } if (isset($params['application_name'])) { $dsn .= 'application_name=' . $params['application_name'] . ';'; } return $dsn; }
php
private function _constructPdoDsn(array $params) { $dsn = 'pgsql:'; if (isset($params['host']) && $params['host'] !== '') { $dsn .= 'host=' . $params['host'] . ';'; } if (isset($params['port']) && $params['port'] !== '') { $dsn .= 'port=' . $params['port'] . ';'; } if (isset($params['dbname'])) { $dsn .= 'dbname=' . $params['dbname'] . ';'; } elseif (isset($params['default_dbname'])) { $dsn .= 'dbname=' . $params['default_dbname'] . ';'; } else { // Used for temporary connections to allow operations like dropping the database currently connected to. // Connecting without an explicit database does not work, therefore "postgres" database is used // as it is mostly present in every server setup. $dsn .= 'dbname=postgres;'; } if (isset($params['sslmode'])) { $dsn .= 'sslmode=' . $params['sslmode'] . ';'; } if (isset($params['sslrootcert'])) { $dsn .= 'sslrootcert=' . $params['sslrootcert'] . ';'; } if (isset($params['sslcert'])) { $dsn .= 'sslcert=' . $params['sslcert'] . ';'; } if (isset($params['sslkey'])) { $dsn .= 'sslkey=' . $params['sslkey'] . ';'; } if (isset($params['sslcrl'])) { $dsn .= 'sslcrl=' . $params['sslcrl'] . ';'; } if (isset($params['application_name'])) { $dsn .= 'application_name=' . $params['application_name'] . ';'; } return $dsn; }
[ "private", "function", "_constructPdoDsn", "(", "array", "$", "params", ")", "{", "$", "dsn", "=", "'pgsql:'", ";", "if", "(", "isset", "(", "$", "params", "[", "'host'", "]", ")", "&&", "$", "params", "[", "'host'", "]", "!==", "''", ")", "{", "$", "dsn", ".=", "'host='", ".", "$", "params", "[", "'host'", "]", ".", "';'", ";", "}", "if", "(", "isset", "(", "$", "params", "[", "'port'", "]", ")", "&&", "$", "params", "[", "'port'", "]", "!==", "''", ")", "{", "$", "dsn", ".=", "'port='", ".", "$", "params", "[", "'port'", "]", ".", "';'", ";", "}", "if", "(", "isset", "(", "$", "params", "[", "'dbname'", "]", ")", ")", "{", "$", "dsn", ".=", "'dbname='", ".", "$", "params", "[", "'dbname'", "]", ".", "';'", ";", "}", "elseif", "(", "isset", "(", "$", "params", "[", "'default_dbname'", "]", ")", ")", "{", "$", "dsn", ".=", "'dbname='", ".", "$", "params", "[", "'default_dbname'", "]", ".", "';'", ";", "}", "else", "{", "// Used for temporary connections to allow operations like dropping the database currently connected to.", "// Connecting without an explicit database does not work, therefore \"postgres\" database is used", "// as it is mostly present in every server setup.", "$", "dsn", ".=", "'dbname=postgres;'", ";", "}", "if", "(", "isset", "(", "$", "params", "[", "'sslmode'", "]", ")", ")", "{", "$", "dsn", ".=", "'sslmode='", ".", "$", "params", "[", "'sslmode'", "]", ".", "';'", ";", "}", "if", "(", "isset", "(", "$", "params", "[", "'sslrootcert'", "]", ")", ")", "{", "$", "dsn", ".=", "'sslrootcert='", ".", "$", "params", "[", "'sslrootcert'", "]", ".", "';'", ";", "}", "if", "(", "isset", "(", "$", "params", "[", "'sslcert'", "]", ")", ")", "{", "$", "dsn", ".=", "'sslcert='", ".", "$", "params", "[", "'sslcert'", "]", ".", "';'", ";", "}", "if", "(", "isset", "(", "$", "params", "[", "'sslkey'", "]", ")", ")", "{", "$", "dsn", ".=", "'sslkey='", ".", "$", "params", "[", "'sslkey'", "]", ".", "';'", ";", "}", "if", "(", "isset", "(", "$", "params", "[", "'sslcrl'", "]", ")", ")", "{", "$", "dsn", ".=", "'sslcrl='", ".", "$", "params", "[", "'sslcrl'", "]", ".", "';'", ";", "}", "if", "(", "isset", "(", "$", "params", "[", "'application_name'", "]", ")", ")", "{", "$", "dsn", ".=", "'application_name='", ".", "$", "params", "[", "'application_name'", "]", ".", "';'", ";", "}", "return", "$", "dsn", ";", "}" ]
Constructs the Postgres PDO DSN. @param mixed[] $params @return string The DSN.
[ "Constructs", "the", "Postgres", "PDO", "DSN", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php#L59-L107
train
doctrine/dbal
lib/Doctrine/DBAL/Cache/QueryCacheProfile.php
QueryCacheProfile.generateCacheKeys
public function generateCacheKeys($query, $params, $types, array $connectionParams = []) { $realCacheKey = 'query=' . $query . '&params=' . serialize($params) . '&types=' . serialize($types) . '&connectionParams=' . hash('sha256', serialize($connectionParams)); // should the key be automatically generated using the inputs or is the cache key set? if ($this->cacheKey === null) { $cacheKey = sha1($realCacheKey); } else { $cacheKey = $this->cacheKey; } return [$cacheKey, $realCacheKey]; }
php
public function generateCacheKeys($query, $params, $types, array $connectionParams = []) { $realCacheKey = 'query=' . $query . '&params=' . serialize($params) . '&types=' . serialize($types) . '&connectionParams=' . hash('sha256', serialize($connectionParams)); // should the key be automatically generated using the inputs or is the cache key set? if ($this->cacheKey === null) { $cacheKey = sha1($realCacheKey); } else { $cacheKey = $this->cacheKey; } return [$cacheKey, $realCacheKey]; }
[ "public", "function", "generateCacheKeys", "(", "$", "query", ",", "$", "params", ",", "$", "types", ",", "array", "$", "connectionParams", "=", "[", "]", ")", "{", "$", "realCacheKey", "=", "'query='", ".", "$", "query", ".", "'&params='", ".", "serialize", "(", "$", "params", ")", ".", "'&types='", ".", "serialize", "(", "$", "types", ")", ".", "'&connectionParams='", ".", "hash", "(", "'sha256'", ",", "serialize", "(", "$", "connectionParams", ")", ")", ";", "// should the key be automatically generated using the inputs or is the cache key set?", "if", "(", "$", "this", "->", "cacheKey", "===", "null", ")", "{", "$", "cacheKey", "=", "sha1", "(", "$", "realCacheKey", ")", ";", "}", "else", "{", "$", "cacheKey", "=", "$", "this", "->", "cacheKey", ";", "}", "return", "[", "$", "cacheKey", ",", "$", "realCacheKey", "]", ";", "}" ]
Generates the real cache key from query, params, types and connection parameters. @param string $query @param mixed[] $params @param int[]|string[] $types @param mixed[] $connectionParams @return string[]
[ "Generates", "the", "real", "cache", "key", "from", "query", "params", "types", "and", "connection", "parameters", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Cache/QueryCacheProfile.php#L77-L92
train
doctrine/dbal
lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php
MysqliStatement.bindTypedParameters
private function bindTypedParameters() { $streams = $values = []; $types = $this->types; foreach ($this->_bindedValues as $parameter => $value) { if (! isset($types[$parameter - 1])) { $types[$parameter - 1] = static::$_paramTypeMap[ParameterType::STRING]; } if ($types[$parameter - 1] === static::$_paramTypeMap[ParameterType::LARGE_OBJECT]) { if (is_resource($value)) { if (get_resource_type($value) !== 'stream') { throw new InvalidArgumentException('Resources passed with the LARGE_OBJECT parameter type must be stream resources.'); } $streams[$parameter] = $value; $values[$parameter] = null; continue; } $types[$parameter - 1] = static::$_paramTypeMap[ParameterType::STRING]; } $values[$parameter] = $value; } if (! $this->_stmt->bind_param($types, ...$values)) { throw new MysqliException($this->_stmt->error, $this->_stmt->sqlstate, $this->_stmt->errno); } $this->sendLongData($streams); }
php
private function bindTypedParameters() { $streams = $values = []; $types = $this->types; foreach ($this->_bindedValues as $parameter => $value) { if (! isset($types[$parameter - 1])) { $types[$parameter - 1] = static::$_paramTypeMap[ParameterType::STRING]; } if ($types[$parameter - 1] === static::$_paramTypeMap[ParameterType::LARGE_OBJECT]) { if (is_resource($value)) { if (get_resource_type($value) !== 'stream') { throw new InvalidArgumentException('Resources passed with the LARGE_OBJECT parameter type must be stream resources.'); } $streams[$parameter] = $value; $values[$parameter] = null; continue; } $types[$parameter - 1] = static::$_paramTypeMap[ParameterType::STRING]; } $values[$parameter] = $value; } if (! $this->_stmt->bind_param($types, ...$values)) { throw new MysqliException($this->_stmt->error, $this->_stmt->sqlstate, $this->_stmt->errno); } $this->sendLongData($streams); }
[ "private", "function", "bindTypedParameters", "(", ")", "{", "$", "streams", "=", "$", "values", "=", "[", "]", ";", "$", "types", "=", "$", "this", "->", "types", ";", "foreach", "(", "$", "this", "->", "_bindedValues", "as", "$", "parameter", "=>", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "$", "types", "[", "$", "parameter", "-", "1", "]", ")", ")", "{", "$", "types", "[", "$", "parameter", "-", "1", "]", "=", "static", "::", "$", "_paramTypeMap", "[", "ParameterType", "::", "STRING", "]", ";", "}", "if", "(", "$", "types", "[", "$", "parameter", "-", "1", "]", "===", "static", "::", "$", "_paramTypeMap", "[", "ParameterType", "::", "LARGE_OBJECT", "]", ")", "{", "if", "(", "is_resource", "(", "$", "value", ")", ")", "{", "if", "(", "get_resource_type", "(", "$", "value", ")", "!==", "'stream'", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Resources passed with the LARGE_OBJECT parameter type must be stream resources.'", ")", ";", "}", "$", "streams", "[", "$", "parameter", "]", "=", "$", "value", ";", "$", "values", "[", "$", "parameter", "]", "=", "null", ";", "continue", ";", "}", "$", "types", "[", "$", "parameter", "-", "1", "]", "=", "static", "::", "$", "_paramTypeMap", "[", "ParameterType", "::", "STRING", "]", ";", "}", "$", "values", "[", "$", "parameter", "]", "=", "$", "value", ";", "}", "if", "(", "!", "$", "this", "->", "_stmt", "->", "bind_param", "(", "$", "types", ",", "...", "$", "values", ")", ")", "{", "throw", "new", "MysqliException", "(", "$", "this", "->", "_stmt", "->", "error", ",", "$", "this", "->", "_stmt", "->", "sqlstate", ",", "$", "this", "->", "_stmt", "->", "errno", ")", ";", "}", "$", "this", "->", "sendLongData", "(", "$", "streams", ")", ";", "}" ]
Binds parameters with known types previously bound to the statement
[ "Binds", "parameters", "with", "known", "types", "previously", "bound", "to", "the", "statement" ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php#L210-L241
train
doctrine/dbal
lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php
MysqliStatement.bindUntypedValues
private function bindUntypedValues(array $values) { $params = []; $types = str_repeat('s', count($values)); foreach ($values as &$v) { $params[] =& $v; } return $this->_stmt->bind_param($types, ...$params); }
php
private function bindUntypedValues(array $values) { $params = []; $types = str_repeat('s', count($values)); foreach ($values as &$v) { $params[] =& $v; } return $this->_stmt->bind_param($types, ...$params); }
[ "private", "function", "bindUntypedValues", "(", "array", "$", "values", ")", "{", "$", "params", "=", "[", "]", ";", "$", "types", "=", "str_repeat", "(", "'s'", ",", "count", "(", "$", "values", ")", ")", ";", "foreach", "(", "$", "values", "as", "&", "$", "v", ")", "{", "$", "params", "[", "]", "=", "&", "$", "v", ";", "}", "return", "$", "this", "->", "_stmt", "->", "bind_param", "(", "$", "types", ",", "...", "$", "params", ")", ";", "}" ]
Binds a array of values to bound parameters. @param mixed[] $values @return bool
[ "Binds", "a", "array", "of", "values", "to", "bound", "parameters", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php#L272-L282
train
doctrine/dbal
lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereException.php
SQLAnywhereException.fromSQLAnywhereError
public static function fromSQLAnywhereError($conn = null, $stmt = null) { $state = $conn ? sasql_sqlstate($conn) : sasql_sqlstate(); $code = null; $message = null; /** * Try retrieving the last error from statement resource if given */ if ($stmt) { $code = sasql_stmt_errno($stmt); $message = sasql_stmt_error($stmt); } /** * Try retrieving the last error from the connection resource * if either the statement resource is not given or the statement * resource is given but the last error could not be retrieved from it (fallback). * Depending on the type of error, it is sometimes necessary to retrieve * it from the connection resource even though it occurred during * a prepared statement. */ if ($conn && ! $code) { $code = sasql_errorcode($conn); $message = sasql_error($conn); } /** * Fallback mode if either no connection resource is given * or the last error could not be retrieved from the given * connection / statement resource. */ if (! $conn || ! $code) { $code = sasql_errorcode(); $message = sasql_error(); } if ($message) { return new self('SQLSTATE [' . $state . '] [' . $code . '] ' . $message, $state, $code); } return new self('SQL Anywhere error occurred but no error message was retrieved from driver.', $state, $code); }
php
public static function fromSQLAnywhereError($conn = null, $stmt = null) { $state = $conn ? sasql_sqlstate($conn) : sasql_sqlstate(); $code = null; $message = null; /** * Try retrieving the last error from statement resource if given */ if ($stmt) { $code = sasql_stmt_errno($stmt); $message = sasql_stmt_error($stmt); } /** * Try retrieving the last error from the connection resource * if either the statement resource is not given or the statement * resource is given but the last error could not be retrieved from it (fallback). * Depending on the type of error, it is sometimes necessary to retrieve * it from the connection resource even though it occurred during * a prepared statement. */ if ($conn && ! $code) { $code = sasql_errorcode($conn); $message = sasql_error($conn); } /** * Fallback mode if either no connection resource is given * or the last error could not be retrieved from the given * connection / statement resource. */ if (! $conn || ! $code) { $code = sasql_errorcode(); $message = sasql_error(); } if ($message) { return new self('SQLSTATE [' . $state . '] [' . $code . '] ' . $message, $state, $code); } return new self('SQL Anywhere error occurred but no error message was retrieved from driver.', $state, $code); }
[ "public", "static", "function", "fromSQLAnywhereError", "(", "$", "conn", "=", "null", ",", "$", "stmt", "=", "null", ")", "{", "$", "state", "=", "$", "conn", "?", "sasql_sqlstate", "(", "$", "conn", ")", ":", "sasql_sqlstate", "(", ")", ";", "$", "code", "=", "null", ";", "$", "message", "=", "null", ";", "/**\n * Try retrieving the last error from statement resource if given\n */", "if", "(", "$", "stmt", ")", "{", "$", "code", "=", "sasql_stmt_errno", "(", "$", "stmt", ")", ";", "$", "message", "=", "sasql_stmt_error", "(", "$", "stmt", ")", ";", "}", "/**\n * Try retrieving the last error from the connection resource\n * if either the statement resource is not given or the statement\n * resource is given but the last error could not be retrieved from it (fallback).\n * Depending on the type of error, it is sometimes necessary to retrieve\n * it from the connection resource even though it occurred during\n * a prepared statement.\n */", "if", "(", "$", "conn", "&&", "!", "$", "code", ")", "{", "$", "code", "=", "sasql_errorcode", "(", "$", "conn", ")", ";", "$", "message", "=", "sasql_error", "(", "$", "conn", ")", ";", "}", "/**\n * Fallback mode if either no connection resource is given\n * or the last error could not be retrieved from the given\n * connection / statement resource.\n */", "if", "(", "!", "$", "conn", "||", "!", "$", "code", ")", "{", "$", "code", "=", "sasql_errorcode", "(", ")", ";", "$", "message", "=", "sasql_error", "(", ")", ";", "}", "if", "(", "$", "message", ")", "{", "return", "new", "self", "(", "'SQLSTATE ['", ".", "$", "state", ".", "'] ['", ".", "$", "code", ".", "'] '", ".", "$", "message", ",", "$", "state", ",", "$", "code", ")", ";", "}", "return", "new", "self", "(", "'SQL Anywhere error occurred but no error message was retrieved from driver.'", ",", "$", "state", ",", "$", "code", ")", ";", "}" ]
Helper method to turn SQL Anywhere error into exception. @param resource|null $conn The SQL Anywhere connection resource to retrieve the last error from. @param resource|null $stmt The SQL Anywhere statement resource to retrieve the last error from. @return SQLAnywhereException @throws InvalidArgumentException
[ "Helper", "method", "to", "turn", "SQL", "Anywhere", "error", "into", "exception", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereException.php#L28-L70
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/AbstractAsset.php
AbstractAsset._setName
protected function _setName($name) { if ($this->isIdentifierQuoted($name)) { $this->_quoted = true; $name = $this->trimQuotes($name); } if (strpos($name, '.') !== false) { $parts = explode('.', $name); $this->_namespace = $parts[0]; $name = $parts[1]; } $this->_name = $name; }
php
protected function _setName($name) { if ($this->isIdentifierQuoted($name)) { $this->_quoted = true; $name = $this->trimQuotes($name); } if (strpos($name, '.') !== false) { $parts = explode('.', $name); $this->_namespace = $parts[0]; $name = $parts[1]; } $this->_name = $name; }
[ "protected", "function", "_setName", "(", "$", "name", ")", "{", "if", "(", "$", "this", "->", "isIdentifierQuoted", "(", "$", "name", ")", ")", "{", "$", "this", "->", "_quoted", "=", "true", ";", "$", "name", "=", "$", "this", "->", "trimQuotes", "(", "$", "name", ")", ";", "}", "if", "(", "strpos", "(", "$", "name", ",", "'.'", ")", "!==", "false", ")", "{", "$", "parts", "=", "explode", "(", "'.'", ",", "$", "name", ")", ";", "$", "this", "->", "_namespace", "=", "$", "parts", "[", "0", "]", ";", "$", "name", "=", "$", "parts", "[", "1", "]", ";", "}", "$", "this", "->", "_name", "=", "$", "name", ";", "}" ]
Sets the name of this asset. @param string $name @return void
[ "Sets", "the", "name", "of", "this", "asset", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/AbstractAsset.php#L45-L57
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/AbstractAsset.php
AbstractAsset.getQuotedName
public function getQuotedName(AbstractPlatform $platform) { $keywords = $platform->getReservedKeywordsList(); $parts = explode('.', $this->getName()); foreach ($parts as $k => $v) { $parts[$k] = $this->_quoted || $keywords->isKeyword($v) ? $platform->quoteIdentifier($v) : $v; } return implode('.', $parts); }
php
public function getQuotedName(AbstractPlatform $platform) { $keywords = $platform->getReservedKeywordsList(); $parts = explode('.', $this->getName()); foreach ($parts as $k => $v) { $parts[$k] = $this->_quoted || $keywords->isKeyword($v) ? $platform->quoteIdentifier($v) : $v; } return implode('.', $parts); }
[ "public", "function", "getQuotedName", "(", "AbstractPlatform", "$", "platform", ")", "{", "$", "keywords", "=", "$", "platform", "->", "getReservedKeywordsList", "(", ")", ";", "$", "parts", "=", "explode", "(", "'.'", ",", "$", "this", "->", "getName", "(", ")", ")", ";", "foreach", "(", "$", "parts", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "parts", "[", "$", "k", "]", "=", "$", "this", "->", "_quoted", "||", "$", "keywords", "->", "isKeyword", "(", "$", "v", ")", "?", "$", "platform", "->", "quoteIdentifier", "(", "$", "v", ")", ":", "$", "v", ";", "}", "return", "implode", "(", "'.'", ",", "$", "parts", ")", ";", "}" ]
Gets the quoted representation of this asset but only if it was defined with one. Otherwise return the plain unquoted value as inserted. @return string
[ "Gets", "the", "quoted", "representation", "of", "this", "asset", "but", "only", "if", "it", "was", "defined", "with", "one", ".", "Otherwise", "return", "the", "plain", "unquoted", "value", "as", "inserted", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/AbstractAsset.php#L178-L187
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/AbstractAsset.php
AbstractAsset._generateIdentifierName
protected function _generateIdentifierName($columnNames, $prefix = '', $maxSize = 30) { $hash = implode('', array_map(static function ($column) { return dechex(crc32($column)); }, $columnNames)); return strtoupper(substr($prefix . '_' . $hash, 0, $maxSize)); }
php
protected function _generateIdentifierName($columnNames, $prefix = '', $maxSize = 30) { $hash = implode('', array_map(static function ($column) { return dechex(crc32($column)); }, $columnNames)); return strtoupper(substr($prefix . '_' . $hash, 0, $maxSize)); }
[ "protected", "function", "_generateIdentifierName", "(", "$", "columnNames", ",", "$", "prefix", "=", "''", ",", "$", "maxSize", "=", "30", ")", "{", "$", "hash", "=", "implode", "(", "''", ",", "array_map", "(", "static", "function", "(", "$", "column", ")", "{", "return", "dechex", "(", "crc32", "(", "$", "column", ")", ")", ";", "}", ",", "$", "columnNames", ")", ")", ";", "return", "strtoupper", "(", "substr", "(", "$", "prefix", ".", "'_'", ".", "$", "hash", ",", "0", ",", "$", "maxSize", ")", ")", ";", "}" ]
Generates an identifier from a list of column names obeying a certain string length. This is especially important for Oracle, since it does not allow identifiers larger than 30 chars, however building idents automatically for foreign keys, composite keys or such can easily create very long names. @param string[] $columnNames @param string $prefix @param int $maxSize @return string
[ "Generates", "an", "identifier", "from", "a", "list", "of", "column", "names", "obeying", "a", "certain", "string", "length", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/AbstractAsset.php#L202-L209
train
doctrine/dbal
lib/Doctrine/DBAL/Id/TableGenerator.php
TableGenerator.nextValue
public function nextValue($sequenceName) { if (isset($this->sequences[$sequenceName])) { $value = $this->sequences[$sequenceName]['value']; $this->sequences[$sequenceName]['value']++; if ($this->sequences[$sequenceName]['value'] >= $this->sequences[$sequenceName]['max']) { unset($this->sequences[$sequenceName]); } return $value; } $this->conn->beginTransaction(); try { $platform = $this->conn->getDatabasePlatform(); $sql = 'SELECT sequence_value, sequence_increment_by' . ' FROM ' . $platform->appendLockHint($this->generatorTableName, LockMode::PESSIMISTIC_WRITE) . ' WHERE sequence_name = ? ' . $platform->getWriteLockSQL(); $stmt = $this->conn->executeQuery($sql, [$sequenceName]); $row = $stmt->fetch(FetchMode::ASSOCIATIVE); if ($row !== false) { $row = array_change_key_case($row, CASE_LOWER); $value = $row['sequence_value']; $value++; if ($row['sequence_increment_by'] > 1) { $this->sequences[$sequenceName] = [ 'value' => $value, 'max' => $row['sequence_value'] + $row['sequence_increment_by'], ]; } $sql = 'UPDATE ' . $this->generatorTableName . ' ' . 'SET sequence_value = sequence_value + sequence_increment_by ' . 'WHERE sequence_name = ? AND sequence_value = ?'; $rows = $this->conn->executeUpdate($sql, [$sequenceName, $row['sequence_value']]); if ($rows !== 1) { throw new DBALException('Race-condition detected while updating sequence. Aborting generation'); } } else { $this->conn->insert( $this->generatorTableName, ['sequence_name' => $sequenceName, 'sequence_value' => 1, 'sequence_increment_by' => 1] ); $value = 1; } $this->conn->commit(); } catch (Throwable $e) { $this->conn->rollBack(); throw new DBALException('Error occurred while generating ID with TableGenerator, aborted generation: ' . $e->getMessage(), 0, $e); } return $value; }
php
public function nextValue($sequenceName) { if (isset($this->sequences[$sequenceName])) { $value = $this->sequences[$sequenceName]['value']; $this->sequences[$sequenceName]['value']++; if ($this->sequences[$sequenceName]['value'] >= $this->sequences[$sequenceName]['max']) { unset($this->sequences[$sequenceName]); } return $value; } $this->conn->beginTransaction(); try { $platform = $this->conn->getDatabasePlatform(); $sql = 'SELECT sequence_value, sequence_increment_by' . ' FROM ' . $platform->appendLockHint($this->generatorTableName, LockMode::PESSIMISTIC_WRITE) . ' WHERE sequence_name = ? ' . $platform->getWriteLockSQL(); $stmt = $this->conn->executeQuery($sql, [$sequenceName]); $row = $stmt->fetch(FetchMode::ASSOCIATIVE); if ($row !== false) { $row = array_change_key_case($row, CASE_LOWER); $value = $row['sequence_value']; $value++; if ($row['sequence_increment_by'] > 1) { $this->sequences[$sequenceName] = [ 'value' => $value, 'max' => $row['sequence_value'] + $row['sequence_increment_by'], ]; } $sql = 'UPDATE ' . $this->generatorTableName . ' ' . 'SET sequence_value = sequence_value + sequence_increment_by ' . 'WHERE sequence_name = ? AND sequence_value = ?'; $rows = $this->conn->executeUpdate($sql, [$sequenceName, $row['sequence_value']]); if ($rows !== 1) { throw new DBALException('Race-condition detected while updating sequence. Aborting generation'); } } else { $this->conn->insert( $this->generatorTableName, ['sequence_name' => $sequenceName, 'sequence_value' => 1, 'sequence_increment_by' => 1] ); $value = 1; } $this->conn->commit(); } catch (Throwable $e) { $this->conn->rollBack(); throw new DBALException('Error occurred while generating ID with TableGenerator, aborted generation: ' . $e->getMessage(), 0, $e); } return $value; }
[ "public", "function", "nextValue", "(", "$", "sequenceName", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "sequences", "[", "$", "sequenceName", "]", ")", ")", "{", "$", "value", "=", "$", "this", "->", "sequences", "[", "$", "sequenceName", "]", "[", "'value'", "]", ";", "$", "this", "->", "sequences", "[", "$", "sequenceName", "]", "[", "'value'", "]", "++", ";", "if", "(", "$", "this", "->", "sequences", "[", "$", "sequenceName", "]", "[", "'value'", "]", ">=", "$", "this", "->", "sequences", "[", "$", "sequenceName", "]", "[", "'max'", "]", ")", "{", "unset", "(", "$", "this", "->", "sequences", "[", "$", "sequenceName", "]", ")", ";", "}", "return", "$", "value", ";", "}", "$", "this", "->", "conn", "->", "beginTransaction", "(", ")", ";", "try", "{", "$", "platform", "=", "$", "this", "->", "conn", "->", "getDatabasePlatform", "(", ")", ";", "$", "sql", "=", "'SELECT sequence_value, sequence_increment_by'", ".", "' FROM '", ".", "$", "platform", "->", "appendLockHint", "(", "$", "this", "->", "generatorTableName", ",", "LockMode", "::", "PESSIMISTIC_WRITE", ")", ".", "' WHERE sequence_name = ? '", ".", "$", "platform", "->", "getWriteLockSQL", "(", ")", ";", "$", "stmt", "=", "$", "this", "->", "conn", "->", "executeQuery", "(", "$", "sql", ",", "[", "$", "sequenceName", "]", ")", ";", "$", "row", "=", "$", "stmt", "->", "fetch", "(", "FetchMode", "::", "ASSOCIATIVE", ")", ";", "if", "(", "$", "row", "!==", "false", ")", "{", "$", "row", "=", "array_change_key_case", "(", "$", "row", ",", "CASE_LOWER", ")", ";", "$", "value", "=", "$", "row", "[", "'sequence_value'", "]", ";", "$", "value", "++", ";", "if", "(", "$", "row", "[", "'sequence_increment_by'", "]", ">", "1", ")", "{", "$", "this", "->", "sequences", "[", "$", "sequenceName", "]", "=", "[", "'value'", "=>", "$", "value", ",", "'max'", "=>", "$", "row", "[", "'sequence_value'", "]", "+", "$", "row", "[", "'sequence_increment_by'", "]", ",", "]", ";", "}", "$", "sql", "=", "'UPDATE '", ".", "$", "this", "->", "generatorTableName", ".", "' '", ".", "'SET sequence_value = sequence_value + sequence_increment_by '", ".", "'WHERE sequence_name = ? AND sequence_value = ?'", ";", "$", "rows", "=", "$", "this", "->", "conn", "->", "executeUpdate", "(", "$", "sql", ",", "[", "$", "sequenceName", ",", "$", "row", "[", "'sequence_value'", "]", "]", ")", ";", "if", "(", "$", "rows", "!==", "1", ")", "{", "throw", "new", "DBALException", "(", "'Race-condition detected while updating sequence. Aborting generation'", ")", ";", "}", "}", "else", "{", "$", "this", "->", "conn", "->", "insert", "(", "$", "this", "->", "generatorTableName", ",", "[", "'sequence_name'", "=>", "$", "sequenceName", ",", "'sequence_value'", "=>", "1", ",", "'sequence_increment_by'", "=>", "1", "]", ")", ";", "$", "value", "=", "1", ";", "}", "$", "this", "->", "conn", "->", "commit", "(", ")", ";", "}", "catch", "(", "Throwable", "$", "e", ")", "{", "$", "this", "->", "conn", "->", "rollBack", "(", ")", ";", "throw", "new", "DBALException", "(", "'Error occurred while generating ID with TableGenerator, aborted generation: '", ".", "$", "e", "->", "getMessage", "(", ")", ",", "0", ",", "$", "e", ")", ";", "}", "return", "$", "value", ";", "}" ]
Generates the next unused value for the given sequence name. @param string $sequenceName @return int @throws DBALException
[ "Generates", "the", "next", "unused", "value", "for", "the", "given", "sequence", "name", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Id/TableGenerator.php#L86-L144
train
doctrine/dbal
lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
SQLServerPlatform.getCreateColumnCommentSQL
protected function getCreateColumnCommentSQL($tableName, $columnName, $comment) { if (strpos($tableName, '.') !== false) { [$schemaSQL, $tableSQL] = explode('.', $tableName); $schemaSQL = $this->quoteStringLiteral($schemaSQL); $tableSQL = $this->quoteStringLiteral($tableSQL); } else { $schemaSQL = "'dbo'"; $tableSQL = $this->quoteStringLiteral($tableName); } return $this->getAddExtendedPropertySQL( 'MS_Description', $comment, 'SCHEMA', $schemaSQL, 'TABLE', $tableSQL, 'COLUMN', $columnName ); }
php
protected function getCreateColumnCommentSQL($tableName, $columnName, $comment) { if (strpos($tableName, '.') !== false) { [$schemaSQL, $tableSQL] = explode('.', $tableName); $schemaSQL = $this->quoteStringLiteral($schemaSQL); $tableSQL = $this->quoteStringLiteral($tableSQL); } else { $schemaSQL = "'dbo'"; $tableSQL = $this->quoteStringLiteral($tableName); } return $this->getAddExtendedPropertySQL( 'MS_Description', $comment, 'SCHEMA', $schemaSQL, 'TABLE', $tableSQL, 'COLUMN', $columnName ); }
[ "protected", "function", "getCreateColumnCommentSQL", "(", "$", "tableName", ",", "$", "columnName", ",", "$", "comment", ")", "{", "if", "(", "strpos", "(", "$", "tableName", ",", "'.'", ")", "!==", "false", ")", "{", "[", "$", "schemaSQL", ",", "$", "tableSQL", "]", "=", "explode", "(", "'.'", ",", "$", "tableName", ")", ";", "$", "schemaSQL", "=", "$", "this", "->", "quoteStringLiteral", "(", "$", "schemaSQL", ")", ";", "$", "tableSQL", "=", "$", "this", "->", "quoteStringLiteral", "(", "$", "tableSQL", ")", ";", "}", "else", "{", "$", "schemaSQL", "=", "\"'dbo'\"", ";", "$", "tableSQL", "=", "$", "this", "->", "quoteStringLiteral", "(", "$", "tableName", ")", ";", "}", "return", "$", "this", "->", "getAddExtendedPropertySQL", "(", "'MS_Description'", ",", "$", "comment", ",", "'SCHEMA'", ",", "$", "schemaSQL", ",", "'TABLE'", ",", "$", "tableSQL", ",", "'COLUMN'", ",", "$", "columnName", ")", ";", "}" ]
Returns the SQL statement for creating a column comment. SQL Server does not support native column comments, therefore the extended properties functionality is used as a workaround to store them. The property name used to store column comments is "MS_Description" which provides compatibility with SQL Server Management Studio, as column comments are stored in the same property there when specifying a column's "Description" attribute. @param string $tableName The quoted table name to which the column belongs. @param string $columnName The quoted column name to create the comment for. @param string|null $comment The column's comment. @return string
[ "Returns", "the", "SQL", "statement", "for", "creating", "a", "column", "comment", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php#L349-L370
train
doctrine/dbal
lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
SQLServerPlatform.getDefaultConstraintDeclarationSQL
public function getDefaultConstraintDeclarationSQL($table, array $column) { if (! isset($column['default'])) { throw new InvalidArgumentException("Incomplete column definition. 'default' required."); } $columnName = new Identifier($column['name']); return ' CONSTRAINT ' . $this->generateDefaultConstraintName($table, $column['name']) . $this->getDefaultValueDeclarationSQL($column) . ' FOR ' . $columnName->getQuotedName($this); }
php
public function getDefaultConstraintDeclarationSQL($table, array $column) { if (! isset($column['default'])) { throw new InvalidArgumentException("Incomplete column definition. 'default' required."); } $columnName = new Identifier($column['name']); return ' CONSTRAINT ' . $this->generateDefaultConstraintName($table, $column['name']) . $this->getDefaultValueDeclarationSQL($column) . ' FOR ' . $columnName->getQuotedName($this); }
[ "public", "function", "getDefaultConstraintDeclarationSQL", "(", "$", "table", ",", "array", "$", "column", ")", "{", "if", "(", "!", "isset", "(", "$", "column", "[", "'default'", "]", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Incomplete column definition. 'default' required.\"", ")", ";", "}", "$", "columnName", "=", "new", "Identifier", "(", "$", "column", "[", "'name'", "]", ")", ";", "return", "' CONSTRAINT '", ".", "$", "this", "->", "generateDefaultConstraintName", "(", "$", "table", ",", "$", "column", "[", "'name'", "]", ")", ".", "$", "this", "->", "getDefaultValueDeclarationSQL", "(", "$", "column", ")", ".", "' FOR '", ".", "$", "columnName", "->", "getQuotedName", "(", "$", "this", ")", ";", "}" ]
Returns the SQL snippet for declaring a default constraint. @param string $table Name of the table to return the default constraint declaration for. @param mixed[] $column Column definition. @return string @throws InvalidArgumentException
[ "Returns", "the", "SQL", "snippet", "for", "declaring", "a", "default", "constraint", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php#L382-L394
train
doctrine/dbal
lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
SQLServerPlatform._appendUniqueConstraintDefinition
private function _appendUniqueConstraintDefinition($sql, Index $index) { $fields = []; foreach ($index->getQuotedColumns($this) as $field) { $fields[] = $field . ' IS NOT NULL'; } return $sql . ' WHERE ' . implode(' AND ', $fields); }
php
private function _appendUniqueConstraintDefinition($sql, Index $index) { $fields = []; foreach ($index->getQuotedColumns($this) as $field) { $fields[] = $field . ' IS NOT NULL'; } return $sql . ' WHERE ' . implode(' AND ', $fields); }
[ "private", "function", "_appendUniqueConstraintDefinition", "(", "$", "sql", ",", "Index", "$", "index", ")", "{", "$", "fields", "=", "[", "]", ";", "foreach", "(", "$", "index", "->", "getQuotedColumns", "(", "$", "this", ")", "as", "$", "field", ")", "{", "$", "fields", "[", "]", "=", "$", "field", ".", "' IS NOT NULL'", ";", "}", "return", "$", "sql", ".", "' WHERE '", ".", "implode", "(", "' AND '", ",", "$", "fields", ")", ";", "}" ]
Extend unique key constraint with required filters @param string $sql @return string
[ "Extend", "unique", "key", "constraint", "with", "required", "filters" ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php#L448-L457
train
doctrine/dbal
lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
SQLServerPlatform.getAlterTableAddDefaultConstraintClause
private function getAlterTableAddDefaultConstraintClause($tableName, Column $column) { $columnDef = $column->toArray(); $columnDef['name'] = $column->getQuotedName($this); return 'ADD' . $this->getDefaultConstraintDeclarationSQL($tableName, $columnDef); }
php
private function getAlterTableAddDefaultConstraintClause($tableName, Column $column) { $columnDef = $column->toArray(); $columnDef['name'] = $column->getQuotedName($this); return 'ADD' . $this->getDefaultConstraintDeclarationSQL($tableName, $columnDef); }
[ "private", "function", "getAlterTableAddDefaultConstraintClause", "(", "$", "tableName", ",", "Column", "$", "column", ")", "{", "$", "columnDef", "=", "$", "column", "->", "toArray", "(", ")", ";", "$", "columnDef", "[", "'name'", "]", "=", "$", "column", "->", "getQuotedName", "(", "$", "this", ")", ";", "return", "'ADD'", ".", "$", "this", "->", "getDefaultConstraintDeclarationSQL", "(", "$", "tableName", ",", "$", "columnDef", ")", ";", "}" ]
Returns the SQL clause for adding a default constraint in an ALTER TABLE statement. @param string $tableName The name of the table to generate the clause for. @param Column $column The column to generate the clause for. @return string
[ "Returns", "the", "SQL", "clause", "for", "adding", "a", "default", "constraint", "in", "an", "ALTER", "TABLE", "statement", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php#L633-L639
train
doctrine/dbal
lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
SQLServerPlatform.alterColumnRequiresDropDefaultConstraint
private function alterColumnRequiresDropDefaultConstraint(ColumnDiff $columnDiff) { // We can only decide whether to drop an existing default constraint // if we know the original default value. if (! $columnDiff->fromColumn instanceof Column) { return false; } // We only need to drop an existing default constraint if we know the // column was defined with a default value before. if ($columnDiff->fromColumn->getDefault() === null) { return false; } // We need to drop an existing default constraint if the column was // defined with a default value before and it has changed. if ($columnDiff->hasChanged('default')) { return true; } // We need to drop an existing default constraint if the column was // defined with a default value before and the native column type has changed. return $columnDiff->hasChanged('type') || $columnDiff->hasChanged('fixed'); }
php
private function alterColumnRequiresDropDefaultConstraint(ColumnDiff $columnDiff) { // We can only decide whether to drop an existing default constraint // if we know the original default value. if (! $columnDiff->fromColumn instanceof Column) { return false; } // We only need to drop an existing default constraint if we know the // column was defined with a default value before. if ($columnDiff->fromColumn->getDefault() === null) { return false; } // We need to drop an existing default constraint if the column was // defined with a default value before and it has changed. if ($columnDiff->hasChanged('default')) { return true; } // We need to drop an existing default constraint if the column was // defined with a default value before and the native column type has changed. return $columnDiff->hasChanged('type') || $columnDiff->hasChanged('fixed'); }
[ "private", "function", "alterColumnRequiresDropDefaultConstraint", "(", "ColumnDiff", "$", "columnDiff", ")", "{", "// We can only decide whether to drop an existing default constraint", "// if we know the original default value.", "if", "(", "!", "$", "columnDiff", "->", "fromColumn", "instanceof", "Column", ")", "{", "return", "false", ";", "}", "// We only need to drop an existing default constraint if we know the", "// column was defined with a default value before.", "if", "(", "$", "columnDiff", "->", "fromColumn", "->", "getDefault", "(", ")", "===", "null", ")", "{", "return", "false", ";", "}", "// We need to drop an existing default constraint if the column was", "// defined with a default value before and it has changed.", "if", "(", "$", "columnDiff", "->", "hasChanged", "(", "'default'", ")", ")", "{", "return", "true", ";", "}", "// We need to drop an existing default constraint if the column was", "// defined with a default value before and the native column type has changed.", "return", "$", "columnDiff", "->", "hasChanged", "(", "'type'", ")", "||", "$", "columnDiff", "->", "hasChanged", "(", "'fixed'", ")", ";", "}" ]
Checks whether a column alteration requires dropping its default constraint first. Different to other database vendors SQL Server implements column default values as constraints and therefore changes in a column's default value as well as changes in a column's type require dropping the default constraint first before being to alter the particular column to the new definition. @param ColumnDiff $columnDiff The column diff to evaluate. @return bool True if the column alteration requires dropping its default constraint first, false otherwise.
[ "Checks", "whether", "a", "column", "alteration", "requires", "dropping", "its", "default", "constraint", "first", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php#L666-L689
train
doctrine/dbal
lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
SQLServerPlatform.getAlterColumnCommentSQL
protected function getAlterColumnCommentSQL($tableName, $columnName, $comment) { if (strpos($tableName, '.') !== false) { [$schemaSQL, $tableSQL] = explode('.', $tableName); $schemaSQL = $this->quoteStringLiteral($schemaSQL); $tableSQL = $this->quoteStringLiteral($tableSQL); } else { $schemaSQL = "'dbo'"; $tableSQL = $this->quoteStringLiteral($tableName); } return $this->getUpdateExtendedPropertySQL( 'MS_Description', $comment, 'SCHEMA', $schemaSQL, 'TABLE', $tableSQL, 'COLUMN', $columnName ); }
php
protected function getAlterColumnCommentSQL($tableName, $columnName, $comment) { if (strpos($tableName, '.') !== false) { [$schemaSQL, $tableSQL] = explode('.', $tableName); $schemaSQL = $this->quoteStringLiteral($schemaSQL); $tableSQL = $this->quoteStringLiteral($tableSQL); } else { $schemaSQL = "'dbo'"; $tableSQL = $this->quoteStringLiteral($tableName); } return $this->getUpdateExtendedPropertySQL( 'MS_Description', $comment, 'SCHEMA', $schemaSQL, 'TABLE', $tableSQL, 'COLUMN', $columnName ); }
[ "protected", "function", "getAlterColumnCommentSQL", "(", "$", "tableName", ",", "$", "columnName", ",", "$", "comment", ")", "{", "if", "(", "strpos", "(", "$", "tableName", ",", "'.'", ")", "!==", "false", ")", "{", "[", "$", "schemaSQL", ",", "$", "tableSQL", "]", "=", "explode", "(", "'.'", ",", "$", "tableName", ")", ";", "$", "schemaSQL", "=", "$", "this", "->", "quoteStringLiteral", "(", "$", "schemaSQL", ")", ";", "$", "tableSQL", "=", "$", "this", "->", "quoteStringLiteral", "(", "$", "tableSQL", ")", ";", "}", "else", "{", "$", "schemaSQL", "=", "\"'dbo'\"", ";", "$", "tableSQL", "=", "$", "this", "->", "quoteStringLiteral", "(", "$", "tableName", ")", ";", "}", "return", "$", "this", "->", "getUpdateExtendedPropertySQL", "(", "'MS_Description'", ",", "$", "comment", ",", "'SCHEMA'", ",", "$", "schemaSQL", ",", "'TABLE'", ",", "$", "tableSQL", ",", "'COLUMN'", ",", "$", "columnName", ")", ";", "}" ]
Returns the SQL statement for altering a column comment. SQL Server does not support native column comments, therefore the extended properties functionality is used as a workaround to store them. The property name used to store column comments is "MS_Description" which provides compatibility with SQL Server Management Studio, as column comments are stored in the same property there when specifying a column's "Description" attribute. @param string $tableName The quoted table name to which the column belongs. @param string $columnName The quoted column name to alter the comment for. @param string|null $comment The column's comment. @return string
[ "Returns", "the", "SQL", "statement", "for", "altering", "a", "column", "comment", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php#L708-L729
train
doctrine/dbal
lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
SQLServerPlatform.getDropColumnCommentSQL
protected function getDropColumnCommentSQL($tableName, $columnName) { if (strpos($tableName, '.') !== false) { [$schemaSQL, $tableSQL] = explode('.', $tableName); $schemaSQL = $this->quoteStringLiteral($schemaSQL); $tableSQL = $this->quoteStringLiteral($tableSQL); } else { $schemaSQL = "'dbo'"; $tableSQL = $this->quoteStringLiteral($tableName); } return $this->getDropExtendedPropertySQL( 'MS_Description', 'SCHEMA', $schemaSQL, 'TABLE', $tableSQL, 'COLUMN', $columnName ); }
php
protected function getDropColumnCommentSQL($tableName, $columnName) { if (strpos($tableName, '.') !== false) { [$schemaSQL, $tableSQL] = explode('.', $tableName); $schemaSQL = $this->quoteStringLiteral($schemaSQL); $tableSQL = $this->quoteStringLiteral($tableSQL); } else { $schemaSQL = "'dbo'"; $tableSQL = $this->quoteStringLiteral($tableName); } return $this->getDropExtendedPropertySQL( 'MS_Description', 'SCHEMA', $schemaSQL, 'TABLE', $tableSQL, 'COLUMN', $columnName ); }
[ "protected", "function", "getDropColumnCommentSQL", "(", "$", "tableName", ",", "$", "columnName", ")", "{", "if", "(", "strpos", "(", "$", "tableName", ",", "'.'", ")", "!==", "false", ")", "{", "[", "$", "schemaSQL", ",", "$", "tableSQL", "]", "=", "explode", "(", "'.'", ",", "$", "tableName", ")", ";", "$", "schemaSQL", "=", "$", "this", "->", "quoteStringLiteral", "(", "$", "schemaSQL", ")", ";", "$", "tableSQL", "=", "$", "this", "->", "quoteStringLiteral", "(", "$", "tableSQL", ")", ";", "}", "else", "{", "$", "schemaSQL", "=", "\"'dbo'\"", ";", "$", "tableSQL", "=", "$", "this", "->", "quoteStringLiteral", "(", "$", "tableName", ")", ";", "}", "return", "$", "this", "->", "getDropExtendedPropertySQL", "(", "'MS_Description'", ",", "'SCHEMA'", ",", "$", "schemaSQL", ",", "'TABLE'", ",", "$", "tableSQL", ",", "'COLUMN'", ",", "$", "columnName", ")", ";", "}" ]
Returns the SQL statement for dropping a column comment. SQL Server does not support native column comments, therefore the extended properties functionality is used as a workaround to store them. The property name used to store column comments is "MS_Description" which provides compatibility with SQL Server Management Studio, as column comments are stored in the same property there when specifying a column's "Description" attribute. @param string $tableName The quoted table name to which the column belongs. @param string $columnName The quoted column name to drop the comment for. @return string
[ "Returns", "the", "SQL", "statement", "for", "dropping", "a", "column", "comment", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php#L747-L767
train
doctrine/dbal
lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
SQLServerPlatform.getAddExtendedPropertySQL
public function getAddExtendedPropertySQL( $name, $value = null, $level0Type = null, $level0Name = null, $level1Type = null, $level1Name = null, $level2Type = null, $level2Name = null ) { return 'EXEC sp_addextendedproperty ' . 'N' . $this->quoteStringLiteral($name) . ', N' . $this->quoteStringLiteral((string) $value) . ', ' . 'N' . $this->quoteStringLiteral((string) $level0Type) . ', ' . $level0Name . ', ' . 'N' . $this->quoteStringLiteral((string) $level1Type) . ', ' . $level1Name . ', ' . 'N' . $this->quoteStringLiteral((string) $level2Type) . ', ' . $level2Name; }
php
public function getAddExtendedPropertySQL( $name, $value = null, $level0Type = null, $level0Name = null, $level1Type = null, $level1Name = null, $level2Type = null, $level2Name = null ) { return 'EXEC sp_addextendedproperty ' . 'N' . $this->quoteStringLiteral($name) . ', N' . $this->quoteStringLiteral((string) $value) . ', ' . 'N' . $this->quoteStringLiteral((string) $level0Type) . ', ' . $level0Name . ', ' . 'N' . $this->quoteStringLiteral((string) $level1Type) . ', ' . $level1Name . ', ' . 'N' . $this->quoteStringLiteral((string) $level2Type) . ', ' . $level2Name; }
[ "public", "function", "getAddExtendedPropertySQL", "(", "$", "name", ",", "$", "value", "=", "null", ",", "$", "level0Type", "=", "null", ",", "$", "level0Name", "=", "null", ",", "$", "level1Type", "=", "null", ",", "$", "level1Name", "=", "null", ",", "$", "level2Type", "=", "null", ",", "$", "level2Name", "=", "null", ")", "{", "return", "'EXEC sp_addextendedproperty '", ".", "'N'", ".", "$", "this", "->", "quoteStringLiteral", "(", "$", "name", ")", ".", "', N'", ".", "$", "this", "->", "quoteStringLiteral", "(", "(", "string", ")", "$", "value", ")", ".", "', '", ".", "'N'", ".", "$", "this", "->", "quoteStringLiteral", "(", "(", "string", ")", "$", "level0Type", ")", ".", "', '", ".", "$", "level0Name", ".", "', '", ".", "'N'", ".", "$", "this", "->", "quoteStringLiteral", "(", "(", "string", ")", "$", "level1Type", ")", ".", "', '", ".", "$", "level1Name", ".", "', '", ".", "'N'", ".", "$", "this", "->", "quoteStringLiteral", "(", "(", "string", ")", "$", "level2Type", ")", ".", "', '", ".", "$", "level2Name", ";", "}" ]
Returns the SQL statement for adding an extended property to a database object. @link http://msdn.microsoft.com/en-us/library/ms180047%28v=sql.90%29.aspx @param string $name The name of the property to add. @param string|null $value The value of the property to add. @param string|null $level0Type The type of the object at level 0 the property belongs to. @param string|null $level0Name The name of the object at level 0 the property belongs to. @param string|null $level1Type The type of the object at level 1 the property belongs to. @param string|null $level1Name The name of the object at level 1 the property belongs to. @param string|null $level2Type The type of the object at level 2 the property belongs to. @param string|null $level2Name The name of the object at level 2 the property belongs to. @return string
[ "Returns", "the", "SQL", "statement", "for", "adding", "an", "extended", "property", "to", "a", "database", "object", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php#L799-L814
train
doctrine/dbal
lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
SQLServerPlatform.getDropExtendedPropertySQL
public function getDropExtendedPropertySQL( $name, $level0Type = null, $level0Name = null, $level1Type = null, $level1Name = null, $level2Type = null, $level2Name = null ) { return 'EXEC sp_dropextendedproperty ' . 'N' . $this->quoteStringLiteral($name) . ', ' . 'N' . $this->quoteStringLiteral((string) $level0Type) . ', ' . $level0Name . ', ' . 'N' . $this->quoteStringLiteral((string) $level1Type) . ', ' . $level1Name . ', ' . 'N' . $this->quoteStringLiteral((string) $level2Type) . ', ' . $level2Name; }
php
public function getDropExtendedPropertySQL( $name, $level0Type = null, $level0Name = null, $level1Type = null, $level1Name = null, $level2Type = null, $level2Name = null ) { return 'EXEC sp_dropextendedproperty ' . 'N' . $this->quoteStringLiteral($name) . ', ' . 'N' . $this->quoteStringLiteral((string) $level0Type) . ', ' . $level0Name . ', ' . 'N' . $this->quoteStringLiteral((string) $level1Type) . ', ' . $level1Name . ', ' . 'N' . $this->quoteStringLiteral((string) $level2Type) . ', ' . $level2Name; }
[ "public", "function", "getDropExtendedPropertySQL", "(", "$", "name", ",", "$", "level0Type", "=", "null", ",", "$", "level0Name", "=", "null", ",", "$", "level1Type", "=", "null", ",", "$", "level1Name", "=", "null", ",", "$", "level2Type", "=", "null", ",", "$", "level2Name", "=", "null", ")", "{", "return", "'EXEC sp_dropextendedproperty '", ".", "'N'", ".", "$", "this", "->", "quoteStringLiteral", "(", "$", "name", ")", ".", "', '", ".", "'N'", ".", "$", "this", "->", "quoteStringLiteral", "(", "(", "string", ")", "$", "level0Type", ")", ".", "', '", ".", "$", "level0Name", ".", "', '", ".", "'N'", ".", "$", "this", "->", "quoteStringLiteral", "(", "(", "string", ")", "$", "level1Type", ")", ".", "', '", ".", "$", "level1Name", ".", "', '", ".", "'N'", ".", "$", "this", "->", "quoteStringLiteral", "(", "(", "string", ")", "$", "level2Type", ")", ".", "', '", ".", "$", "level2Name", ";", "}" ]
Returns the SQL statement for dropping an extended property from a database object. @link http://technet.microsoft.com/en-gb/library/ms178595%28v=sql.90%29.aspx @param string $name The name of the property to drop. @param string|null $level0Type The type of the object at level 0 the property belongs to. @param string|null $level0Name The name of the object at level 0 the property belongs to. @param string|null $level1Type The type of the object at level 1 the property belongs to. @param string|null $level1Name The name of the object at level 1 the property belongs to. @param string|null $level2Type The type of the object at level 2 the property belongs to. @param string|null $level2Name The name of the object at level 2 the property belongs to. @return string
[ "Returns", "the", "SQL", "statement", "for", "dropping", "an", "extended", "property", "from", "a", "database", "object", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php#L831-L845
train
doctrine/dbal
lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
SQLServerPlatform.getTableWhereClause
private function getTableWhereClause($table, $schemaColumn, $tableColumn) { if (strpos($table, '.') !== false) { [$schema, $table] = explode('.', $table); $schema = $this->quoteStringLiteral($schema); $table = $this->quoteStringLiteral($table); } else { $schema = 'SCHEMA_NAME()'; $table = $this->quoteStringLiteral($table); } return sprintf('(%s = %s AND %s = %s)', $tableColumn, $table, $schemaColumn, $schema); }
php
private function getTableWhereClause($table, $schemaColumn, $tableColumn) { if (strpos($table, '.') !== false) { [$schema, $table] = explode('.', $table); $schema = $this->quoteStringLiteral($schema); $table = $this->quoteStringLiteral($table); } else { $schema = 'SCHEMA_NAME()'; $table = $this->quoteStringLiteral($table); } return sprintf('(%s = %s AND %s = %s)', $tableColumn, $table, $schemaColumn, $schema); }
[ "private", "function", "getTableWhereClause", "(", "$", "table", ",", "$", "schemaColumn", ",", "$", "tableColumn", ")", "{", "if", "(", "strpos", "(", "$", "table", ",", "'.'", ")", "!==", "false", ")", "{", "[", "$", "schema", ",", "$", "table", "]", "=", "explode", "(", "'.'", ",", "$", "table", ")", ";", "$", "schema", "=", "$", "this", "->", "quoteStringLiteral", "(", "$", "schema", ")", ";", "$", "table", "=", "$", "this", "->", "quoteStringLiteral", "(", "$", "table", ")", ";", "}", "else", "{", "$", "schema", "=", "'SCHEMA_NAME()'", ";", "$", "table", "=", "$", "this", "->", "quoteStringLiteral", "(", "$", "table", ")", ";", "}", "return", "sprintf", "(", "'(%s = %s AND %s = %s)'", ",", "$", "tableColumn", ",", "$", "table", ",", "$", "schemaColumn", ",", "$", "schema", ")", ";", "}" ]
Returns the where clause to filter schema and table name in a query. @param string $table The full qualified name of the table. @param string $schemaColumn The name of the column to compare the schema to in the where clause. @param string $tableColumn The name of the column to compare the table to in the where clause. @return string
[ "Returns", "the", "where", "clause", "to", "filter", "schema", "and", "table", "name", "in", "a", "query", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php#L1001-L1013
train
doctrine/dbal
lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
SQLServerPlatform.isOrderByInTopNSubquery
private function isOrderByInTopNSubquery($query, $currentPosition) { // Grab query text on the same nesting level as the ORDER BY clause we're examining. $subQueryBuffer = ''; $parenCount = 0; // If $parenCount goes negative, we've exited the subquery we're examining. // If $currentPosition goes negative, we've reached the beginning of the query. while ($parenCount >= 0 && $currentPosition >= 0) { if ($query[$currentPosition] === '(') { $parenCount--; } elseif ($query[$currentPosition] === ')') { $parenCount++; } // Only yank query text on the same nesting level as the ORDER BY clause. $subQueryBuffer = ($parenCount === 0 ? $query[$currentPosition] : ' ') . $subQueryBuffer; $currentPosition--; } return (bool) preg_match('/SELECT\s+(DISTINCT\s+)?TOP\s/i', $subQueryBuffer); }
php
private function isOrderByInTopNSubquery($query, $currentPosition) { // Grab query text on the same nesting level as the ORDER BY clause we're examining. $subQueryBuffer = ''; $parenCount = 0; // If $parenCount goes negative, we've exited the subquery we're examining. // If $currentPosition goes negative, we've reached the beginning of the query. while ($parenCount >= 0 && $currentPosition >= 0) { if ($query[$currentPosition] === '(') { $parenCount--; } elseif ($query[$currentPosition] === ')') { $parenCount++; } // Only yank query text on the same nesting level as the ORDER BY clause. $subQueryBuffer = ($parenCount === 0 ? $query[$currentPosition] : ' ') . $subQueryBuffer; $currentPosition--; } return (bool) preg_match('/SELECT\s+(DISTINCT\s+)?TOP\s/i', $subQueryBuffer); }
[ "private", "function", "isOrderByInTopNSubquery", "(", "$", "query", ",", "$", "currentPosition", ")", "{", "// Grab query text on the same nesting level as the ORDER BY clause we're examining.", "$", "subQueryBuffer", "=", "''", ";", "$", "parenCount", "=", "0", ";", "// If $parenCount goes negative, we've exited the subquery we're examining.", "// If $currentPosition goes negative, we've reached the beginning of the query.", "while", "(", "$", "parenCount", ">=", "0", "&&", "$", "currentPosition", ">=", "0", ")", "{", "if", "(", "$", "query", "[", "$", "currentPosition", "]", "===", "'('", ")", "{", "$", "parenCount", "--", ";", "}", "elseif", "(", "$", "query", "[", "$", "currentPosition", "]", "===", "')'", ")", "{", "$", "parenCount", "++", ";", "}", "// Only yank query text on the same nesting level as the ORDER BY clause.", "$", "subQueryBuffer", "=", "(", "$", "parenCount", "===", "0", "?", "$", "query", "[", "$", "currentPosition", "]", ":", "' '", ")", ".", "$", "subQueryBuffer", ";", "$", "currentPosition", "--", ";", "}", "return", "(", "bool", ")", "preg_match", "(", "'/SELECT\\s+(DISTINCT\\s+)?TOP\\s/i'", ",", "$", "subQueryBuffer", ")", ";", "}" ]
Check an ORDER BY clause to see if it is in a TOP N query or subquery. @param string $query The query @param int $currentPosition Start position of ORDER BY clause @return bool true if ORDER BY is in a TOP N query, false otherwise
[ "Check", "an", "ORDER", "BY", "clause", "to", "see", "if", "it", "is", "in", "a", "TOP", "N", "query", "or", "subquery", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php#L1364-L1386
train
doctrine/dbal
lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
SQLServerPlatform.generateIdentifierName
private function generateIdentifierName($identifier) { // Always generate name for unquoted identifiers to ensure consistency. $identifier = new Identifier($identifier); return strtoupper(dechex(crc32($identifier->getName()))); }
php
private function generateIdentifierName($identifier) { // Always generate name for unquoted identifiers to ensure consistency. $identifier = new Identifier($identifier); return strtoupper(dechex(crc32($identifier->getName()))); }
[ "private", "function", "generateIdentifierName", "(", "$", "identifier", ")", "{", "// Always generate name for unquoted identifiers to ensure consistency.", "$", "identifier", "=", "new", "Identifier", "(", "$", "identifier", ")", ";", "return", "strtoupper", "(", "dechex", "(", "crc32", "(", "$", "identifier", "->", "getName", "(", ")", ")", ")", ")", ";", "}" ]
Returns a hash value for a given identifier. @param string $identifier Identifier to generate a hash value for. @return string
[ "Returns", "a", "hash", "value", "for", "a", "given", "identifier", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php#L1683-L1689
train
doctrine/dbal
lib/Doctrine/DBAL/Types/TypeRegistry.php
TypeRegistry.get
public function get(string $name) : Type { if (! isset($this->instances[$name])) { throw DBALException::unknownColumnType($name); } return $this->instances[$name]; }
php
public function get(string $name) : Type { if (! isset($this->instances[$name])) { throw DBALException::unknownColumnType($name); } return $this->instances[$name]; }
[ "public", "function", "get", "(", "string", "$", "name", ")", ":", "Type", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "instances", "[", "$", "name", "]", ")", ")", "{", "throw", "DBALException", "::", "unknownColumnType", "(", "$", "name", ")", ";", "}", "return", "$", "this", "->", "instances", "[", "$", "name", "]", ";", "}" ]
Finds a type by the given name. @throws DBALException
[ "Finds", "a", "type", "by", "the", "given", "name", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Types/TypeRegistry.php#L27-L34
train
doctrine/dbal
lib/Doctrine/DBAL/Types/TypeRegistry.php
TypeRegistry.lookupName
public function lookupName(Type $type) : string { $name = $this->findTypeName($type); if ($name === null) { throw DBALException::typeNotRegistered($type); } return $name; }
php
public function lookupName(Type $type) : string { $name = $this->findTypeName($type); if ($name === null) { throw DBALException::typeNotRegistered($type); } return $name; }
[ "public", "function", "lookupName", "(", "Type", "$", "type", ")", ":", "string", "{", "$", "name", "=", "$", "this", "->", "findTypeName", "(", "$", "type", ")", ";", "if", "(", "$", "name", "===", "null", ")", "{", "throw", "DBALException", "::", "typeNotRegistered", "(", "$", "type", ")", ";", "}", "return", "$", "name", ";", "}" ]
Finds a name for the given type. @throws DBALException
[ "Finds", "a", "name", "for", "the", "given", "type", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Types/TypeRegistry.php#L41-L50
train
doctrine/dbal
lib/Doctrine/DBAL/Types/TypeRegistry.php
TypeRegistry.register
public function register(string $name, Type $type) : void { if (isset($this->instances[$name])) { throw DBALException::typeExists($name); } if ($this->findTypeName($type) !== null) { throw DBALException::typeAlreadyRegistered($type); } $this->instances[$name] = $type; }
php
public function register(string $name, Type $type) : void { if (isset($this->instances[$name])) { throw DBALException::typeExists($name); } if ($this->findTypeName($type) !== null) { throw DBALException::typeAlreadyRegistered($type); } $this->instances[$name] = $type; }
[ "public", "function", "register", "(", "string", "$", "name", ",", "Type", "$", "type", ")", ":", "void", "{", "if", "(", "isset", "(", "$", "this", "->", "instances", "[", "$", "name", "]", ")", ")", "{", "throw", "DBALException", "::", "typeExists", "(", "$", "name", ")", ";", "}", "if", "(", "$", "this", "->", "findTypeName", "(", "$", "type", ")", "!==", "null", ")", "{", "throw", "DBALException", "::", "typeAlreadyRegistered", "(", "$", "type", ")", ";", "}", "$", "this", "->", "instances", "[", "$", "name", "]", "=", "$", "type", ";", "}" ]
Registers a custom type to the type map. @throws DBALException
[ "Registers", "a", "custom", "type", "to", "the", "type", "map", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Types/TypeRegistry.php#L65-L76
train
doctrine/dbal
lib/Doctrine/DBAL/Driver/AbstractOracleDriver/EasyConnectString.php
EasyConnectString.fromConnectionParameters
public static function fromConnectionParameters(array $params) : self { if (! empty($params['connectstring'])) { return new self($params['connectstring']); } if (empty($params['host'])) { return new self($params['dbname'] ?? ''); } $connectData = []; if (isset($params['servicename']) || isset($params['dbname'])) { $serviceKey = 'SID'; if (! empty($params['service'])) { $serviceKey = 'SERVICE_NAME'; } $serviceName = $params['servicename'] ?? $params['dbname']; $connectData[$serviceKey] = $serviceName; } if (! empty($params['instancename'])) { $connectData['INSTANCE_NAME'] = $params['instancename']; } if (! empty($params['pooled'])) { $connectData['SERVER'] = 'POOLED'; } return self::fromArray([ 'DESCRIPTION' => [ 'ADDRESS' => [ 'PROTOCOL' => 'TCP', 'HOST' => $params['host'], 'PORT' => $params['port'] ?? 1521, ], 'CONNECT_DATA' => $connectData, ], ]); }
php
public static function fromConnectionParameters(array $params) : self { if (! empty($params['connectstring'])) { return new self($params['connectstring']); } if (empty($params['host'])) { return new self($params['dbname'] ?? ''); } $connectData = []; if (isset($params['servicename']) || isset($params['dbname'])) { $serviceKey = 'SID'; if (! empty($params['service'])) { $serviceKey = 'SERVICE_NAME'; } $serviceName = $params['servicename'] ?? $params['dbname']; $connectData[$serviceKey] = $serviceName; } if (! empty($params['instancename'])) { $connectData['INSTANCE_NAME'] = $params['instancename']; } if (! empty($params['pooled'])) { $connectData['SERVER'] = 'POOLED'; } return self::fromArray([ 'DESCRIPTION' => [ 'ADDRESS' => [ 'PROTOCOL' => 'TCP', 'HOST' => $params['host'], 'PORT' => $params['port'] ?? 1521, ], 'CONNECT_DATA' => $connectData, ], ]); }
[ "public", "static", "function", "fromConnectionParameters", "(", "array", "$", "params", ")", ":", "self", "{", "if", "(", "!", "empty", "(", "$", "params", "[", "'connectstring'", "]", ")", ")", "{", "return", "new", "self", "(", "$", "params", "[", "'connectstring'", "]", ")", ";", "}", "if", "(", "empty", "(", "$", "params", "[", "'host'", "]", ")", ")", "{", "return", "new", "self", "(", "$", "params", "[", "'dbname'", "]", "??", "''", ")", ";", "}", "$", "connectData", "=", "[", "]", ";", "if", "(", "isset", "(", "$", "params", "[", "'servicename'", "]", ")", "||", "isset", "(", "$", "params", "[", "'dbname'", "]", ")", ")", "{", "$", "serviceKey", "=", "'SID'", ";", "if", "(", "!", "empty", "(", "$", "params", "[", "'service'", "]", ")", ")", "{", "$", "serviceKey", "=", "'SERVICE_NAME'", ";", "}", "$", "serviceName", "=", "$", "params", "[", "'servicename'", "]", "??", "$", "params", "[", "'dbname'", "]", ";", "$", "connectData", "[", "$", "serviceKey", "]", "=", "$", "serviceName", ";", "}", "if", "(", "!", "empty", "(", "$", "params", "[", "'instancename'", "]", ")", ")", "{", "$", "connectData", "[", "'INSTANCE_NAME'", "]", "=", "$", "params", "[", "'instancename'", "]", ";", "}", "if", "(", "!", "empty", "(", "$", "params", "[", "'pooled'", "]", ")", ")", "{", "$", "connectData", "[", "'SERVER'", "]", "=", "'POOLED'", ";", "}", "return", "self", "::", "fromArray", "(", "[", "'DESCRIPTION'", "=>", "[", "'ADDRESS'", "=>", "[", "'PROTOCOL'", "=>", "'TCP'", ",", "'HOST'", "=>", "$", "params", "[", "'host'", "]", ",", "'PORT'", "=>", "$", "params", "[", "'port'", "]", "??", "1521", ",", "]", ",", "'CONNECT_DATA'", "=>", "$", "connectData", ",", "]", ",", "]", ")", ";", "}" ]
Creates the object from the given DBAL connection parameters. @param mixed[] $params
[ "Creates", "the", "object", "from", "the", "given", "DBAL", "connection", "parameters", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Driver/AbstractOracleDriver/EasyConnectString.php#L46-L88
train
doctrine/dbal
lib/Doctrine/DBAL/DBALException.php
DBALException.formatParameters
private static function formatParameters(array $params) { return '[' . implode(', ', array_map(static function ($param) { if (is_resource($param)) { return (string) $param; } $json = @json_encode($param); if (! is_string($json) || $json === 'null' && is_string($param)) { // JSON encoding failed, this is not a UTF-8 string. return sprintf('"%s"', preg_replace('/.{2}/', '\\x$0', bin2hex($param))); } return $json; }, $params)) . ']'; }
php
private static function formatParameters(array $params) { return '[' . implode(', ', array_map(static function ($param) { if (is_resource($param)) { return (string) $param; } $json = @json_encode($param); if (! is_string($json) || $json === 'null' && is_string($param)) { // JSON encoding failed, this is not a UTF-8 string. return sprintf('"%s"', preg_replace('/.{2}/', '\\x$0', bin2hex($param))); } return $json; }, $params)) . ']'; }
[ "private", "static", "function", "formatParameters", "(", "array", "$", "params", ")", "{", "return", "'['", ".", "implode", "(", "', '", ",", "array_map", "(", "static", "function", "(", "$", "param", ")", "{", "if", "(", "is_resource", "(", "$", "param", ")", ")", "{", "return", "(", "string", ")", "$", "param", ";", "}", "$", "json", "=", "@", "json_encode", "(", "$", "param", ")", ";", "if", "(", "!", "is_string", "(", "$", "json", ")", "||", "$", "json", "===", "'null'", "&&", "is_string", "(", "$", "param", ")", ")", "{", "// JSON encoding failed, this is not a UTF-8 string.", "return", "sprintf", "(", "'\"%s\"'", ",", "preg_replace", "(", "'/.{2}/'", ",", "'\\\\x$0'", ",", "bin2hex", "(", "$", "param", ")", ")", ")", ";", "}", "return", "$", "json", ";", "}", ",", "$", "params", ")", ")", ".", "']'", ";", "}" ]
Returns a human-readable representation of an array of parameters. This properly handles binary data by returning a hex representation. @param mixed[] $params @return string
[ "Returns", "a", "human", "-", "readable", "representation", "of", "an", "array", "of", "parameters", ".", "This", "properly", "handles", "binary", "data", "by", "returning", "a", "hex", "representation", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/DBALException.php#L180-L196
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php
PostgreSqlSchemaManager.getSchemaSearchPaths
public function getSchemaSearchPaths() { $params = $this->_conn->getParams(); $schema = explode(',', $this->_conn->fetchColumn('SHOW search_path')); if (isset($params['user'])) { $schema = str_replace('"$user"', $params['user'], $schema); } return array_map('trim', $schema); }
php
public function getSchemaSearchPaths() { $params = $this->_conn->getParams(); $schema = explode(',', $this->_conn->fetchColumn('SHOW search_path')); if (isset($params['user'])) { $schema = str_replace('"$user"', $params['user'], $schema); } return array_map('trim', $schema); }
[ "public", "function", "getSchemaSearchPaths", "(", ")", "{", "$", "params", "=", "$", "this", "->", "_conn", "->", "getParams", "(", ")", ";", "$", "schema", "=", "explode", "(", "','", ",", "$", "this", "->", "_conn", "->", "fetchColumn", "(", "'SHOW search_path'", ")", ")", ";", "if", "(", "isset", "(", "$", "params", "[", "'user'", "]", ")", ")", "{", "$", "schema", "=", "str_replace", "(", "'\"$user\"'", ",", "$", "params", "[", "'user'", "]", ",", "$", "schema", ")", ";", "}", "return", "array_map", "(", "'trim'", ",", "$", "schema", ")", ";", "}" ]
Returns an array of schema search paths. This is a PostgreSQL only function. @return string[]
[ "Returns", "an", "array", "of", "schema", "search", "paths", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php#L56-L66
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php
PostgreSqlSchemaManager.determineExistingSchemaSearchPaths
public function determineExistingSchemaSearchPaths() { $names = $this->getSchemaNames(); $paths = $this->getSchemaSearchPaths(); $this->existingSchemaPaths = array_filter($paths, static function ($v) use ($names) { return in_array($v, $names); }); }
php
public function determineExistingSchemaSearchPaths() { $names = $this->getSchemaNames(); $paths = $this->getSchemaSearchPaths(); $this->existingSchemaPaths = array_filter($paths, static function ($v) use ($names) { return in_array($v, $names); }); }
[ "public", "function", "determineExistingSchemaSearchPaths", "(", ")", "{", "$", "names", "=", "$", "this", "->", "getSchemaNames", "(", ")", ";", "$", "paths", "=", "$", "this", "->", "getSchemaSearchPaths", "(", ")", ";", "$", "this", "->", "existingSchemaPaths", "=", "array_filter", "(", "$", "paths", ",", "static", "function", "(", "$", "v", ")", "use", "(", "$", "names", ")", "{", "return", "in_array", "(", "$", "v", ",", "$", "names", ")", ";", "}", ")", ";", "}" ]
Sets or resets the order of the existing schemas in the current search path of the user. This is a PostgreSQL only function. @return void
[ "Sets", "or", "resets", "the", "order", "of", "the", "existing", "schemas", "in", "the", "current", "search", "path", "of", "the", "user", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php#L91-L99
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/Schema.php
Schema.hasNamespace
public function hasNamespace($namespaceName) { $namespaceName = strtolower($this->getUnquotedAssetName($namespaceName)); return isset($this->namespaces[$namespaceName]); }
php
public function hasNamespace($namespaceName) { $namespaceName = strtolower($this->getUnquotedAssetName($namespaceName)); return isset($this->namespaces[$namespaceName]); }
[ "public", "function", "hasNamespace", "(", "$", "namespaceName", ")", "{", "$", "namespaceName", "=", "strtolower", "(", "$", "this", "->", "getUnquotedAssetName", "(", "$", "namespaceName", ")", ")", ";", "return", "isset", "(", "$", "this", "->", "namespaces", "[", "$", "namespaceName", "]", ")", ";", "}" ]
Does this schema have a namespace with the given name? @param string $namespaceName @return bool
[ "Does", "this", "schema", "have", "a", "namespace", "with", "the", "given", "name?" ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/Schema.php#L217-L222
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/Schema.php
Schema.hasTable
public function hasTable($tableName) { $tableName = $this->getFullQualifiedAssetName($tableName); return isset($this->_tables[$tableName]); }
php
public function hasTable($tableName) { $tableName = $this->getFullQualifiedAssetName($tableName); return isset($this->_tables[$tableName]); }
[ "public", "function", "hasTable", "(", "$", "tableName", ")", "{", "$", "tableName", "=", "$", "this", "->", "getFullQualifiedAssetName", "(", "$", "tableName", ")", ";", "return", "isset", "(", "$", "this", "->", "_tables", "[", "$", "tableName", "]", ")", ";", "}" ]
Does this schema have a table with the given name? @param string $tableName @return bool
[ "Does", "this", "schema", "have", "a", "table", "with", "the", "given", "name?" ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/Schema.php#L231-L236
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/Schema.php
Schema.createNamespace
public function createNamespace($namespaceName) { $unquotedNamespaceName = strtolower($this->getUnquotedAssetName($namespaceName)); if (isset($this->namespaces[$unquotedNamespaceName])) { throw SchemaException::namespaceAlreadyExists($unquotedNamespaceName); } $this->namespaces[$unquotedNamespaceName] = $namespaceName; return $this; }
php
public function createNamespace($namespaceName) { $unquotedNamespaceName = strtolower($this->getUnquotedAssetName($namespaceName)); if (isset($this->namespaces[$unquotedNamespaceName])) { throw SchemaException::namespaceAlreadyExists($unquotedNamespaceName); } $this->namespaces[$unquotedNamespaceName] = $namespaceName; return $this; }
[ "public", "function", "createNamespace", "(", "$", "namespaceName", ")", "{", "$", "unquotedNamespaceName", "=", "strtolower", "(", "$", "this", "->", "getUnquotedAssetName", "(", "$", "namespaceName", ")", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "namespaces", "[", "$", "unquotedNamespaceName", "]", ")", ")", "{", "throw", "SchemaException", "::", "namespaceAlreadyExists", "(", "$", "unquotedNamespaceName", ")", ";", "}", "$", "this", "->", "namespaces", "[", "$", "unquotedNamespaceName", "]", "=", "$", "namespaceName", ";", "return", "$", "this", ";", "}" ]
Creates a new namespace. @param string $namespaceName The name of the namespace to create. @return \Doctrine\DBAL\Schema\Schema This schema instance. @throws SchemaException
[ "Creates", "a", "new", "namespace", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/Schema.php#L294-L305
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/Schema.php
Schema.dropTable
public function dropTable($tableName) { $tableName = $this->getFullQualifiedAssetName($tableName); $this->getTable($tableName); unset($this->_tables[$tableName]); return $this; }
php
public function dropTable($tableName) { $tableName = $this->getFullQualifiedAssetName($tableName); $this->getTable($tableName); unset($this->_tables[$tableName]); return $this; }
[ "public", "function", "dropTable", "(", "$", "tableName", ")", "{", "$", "tableName", "=", "$", "this", "->", "getFullQualifiedAssetName", "(", "$", "tableName", ")", ";", "$", "this", "->", "getTable", "(", "$", "tableName", ")", ";", "unset", "(", "$", "this", "->", "_tables", "[", "$", "tableName", "]", ")", ";", "return", "$", "this", ";", "}" ]
Drops a table from the schema. @param string $tableName @return \Doctrine\DBAL\Schema\Schema
[ "Drops", "a", "table", "from", "the", "schema", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/Schema.php#L352-L359
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/Schema.php
Schema.createSequence
public function createSequence($sequenceName, $allocationSize = 1, $initialValue = 1) { $seq = new Sequence($sequenceName, $allocationSize, $initialValue); $this->_addSequence($seq); return $seq; }
php
public function createSequence($sequenceName, $allocationSize = 1, $initialValue = 1) { $seq = new Sequence($sequenceName, $allocationSize, $initialValue); $this->_addSequence($seq); return $seq; }
[ "public", "function", "createSequence", "(", "$", "sequenceName", ",", "$", "allocationSize", "=", "1", ",", "$", "initialValue", "=", "1", ")", "{", "$", "seq", "=", "new", "Sequence", "(", "$", "sequenceName", ",", "$", "allocationSize", ",", "$", "initialValue", ")", ";", "$", "this", "->", "_addSequence", "(", "$", "seq", ")", ";", "return", "$", "seq", ";", "}" ]
Creates a new sequence. @param string $sequenceName @param int $allocationSize @param int $initialValue @return Sequence
[ "Creates", "a", "new", "sequence", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/Schema.php#L370-L376
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/Schema.php
Schema.toSql
public function toSql(AbstractPlatform $platform) { $sqlCollector = new CreateSchemaSqlCollector($platform); $this->visit($sqlCollector); return $sqlCollector->getQueries(); }
php
public function toSql(AbstractPlatform $platform) { $sqlCollector = new CreateSchemaSqlCollector($platform); $this->visit($sqlCollector); return $sqlCollector->getQueries(); }
[ "public", "function", "toSql", "(", "AbstractPlatform", "$", "platform", ")", "{", "$", "sqlCollector", "=", "new", "CreateSchemaSqlCollector", "(", "$", "platform", ")", ";", "$", "this", "->", "visit", "(", "$", "sqlCollector", ")", ";", "return", "$", "sqlCollector", "->", "getQueries", "(", ")", ";", "}" ]
Returns an array of necessary SQL queries to create the schema on the given platform. @return string[]
[ "Returns", "an", "array", "of", "necessary", "SQL", "queries", "to", "create", "the", "schema", "on", "the", "given", "platform", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/Schema.php#L396-L402
train
doctrine/dbal
lib/Doctrine/DBAL/Schema/Schema.php
Schema.toDropSql
public function toDropSql(AbstractPlatform $platform) { $dropSqlCollector = new DropSchemaSqlCollector($platform); $this->visit($dropSqlCollector); return $dropSqlCollector->getQueries(); }
php
public function toDropSql(AbstractPlatform $platform) { $dropSqlCollector = new DropSchemaSqlCollector($platform); $this->visit($dropSqlCollector); return $dropSqlCollector->getQueries(); }
[ "public", "function", "toDropSql", "(", "AbstractPlatform", "$", "platform", ")", "{", "$", "dropSqlCollector", "=", "new", "DropSchemaSqlCollector", "(", "$", "platform", ")", ";", "$", "this", "->", "visit", "(", "$", "dropSqlCollector", ")", ";", "return", "$", "dropSqlCollector", "->", "getQueries", "(", ")", ";", "}" ]
Return an array of necessary SQL queries to drop the schema on the given platform. @return string[]
[ "Return", "an", "array", "of", "necessary", "SQL", "queries", "to", "drop", "the", "schema", "on", "the", "given", "platform", "." ]
e4978c2299d4d8e4f39da94f4d567e698e9bdbeb
https://github.com/doctrine/dbal/blob/e4978c2299d4d8e4f39da94f4d567e698e9bdbeb/lib/Doctrine/DBAL/Schema/Schema.php#L409-L415
train
composer/satis
src/PackageSelection/PackageSelection.php
PackageSelection.createStripHostsPatterns
private function createStripHostsPatterns($stripHostsConfig) { if (!is_array($stripHostsConfig)) { return $stripHostsConfig; } $patterns = []; foreach ($stripHostsConfig as $entry) { if (!strlen($entry)) { continue; } if ('/private' === $entry || '/local' === $entry) { $patterns[] = [$entry]; continue; } elseif (false !== strpos($entry, ':')) { $type = 'ipv6'; if (!defined('AF_INET6')) { $this->output->writeln('<error>Unable to use IPv6.</error>'); continue; } } elseif (0 === preg_match('#[^/.\\d]#', $entry)) { $type = 'ipv4'; } else { $type = 'name'; $host = '#^(?:.+\.)?' . preg_quote($entry, '#') . '$#ui'; $patterns[] = [$type, $host]; continue; } @list($host, $mask) = explode('/', $entry, 2); $host = @inet_pton($host); if (false === $host || (int) $mask != $mask) { $this->output->writeln(sprintf('<error>Invalid subnet "%s"</error>', $entry)); continue; } $host = unpack('N*', $host); if (null === $mask) { $mask = 'ipv4' === $type ? 32 : 128; } else { $mask = (int) $mask; if ($mask < 0 || 'ipv4' === $type && $mask > 32 || 'ipv6' === $type && $mask > 128) { continue; } } $patterns[] = [$type, $host, $mask]; } return $patterns; }
php
private function createStripHostsPatterns($stripHostsConfig) { if (!is_array($stripHostsConfig)) { return $stripHostsConfig; } $patterns = []; foreach ($stripHostsConfig as $entry) { if (!strlen($entry)) { continue; } if ('/private' === $entry || '/local' === $entry) { $patterns[] = [$entry]; continue; } elseif (false !== strpos($entry, ':')) { $type = 'ipv6'; if (!defined('AF_INET6')) { $this->output->writeln('<error>Unable to use IPv6.</error>'); continue; } } elseif (0 === preg_match('#[^/.\\d]#', $entry)) { $type = 'ipv4'; } else { $type = 'name'; $host = '#^(?:.+\.)?' . preg_quote($entry, '#') . '$#ui'; $patterns[] = [$type, $host]; continue; } @list($host, $mask) = explode('/', $entry, 2); $host = @inet_pton($host); if (false === $host || (int) $mask != $mask) { $this->output->writeln(sprintf('<error>Invalid subnet "%s"</error>', $entry)); continue; } $host = unpack('N*', $host); if (null === $mask) { $mask = 'ipv4' === $type ? 32 : 128; } else { $mask = (int) $mask; if ($mask < 0 || 'ipv4' === $type && $mask > 32 || 'ipv6' === $type && $mask > 128) { continue; } } $patterns[] = [$type, $host, $mask]; } return $patterns; }
[ "private", "function", "createStripHostsPatterns", "(", "$", "stripHostsConfig", ")", "{", "if", "(", "!", "is_array", "(", "$", "stripHostsConfig", ")", ")", "{", "return", "$", "stripHostsConfig", ";", "}", "$", "patterns", "=", "[", "]", ";", "foreach", "(", "$", "stripHostsConfig", "as", "$", "entry", ")", "{", "if", "(", "!", "strlen", "(", "$", "entry", ")", ")", "{", "continue", ";", "}", "if", "(", "'/private'", "===", "$", "entry", "||", "'/local'", "===", "$", "entry", ")", "{", "$", "patterns", "[", "]", "=", "[", "$", "entry", "]", ";", "continue", ";", "}", "elseif", "(", "false", "!==", "strpos", "(", "$", "entry", ",", "':'", ")", ")", "{", "$", "type", "=", "'ipv6'", ";", "if", "(", "!", "defined", "(", "'AF_INET6'", ")", ")", "{", "$", "this", "->", "output", "->", "writeln", "(", "'<error>Unable to use IPv6.</error>'", ")", ";", "continue", ";", "}", "}", "elseif", "(", "0", "===", "preg_match", "(", "'#[^/.\\\\d]#'", ",", "$", "entry", ")", ")", "{", "$", "type", "=", "'ipv4'", ";", "}", "else", "{", "$", "type", "=", "'name'", ";", "$", "host", "=", "'#^(?:.+\\.)?'", ".", "preg_quote", "(", "$", "entry", ",", "'#'", ")", ".", "'$#ui'", ";", "$", "patterns", "[", "]", "=", "[", "$", "type", ",", "$", "host", "]", ";", "continue", ";", "}", "@", "list", "(", "$", "host", ",", "$", "mask", ")", "=", "explode", "(", "'/'", ",", "$", "entry", ",", "2", ")", ";", "$", "host", "=", "@", "inet_pton", "(", "$", "host", ")", ";", "if", "(", "false", "===", "$", "host", "||", "(", "int", ")", "$", "mask", "!=", "$", "mask", ")", "{", "$", "this", "->", "output", "->", "writeln", "(", "sprintf", "(", "'<error>Invalid subnet \"%s\"</error>'", ",", "$", "entry", ")", ")", ";", "continue", ";", "}", "$", "host", "=", "unpack", "(", "'N*'", ",", "$", "host", ")", ";", "if", "(", "null", "===", "$", "mask", ")", "{", "$", "mask", "=", "'ipv4'", "===", "$", "type", "?", "32", ":", "128", ";", "}", "else", "{", "$", "mask", "=", "(", "int", ")", "$", "mask", ";", "if", "(", "$", "mask", "<", "0", "||", "'ipv4'", "===", "$", "type", "&&", "$", "mask", ">", "32", "||", "'ipv6'", "===", "$", "type", "&&", "$", "mask", ">", "128", ")", "{", "continue", ";", "}", "}", "$", "patterns", "[", "]", "=", "[", "$", "type", ",", "$", "host", ",", "$", "mask", "]", ";", "}", "return", "$", "patterns", ";", "}" ]
Create patterns from strip-hosts @param array|false $stripHostsConfig @return array|false
[ "Create", "patterns", "from", "strip", "-", "hosts" ]
284570854f4b8d4c8388c9970d90f1bfe47d6b55
https://github.com/composer/satis/blob/284570854f4b8d4c8388c9970d90f1bfe47d6b55/src/PackageSelection/PackageSelection.php#L286-L342
train
composer/satis
src/PackageSelection/PackageSelection.php
PackageSelection.applyStripHosts
private function applyStripHosts() { if (false === $this->stripHosts) { return; } foreach ($this->selected as $uniqueName => $package) { $sources = []; if ($package->getSourceType()) { $sources[] = 'source'; } if ($package->getDistType()) { $sources[] = 'dist'; } foreach ($sources as $i => $s) { $url = 'source' === $s ? $package->getSourceUrl() : $package->getDistUrl(); // skip distURL applied by ArchiveBuilder if ('dist' === $s && null !== $this->archiveEndpoint && substr($url, 0, strlen($this->archiveEndpoint)) === $this->archiveEndpoint ) { continue; } if ($this->matchStripHostsPatterns($url)) { if ('dist' === $s) { // if the type is not set, ArrayDumper ignores the other properties $package->setDistType(null); } else { $package->setSourceType(null); } unset($sources[$i]); if (0 === count($sources)) { $this->output->writeln(sprintf('<error>%s has no source left after applying the strip-hosts filters and will be removed</error>', $package->getUniqueName())); unset($this->selected[$uniqueName]); } } } } }
php
private function applyStripHosts() { if (false === $this->stripHosts) { return; } foreach ($this->selected as $uniqueName => $package) { $sources = []; if ($package->getSourceType()) { $sources[] = 'source'; } if ($package->getDistType()) { $sources[] = 'dist'; } foreach ($sources as $i => $s) { $url = 'source' === $s ? $package->getSourceUrl() : $package->getDistUrl(); // skip distURL applied by ArchiveBuilder if ('dist' === $s && null !== $this->archiveEndpoint && substr($url, 0, strlen($this->archiveEndpoint)) === $this->archiveEndpoint ) { continue; } if ($this->matchStripHostsPatterns($url)) { if ('dist' === $s) { // if the type is not set, ArrayDumper ignores the other properties $package->setDistType(null); } else { $package->setSourceType(null); } unset($sources[$i]); if (0 === count($sources)) { $this->output->writeln(sprintf('<error>%s has no source left after applying the strip-hosts filters and will be removed</error>', $package->getUniqueName())); unset($this->selected[$uniqueName]); } } } } }
[ "private", "function", "applyStripHosts", "(", ")", "{", "if", "(", "false", "===", "$", "this", "->", "stripHosts", ")", "{", "return", ";", "}", "foreach", "(", "$", "this", "->", "selected", "as", "$", "uniqueName", "=>", "$", "package", ")", "{", "$", "sources", "=", "[", "]", ";", "if", "(", "$", "package", "->", "getSourceType", "(", ")", ")", "{", "$", "sources", "[", "]", "=", "'source'", ";", "}", "if", "(", "$", "package", "->", "getDistType", "(", ")", ")", "{", "$", "sources", "[", "]", "=", "'dist'", ";", "}", "foreach", "(", "$", "sources", "as", "$", "i", "=>", "$", "s", ")", "{", "$", "url", "=", "'source'", "===", "$", "s", "?", "$", "package", "->", "getSourceUrl", "(", ")", ":", "$", "package", "->", "getDistUrl", "(", ")", ";", "// skip distURL applied by ArchiveBuilder", "if", "(", "'dist'", "===", "$", "s", "&&", "null", "!==", "$", "this", "->", "archiveEndpoint", "&&", "substr", "(", "$", "url", ",", "0", ",", "strlen", "(", "$", "this", "->", "archiveEndpoint", ")", ")", "===", "$", "this", "->", "archiveEndpoint", ")", "{", "continue", ";", "}", "if", "(", "$", "this", "->", "matchStripHostsPatterns", "(", "$", "url", ")", ")", "{", "if", "(", "'dist'", "===", "$", "s", ")", "{", "// if the type is not set, ArrayDumper ignores the other properties", "$", "package", "->", "setDistType", "(", "null", ")", ";", "}", "else", "{", "$", "package", "->", "setSourceType", "(", "null", ")", ";", "}", "unset", "(", "$", "sources", "[", "$", "i", "]", ")", ";", "if", "(", "0", "===", "count", "(", "$", "sources", ")", ")", "{", "$", "this", "->", "output", "->", "writeln", "(", "sprintf", "(", "'<error>%s has no source left after applying the strip-hosts filters and will be removed</error>'", ",", "$", "package", "->", "getUniqueName", "(", ")", ")", ")", ";", "unset", "(", "$", "this", "->", "selected", "[", "$", "uniqueName", "]", ")", ";", "}", "}", "}", "}", "}" ]
Apply the patterns from strip-hosts
[ "Apply", "the", "patterns", "from", "strip", "-", "hosts" ]
284570854f4b8d4c8388c9970d90f1bfe47d6b55
https://github.com/composer/satis/blob/284570854f4b8d4c8388c9970d90f1bfe47d6b55/src/PackageSelection/PackageSelection.php#L347-L391
train
composer/satis
src/PackageSelection/PackageSelection.php
PackageSelection.matchStripHostsPatterns
private function matchStripHostsPatterns($url) { if (Filesystem::isLocalPath($url)) { return true; } if (is_array($this->stripHosts)) { $url = trim(parse_url($url, PHP_URL_HOST), '[]'); if (false !== filter_var($url, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { $urltype = 'ipv4'; } elseif (false !== filter_var($url, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { $urltype = 'ipv6'; } else { $urltype = 'name'; } if ('ipv4' === $urltype || 'ipv6' === $urltype) { $urlunpack = unpack('N*', @inet_pton($url)); } foreach ($this->stripHosts as $pattern) { @list($type, $host, $mask) = $pattern; if ('/local' === $type) { if ('name' === $urltype && 'localhost' === strtolower($url) || ('ipv4' === $urltype || 'ipv6' === $urltype) && false === filter_var($url, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE) ) { return true; } } elseif ('/private' === $type) { if (('ipv4' === $urltype || 'ipv6' === $urltype) && false === filter_var($url, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE) ) { return true; } } elseif ('ipv4' === $type || 'ipv6' === $type) { if ($urltype === $type && $this->matchAddr($urlunpack, $host, $mask)) { return true; } } elseif ('name' === $type) { if ('name' === $urltype && preg_match($host, $url)) { return true; } } } } }
php
private function matchStripHostsPatterns($url) { if (Filesystem::isLocalPath($url)) { return true; } if (is_array($this->stripHosts)) { $url = trim(parse_url($url, PHP_URL_HOST), '[]'); if (false !== filter_var($url, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { $urltype = 'ipv4'; } elseif (false !== filter_var($url, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { $urltype = 'ipv6'; } else { $urltype = 'name'; } if ('ipv4' === $urltype || 'ipv6' === $urltype) { $urlunpack = unpack('N*', @inet_pton($url)); } foreach ($this->stripHosts as $pattern) { @list($type, $host, $mask) = $pattern; if ('/local' === $type) { if ('name' === $urltype && 'localhost' === strtolower($url) || ('ipv4' === $urltype || 'ipv6' === $urltype) && false === filter_var($url, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE) ) { return true; } } elseif ('/private' === $type) { if (('ipv4' === $urltype || 'ipv6' === $urltype) && false === filter_var($url, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE) ) { return true; } } elseif ('ipv4' === $type || 'ipv6' === $type) { if ($urltype === $type && $this->matchAddr($urlunpack, $host, $mask)) { return true; } } elseif ('name' === $type) { if ('name' === $urltype && preg_match($host, $url)) { return true; } } } } }
[ "private", "function", "matchStripHostsPatterns", "(", "$", "url", ")", "{", "if", "(", "Filesystem", "::", "isLocalPath", "(", "$", "url", ")", ")", "{", "return", "true", ";", "}", "if", "(", "is_array", "(", "$", "this", "->", "stripHosts", ")", ")", "{", "$", "url", "=", "trim", "(", "parse_url", "(", "$", "url", ",", "PHP_URL_HOST", ")", ",", "'[]'", ")", ";", "if", "(", "false", "!==", "filter_var", "(", "$", "url", ",", "FILTER_VALIDATE_IP", ",", "FILTER_FLAG_IPV4", ")", ")", "{", "$", "urltype", "=", "'ipv4'", ";", "}", "elseif", "(", "false", "!==", "filter_var", "(", "$", "url", ",", "FILTER_VALIDATE_IP", ",", "FILTER_FLAG_IPV6", ")", ")", "{", "$", "urltype", "=", "'ipv6'", ";", "}", "else", "{", "$", "urltype", "=", "'name'", ";", "}", "if", "(", "'ipv4'", "===", "$", "urltype", "||", "'ipv6'", "===", "$", "urltype", ")", "{", "$", "urlunpack", "=", "unpack", "(", "'N*'", ",", "@", "inet_pton", "(", "$", "url", ")", ")", ";", "}", "foreach", "(", "$", "this", "->", "stripHosts", "as", "$", "pattern", ")", "{", "@", "list", "(", "$", "type", ",", "$", "host", ",", "$", "mask", ")", "=", "$", "pattern", ";", "if", "(", "'/local'", "===", "$", "type", ")", "{", "if", "(", "'name'", "===", "$", "urltype", "&&", "'localhost'", "===", "strtolower", "(", "$", "url", ")", "||", "(", "'ipv4'", "===", "$", "urltype", "||", "'ipv6'", "===", "$", "urltype", ")", "&&", "false", "===", "filter_var", "(", "$", "url", ",", "FILTER_VALIDATE_IP", ",", "FILTER_FLAG_NO_RES_RANGE", ")", ")", "{", "return", "true", ";", "}", "}", "elseif", "(", "'/private'", "===", "$", "type", ")", "{", "if", "(", "(", "'ipv4'", "===", "$", "urltype", "||", "'ipv6'", "===", "$", "urltype", ")", "&&", "false", "===", "filter_var", "(", "$", "url", ",", "FILTER_VALIDATE_IP", ",", "FILTER_FLAG_NO_PRIV_RANGE", ")", ")", "{", "return", "true", ";", "}", "}", "elseif", "(", "'ipv4'", "===", "$", "type", "||", "'ipv6'", "===", "$", "type", ")", "{", "if", "(", "$", "urltype", "===", "$", "type", "&&", "$", "this", "->", "matchAddr", "(", "$", "urlunpack", ",", "$", "host", ",", "$", "mask", ")", ")", "{", "return", "true", ";", "}", "}", "elseif", "(", "'name'", "===", "$", "type", ")", "{", "if", "(", "'name'", "===", "$", "urltype", "&&", "preg_match", "(", "$", "host", ",", "$", "url", ")", ")", "{", "return", "true", ";", "}", "}", "}", "}", "}" ]
Match an URL against the patterns from strip-hosts @return bool
[ "Match", "an", "URL", "against", "the", "patterns", "from", "strip", "-", "hosts" ]
284570854f4b8d4c8388c9970d90f1bfe47d6b55
https://github.com/composer/satis/blob/284570854f4b8d4c8388c9970d90f1bfe47d6b55/src/PackageSelection/PackageSelection.php#L398-L446
train
composer/satis
src/PackageSelection/PackageSelection.php
PackageSelection.matchAddr
private function matchAddr($addr1, $addr2, $len = 0, $chunklen = 32) { for (; $len > 0; $len -= $chunklen, next($addr1), next($addr2)) { $shift = $len >= $chunklen ? 0 : $chunklen - $len; if ((current($addr1) >> $shift) !== (current($addr2) >> $shift)) { return false; } } return true; }
php
private function matchAddr($addr1, $addr2, $len = 0, $chunklen = 32) { for (; $len > 0; $len -= $chunklen, next($addr1), next($addr2)) { $shift = $len >= $chunklen ? 0 : $chunklen - $len; if ((current($addr1) >> $shift) !== (current($addr2) >> $shift)) { return false; } } return true; }
[ "private", "function", "matchAddr", "(", "$", "addr1", ",", "$", "addr2", ",", "$", "len", "=", "0", ",", "$", "chunklen", "=", "32", ")", "{", "for", "(", ";", "$", "len", ">", "0", ";", "$", "len", "-=", "$", "chunklen", ",", "next", "(", "$", "addr1", ")", ",", "next", "(", "$", "addr2", ")", ")", "{", "$", "shift", "=", "$", "len", ">=", "$", "chunklen", "?", "0", ":", "$", "chunklen", "-", "$", "len", ";", "if", "(", "(", "current", "(", "$", "addr1", ")", ">>", "$", "shift", ")", "!==", "(", "current", "(", "$", "addr2", ")", ">>", "$", "shift", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Test if two addresses have the same prefix @param int[] $addr1 Chunked addr @param int[] $addr2 Chunked addr @param int $len Length of the test @param int $chunklen Length of each chunk @return bool
[ "Test", "if", "two", "addresses", "have", "the", "same", "prefix" ]
284570854f4b8d4c8388c9970d90f1bfe47d6b55
https://github.com/composer/satis/blob/284570854f4b8d4c8388c9970d90f1bfe47d6b55/src/PackageSelection/PackageSelection.php#L462-L472
train
composer/satis
src/PackageSelection/PackageSelection.php
PackageSelection.addRepositories
private function addRepositories(Pool $pool, array $repos) { foreach ($repos as $repo) { try { $pool->addRepository($repo); } catch (\Exception $exception) { if (!$this->skipErrors) { throw $exception; } $this->output->writeln(sprintf("<error>Skipping Exception '%s'.</error>", $exception->getMessage())); } } }
php
private function addRepositories(Pool $pool, array $repos) { foreach ($repos as $repo) { try { $pool->addRepository($repo); } catch (\Exception $exception) { if (!$this->skipErrors) { throw $exception; } $this->output->writeln(sprintf("<error>Skipping Exception '%s'.</error>", $exception->getMessage())); } } }
[ "private", "function", "addRepositories", "(", "Pool", "$", "pool", ",", "array", "$", "repos", ")", "{", "foreach", "(", "$", "repos", "as", "$", "repo", ")", "{", "try", "{", "$", "pool", "->", "addRepository", "(", "$", "repo", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "exception", ")", "{", "if", "(", "!", "$", "this", "->", "skipErrors", ")", "{", "throw", "$", "exception", ";", "}", "$", "this", "->", "output", "->", "writeln", "(", "sprintf", "(", "\"<error>Skipping Exception '%s'.</error>\"", ",", "$", "exception", "->", "getMessage", "(", ")", ")", ")", ";", "}", "}", "}" ]
Add repositories to a pool @param Pool $pool The Pool instance @param RepositoryInterface[] $repos Array of repositories
[ "Add", "repositories", "to", "a", "pool" ]
284570854f4b8d4c8388c9970d90f1bfe47d6b55
https://github.com/composer/satis/blob/284570854f4b8d4c8388c9970d90f1bfe47d6b55/src/PackageSelection/PackageSelection.php#L482-L495
train
composer/satis
src/PackageSelection/PackageSelection.php
PackageSelection.setSelectedAsAbandoned
private function setSelectedAsAbandoned() { foreach ($this->selected as $name => $package) { if (array_key_exists($package->getName(), $this->abandoned)) { $package->setAbandoned($this->abandoned[$package->getName()]); } } }
php
private function setSelectedAsAbandoned() { foreach ($this->selected as $name => $package) { if (array_key_exists($package->getName(), $this->abandoned)) { $package->setAbandoned($this->abandoned[$package->getName()]); } } }
[ "private", "function", "setSelectedAsAbandoned", "(", ")", "{", "foreach", "(", "$", "this", "->", "selected", "as", "$", "name", "=>", "$", "package", ")", "{", "if", "(", "array_key_exists", "(", "$", "package", "->", "getName", "(", ")", ",", "$", "this", "->", "abandoned", ")", ")", "{", "$", "package", "->", "setAbandoned", "(", "$", "this", "->", "abandoned", "[", "$", "package", "->", "getName", "(", ")", "]", ")", ";", "}", "}", "}" ]
Marks selected packages as abandoned by Configuration file
[ "Marks", "selected", "packages", "as", "abandoned", "by", "Configuration", "file" ]
284570854f4b8d4c8388c9970d90f1bfe47d6b55
https://github.com/composer/satis/blob/284570854f4b8d4c8388c9970d90f1bfe47d6b55/src/PackageSelection/PackageSelection.php#L500-L507
train
composer/satis
src/PackageSelection/PackageSelection.php
PackageSelection.getFilteredLinks
private function getFilteredLinks(Composer $composer) { $links = array_values($composer->getPackage()->getRequires()); // only pick up packages in our filter, if a filter has been set. if ($this->hasFilterForPackages()) { $packagesFilter = $this->packagesFilter; $links = array_filter($links, function (Link $link) use ($packagesFilter) { return in_array($link->getTarget(), $packagesFilter); }); } return array_values($links); }
php
private function getFilteredLinks(Composer $composer) { $links = array_values($composer->getPackage()->getRequires()); // only pick up packages in our filter, if a filter has been set. if ($this->hasFilterForPackages()) { $packagesFilter = $this->packagesFilter; $links = array_filter($links, function (Link $link) use ($packagesFilter) { return in_array($link->getTarget(), $packagesFilter); }); } return array_values($links); }
[ "private", "function", "getFilteredLinks", "(", "Composer", "$", "composer", ")", "{", "$", "links", "=", "array_values", "(", "$", "composer", "->", "getPackage", "(", ")", "->", "getRequires", "(", ")", ")", ";", "// only pick up packages in our filter, if a filter has been set.", "if", "(", "$", "this", "->", "hasFilterForPackages", "(", ")", ")", "{", "$", "packagesFilter", "=", "$", "this", "->", "packagesFilter", ";", "$", "links", "=", "array_filter", "(", "$", "links", ",", "function", "(", "Link", "$", "link", ")", "use", "(", "$", "packagesFilter", ")", "{", "return", "in_array", "(", "$", "link", "->", "getTarget", "(", ")", ",", "$", "packagesFilter", ")", ";", "}", ")", ";", "}", "return", "array_values", "(", "$", "links", ")", ";", "}" ]
Gets a list of filtered Links. @param Composer $composer The Composer instance @return Link[]
[ "Gets", "a", "list", "of", "filtered", "Links", "." ]
284570854f4b8d4c8388c9970d90f1bfe47d6b55
https://github.com/composer/satis/blob/284570854f4b8d4c8388c9970d90f1bfe47d6b55/src/PackageSelection/PackageSelection.php#L516-L529
train
composer/satis
src/PackageSelection/PackageSelection.php
PackageSelection.getAllLinks
private function getAllLinks($repos, $minimumStability, $verbose) { $links = []; foreach ($repos as $repo) { // collect links for composer repos with providers if ($repo instanceof ComposerRepository && $repo->hasProviders()) { foreach ($repo->getProviderNames() as $name) { $links[] = new Link('__root__', $name, new EmptyConstraint(), 'requires', '*'); } } else { $packages = $this->getPackages($repo); foreach ($packages as $package) { // skip aliases if ($package instanceof AliasPackage) { continue; } if (BasePackage::$stabilities[$package->getStability()] > BasePackage::$stabilities[$minimumStability]) { if ($verbose) { $this->output->writeln('Skipped ' . $package->getPrettyName() . ' (' . $package->getStability() . ')'); } continue; } $links[] = $package; } } } return $links; }
php
private function getAllLinks($repos, $minimumStability, $verbose) { $links = []; foreach ($repos as $repo) { // collect links for composer repos with providers if ($repo instanceof ComposerRepository && $repo->hasProviders()) { foreach ($repo->getProviderNames() as $name) { $links[] = new Link('__root__', $name, new EmptyConstraint(), 'requires', '*'); } } else { $packages = $this->getPackages($repo); foreach ($packages as $package) { // skip aliases if ($package instanceof AliasPackage) { continue; } if (BasePackage::$stabilities[$package->getStability()] > BasePackage::$stabilities[$minimumStability]) { if ($verbose) { $this->output->writeln('Skipped ' . $package->getPrettyName() . ' (' . $package->getStability() . ')'); } continue; } $links[] = $package; } } } return $links; }
[ "private", "function", "getAllLinks", "(", "$", "repos", ",", "$", "minimumStability", ",", "$", "verbose", ")", "{", "$", "links", "=", "[", "]", ";", "foreach", "(", "$", "repos", "as", "$", "repo", ")", "{", "// collect links for composer repos with providers", "if", "(", "$", "repo", "instanceof", "ComposerRepository", "&&", "$", "repo", "->", "hasProviders", "(", ")", ")", "{", "foreach", "(", "$", "repo", "->", "getProviderNames", "(", ")", "as", "$", "name", ")", "{", "$", "links", "[", "]", "=", "new", "Link", "(", "'__root__'", ",", "$", "name", ",", "new", "EmptyConstraint", "(", ")", ",", "'requires'", ",", "'*'", ")", ";", "}", "}", "else", "{", "$", "packages", "=", "$", "this", "->", "getPackages", "(", "$", "repo", ")", ";", "foreach", "(", "$", "packages", "as", "$", "package", ")", "{", "// skip aliases", "if", "(", "$", "package", "instanceof", "AliasPackage", ")", "{", "continue", ";", "}", "if", "(", "BasePackage", "::", "$", "stabilities", "[", "$", "package", "->", "getStability", "(", ")", "]", ">", "BasePackage", "::", "$", "stabilities", "[", "$", "minimumStability", "]", ")", "{", "if", "(", "$", "verbose", ")", "{", "$", "this", "->", "output", "->", "writeln", "(", "'Skipped '", ".", "$", "package", "->", "getPrettyName", "(", ")", ".", "' ('", ".", "$", "package", "->", "getStability", "(", ")", ".", "')'", ")", ";", "}", "continue", ";", "}", "$", "links", "[", "]", "=", "$", "package", ";", "}", "}", "}", "return", "$", "links", ";", "}" ]
Gets all Links. This method is called when 'require-all' is set to true. @param array $repos List of all Repositories configured @param string $minimumStability The minimum stability each package must have to be selected @param bool $verbose Output info if true @return Link[]|Package[]
[ "Gets", "all", "Links", "." ]
284570854f4b8d4c8388c9970d90f1bfe47d6b55
https://github.com/composer/satis/blob/284570854f4b8d4c8388c9970d90f1bfe47d6b55/src/PackageSelection/PackageSelection.php#L542-L574
train
composer/satis
src/PackageSelection/PackageSelection.php
PackageSelection.getDepRepos
private function getDepRepos(Composer $composer) { $depRepos = []; if (\is_array($this->depRepositories)) { $rm = $composer->getRepositoryManager(); foreach ($this->depRepositories as $index => $repoConfig) { $name = \is_int($index) && isset($repoConfig['url']) ? $repoConfig['url'] : $index; $type = $repoConfig['type'] ?? ''; $depRepos[$index] = $rm->createRepository($type, $repoConfig, $name); } } return $depRepos; }
php
private function getDepRepos(Composer $composer) { $depRepos = []; if (\is_array($this->depRepositories)) { $rm = $composer->getRepositoryManager(); foreach ($this->depRepositories as $index => $repoConfig) { $name = \is_int($index) && isset($repoConfig['url']) ? $repoConfig['url'] : $index; $type = $repoConfig['type'] ?? ''; $depRepos[$index] = $rm->createRepository($type, $repoConfig, $name); } } return $depRepos; }
[ "private", "function", "getDepRepos", "(", "Composer", "$", "composer", ")", "{", "$", "depRepos", "=", "[", "]", ";", "if", "(", "\\", "is_array", "(", "$", "this", "->", "depRepositories", ")", ")", "{", "$", "rm", "=", "$", "composer", "->", "getRepositoryManager", "(", ")", ";", "foreach", "(", "$", "this", "->", "depRepositories", "as", "$", "index", "=>", "$", "repoConfig", ")", "{", "$", "name", "=", "\\", "is_int", "(", "$", "index", ")", "&&", "isset", "(", "$", "repoConfig", "[", "'url'", "]", ")", "?", "$", "repoConfig", "[", "'url'", "]", ":", "$", "index", ";", "$", "type", "=", "$", "repoConfig", "[", "'type'", "]", "??", "''", ";", "$", "depRepos", "[", "$", "index", "]", "=", "$", "rm", "->", "createRepository", "(", "$", "type", ",", "$", "repoConfig", ",", "$", "name", ")", ";", "}", "}", "return", "$", "depRepos", ";", "}" ]
Create the additional repositories @return RepositoryInterface[]
[ "Create", "the", "additional", "repositories" ]
284570854f4b8d4c8388c9970d90f1bfe47d6b55
https://github.com/composer/satis/blob/284570854f4b8d4c8388c9970d90f1bfe47d6b55/src/PackageSelection/PackageSelection.php#L673-L686
train
composer/satis
src/PackageSelection/PackageSelection.php
PackageSelection.getPackages
private function getPackages(RepositoryInterface $repo) { $packages = []; if ($this->hasFilterForPackages()) { // apply package filter if defined foreach ($this->packagesFilter as $filter) { $packages += $repo->findPackages($filter); } } else { // process other repos directly $packages = $repo->getPackages(); } return $packages; }
php
private function getPackages(RepositoryInterface $repo) { $packages = []; if ($this->hasFilterForPackages()) { // apply package filter if defined foreach ($this->packagesFilter as $filter) { $packages += $repo->findPackages($filter); } } else { // process other repos directly $packages = $repo->getPackages(); } return $packages; }
[ "private", "function", "getPackages", "(", "RepositoryInterface", "$", "repo", ")", "{", "$", "packages", "=", "[", "]", ";", "if", "(", "$", "this", "->", "hasFilterForPackages", "(", ")", ")", "{", "// apply package filter if defined", "foreach", "(", "$", "this", "->", "packagesFilter", "as", "$", "filter", ")", "{", "$", "packages", "+=", "$", "repo", "->", "findPackages", "(", "$", "filter", ")", ";", "}", "}", "else", "{", "// process other repos directly", "$", "packages", "=", "$", "repo", "->", "getPackages", "(", ")", ";", "}", "return", "$", "packages", ";", "}" ]
Gets All or filtered Packages of a Repository. @param RepositoryInterface $repo a Repository @return PackageInterface[]
[ "Gets", "All", "or", "filtered", "Packages", "of", "a", "Repository", "." ]
284570854f4b8d4c8388c9970d90f1bfe47d6b55
https://github.com/composer/satis/blob/284570854f4b8d4c8388c9970d90f1bfe47d6b55/src/PackageSelection/PackageSelection.php#L695-L710
train
composer/satis
src/PackageSelection/PackageSelection.php
PackageSelection.getRequired
private function getRequired(PackageInterface $package, bool $isRoot) { $required = []; if ($this->requireDependencies) { $required = $package->getRequires(); } if (($isRoot || !$this->requireDependencyFilter) && $this->requireDevDependencies) { $required = array_merge($required, $package->getDevRequires()); } return $required; }
php
private function getRequired(PackageInterface $package, bool $isRoot) { $required = []; if ($this->requireDependencies) { $required = $package->getRequires(); } if (($isRoot || !$this->requireDependencyFilter) && $this->requireDevDependencies) { $required = array_merge($required, $package->getDevRequires()); } return $required; }
[ "private", "function", "getRequired", "(", "PackageInterface", "$", "package", ",", "bool", "$", "isRoot", ")", "{", "$", "required", "=", "[", "]", ";", "if", "(", "$", "this", "->", "requireDependencies", ")", "{", "$", "required", "=", "$", "package", "->", "getRequires", "(", ")", ";", "}", "if", "(", "(", "$", "isRoot", "||", "!", "$", "this", "->", "requireDependencyFilter", ")", "&&", "$", "this", "->", "requireDevDependencies", ")", "{", "$", "required", "=", "array_merge", "(", "$", "required", ",", "$", "package", "->", "getDevRequires", "(", ")", ")", ";", "}", "return", "$", "required", ";", "}" ]
Gets the required Links if needed. @param PackageInterface $package A package @param bool $isRoot If the packages are linked in root or as dependency @return Link[]
[ "Gets", "the", "required", "Links", "if", "needed", "." ]
284570854f4b8d4c8388c9970d90f1bfe47d6b55
https://github.com/composer/satis/blob/284570854f4b8d4c8388c9970d90f1bfe47d6b55/src/PackageSelection/PackageSelection.php#L721-L733
train
composer/satis
src/PackageSelection/PackageSelection.php
PackageSelection.filterRepositories
private function filterRepositories(array $repositories) { $url = $this->repositoryFilter; return array_filter($repositories, function ($repository) use ($url) { if (!($repository instanceof ConfigurableRepositoryInterface)) { return false; } $config = $repository->getRepoConfig(); if (!isset($config['url']) || $config['url'] !== $url) { return false; } return true; }); }
php
private function filterRepositories(array $repositories) { $url = $this->repositoryFilter; return array_filter($repositories, function ($repository) use ($url) { if (!($repository instanceof ConfigurableRepositoryInterface)) { return false; } $config = $repository->getRepoConfig(); if (!isset($config['url']) || $config['url'] !== $url) { return false; } return true; }); }
[ "private", "function", "filterRepositories", "(", "array", "$", "repositories", ")", "{", "$", "url", "=", "$", "this", "->", "repositoryFilter", ";", "return", "array_filter", "(", "$", "repositories", ",", "function", "(", "$", "repository", ")", "use", "(", "$", "url", ")", "{", "if", "(", "!", "(", "$", "repository", "instanceof", "ConfigurableRepositoryInterface", ")", ")", "{", "return", "false", ";", "}", "$", "config", "=", "$", "repository", "->", "getRepoConfig", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "config", "[", "'url'", "]", ")", "||", "$", "config", "[", "'url'", "]", "!==", "$", "url", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}", ")", ";", "}" ]
Filter given repositories. @param RepositoryInterface[] $repositories @return RepositoryInterface[]
[ "Filter", "given", "repositories", "." ]
284570854f4b8d4c8388c9970d90f1bfe47d6b55
https://github.com/composer/satis/blob/284570854f4b8d4c8388c9970d90f1bfe47d6b55/src/PackageSelection/PackageSelection.php#L742-L759
train
composer/satis
src/Builder/WebBuilder.php
WebBuilder.setDependencies
private function setDependencies(array $packages): self { $dependencies = []; foreach ($packages as $package) { foreach ($package->getRequires() as $link) { $dependencies[$link->getTarget()][$link->getSource()] = $link->getSource(); } } $this->dependencies = $dependencies; return $this; }
php
private function setDependencies(array $packages): self { $dependencies = []; foreach ($packages as $package) { foreach ($package->getRequires() as $link) { $dependencies[$link->getTarget()][$link->getSource()] = $link->getSource(); } } $this->dependencies = $dependencies; return $this; }
[ "private", "function", "setDependencies", "(", "array", "$", "packages", ")", ":", "self", "{", "$", "dependencies", "=", "[", "]", ";", "foreach", "(", "$", "packages", "as", "$", "package", ")", "{", "foreach", "(", "$", "package", "->", "getRequires", "(", ")", "as", "$", "link", ")", "{", "$", "dependencies", "[", "$", "link", "->", "getTarget", "(", ")", "]", "[", "$", "link", "->", "getSource", "(", ")", "]", "=", "$", "link", "->", "getSource", "(", ")", ";", "}", "}", "$", "this", "->", "dependencies", "=", "$", "dependencies", ";", "return", "$", "this", ";", "}" ]
Defines the required packages. @param PackageInterface[] $packages List of packages to dump @return $this
[ "Defines", "the", "required", "packages", "." ]
284570854f4b8d4c8388c9970d90f1bfe47d6b55
https://github.com/composer/satis/blob/284570854f4b8d4c8388c9970d90f1bfe47d6b55/src/Builder/WebBuilder.php#L102-L114
train
composer/satis
src/Builder/WebBuilder.php
WebBuilder.getMappedPackageList
private function getMappedPackageList(array $packages): array { $groupedPackages = $this->groupPackagesByName($packages); $mappedPackages = []; foreach ($groupedPackages as $name => $packages) { $highest = $this->getHighestVersion($packages); $mappedPackages[$name] = [ 'highest' => $highest, 'abandoned' => $highest instanceof CompletePackageInterface ? $highest->isAbandoned() : false, 'replacement' => $highest instanceof CompletePackageInterface ? $highest->getReplacementPackage() : null, 'versions' => $this->getDescSortedVersions($packages), ]; } return $mappedPackages; }
php
private function getMappedPackageList(array $packages): array { $groupedPackages = $this->groupPackagesByName($packages); $mappedPackages = []; foreach ($groupedPackages as $name => $packages) { $highest = $this->getHighestVersion($packages); $mappedPackages[$name] = [ 'highest' => $highest, 'abandoned' => $highest instanceof CompletePackageInterface ? $highest->isAbandoned() : false, 'replacement' => $highest instanceof CompletePackageInterface ? $highest->getReplacementPackage() : null, 'versions' => $this->getDescSortedVersions($packages), ]; } return $mappedPackages; }
[ "private", "function", "getMappedPackageList", "(", "array", "$", "packages", ")", ":", "array", "{", "$", "groupedPackages", "=", "$", "this", "->", "groupPackagesByName", "(", "$", "packages", ")", ";", "$", "mappedPackages", "=", "[", "]", ";", "foreach", "(", "$", "groupedPackages", "as", "$", "name", "=>", "$", "packages", ")", "{", "$", "highest", "=", "$", "this", "->", "getHighestVersion", "(", "$", "packages", ")", ";", "$", "mappedPackages", "[", "$", "name", "]", "=", "[", "'highest'", "=>", "$", "highest", ",", "'abandoned'", "=>", "$", "highest", "instanceof", "CompletePackageInterface", "?", "$", "highest", "->", "isAbandoned", "(", ")", ":", "false", ",", "'replacement'", "=>", "$", "highest", "instanceof", "CompletePackageInterface", "?", "$", "highest", "->", "getReplacementPackage", "(", ")", ":", "null", ",", "'versions'", "=>", "$", "this", "->", "getDescSortedVersions", "(", "$", "packages", ")", ",", "]", ";", "}", "return", "$", "mappedPackages", ";", "}" ]
Gets a list of packages grouped by name with a list of versions. @param PackageInterface[] $packages List of packages to dump @return array Grouped list of packages with versions
[ "Gets", "a", "list", "of", "packages", "grouped", "by", "name", "with", "a", "list", "of", "versions", "." ]
284570854f4b8d4c8388c9970d90f1bfe47d6b55
https://github.com/composer/satis/blob/284570854f4b8d4c8388c9970d90f1bfe47d6b55/src/Builder/WebBuilder.php#L123-L140
train
composer/satis
src/Builder/WebBuilder.php
WebBuilder.groupPackagesByName
private function groupPackagesByName(array $packages): array { $groupedPackages = []; foreach ($packages as $package) { $groupedPackages[$package->getName()][] = $package; } return $groupedPackages; }
php
private function groupPackagesByName(array $packages): array { $groupedPackages = []; foreach ($packages as $package) { $groupedPackages[$package->getName()][] = $package; } return $groupedPackages; }
[ "private", "function", "groupPackagesByName", "(", "array", "$", "packages", ")", ":", "array", "{", "$", "groupedPackages", "=", "[", "]", ";", "foreach", "(", "$", "packages", "as", "$", "package", ")", "{", "$", "groupedPackages", "[", "$", "package", "->", "getName", "(", ")", "]", "[", "]", "=", "$", "package", ";", "}", "return", "$", "groupedPackages", ";", "}" ]
Gets a list of packages grouped by name. @param PackageInterface[] $packages List of packages to dump @return array List of packages grouped by name
[ "Gets", "a", "list", "of", "packages", "grouped", "by", "name", "." ]
284570854f4b8d4c8388c9970d90f1bfe47d6b55
https://github.com/composer/satis/blob/284570854f4b8d4c8388c9970d90f1bfe47d6b55/src/Builder/WebBuilder.php#L149-L157
train
composer/satis
src/Builder/WebBuilder.php
WebBuilder.getHighestVersion
private function getHighestVersion(array $packages): ?PackageInterface { /** @var $highestVersion PackageInterface|null */ $highestVersion = null; foreach ($packages as $package) { if (null === $highestVersion || version_compare($package->getVersion(), $highestVersion->getVersion(), '>=')) { $highestVersion = $package; } } return $highestVersion; }
php
private function getHighestVersion(array $packages): ?PackageInterface { /** @var $highestVersion PackageInterface|null */ $highestVersion = null; foreach ($packages as $package) { if (null === $highestVersion || version_compare($package->getVersion(), $highestVersion->getVersion(), '>=')) { $highestVersion = $package; } } return $highestVersion; }
[ "private", "function", "getHighestVersion", "(", "array", "$", "packages", ")", ":", "?", "PackageInterface", "{", "/** @var $highestVersion PackageInterface|null */", "$", "highestVersion", "=", "null", ";", "foreach", "(", "$", "packages", "as", "$", "package", ")", "{", "if", "(", "null", "===", "$", "highestVersion", "||", "version_compare", "(", "$", "package", "->", "getVersion", "(", ")", ",", "$", "highestVersion", "->", "getVersion", "(", ")", ",", "'>='", ")", ")", "{", "$", "highestVersion", "=", "$", "package", ";", "}", "}", "return", "$", "highestVersion", ";", "}" ]
Gets the highest version of packages. @param PackageInterface[] $packages List of packages to dump @return PackageInterface The package with the highest version
[ "Gets", "the", "highest", "version", "of", "packages", "." ]
284570854f4b8d4c8388c9970d90f1bfe47d6b55
https://github.com/composer/satis/blob/284570854f4b8d4c8388c9970d90f1bfe47d6b55/src/Builder/WebBuilder.php#L166-L177
train
composer/satis
src/Builder/WebBuilder.php
WebBuilder.getDescSortedVersions
private function getDescSortedVersions(array $packages): array { usort($packages, function (PackageInterface $a, PackageInterface $b) { return version_compare($b->getVersion(), $a->getVersion()); }); return $packages; }
php
private function getDescSortedVersions(array $packages): array { usort($packages, function (PackageInterface $a, PackageInterface $b) { return version_compare($b->getVersion(), $a->getVersion()); }); return $packages; }
[ "private", "function", "getDescSortedVersions", "(", "array", "$", "packages", ")", ":", "array", "{", "usort", "(", "$", "packages", ",", "function", "(", "PackageInterface", "$", "a", ",", "PackageInterface", "$", "b", ")", "{", "return", "version_compare", "(", "$", "b", "->", "getVersion", "(", ")", ",", "$", "a", "->", "getVersion", "(", ")", ")", ";", "}", ")", ";", "return", "$", "packages", ";", "}" ]
Sorts by version the list of packages. @param PackageInterface[] $packages List of packages to dump @return PackageInterface[] Sorted list of packages by version
[ "Sorts", "by", "version", "the", "list", "of", "packages", "." ]
284570854f4b8d4c8388c9970d90f1bfe47d6b55
https://github.com/composer/satis/blob/284570854f4b8d4c8388c9970d90f1bfe47d6b55/src/Builder/WebBuilder.php#L186-L193
train
matomo-org/device-detector
Parser/Device/HbbTv.php
HbbTv.parse
public function parse() { // only parse user agents containing hbbtv fragment if (!$this->isHbbTv()) { return false; } parent::parse(); // always set device type to tv, even if no model/brand could be found $this->deviceType = self::DEVICE_TYPE_TV; return true; }
php
public function parse() { // only parse user agents containing hbbtv fragment if (!$this->isHbbTv()) { return false; } parent::parse(); // always set device type to tv, even if no model/brand could be found $this->deviceType = self::DEVICE_TYPE_TV; return true; }
[ "public", "function", "parse", "(", ")", "{", "// only parse user agents containing hbbtv fragment", "if", "(", "!", "$", "this", "->", "isHbbTv", "(", ")", ")", "{", "return", "false", ";", "}", "parent", "::", "parse", "(", ")", ";", "// always set device type to tv, even if no model/brand could be found", "$", "this", "->", "deviceType", "=", "self", "::", "DEVICE_TYPE_TV", ";", "return", "true", ";", "}" ]
Parses the current UA and checks whether it contains HbbTv information @see televisions.yml for list of detected televisions
[ "Parses", "the", "current", "UA", "and", "checks", "whether", "it", "contains", "HbbTv", "information" ]
61f93df202f3ffa1b5f2ff6d8620944e3f18ae4b
https://github.com/matomo-org/device-detector/blob/61f93df202f3ffa1b5f2ff6d8620944e3f18ae4b/Parser/Device/HbbTv.php#L27-L40
train
matomo-org/device-detector
DeviceDetector.php
DeviceDetector.setUserAgent
public function setUserAgent($userAgent) { if ($this->userAgent != $userAgent) { $this->reset(); } $this->userAgent = $userAgent; }
php
public function setUserAgent($userAgent) { if ($this->userAgent != $userAgent) { $this->reset(); } $this->userAgent = $userAgent; }
[ "public", "function", "setUserAgent", "(", "$", "userAgent", ")", "{", "if", "(", "$", "this", "->", "userAgent", "!=", "$", "userAgent", ")", "{", "$", "this", "->", "reset", "(", ")", ";", "}", "$", "this", "->", "userAgent", "=", "$", "userAgent", ";", "}" ]
Sets the useragent to be parsed @param string $userAgent
[ "Sets", "the", "useragent", "to", "be", "parsed" ]
61f93df202f3ffa1b5f2ff6d8620944e3f18ae4b
https://github.com/matomo-org/device-detector/blob/61f93df202f3ffa1b5f2ff6d8620944e3f18ae4b/DeviceDetector.php#L215-L221
train
matomo-org/device-detector
DeviceDetector.php
DeviceDetector.isDesktop
public function isDesktop() { $osShort = $this->getOs('short_name'); if (empty($osShort) || self::UNKNOWN == $osShort) { return false; } // Check for browsers available for mobile devices only if ($this->usesMobileBrowser()) { return false; } $decodedFamily = OperatingSystem::getOsFamily($osShort); return in_array($decodedFamily, self::$desktopOsArray); }
php
public function isDesktop() { $osShort = $this->getOs('short_name'); if (empty($osShort) || self::UNKNOWN == $osShort) { return false; } // Check for browsers available for mobile devices only if ($this->usesMobileBrowser()) { return false; } $decodedFamily = OperatingSystem::getOsFamily($osShort); return in_array($decodedFamily, self::$desktopOsArray); }
[ "public", "function", "isDesktop", "(", ")", "{", "$", "osShort", "=", "$", "this", "->", "getOs", "(", "'short_name'", ")", ";", "if", "(", "empty", "(", "$", "osShort", ")", "||", "self", "::", "UNKNOWN", "==", "$", "osShort", ")", "{", "return", "false", ";", "}", "// Check for browsers available for mobile devices only", "if", "(", "$", "this", "->", "usesMobileBrowser", "(", ")", ")", "{", "return", "false", ";", "}", "$", "decodedFamily", "=", "OperatingSystem", "::", "getOsFamily", "(", "$", "osShort", ")", ";", "return", "in_array", "(", "$", "decodedFamily", ",", "self", "::", "$", "desktopOsArray", ")", ";", "}" ]
Returns if the parsed UA was identified as desktop device Desktop devices are all devices with an unknown type that are running a desktop os @see self::$desktopOsArray @return bool
[ "Returns", "if", "the", "parsed", "UA", "was", "identified", "as", "desktop", "device", "Desktop", "devices", "are", "all", "devices", "with", "an", "unknown", "type", "that", "are", "running", "a", "desktop", "os" ]
61f93df202f3ffa1b5f2ff6d8620944e3f18ae4b
https://github.com/matomo-org/device-detector/blob/61f93df202f3ffa1b5f2ff6d8620944e3f18ae4b/DeviceDetector.php#L418-L433
train
matomo-org/device-detector
DeviceDetector.php
DeviceDetector.getOs
public function getOs($attr = '') { if ($attr == '') { return $this->os; } if (!isset($this->os[$attr])) { return self::UNKNOWN; } return $this->os[$attr]; }
php
public function getOs($attr = '') { if ($attr == '') { return $this->os; } if (!isset($this->os[$attr])) { return self::UNKNOWN; } return $this->os[$attr]; }
[ "public", "function", "getOs", "(", "$", "attr", "=", "''", ")", "{", "if", "(", "$", "attr", "==", "''", ")", "{", "return", "$", "this", "->", "os", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "os", "[", "$", "attr", "]", ")", ")", "{", "return", "self", "::", "UNKNOWN", ";", "}", "return", "$", "this", "->", "os", "[", "$", "attr", "]", ";", "}" ]
Returns the operating system data extracted from the parsed UA If $attr is given only that property will be returned @param string $attr property to return(optional) @return array|string
[ "Returns", "the", "operating", "system", "data", "extracted", "from", "the", "parsed", "UA" ]
61f93df202f3ffa1b5f2ff6d8620944e3f18ae4b
https://github.com/matomo-org/device-detector/blob/61f93df202f3ffa1b5f2ff6d8620944e3f18ae4b/DeviceDetector.php#L444-L455
train
matomo-org/device-detector
DeviceDetector.php
DeviceDetector.getClient
public function getClient($attr = '') { if ($attr == '') { return $this->client; } if (!isset($this->client[$attr])) { return self::UNKNOWN; } return $this->client[$attr]; }
php
public function getClient($attr = '') { if ($attr == '') { return $this->client; } if (!isset($this->client[$attr])) { return self::UNKNOWN; } return $this->client[$attr]; }
[ "public", "function", "getClient", "(", "$", "attr", "=", "''", ")", "{", "if", "(", "$", "attr", "==", "''", ")", "{", "return", "$", "this", "->", "client", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "client", "[", "$", "attr", "]", ")", ")", "{", "return", "self", "::", "UNKNOWN", ";", "}", "return", "$", "this", "->", "client", "[", "$", "attr", "]", ";", "}" ]
Returns the client data extracted from the parsed UA If $attr is given only that property will be returned @param string $attr property to return(optional) @return array|string
[ "Returns", "the", "client", "data", "extracted", "from", "the", "parsed", "UA" ]
61f93df202f3ffa1b5f2ff6d8620944e3f18ae4b
https://github.com/matomo-org/device-detector/blob/61f93df202f3ffa1b5f2ff6d8620944e3f18ae4b/DeviceDetector.php#L466-L477
train
matomo-org/device-detector
DeviceDetector.php
DeviceDetector.parse
public function parse() { if ($this->isParsed()) { return; } $this->parsed = true; // skip parsing for empty useragents or those not containing any letter if (empty($this->userAgent) || !preg_match('/([a-z])/i', $this->userAgent)) { return; } $this->parseBot(); if ($this->isBot()) { return; } $this->parseOs(); /** * Parse Clients * Clients might be browsers, Feed Readers, Mobile Apps, Media Players or * any other application accessing with an parseable UA */ $this->parseClient(); $this->parseDevice(); }
php
public function parse() { if ($this->isParsed()) { return; } $this->parsed = true; // skip parsing for empty useragents or those not containing any letter if (empty($this->userAgent) || !preg_match('/([a-z])/i', $this->userAgent)) { return; } $this->parseBot(); if ($this->isBot()) { return; } $this->parseOs(); /** * Parse Clients * Clients might be browsers, Feed Readers, Mobile Apps, Media Players or * any other application accessing with an parseable UA */ $this->parseClient(); $this->parseDevice(); }
[ "public", "function", "parse", "(", ")", "{", "if", "(", "$", "this", "->", "isParsed", "(", ")", ")", "{", "return", ";", "}", "$", "this", "->", "parsed", "=", "true", ";", "// skip parsing for empty useragents or those not containing any letter", "if", "(", "empty", "(", "$", "this", "->", "userAgent", ")", "||", "!", "preg_match", "(", "'/([a-z])/i'", ",", "$", "this", "->", "userAgent", ")", ")", "{", "return", ";", "}", "$", "this", "->", "parseBot", "(", ")", ";", "if", "(", "$", "this", "->", "isBot", "(", ")", ")", "{", "return", ";", "}", "$", "this", "->", "parseOs", "(", ")", ";", "/**\n * Parse Clients\n * Clients might be browsers, Feed Readers, Mobile Apps, Media Players or\n * any other application accessing with an parseable UA\n */", "$", "this", "->", "parseClient", "(", ")", ";", "$", "this", "->", "parseDevice", "(", ")", ";", "}" ]
Triggers the parsing of the current user agent
[ "Triggers", "the", "parsing", "of", "the", "current", "user", "agent" ]
61f93df202f3ffa1b5f2ff6d8620944e3f18ae4b
https://github.com/matomo-org/device-detector/blob/61f93df202f3ffa1b5f2ff6d8620944e3f18ae4b/DeviceDetector.php#L574-L602
train
matomo-org/device-detector
DeviceDetector.php
DeviceDetector.parseBot
protected function parseBot() { if ($this->skipBotDetection) { $this->bot = false; return false; } $parsers = $this->getBotParsers(); foreach ($parsers as $parser) { $parser->setUserAgent($this->getUserAgent()); $parser->setYamlParser($this->getYamlParser()); $parser->setCache($this->getCache()); if ($this->discardBotInformation) { $parser->discardDetails(); } $bot = $parser->parse(); if (!empty($bot)) { $this->bot = $bot; break; } } }
php
protected function parseBot() { if ($this->skipBotDetection) { $this->bot = false; return false; } $parsers = $this->getBotParsers(); foreach ($parsers as $parser) { $parser->setUserAgent($this->getUserAgent()); $parser->setYamlParser($this->getYamlParser()); $parser->setCache($this->getCache()); if ($this->discardBotInformation) { $parser->discardDetails(); } $bot = $parser->parse(); if (!empty($bot)) { $this->bot = $bot; break; } } }
[ "protected", "function", "parseBot", "(", ")", "{", "if", "(", "$", "this", "->", "skipBotDetection", ")", "{", "$", "this", "->", "bot", "=", "false", ";", "return", "false", ";", "}", "$", "parsers", "=", "$", "this", "->", "getBotParsers", "(", ")", ";", "foreach", "(", "$", "parsers", "as", "$", "parser", ")", "{", "$", "parser", "->", "setUserAgent", "(", "$", "this", "->", "getUserAgent", "(", ")", ")", ";", "$", "parser", "->", "setYamlParser", "(", "$", "this", "->", "getYamlParser", "(", ")", ")", ";", "$", "parser", "->", "setCache", "(", "$", "this", "->", "getCache", "(", ")", ")", ";", "if", "(", "$", "this", "->", "discardBotInformation", ")", "{", "$", "parser", "->", "discardDetails", "(", ")", ";", "}", "$", "bot", "=", "$", "parser", "->", "parse", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "bot", ")", ")", "{", "$", "this", "->", "bot", "=", "$", "bot", ";", "break", ";", "}", "}", "}" ]
Parses the UA for bot information using the Bot parser
[ "Parses", "the", "UA", "for", "bot", "information", "using", "the", "Bot", "parser" ]
61f93df202f3ffa1b5f2ff6d8620944e3f18ae4b
https://github.com/matomo-org/device-detector/blob/61f93df202f3ffa1b5f2ff6d8620944e3f18ae4b/DeviceDetector.php#L607-L629
train
matomo-org/device-detector
DeviceDetector.php
DeviceDetector.getInfoFromUserAgent
public static function getInfoFromUserAgent($ua) { $deviceDetector = new DeviceDetector($ua); $deviceDetector->parse(); if ($deviceDetector->isBot()) { return array( 'user_agent' => $deviceDetector->getUserAgent(), 'bot' => $deviceDetector->getBot() ); } $osFamily = OperatingSystem::getOsFamily($deviceDetector->getOs('short_name')); $browserFamily = \DeviceDetector\Parser\Client\Browser::getBrowserFamily($deviceDetector->getClient('short_name')); $processed = array( 'user_agent' => $deviceDetector->getUserAgent(), 'os' => $deviceDetector->getOs(), 'client' => $deviceDetector->getClient(), 'device' => array( 'type' => $deviceDetector->getDeviceName(), 'brand' => $deviceDetector->getBrand(), 'model' => $deviceDetector->getModel(), ), 'os_family' => $osFamily !== false ? $osFamily : 'Unknown', 'browser_family' => $browserFamily !== false ? $browserFamily : 'Unknown', ); return $processed; }
php
public static function getInfoFromUserAgent($ua) { $deviceDetector = new DeviceDetector($ua); $deviceDetector->parse(); if ($deviceDetector->isBot()) { return array( 'user_agent' => $deviceDetector->getUserAgent(), 'bot' => $deviceDetector->getBot() ); } $osFamily = OperatingSystem::getOsFamily($deviceDetector->getOs('short_name')); $browserFamily = \DeviceDetector\Parser\Client\Browser::getBrowserFamily($deviceDetector->getClient('short_name')); $processed = array( 'user_agent' => $deviceDetector->getUserAgent(), 'os' => $deviceDetector->getOs(), 'client' => $deviceDetector->getClient(), 'device' => array( 'type' => $deviceDetector->getDeviceName(), 'brand' => $deviceDetector->getBrand(), 'model' => $deviceDetector->getModel(), ), 'os_family' => $osFamily !== false ? $osFamily : 'Unknown', 'browser_family' => $browserFamily !== false ? $browserFamily : 'Unknown', ); return $processed; }
[ "public", "static", "function", "getInfoFromUserAgent", "(", "$", "ua", ")", "{", "$", "deviceDetector", "=", "new", "DeviceDetector", "(", "$", "ua", ")", ";", "$", "deviceDetector", "->", "parse", "(", ")", ";", "if", "(", "$", "deviceDetector", "->", "isBot", "(", ")", ")", "{", "return", "array", "(", "'user_agent'", "=>", "$", "deviceDetector", "->", "getUserAgent", "(", ")", ",", "'bot'", "=>", "$", "deviceDetector", "->", "getBot", "(", ")", ")", ";", "}", "$", "osFamily", "=", "OperatingSystem", "::", "getOsFamily", "(", "$", "deviceDetector", "->", "getOs", "(", "'short_name'", ")", ")", ";", "$", "browserFamily", "=", "\\", "DeviceDetector", "\\", "Parser", "\\", "Client", "\\", "Browser", "::", "getBrowserFamily", "(", "$", "deviceDetector", "->", "getClient", "(", "'short_name'", ")", ")", ";", "$", "processed", "=", "array", "(", "'user_agent'", "=>", "$", "deviceDetector", "->", "getUserAgent", "(", ")", ",", "'os'", "=>", "$", "deviceDetector", "->", "getOs", "(", ")", ",", "'client'", "=>", "$", "deviceDetector", "->", "getClient", "(", ")", ",", "'device'", "=>", "array", "(", "'type'", "=>", "$", "deviceDetector", "->", "getDeviceName", "(", ")", ",", "'brand'", "=>", "$", "deviceDetector", "->", "getBrand", "(", ")", ",", "'model'", "=>", "$", "deviceDetector", "->", "getModel", "(", ")", ",", ")", ",", "'os_family'", "=>", "$", "osFamily", "!==", "false", "?", "$", "osFamily", ":", "'Unknown'", ",", "'browser_family'", "=>", "$", "browserFamily", "!==", "false", "?", "$", "browserFamily", ":", "'Unknown'", ",", ")", ";", "return", "$", "processed", ";", "}" ]
Parses a useragent and returns the detected data ATTENTION: Use that method only for testing or very small applications To get fast results from DeviceDetector you need to make your own implementation, that should use one of the caching mechanisms. See README.md for more information. @internal @deprecated @param string $ua UserAgent to parse @return array
[ "Parses", "a", "useragent", "and", "returns", "the", "detected", "data" ]
61f93df202f3ffa1b5f2ff6d8620944e3f18ae4b
https://github.com/matomo-org/device-detector/blob/61f93df202f3ffa1b5f2ff6d8620944e3f18ae4b/DeviceDetector.php#L804-L832
train
matomo-org/device-detector
DeviceDetector.php
DeviceDetector.setCache
public function setCache($cache) { if ($cache instanceof Cache || (class_exists('\Doctrine\Common\Cache\CacheProvider') && $cache instanceof \Doctrine\Common\Cache\CacheProvider) ) { $this->cache = $cache; return; } throw new \Exception('Cache not supported'); }
php
public function setCache($cache) { if ($cache instanceof Cache || (class_exists('\Doctrine\Common\Cache\CacheProvider') && $cache instanceof \Doctrine\Common\Cache\CacheProvider) ) { $this->cache = $cache; return; } throw new \Exception('Cache not supported'); }
[ "public", "function", "setCache", "(", "$", "cache", ")", "{", "if", "(", "$", "cache", "instanceof", "Cache", "||", "(", "class_exists", "(", "'\\Doctrine\\Common\\Cache\\CacheProvider'", ")", "&&", "$", "cache", "instanceof", "\\", "Doctrine", "\\", "Common", "\\", "Cache", "\\", "CacheProvider", ")", ")", "{", "$", "this", "->", "cache", "=", "$", "cache", ";", "return", ";", "}", "throw", "new", "\\", "Exception", "(", "'Cache not supported'", ")", ";", "}" ]
Sets the Cache class @param Cache|\Doctrine\Common\Cache\CacheProvider $cache @throws \Exception
[ "Sets", "the", "Cache", "class" ]
61f93df202f3ffa1b5f2ff6d8620944e3f18ae4b
https://github.com/matomo-org/device-detector/blob/61f93df202f3ffa1b5f2ff6d8620944e3f18ae4b/DeviceDetector.php#L840-L850
train