Skip to content

Commit 9d63c3b

Browse files
authored
Merge pull request #4348 from morozov/psalm-3
Bump Psalm level to 3
2 parents 29bf315 + 7722b51 commit 9d63c3b

File tree

98 files changed

+481
-364
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+481
-364
lines changed

lib/Doctrine/DBAL/Cache/ResultCacheStatement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ public function fetchAllNumeric(): array
244244

245245
$this->store($data);
246246

247-
return array_map('array_values', $this->data);
247+
return array_map('array_values', $data);
248248
}
249249

250250
/**

lib/Doctrine/DBAL/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function setResultCacheImpl(Cache $cacheImpl)
7373
*
7474
* @deprecated Use Configuration::setSchemaAssetsFilter() instead
7575
*
76-
* @param string $filterExpression
76+
* @param string|null $filterExpression
7777
*
7878
* @return void
7979
*/

lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
class DB2Connection implements ConnectionInterface, ServerInfoAwareConnection
3838
{
3939
/** @var resource */
40-
private $conn = null;
40+
private $conn;
4141

4242
/**
4343
* @internal The connection can be only instantiated by its driver.
@@ -93,7 +93,7 @@ public function prepare($sql)
9393
$stmt = @db2_prepare($this->conn, $sql);
9494

9595
if ($stmt === false) {
96-
throw PrepareFailed::new(error_get_last()['message']);
96+
throw PrepareFailed::new(error_get_last());
9797
}
9898

9999
return new Statement($stmt);

lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -455,9 +455,9 @@ public function free(): void
455455
/**
456456
* Casts a stdClass object to the given class name mapping its' properties.
457457
*
458-
* @param stdClass $sourceObject Object to cast from.
459-
* @param string|object $destinationClass Name of the class or class instance to cast to.
460-
* @param mixed[] $ctorArgs Arguments to use for constructing the destination class instance.
458+
* @param stdClass $sourceObject Object to cast from.
459+
* @param class-string|object $destinationClass Name of the class or class instance to cast to.
460+
* @param mixed[] $ctorArgs Arguments to use for constructing the destination class instance.
461461
*
462462
* @return object
463463
*
@@ -527,7 +527,7 @@ private function createTemporaryFile()
527527
$handle = @tmpfile();
528528

529529
if ($handle === false) {
530-
throw CannotCreateTemporaryFile::new(error_get_last()['message']);
530+
throw CannotCreateTemporaryFile::new(error_get_last());
531531
}
532532

533533
return $handle;
@@ -542,7 +542,7 @@ private function createTemporaryFile()
542542
private function copyStreamToStream($source, $target): void
543543
{
544544
if (@stream_copy_to_stream($source, $target) === false) {
545-
throw CannotCopyStreamToStream::new(error_get_last()['message']);
545+
throw CannotCopyStreamToStream::new(error_get_last());
546546
}
547547
}
548548

@@ -554,7 +554,7 @@ private function copyStreamToStream($source, $target): void
554554
private function writeStringToStream(string $string, $target): void
555555
{
556556
if (@fwrite($target, $string) === false) {
557-
throw CannotWriteToTemporaryFile::new(error_get_last()['message']);
557+
throw CannotWriteToTemporaryFile::new(error_get_last());
558558
}
559559
}
560560
}

lib/Doctrine/DBAL/Driver/IBMDB2/Exception/CannotCopyStreamToStream.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,17 @@
1313
*/
1414
final class CannotCopyStreamToStream extends DB2Exception
1515
{
16-
public static function new(string $message): self
16+
/**
17+
* @psalm-param array{message: string}|null $error
18+
*/
19+
public static function new(?array $error): self
1720
{
18-
return new self('Could not copy source stream to temporary file: ' . $message);
21+
$message = 'Could not copy source stream to temporary file';
22+
23+
if ($error !== null) {
24+
$message .= ': ' . $error['message'];
25+
}
26+
27+
return new self($message);
1928
}
2029
}

lib/Doctrine/DBAL/Driver/IBMDB2/Exception/CannotCreateTemporaryFile.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,17 @@
1313
*/
1414
final class CannotCreateTemporaryFile extends DB2Exception
1515
{
16-
public static function new(string $message): self
16+
/**
17+
* @psalm-param array{message: string}|null $error
18+
*/
19+
public static function new(?array $error): self
1720
{
18-
return new self('Could not create temporary file: ' . $message);
21+
$message = 'Could not create temporary file';
22+
23+
if ($error !== null) {
24+
$message .= ': ' . $error['message'];
25+
}
26+
27+
return new self($message);
1928
}
2029
}

lib/Doctrine/DBAL/Driver/IBMDB2/Exception/CannotWriteToTemporaryFile.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,17 @@
1313
*/
1414
final class CannotWriteToTemporaryFile extends DB2Exception
1515
{
16-
public static function new(string $message): self
16+
/**
17+
* @psalm-param array{message: string}|null $error
18+
*/
19+
public static function new(?array $error): self
1720
{
18-
return new self('Could not write string to temporary file: ' . $message);
21+
$message = 'Could not write string to temporary file';
22+
23+
if ($error !== null) {
24+
$message .= ': ' . $error['message'];
25+
}
26+
27+
return new self($message);
1928
}
2029
}

lib/Doctrine/DBAL/Driver/IBMDB2/Exception/PrepareFailed.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,15 @@
1313
*/
1414
final class PrepareFailed extends AbstractException
1515
{
16-
public static function new(string $message): self
16+
/**
17+
* @psalm-param array{message: string}|null $error
18+
*/
19+
public static function new(?array $error): self
1720
{
18-
return new self($message);
21+
if ($error === null) {
22+
return new self('Unknown error');
23+
}
24+
25+
return new self($error['message']);
1926
}
2027
}

lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,7 @@ public function bindParam($param, &$variable, $type = ParameterType::STRING, $le
299299
if ($type === ParameterType::LARGE_OBJECT) {
300300
$lob = oci_new_descriptor($this->_dbh, OCI_D_LOB);
301301

302-
$class = 'OCI-Lob';
303-
assert($lob instanceof $class);
302+
assert($lob !== false);
304303

305304
$lob->writeTemporary($variable, OCI_TEMP_BLOB);
306305

lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ public function getName()
5252
/**
5353
* Build the connection string for given connection parameters and driver options.
5454
*
55-
* @param string $host Host address to connect to.
56-
* @param int $port Port to use for the connection (default to SQL Anywhere standard port 2638).
57-
* @param string $server Database server name on the host to connect to.
58-
* SQL Anywhere allows multiple database server instances on the same host,
59-
* therefore specifying the server instance name to use is mandatory.
60-
* @param string $dbname Name of the database on the server instance to connect to.
61-
* @param string $username User name to use for connection authentication.
62-
* @param string $password Password to use for connection authentication.
63-
* @param mixed[] $driverOptions Additional parameters to use for the connection.
55+
* @param string|null $host Host address to connect to.
56+
* @param int|null $port Port to use for the connection (default to SQL Anywhere standard port 2638).
57+
* @param string|null $server Database server name on the host to connect to.
58+
* SQL Anywhere allows multiple database server instances on the same host,
59+
* therefore specifying the server instance name to use is mandatory.
60+
* @param string|null $dbname Name of the database on the server instance to connect to.
61+
* @param string $username User name to use for connection authentication.
62+
* @param string $password Password to use for connection authentication.
63+
* @param mixed[] $driverOptions Additional parameters to use for the connection.
6464
*
6565
* @return string
6666
*/

0 commit comments

Comments
 (0)