From 7882804bed128c323ac69579641827d76aef77f4 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sat, 16 Oct 2021 11:40:19 +0200 Subject: [PATCH 1/3] Add missing upcast --- lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php index ca95d1bf4ce..cdced59c776 100644 --- a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php +++ b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php @@ -317,10 +317,16 @@ private function bindUntypedValues(array $values) /** * @return mixed[]|false|null + * + * @throws StatementError */ private function _fetch() { - $ret = $this->_stmt->fetch(); + try { + $ret = $this->_stmt->fetch(); + } catch (mysqli_sql_exception $e) { + throw StatementError::upcast($e); + } if ($ret === true) { $values = []; From a466400ead8cee48bb38c306ff0604696a644ac1 Mon Sep 17 00:00:00 2001 From: Simon Berger Date: Sun, 17 Oct 2021 19:02:50 +0200 Subject: [PATCH 2/3] #4886 Fixed calling `AbstractPlatform::getAdvancedForeignKeyOptionsSQL` triggers a deprecation --- lib/Doctrine/DBAL/Platforms/AbstractPlatform.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php index 9274e1bfdb4..0af5b391f97 100644 --- a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php @@ -3247,7 +3247,7 @@ public function supportsForeignKeyConstraints() */ public function supportsForeignKeyOnUpdate() { - Deprecation::trigger( + Deprecation::triggerIfCalledFromOutside( 'doctrine/dbal', 'https://github.com/doctrine/dbal/pull/4229', 'AbstractPlatform::supportsForeignKeyOnUpdate() is deprecated without replacement and removed in DBAL 3.0' From 45a2cae104bc2c47a233f926b68d5bfa3d2539f3 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 19 Oct 2021 00:08:28 +0200 Subject: [PATCH 3/3] Cleanup ignored PHPStan errors Signed-off-by: Alexander M. Turek --- phpstan.neon.dist | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 0430b51829e..6815902ef98 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -17,8 +17,6 @@ parameters: - '~^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 - - '~^Property Doctrine\\DBAL\\Schema\\Table::\$_primaryKeyName \(string\) does not accept (default value of type )?false\.\z~' - - '~^Property Doctrine\\DBAL\\Schema\\Schema::\$_schemaConfig \(Doctrine\\DBAL\\Schema\\SchemaConfig\) does not accept default value of type false\.\z~' - '~^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 @@ -35,16 +33,6 @@ parameters: - '~^Class Doctrine\\Common\\(Collections\\Collection|Persistence\\Proxy) not found\.\z~' - '~^.+ on an unknown class Doctrine\\Common\\(Collections\\Collection|Persistence\\Proxy)\.\z~' - # weird class name, represented in stubs as OCI_(Lob|Collection) - - '~unknown class OCI-(Lob|Collection)~' - - '~^Call to method writeTemporary\(\) on an unknown class OCILob\.~' - - # The ReflectionException in the case when the class does not exist is acceptable and does not need to be handled - - '~^Parameter #1 \$argument of class ReflectionClass constructor expects class-string\|T of object, string given\.$~' - - # Needs Generics - - '~Method Doctrine\\DBAL\\Schema\\SchemaDiff::getNewTablesSortedByDependencies\(\) should return array but returns array.~' - # This is deprecated code. Fixing the issue may cause a BC break. # TODO: remove in 3.0.0 - @@ -79,13 +67,6 @@ parameters: paths: - lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php - # Fixing the issue may cause a BC break. - # TODO: fix in 3.0.0 - - - message: '~^Parameter \#2 \$sqlState of class Doctrine\\DBAL\\Driver\\Mysqli\\MysqliException constructor expects string\|null, int given\.$~' - paths: - - lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php - # This is deprecated code. Fixing the issue may cause a BC break. # TODO: remove in 3.0.0 - @@ -93,13 +74,6 @@ parameters: paths: - lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php - # This is poorly typed deprecated code. The issue doesn't have practical implication and can be suppressed. - # TODO: remove in 3.0.0 - - - message: '~^Parameter \#1 \$how of method PDOStatement\:\:fetchAll\(\) expects int, array\|int\|null given\.$~' - paths: - - lib/Doctrine/DBAL/Driver/PDOStatement.php - - message: '~Method Doctrine\\DBAL\\Driver\\PDOSqlsrv\\Connection\:\:lastInsertId\(\) should return string but returns int\|string\|false\|null\.~' paths: @@ -122,9 +96,6 @@ parameters: paths: - lib/Doctrine/DBAL/Connection.php - # The class was added in PHP 8.1 - - '~^Attribute class ReturnTypeWillChange does not exist.$~' - # https://github.com/phpstan/phpstan/issues/5608 - message: '~^Circular definition detected in type alias (Override)?Params\.$~'