Skip to content

Commit

Permalink
Merge pull request #4943 from derrabus/bump/phpstan-on-2.13
Browse files Browse the repository at this point in the history
PHPStan 1.0.2
  • Loading branch information
greg0ire committed Nov 4, 2021
2 parents e94864e + fd088f1 commit 01595c0
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 30 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -41,7 +41,7 @@
"require-dev": {
"doctrine/coding-standard": "9.0.0",
"jetbrains/phpstorm-stubs": "2021.1",
"phpstan/phpstan": "0.12.99",
"phpstan/phpstan": "1.0.2",
"phpunit/phpunit": "^7.5.20|^8.5|9.5.10",
"psalm/plugin-phpunit": "0.16.1",
"squizlabs/php_codesniffer": "3.6.1",
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Connection.php
Expand Up @@ -1641,7 +1641,7 @@ public function errorInfo()
*
* @param string|null $name Name of the sequence object from which the ID should be returned.
*
* @return string A string representation of the last inserted ID.
* @return string|int|false A string representation of the last inserted ID.
*/
public function lastInsertId($name = null)
{
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/DBAL/DBALException.php
Expand Up @@ -156,7 +156,7 @@ public static function driverExceptionDuringQuery(Driver $driver, Throwable $dri

$msg .= ":\n\n" . $driverEx->getMessage();

return static::wrapException($driver, $driverEx, $msg);
return self::wrapException($driver, $driverEx, $msg);
}

/**
Expand All @@ -166,7 +166,7 @@ public static function driverExceptionDuringQuery(Driver $driver, Throwable $dri
*/
public static function driverException(Driver $driver, Throwable $driverEx)
{
return static::wrapException($driver, $driverEx, 'An exception occurred in driver: ' . $driverEx->getMessage());
return self::wrapException($driver, $driverEx, 'An exception occurred in driver: ' . $driverEx->getMessage());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Driver/Connection.php
Expand Up @@ -52,7 +52,7 @@ public function exec($sql);
*
* @param string|null $name
*
* @return string
* @return string|int|false
*/
public function lastInsertId($name = null);

Expand Down
4 changes: 4 additions & 0 deletions lib/Doctrine/DBAL/Driver/PDOConnection.php
Expand Up @@ -99,6 +99,10 @@ public function quote($value, $type = ParameterType::STRING)

/**
* {@inheritdoc}
*
* @param string|null $name
*
* @return string|int|false
*/
#[ReturnTypeWillChange]
public function lastInsertId($name = null)
Expand Down
6 changes: 3 additions & 3 deletions lib/Doctrine/DBAL/SQLParserUtils.php
Expand Up @@ -224,13 +224,13 @@ public static function expandListParameters($query, $params, $types)

foreach ($paramPos as $pos => $paramName) {
$paramLen = strlen($paramName) + 1;
$value = static::extractParam($paramName, $params, true);
$value = self::extractParam($paramName, $params, true);

if (! isset($arrayPositions[$paramName]) && ! isset($arrayPositions[':' . $paramName])) {
$pos += $queryOffset;
$queryOffset -= $paramLen - 1;
$paramsOrd[] = $value;
$typesOrd[] = static::extractParam($paramName, $types, false, ParameterType::STRING);
$typesOrd[] = self::extractParam($paramName, $types, false, ParameterType::STRING);
$query = substr($query, 0, $pos) . '?' . substr($query, $pos + $paramLen);

continue;
Expand All @@ -241,7 +241,7 @@ public static function expandListParameters($query, $params, $types)

foreach ($value as $val) {
$paramsOrd[] = $val;
$typesOrd[] = static::extractParam($paramName, $types, false) - Connection::ARRAY_PARAM_OFFSET;
$typesOrd[] = self::extractParam($paramName, $types, false) - Connection::ARRAY_PARAM_OFFSET;
}

$pos += $queryOffset;
Expand Down
7 changes: 0 additions & 7 deletions lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php
Expand Up @@ -6,7 +6,6 @@
use Doctrine\DBAL\Driver\Exception;
use Doctrine\DBAL\Platforms\SQLServerPlatform;
use Doctrine\DBAL\Types\Type;
use PDOException;
use Throwable;

use function assert;
Expand Down Expand Up @@ -252,12 +251,6 @@ public function listTableIndexes($table)

try {
$tableIndexes = $this->_conn->fetchAllAssociative($sql);
} catch (PDOException $e) {
if ($e->getCode() === 'IMSSP') {
return [];
}

throw $e;
} catch (DBALException $e) {
if (strpos($e->getMessage(), 'SQLSTATE [01000, 15472]') === 0) {
return [];
Expand Down
28 changes: 14 additions & 14 deletions phpstan.neon.dist
Expand Up @@ -16,9 +16,6 @@ parameters:
# removing it would be BC break
- '~^Constructor of class Doctrine\\DBAL\\Schema\\Table has an unused parameter \$idGeneratorType\.\z~'

# changing these would be a BC break, to be done in next major
- '~^Return type \(int\|false\) of method Doctrine\\DBAL\\Driver\\OCI8\\OCI8Connection\:\:lastInsertId\(\) should be compatible with return type \(string\) of method Doctrine\\DBAL\\Driver\\Connection::lastInsertId\(\)~'

# https://github.com/doctrine/dbal/pull/3836
- '~^Parameter #2 \$registeredAliases of static method Doctrine\\DBAL\\Query\\QueryException::nonUniqueAlias\(\) expects array<string>, array<int, int\|string> given\.\z~'

Expand Down Expand Up @@ -61,12 +58,6 @@ parameters:
paths:
- lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php

# Fixing the issue may cause a BC break.
-
message: '~^Method Doctrine\\DBAL\\Driver\\Mysqli\\MysqliConnection::lastInsertId\(\) should return string but returns int\|string\.$~'
paths:
- lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php

# This is deprecated code. Fixing the issue may cause a BC break.
# TODO: remove in 3.0.0
-
Expand All @@ -75,7 +66,7 @@ parameters:
- lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php

-
message: '~Method Doctrine\\DBAL\\Driver\\PDOSqlsrv\\Connection\:\:lastInsertId\(\) should return string but returns int\|string\|false\|null\.~'
message: '~Method Doctrine\\DBAL\\Driver\\PDOSqlsrv\\Connection\:\:lastInsertId\(\) should return int\|string\|false but returns int\|string\|false\|null\.~'
paths:
- lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php

Expand All @@ -96,9 +87,19 @@ parameters:
paths:
- lib/Doctrine/DBAL/Connection.php

# https://github.com/phpstan/phpstan/issues/5608
# PHPStan fails to parse this type alias which is meant for Psalm only.
-
message: '~^Invalid type definition detected in type alias (Override)?Params\.$~'
paths:
- lib/Doctrine/DBAL/DriverManager.php

-
message: '~Template type T of method Doctrine\\DBAL\\DriverManager::getConnection\(\) is not referenced in a parameter\.~'
paths:
- lib/Doctrine/DBAL/DriverManager.php

-
message: '~^Circular definition detected in type alias (Override)?Params\.$~'
message: '~Method Doctrine\\DBAL\\DriverManager::createDriver\(\) should return Doctrine\\DBAL\\Driver but returns object\.~'
paths:
- lib/Doctrine/DBAL/DriverManager.php

Expand All @@ -120,8 +121,7 @@ parameters:
paths:
- lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php

# https://github.com/phpstan/phpstan-src/pull/700
-
message: '~^Parameter #2 \$count of function array_fill expects int<0, max>, int given\.$~'
message: '~Method Doctrine\\DBAL\\Driver\\Mysqli\\MysqliStatement::rowCount\(\) should return int but returns int\|string\.~'
paths:
- lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php
2 changes: 1 addition & 1 deletion tests/Doctrine/Tests/DBAL/Functional/WriteTest.php
Expand Up @@ -366,7 +366,7 @@ public function testDeleteWhereIsNull(): void
* Returns the ID of the last inserted row or skips the test if the currently used driver
* doesn't support this feature
*
* @return string|false
* @return string|int|false
*
* @throws Exception
*/
Expand Down

0 comments on commit 01595c0

Please sign in to comment.