Updated PHPStan to v0.11

parent 07316080
This diff is collapsed.
...@@ -1227,9 +1227,7 @@ class Connection implements DriverConnection ...@@ -1227,9 +1227,7 @@ class Connection implements DriverConnection
} }
/** /**
* Starts a transaction by suspending auto-commit mode. * {@inheritDoc}
*
* @return void
*/ */
public function beginTransaction() public function beginTransaction()
{ {
...@@ -1256,12 +1254,12 @@ class Connection implements DriverConnection ...@@ -1256,12 +1254,12 @@ class Connection implements DriverConnection
$logger->stopQuery(); $logger->stopQuery();
} }
} }
return true;
} }
/** /**
* Commits the current transaction. * {@inheritDoc}
*
* @return void
* *
* @throws ConnectionException If the commit failed due to no active transaction or * @throws ConnectionException If the commit failed due to no active transaction or
* because the transaction was marked for rollback only. * because the transaction was marked for rollback only.
...@@ -1300,10 +1298,12 @@ class Connection implements DriverConnection ...@@ -1300,10 +1298,12 @@ class Connection implements DriverConnection
--$this->transactionNestingLevel; --$this->transactionNestingLevel;
if ($this->autoCommit !== false || $this->transactionNestingLevel !== 0) { if ($this->autoCommit !== false || $this->transactionNestingLevel !== 0) {
return; return true;
} }
$this->beginTransaction(); $this->beginTransaction();
return true;
} }
/** /**
......
...@@ -232,7 +232,7 @@ class MasterSlaveConnection extends Connection ...@@ -232,7 +232,7 @@ class MasterSlaveConnection extends Connection
{ {
$this->connect('master'); $this->connect('master');
parent::beginTransaction(); return parent::beginTransaction();
} }
/** /**
...@@ -242,7 +242,7 @@ class MasterSlaveConnection extends Connection ...@@ -242,7 +242,7 @@ class MasterSlaveConnection extends Connection
{ {
$this->connect('master'); $this->connect('master');
parent::commit(); return parent::commit();
} }
/** /**
......
...@@ -167,7 +167,7 @@ class DB2Statement implements IteratorAggregate, Statement ...@@ -167,7 +167,7 @@ class DB2Statement implements IteratorAggregate, Statement
public function columnCount() public function columnCount()
{ {
if (! $this->stmt) { if (! $this->stmt) {
return false; return 0;
} }
return db2_num_fields($this->stmt); return db2_num_fields($this->stmt);
......
...@@ -11,13 +11,14 @@ use IteratorAggregate; ...@@ -11,13 +11,14 @@ use IteratorAggregate;
use mysqli; use mysqli;
use mysqli_stmt; use mysqli_stmt;
use PDO; use PDO;
use stdClass;
use function array_combine; use function array_combine;
use function array_fill; use function array_fill;
use function assert;
use function count; use function count;
use function feof; use function feof;
use function fread; use function fread;
use function get_resource_type; use function get_resource_type;
use function is_array;
use function is_resource; use function is_resource;
use function sprintf; use function sprintf;
use function str_repeat; use function str_repeat;
...@@ -327,28 +328,23 @@ class MysqliStatement implements IteratorAggregate, Statement ...@@ -327,28 +328,23 @@ class MysqliStatement implements IteratorAggregate, Statement
throw new MysqliException($this->_stmt->error, $this->_stmt->sqlstate, $this->_stmt->errno); throw new MysqliException($this->_stmt->error, $this->_stmt->sqlstate, $this->_stmt->errno);
} }
switch ($fetchMode) { if ($fetchMode === FetchMode::NUMERIC) {
case FetchMode::NUMERIC: return $values;
return $values; }
assert(is_array($this->_columnNames));
$assoc = array_combine($this->_columnNames, $values);
assert(is_array($assoc));
switch ($fetchMode) {
case FetchMode::ASSOCIATIVE: case FetchMode::ASSOCIATIVE:
return array_combine($this->_columnNames, $values); return $assoc;
case FetchMode::MIXED: case FetchMode::MIXED:
$ret = array_combine($this->_columnNames, $values); return $assoc + $values;
$ret += $values;
return $ret;
case FetchMode::STANDARD_OBJECT: case FetchMode::STANDARD_OBJECT:
$assoc = array_combine($this->_columnNames, $values); return (object) $assoc;
$ret = new stdClass();
foreach ($assoc as $column => $value) {
$ret->$column = $value;
}
return $ret;
default: default:
throw new MysqliException(sprintf("Unknown fetch type '%s'", $fetchMode)); throw new MysqliException(sprintf("Unknown fetch type '%s'", $fetchMode));
......
...@@ -356,8 +356,8 @@ class SqlitePlatform extends AbstractPlatform ...@@ -356,8 +356,8 @@ class SqlitePlatform extends AbstractPlatform
/** /**
* Generate a PRIMARY KEY definition if no autoincrement value is used * Generate a PRIMARY KEY definition if no autoincrement value is used
* *
* @param string[] $columns * @param mixed[][] $columns
* @param mixed[] $options * @param mixed[] $options
*/ */
private function getNonAutoincrementPrimaryKeyDefinition(array $columns, array $options) : string private function getNonAutoincrementPrimaryKeyDefinition(array $columns, array $options) : string
{ {
...@@ -368,7 +368,7 @@ class SqlitePlatform extends AbstractPlatform ...@@ -368,7 +368,7 @@ class SqlitePlatform extends AbstractPlatform
$keyColumns = array_unique(array_values($options['primary'])); $keyColumns = array_unique(array_values($options['primary']));
foreach ($keyColumns as $keyColumn) { foreach ($keyColumns as $keyColumn) {
if (isset($columns[$keyColumn]['autoincrement']) && ! empty($columns[$keyColumn]['autoincrement'])) { if (! empty($columns[$keyColumn]['autoincrement'])) {
return ''; return '';
} }
} }
......
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