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:
-
message: '~^Cannot cast array<string>\|bool\|string\|null to int\.$~'
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:
- vendor/phpstan/phpstan-strict-rules/rules.neon
......@@ -51,7 +51,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
/** @var int Default fetch mode to use. */
private $defaultFetchMode = FetchMode::MIXED;
/** @var resource The result set resource to fetch. */
/** @var resource|null The result set resource to fetch. */
private $result;
/** @var resource The prepared SQL statement to execute. */
......
......@@ -140,7 +140,7 @@ abstract class AbstractPlatform
*/
protected $doctrineTypeComments = null;
/** @var EventManager */
/** @var EventManager|null */
protected $_eventManager;
/**
......@@ -167,7 +167,7 @@ abstract class AbstractPlatform
/**
* Gets the EventManager used by the Platform.
*
* @return EventManager
* @return EventManager|null
*/
public function getEventManager()
{
......
......@@ -373,7 +373,7 @@ class SQLAnywhere16Platform extends AbstractPlatform
*/
public function getConcatExpression()
{
return 'STRING(' . implode(', ', (array) func_get_args()) . ')';
return 'STRING(' . implode(', ', func_get_args()) . ')';
}
/**
......
......@@ -3,7 +3,6 @@
namespace Doctrine\DBAL\Platforms;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\Constraint;
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\Identifier;
......@@ -958,8 +957,7 @@ class SqlitePlatform extends AbstractPlatform
{
// Suppress changes on integer type autoincrement columns.
foreach ($diff->changedColumns as $oldColumnName => $columnDiff) {
if (! $columnDiff->fromColumn instanceof Column ||
! $columnDiff->column instanceof Column ||
if ($columnDiff->fromColumn === null ||
! $columnDiff->column->getAutoincrement() ||
! $columnDiff->column->getType() instanceof Types\IntegerType
) {
......
......@@ -18,7 +18,6 @@ use function assert;
use function call_user_func_array;
use function count;
use function func_get_args;
use function is_array;
use function is_callable;
use function preg_match;
use function str_replace;
......@@ -594,9 +593,6 @@ abstract class AbstractSchemaManager
public function alterTable(TableDiff $tableDiff)
{
$queries = $this->_platform->getAlterTableSQL($tableDiff);
if (! is_array($queries) || ! count($queries)) {
return;
}
foreach ($queries as $ddlQuery) {
$this->_execSql($ddlQuery);
......
......@@ -27,7 +27,7 @@ class Table extends AbstractAsset
/** @var Index[] */
protected $_indexes = [];
/** @var string */
/** @var string|false */
protected $_primaryKeyName = false;
/** @var ForeignKeyConstraint[] */
......@@ -142,6 +142,10 @@ class Table extends AbstractAsset
*/
public function dropPrimaryKey()
{
if ($this->_primaryKeyName === false) {
return;
}
$this->dropIndex($this->_primaryKeyName);
$this->_primaryKeyName = false;
}
......@@ -672,11 +676,11 @@ class Table extends AbstractAsset
*/
public function getPrimaryKey()
{
if (! $this->hasPrimaryKey()) {
return null;
if ($this->_primaryKeyName !== false) {
return $this->getIndex($this->_primaryKeyName);
}
return $this->getIndex($this->_primaryKeyName);
return null;
}
/**
......
......@@ -31,12 +31,10 @@ class ConnectionTest extends FunctionalTestCase
parent::tearDown();
}
public function testDriverOptions() : void
public function testSupportedDriverOptions() : void
{
$driverOptions = [MYSQLI_OPT_CONNECT_TIMEOUT => 1];
$connection = $this->getConnection($driverOptions);
self::assertInstanceOf(MysqliConnection::class, $connection);
$this->expectNotToPerformAssertions();
$this->getConnection([MYSQLI_OPT_CONNECT_TIMEOUT => 1]);
}
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