mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-16 13:44:12 +02:00
[ticket/16741] Code review fixes
PHPBB3-16741
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
@@ -50,7 +50,7 @@ class comparator extends \Doctrine\DBAL\Schema\Comparator
|
||||
}
|
||||
|
||||
$index_columns = array_map('strtolower', $index->getUnquotedColumns());
|
||||
if (array_search($columnName, $index_columns, true) === false)
|
||||
if (!in_array($columnName, $index_columns, true))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
|
@@ -4,7 +4,7 @@
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
@@ -18,7 +18,7 @@ use Doctrine\DBAL\Driver\Result as DriverResult;
|
||||
use Doctrine\DBAL\Driver\Statement as DriverStatement;
|
||||
use Doctrine\DBAL\ParameterType;
|
||||
|
||||
class Connection implements DriverConnection
|
||||
class connection implements DriverConnection
|
||||
{
|
||||
/**
|
||||
* @var DriverConnection
|
||||
@@ -68,7 +68,7 @@ class Connection implements DriverConnection
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function lastInsertId($name = null)
|
||||
public function lastInsertId($name = null): ?string
|
||||
{
|
||||
return $this->wrapped->lastInsertId($name);
|
||||
}
|
||||
@@ -76,7 +76,7 @@ class Connection implements DriverConnection
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function beginTransaction()
|
||||
public function beginTransaction(): bool
|
||||
{
|
||||
return $this->wrapped->beginTransaction();
|
||||
}
|
||||
@@ -84,7 +84,7 @@ class Connection implements DriverConnection
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function commit()
|
||||
public function commit(): bool
|
||||
{
|
||||
return $this->wrapped->commit();
|
||||
}
|
||||
@@ -92,7 +92,7 @@ class Connection implements DriverConnection
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function rollBack()
|
||||
public function rollBack(): bool
|
||||
{
|
||||
return $this->wrapped->rollBack();
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
|
@@ -4,7 +4,7 @@
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
|
@@ -4,7 +4,7 @@
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
|
@@ -4,7 +4,7 @@
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
@@ -35,7 +35,7 @@ class statement implements DriverStatement
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function bindValue($param, $value, $type = ParameterType::STRING)
|
||||
public function bindValue($param, $value, $type = ParameterType::STRING): bool
|
||||
{
|
||||
return $this->wrapped->bindValue($param, $value, $type);
|
||||
}
|
||||
@@ -43,7 +43,7 @@ class statement implements DriverStatement
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function bindParam($param, &$variable, $type = ParameterType::STRING, $length = null)
|
||||
public function bindParam($param, &$variable, $type = ParameterType::STRING, $length = null): bool
|
||||
{
|
||||
return $this->wrapped->bindParam($param, $variable, $type, $length);
|
||||
}
|
||||
|
@@ -47,7 +47,7 @@ class oracle_platform extends OraclePlatform
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getCreateIndexSQL(Index $index, $table)
|
||||
public function getCreateIndexSQL(Index $index, $table): string
|
||||
{
|
||||
if ($table instanceof Table)
|
||||
{
|
||||
@@ -79,12 +79,12 @@ class oracle_platform extends OraclePlatform
|
||||
/**
|
||||
* Check whether the index name is too long
|
||||
*
|
||||
* @param string $table_name
|
||||
* @param string $index_name
|
||||
* @param bool $throw_error
|
||||
* @param string $table_name
|
||||
* @param string $index_name
|
||||
* @param bool $throw_error
|
||||
* @return string The index name, shortened if too long
|
||||
*/
|
||||
protected function check_index_name_length($table_name, $index_name, $throw_error = true)
|
||||
protected function check_index_name_length(string $table_name, string $index_name, bool $throw_error = true): string
|
||||
{
|
||||
$max_index_name_length = $this->getMaxIdentifierLength();
|
||||
if (strlen($index_name) > $max_index_name_length)
|
||||
@@ -108,7 +108,9 @@ class oracle_platform extends OraclePlatform
|
||||
|
||||
if ($throw_error)
|
||||
{
|
||||
trigger_error("Index name '$index_name' on table '$table_name' is too long. The maximum is $max_index_name_length characters.", E_USER_ERROR);
|
||||
throw new \InvalidArgumentException(
|
||||
"Index name '$index_name' on table '$table_name' is too long. The maximum is $max_index_name_length characters."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,9 +120,9 @@ class oracle_platform extends OraclePlatform
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIdentitySequenceName($tableName, $columnName)
|
||||
public function getIdentitySequenceName($tableName, $columnName): string
|
||||
{
|
||||
return $tableName.'_SEQ';
|
||||
return $tableName . '_SEQ';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,7 +142,7 @@ class oracle_platform extends OraclePlatform
|
||||
/**
|
||||
* @see OraclePlatform::normalizeIdentifier()
|
||||
*/
|
||||
private function doctrine_normalize_identifier($name)
|
||||
private function doctrine_normalize_identifier($name): Identifier
|
||||
{
|
||||
$identifier = new Identifier($name);
|
||||
|
||||
@@ -150,7 +152,7 @@ class oracle_platform extends OraclePlatform
|
||||
/**
|
||||
* @see OraclePlatform::getAutoincrementIdentifierName()
|
||||
*/
|
||||
private function get_doctrine_autoincrement_identifier_name(Identifier $table)
|
||||
private function get_doctrine_autoincrement_identifier_name(Identifier $table): string
|
||||
{
|
||||
$identifierName = $this->add_doctrine_Suffix($table->getName(), '_AI_PK');
|
||||
|
||||
|
@@ -95,7 +95,7 @@ class postgresql_platform extends PostgreSQL94Platform
|
||||
$post_sql = [];
|
||||
foreach ($columns as $column_name => $column)
|
||||
{
|
||||
if (! empty($column['autoincrement']))
|
||||
if (!empty($column['autoincrement']))
|
||||
{
|
||||
$sequence = new Sequence($this->getIdentitySequenceName($name, $column_name));
|
||||
$sql[] = $this->getCreateSequenceSQL($sequence);
|
||||
@@ -113,7 +113,8 @@ class postgresql_platform extends PostgreSQL94Platform
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $column
|
||||
* @param array $column
|
||||
* @return bool
|
||||
*/
|
||||
private function isSerialColumn(array $column): bool
|
||||
{
|
||||
@@ -138,7 +139,7 @@ class postgresql_platform extends PostgreSQL94Platform
|
||||
1 AS increment_by
|
||||
FROM information_schema.sequences
|
||||
WHERE sequence_schema NOT LIKE 'pg\_%'
|
||||
AND sequence_schema != 'information_schema'";
|
||||
AND sequence_schema <> 'information_schema'";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -4,7 +4,7 @@
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
@@ -37,7 +37,7 @@ class sqlsrv_platform extends SQLServer2012Platform
|
||||
$this->generate_doctrine_identifier_name($column['name']),
|
||||
], [
|
||||
$table,
|
||||
$column['name'].'_1',
|
||||
$column['name'] . '_1',
|
||||
],
|
||||
$sql);
|
||||
}
|
||||
@@ -70,7 +70,7 @@ class sqlsrv_platform extends SQLServer2012Platform
|
||||
$phpbb_names[] = $diff->name;
|
||||
|
||||
// NEW Table name if relevant
|
||||
if ($diff->getNewName() != null)
|
||||
if ($diff->getNewName())
|
||||
{
|
||||
$doctrine_names[] = $this->generate_doctrine_identifier_name($diff->getNewName()->getName());
|
||||
$phpbb_names[] = $diff->getNewName()->getName();
|
||||
@@ -79,30 +79,30 @@ class sqlsrv_platform extends SQLServer2012Platform
|
||||
foreach ($diff->addedColumns as $column)
|
||||
{
|
||||
$doctrine_names[] = $this->generate_doctrine_identifier_name($column->getQuotedName($this));
|
||||
$phpbb_names[] = $column->getQuotedName($this).'_1';
|
||||
$phpbb_names[] = $column->getQuotedName($this) . '_1';
|
||||
}
|
||||
|
||||
foreach ($diff->removedColumns as $column)
|
||||
{
|
||||
$doctrine_names[] = $this->generate_doctrine_identifier_name($column->getQuotedName($this));
|
||||
$phpbb_names[] = $column->getQuotedName($this).'_1';
|
||||
$phpbb_names[] = $column->getQuotedName($this) . '_1';
|
||||
}
|
||||
|
||||
foreach ($diff->renamedColumns as $column)
|
||||
{
|
||||
$doctrine_names[] = $this->generate_doctrine_identifier_name($column->getQuotedName($this));
|
||||
$phpbb_names[] = $column->getQuotedName($this).'_1';
|
||||
$phpbb_names[] = $column->getQuotedName($this) . '_1';
|
||||
}
|
||||
|
||||
foreach ($diff->changedColumns as $column)
|
||||
{
|
||||
$doctrine_names[] = $this->generate_doctrine_identifier_name($column->column->getQuotedName($this));
|
||||
$phpbb_names[] = $column->column->getQuotedName($this).'_1';
|
||||
$phpbb_names[] = $column->column->getQuotedName($this) . '_1';
|
||||
|
||||
if ($column->oldColumnName != $column->column->getQuotedName($this))
|
||||
{
|
||||
$doctrine_names[] = $this->generate_doctrine_identifier_name($column->oldColumnName);
|
||||
$phpbb_names[] = $column->oldColumnName.'_1';
|
||||
$phpbb_names[] = $column->oldColumnName . '_1';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ class sqlsrv_platform extends SQLServer2012Platform
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function generate_doctrine_identifier_name($identifier)
|
||||
private function generate_doctrine_identifier_name(string $identifier): string
|
||||
{
|
||||
// Always generate name for unquoted identifiers to ensure consistency.
|
||||
$identifier = new Identifier($identifier);
|
||||
@@ -132,7 +132,7 @@ class sqlsrv_platform extends SQLServer2012Platform
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function generate_doctrine_default_constraint_name($table, $column)
|
||||
private function generate_doctrine_default_constraint_name(string $table, string $column): string
|
||||
{
|
||||
return 'DF_' . $this->generate_doctrine_identifier_name($table) . '_' . $this->generate_doctrine_identifier_name($column);
|
||||
}
|
||||
|
@@ -4,13 +4,12 @@
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\doctrine;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
Reference in New Issue
Block a user