Reworked type-based and conditions and clarified some types to justify the...

Reworked type-based and conditions and clarified some types to justify the ones that remain unchanged.
parent 2b2848e1
...@@ -73,5 +73,10 @@ parameters: ...@@ -73,5 +73,10 @@ parameters:
- -
message: '~^Cannot cast array<string>\|bool\|string\|null to int\.$~' message: '~^Cannot cast array<string>\|bool\|string\|null to int\.$~'
path: %currentWorkingDirectory%/src/Tools/Console/Command/RunSqlCommand.php path: %currentWorkingDirectory%/src/Tools/Console/Command/RunSqlCommand.php
# https://github.com/phpstan/phpstan/issues/3134
-
message: '~^Call to static method PHPUnit\\Framework\\Assert::assertSame\(\) with Doctrine\\DBAL\\Types\\Type and Doctrine\\DBAL\\Types\\Type will always evaluate to true\.$~'
path: %currentWorkingDirectory%/tests/Types/TypeRegistryTest.php
includes: includes:
- vendor/phpstan/phpstan-strict-rules/rules.neon - vendor/phpstan/phpstan-strict-rules/rules.neon
...@@ -51,7 +51,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement ...@@ -51,7 +51,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
/** @var int Default fetch mode to use. */ /** @var int Default fetch mode to use. */
private $defaultFetchMode = FetchMode::MIXED; private $defaultFetchMode = FetchMode::MIXED;
/** @var resource The result set resource to fetch. */ /** @var resource|null The result set resource to fetch. */
private $result; private $result;
/** @var resource The prepared SQL statement to execute. */ /** @var resource The prepared SQL statement to execute. */
......
...@@ -140,7 +140,7 @@ abstract class AbstractPlatform ...@@ -140,7 +140,7 @@ abstract class AbstractPlatform
*/ */
protected $doctrineTypeComments = null; protected $doctrineTypeComments = null;
/** @var EventManager */ /** @var EventManager|null */
protected $_eventManager; protected $_eventManager;
/** /**
...@@ -167,7 +167,7 @@ abstract class AbstractPlatform ...@@ -167,7 +167,7 @@ abstract class AbstractPlatform
/** /**
* Gets the EventManager used by the Platform. * Gets the EventManager used by the Platform.
* *
* @return EventManager * @return EventManager|null
*/ */
public function getEventManager() public function getEventManager()
{ {
......
...@@ -373,7 +373,7 @@ class SQLAnywhere16Platform extends AbstractPlatform ...@@ -373,7 +373,7 @@ class SQLAnywhere16Platform extends AbstractPlatform
*/ */
public function getConcatExpression() public function getConcatExpression()
{ {
return 'STRING(' . implode(', ', (array) func_get_args()) . ')'; return 'STRING(' . implode(', ', func_get_args()) . ')';
} }
/** /**
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
namespace Doctrine\DBAL\Platforms; namespace Doctrine\DBAL\Platforms;
use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\Constraint; use Doctrine\DBAL\Schema\Constraint;
use Doctrine\DBAL\Schema\ForeignKeyConstraint; use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\Identifier; use Doctrine\DBAL\Schema\Identifier;
...@@ -958,8 +957,7 @@ class SqlitePlatform extends AbstractPlatform ...@@ -958,8 +957,7 @@ class SqlitePlatform extends AbstractPlatform
{ {
// Suppress changes on integer type autoincrement columns. // Suppress changes on integer type autoincrement columns.
foreach ($diff->changedColumns as $oldColumnName => $columnDiff) { foreach ($diff->changedColumns as $oldColumnName => $columnDiff) {
if (! $columnDiff->fromColumn instanceof Column || if ($columnDiff->fromColumn === null ||
! $columnDiff->column instanceof Column ||
! $columnDiff->column->getAutoincrement() || ! $columnDiff->column->getAutoincrement() ||
! $columnDiff->column->getType() instanceof Types\IntegerType ! $columnDiff->column->getType() instanceof Types\IntegerType
) { ) {
......
...@@ -18,7 +18,6 @@ use function assert; ...@@ -18,7 +18,6 @@ use function assert;
use function call_user_func_array; use function call_user_func_array;
use function count; use function count;
use function func_get_args; use function func_get_args;
use function is_array;
use function is_callable; use function is_callable;
use function preg_match; use function preg_match;
use function str_replace; use function str_replace;
...@@ -594,9 +593,6 @@ abstract class AbstractSchemaManager ...@@ -594,9 +593,6 @@ abstract class AbstractSchemaManager
public function alterTable(TableDiff $tableDiff) public function alterTable(TableDiff $tableDiff)
{ {
$queries = $this->_platform->getAlterTableSQL($tableDiff); $queries = $this->_platform->getAlterTableSQL($tableDiff);
if (! is_array($queries) || ! count($queries)) {
return;
}
foreach ($queries as $ddlQuery) { foreach ($queries as $ddlQuery) {
$this->_execSql($ddlQuery); $this->_execSql($ddlQuery);
......
...@@ -27,7 +27,7 @@ class Table extends AbstractAsset ...@@ -27,7 +27,7 @@ class Table extends AbstractAsset
/** @var Index[] */ /** @var Index[] */
protected $_indexes = []; protected $_indexes = [];
/** @var string */ /** @var string|false */
protected $_primaryKeyName = false; protected $_primaryKeyName = false;
/** @var ForeignKeyConstraint[] */ /** @var ForeignKeyConstraint[] */
...@@ -142,6 +142,10 @@ class Table extends AbstractAsset ...@@ -142,6 +142,10 @@ class Table extends AbstractAsset
*/ */
public function dropPrimaryKey() public function dropPrimaryKey()
{ {
if ($this->_primaryKeyName === false) {
return;
}
$this->dropIndex($this->_primaryKeyName); $this->dropIndex($this->_primaryKeyName);
$this->_primaryKeyName = false; $this->_primaryKeyName = false;
} }
...@@ -672,11 +676,11 @@ class Table extends AbstractAsset ...@@ -672,11 +676,11 @@ class Table extends AbstractAsset
*/ */
public function getPrimaryKey() public function getPrimaryKey()
{ {
if (! $this->hasPrimaryKey()) { if ($this->_primaryKeyName !== false) {
return null; return $this->getIndex($this->_primaryKeyName);
} }
return $this->getIndex($this->_primaryKeyName); return null;
} }
/** /**
......
...@@ -31,12 +31,10 @@ class ConnectionTest extends FunctionalTestCase ...@@ -31,12 +31,10 @@ class ConnectionTest extends FunctionalTestCase
parent::tearDown(); parent::tearDown();
} }
public function testDriverOptions() : void public function testSupportedDriverOptions() : void
{ {
$driverOptions = [MYSQLI_OPT_CONNECT_TIMEOUT => 1]; $this->expectNotToPerformAssertions();
$this->getConnection([MYSQLI_OPT_CONNECT_TIMEOUT => 1]);
$connection = $this->getConnection($driverOptions);
self::assertInstanceOf(MysqliConnection::class, $connection);
} }
public function testUnsupportedDriverOption() : void public function testUnsupportedDriverOption() : void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment