Skip to content

Commit

Permalink
WIP Psalm 5.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus committed Dec 19, 2022
1 parent 63e513c commit aa8b860
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 39 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"squizlabs/php_codesniffer": "3.7.1",
"symfony/cache": "^5.4|^6.0",
"symfony/console": "^4.4|^5.4|^6.0",
"vimeo/psalm": "4.30.0"
"vimeo/psalm": "5.3.0"
},
"suggest": {
"symfony/console": "For helpful console commands such as SQL execution and import of files."
Expand Down
27 changes: 24 additions & 3 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,9 @@
<errorLevel type="suppress">
<!-- We're testing with invalid input here. -->
<file name="tests/Platforms/AbstractPlatformTestCase.php"/>

<!-- See https://bugs.php.net/bug.php?id=77591 -->
<referencedFunction name="db2_autocommit"/>
</errorLevel>
</InvalidArgument>
<InvalidDocblock>
Expand Down Expand Up @@ -766,6 +769,7 @@
This issue should be fixed in 4.0
-->
<file name="src/Connection.php"/>
<file name="src/Driver/Mysqli/Result.php"/>
<file name="src/Statement.php"/>
<file name="src/Query/QueryBuilder.php"/>
</errorLevel>
Expand All @@ -778,6 +782,7 @@
This issue should be fixed in 4.0
-->
<file name="src/Connection.php"/>
<file name="src/Driver/Mysqli/Result.php"/>
<file name="src/Statement.php"/>
<file name="src/Query/QueryBuilder.php"/>
</errorLevel>
Expand All @@ -793,10 +798,26 @@

<!-- See https://github.com/doctrine/dbal/pull/3574 -->
<file name="tests/Query/Expression/ExpressionBuilderTest.php"/>

<!-- See https://bugs.php.net/bug.php?id=77591 -->
<referencedFunction name="db2_autocommit"/>
</errorLevel>
</InvalidScalarArgument>
<MethodSignatureMustProvideReturnType>
<errorLevel type="suppress">
<!-- https://github.com/vimeo/psalm/issues/8557 -->
<file name="src/Query/Expression/CompositeExpression.php"/>
<file name="src/Query/QueryBuilder.php"/>
</errorLevel>
</MethodSignatureMustProvideReturnType>
<NoValue>
<errorLevel type="suppress">
<!-- We're checking for invalid input. -->
<file name="src/Platforms/AbstractPlatform.php"/>
<file name="src/Platforms/SQLServerPlatform.php"/>
</errorLevel>
</NoValue>
<UnsupportedReferenceUsage>
<errorLevel type="suppress">
<file name="src/Driver/SQLSrv/Statement.php"/>
</errorLevel>
</UnsupportedReferenceUsage>
</issueHandlers>
</psalm>
2 changes: 1 addition & 1 deletion src/Driver/IBMDB2/Exception/CannotCopyStreamToStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
final class CannotCopyStreamToStream extends AbstractException
{
/** @psalm-param array{message: string}|null $error */
/** @psalm-param array{message: string, ...mixed}|null $error */
public static function new(?array $error): self
{
$message = 'Could not copy source stream to temporary file';
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/IBMDB2/Exception/CannotCreateTemporaryFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
final class CannotCreateTemporaryFile extends AbstractException
{
/** @psalm-param array{message: string}|null $error */
/** @psalm-param array{message: string, ...mixed}|null $error */
public static function new(?array $error): self
{
$message = 'Could not create temporary file';
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/IBMDB2/Exception/PrepareFailed.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
final class PrepareFailed extends AbstractException
{
/** @psalm-param array{message: string}|null $error */
/** @psalm-param array{message: string, ...mixed}|null $error */
public static function new(?array $error): self
{
if ($error === null) {
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/Mysqli/Exception/ConnectionError.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ public static function upcast(mysqli_sql_exception $exception): self
$p = new ReflectionProperty(mysqli_sql_exception::class, 'sqlstate');
$p->setAccessible(true);

return new self($exception->getMessage(), $p->getValue($exception), (int) $exception->getCode(), $exception);
return new self($exception->getMessage(), $p->getValue($exception), $exception->getCode(), $exception);
}
}
2 changes: 1 addition & 1 deletion src/Driver/Mysqli/Exception/ConnectionFailed.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ public static function upcast(mysqli_sql_exception $exception): self
$p = new ReflectionProperty(mysqli_sql_exception::class, 'sqlstate');
$p->setAccessible(true);

return new self($exception->getMessage(), $p->getValue($exception), (int) $exception->getCode(), $exception);
return new self($exception->getMessage(), $p->getValue($exception), $exception->getCode(), $exception);
}
}
2 changes: 1 addition & 1 deletion src/Driver/Mysqli/Exception/InvalidCharset.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static function upcast(mysqli_sql_exception $exception, string $charset):
return new self(
sprintf('Failed to set charset "%s": %s', $charset, $exception->getMessage()),
$p->getValue($exception),
(int) $exception->getCode(),
$exception->getCode(),
$exception,
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/Mysqli/Exception/StatementError.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ public static function upcast(mysqli_sql_exception $exception): self
$p = new ReflectionProperty(mysqli_sql_exception::class, 'sqlstate');
$p->setAccessible(true);

return new self($exception->getMessage(), $p->getValue($exception), (int) $exception->getCode(), $exception);
return new self($exception->getMessage(), $p->getValue($exception), $exception->getCode(), $exception);
}
}
29 changes: 3 additions & 26 deletions src/DriverManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,32 +154,9 @@ private function __construct()
*
* @param Configuration|null $config The configuration to use.
* @param EventManager|null $eventManager The event manager to use.
* @psalm-param array{
* charset?: string,
* dbname?: string,
* default_dbname?: string,
* driver?: key-of<self::DRIVER_MAP>,
* driverClass?: class-string<Driver>,
* driverOptions?: array<mixed>,
* host?: string,
* keepSlave?: bool,
* keepReplica?: bool,
* master?: OverrideParams,
* memory?: bool,
* password?: string,
* path?: string,
* pdo?: \PDO,
* platform?: Platforms\AbstractPlatform,
* port?: int,
* primary?: OverrideParams,
* replica?: array<OverrideParams>,
* sharding?: array<string,mixed>,
* slaves?: array<OverrideParams>,
* user?: string,
* wrapperClass?: class-string<T>,
* } $params
*
* @psalm-return ($params is array{wrapperClass:mixed} ? T : Connection)
* @psalm-param Params $params
*
* @psalm-return ($params is array{wrapperClass: class-string<T>} ? T : Connection)
*
* @throws Exception
*
Expand Down
4 changes: 2 additions & 2 deletions tests/Query/Expression/ExpressionBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public function testIsNotNull(): void

public function testIn(): void
{
self::assertEquals('u.groups IN (1, 3, 4, 7)', $this->expr->in('u.groups', [1, 3, 4, 7]));
self::assertEquals('u.groups IN (1, 3, 4, 7)', $this->expr->in('u.groups', ['1', '3', '4', '7']));
}

public function testInWithPlaceholder(): void
Expand All @@ -237,7 +237,7 @@ public function testInWithPlaceholder(): void

public function testNotIn(): void
{
self::assertEquals('u.groups NOT IN (1, 3, 4, 7)', $this->expr->notIn('u.groups', [1, 3, 4, 7]));
self::assertEquals('u.groups NOT IN (1, 3, 4, 7)', $this->expr->notIn('u.groups', ['1', '3', '4', '7']));
}

public function testNotInWithPlaceholder(): void
Expand Down

0 comments on commit aa8b860

Please sign in to comment.