From b222367582031a882479cddf4402656ce5cf4593 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 15 Apr 2020 18:45:48 +0200 Subject: [PATCH 1/8] Upgrade nikic/php-parser For some reason a low version crashes Psalm. --- composer.json | 1 + composer.lock | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index fd88e428cf2..f17794bcec0 100644 --- a/composer.json +++ b/composer.json @@ -40,6 +40,7 @@ "require-dev": { "doctrine/coding-standard": "^6.0", "jetbrains/phpstorm-stubs": "^2019.1", + "nikic/php-parser": "^4.4", "phpstan/phpstan": "^0.12", "phpunit/phpunit": "^8.4.1", "symfony/console": "^2.0.5|^3.0|^4.0|^5.0", diff --git a/composer.lock b/composer.lock index 4dda16ace6b..215798b08a1 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a0ee337c9500698eeb5d25f1e4a84b69", + "content-hash": "b7f970513c9756e5eaaba3974429c23c", "packages": [ { "name": "doctrine/cache", @@ -816,16 +816,16 @@ }, { "name": "nikic/php-parser", - "version": "v4.3.0", + "version": "v4.4.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "9a9981c347c5c49d6dfe5cf826bb882b824080dc" + "reference": "bd43ec7152eaaab3bd8c6d0aa95ceeb1df8ee120" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/9a9981c347c5c49d6dfe5cf826bb882b824080dc", - "reference": "9a9981c347c5c49d6dfe5cf826bb882b824080dc", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/bd43ec7152eaaab3bd8c6d0aa95ceeb1df8ee120", + "reference": "bd43ec7152eaaab3bd8c6d0aa95ceeb1df8ee120", "shasum": "" }, "require": { @@ -864,7 +864,7 @@ "parser", "php" ], - "time": "2019-11-08T13:50:10+00:00" + "time": "2020-04-10T16:34:50+00:00" }, { "name": "ocramius/package-versions", From bcf6a619fb2bcd6b581c6cd2e6f129f75406fe05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 15 Apr 2020 18:37:45 +0200 Subject: [PATCH 2/8] Add missing use statement --- baseline.xml | 118 ------------------ .../AbstractMySQLPlatformTestCase.php | 1 + 2 files changed, 1 insertion(+), 118 deletions(-) diff --git a/baseline.xml b/baseline.xml index a75903a9716..957906892c3 100644 --- a/baseline.xml +++ b/baseline.xml @@ -95,122 +95,4 @@ PDO::PGSQL_ATTR_DISABLE_PREPARES - - - MySqlPlatform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - $this->platform - - - - - $this->platform - $this->platform - $this->platform - $this->platform - - - - - $this->platform - $this->platform - $this->platform - $this->platform - - - - - $this->platform - - diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php index bbae08c5b2c..9bd0ae62f85 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php @@ -3,6 +3,7 @@ namespace Doctrine\Tests\DBAL\Platforms; use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\DBAL\Platforms\MySqlPlatform; use Doctrine\DBAL\Schema\Comparator; use Doctrine\DBAL\Schema\ForeignKeyConstraint; use Doctrine\DBAL\Schema\Index; From 1e17583551b802057c206b9cc3acfcdb8d224678 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 15 Apr 2020 19:01:42 +0200 Subject: [PATCH 3/8] Avoid conflict with parent phpdoc --- baseline.xml | 10 ---------- lib/Doctrine/DBAL/Platforms/SqlitePlatform.php | 2 ++ lib/Doctrine/DBAL/Schema/OracleSchemaManager.php | 2 ++ 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/baseline.xml b/baseline.xml index 957906892c3..775fb2bdcfa 100644 --- a/baseline.xml +++ b/baseline.xml @@ -71,16 +71,6 @@ sqlsrv_get_field($this->stmt, 0) - - - int - - - - - string - - Collection diff --git a/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php b/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php index b0e3713ab27..4eff83e8dcf 100644 --- a/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php +++ b/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php @@ -807,6 +807,8 @@ public function getCreateConstraintSQL(Constraint $constraint, $table) /** * {@inheritDoc} + * + * @param int|null $createFlags */ public function getCreateTableSQL(Table $table, $createFlags = null) { diff --git a/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php b/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php index 9718f932ef5..dd10cd0f928 100644 --- a/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php @@ -287,6 +287,8 @@ protected function _getPortableDatabaseDefinition($database) /** * {@inheritdoc} * + * @param string|null $database + * * Calling this method without an argument or by passing NULL is deprecated. */ public function createDatabase($database = null) From 4cff5bc66d26a23c2131e3c6579788eef737d874 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 15 Apr 2020 19:12:43 +0200 Subject: [PATCH 4/8] Add stub file for PDO --- baseline.xml | 5 ----- psalm.xml | 1 + 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/baseline.xml b/baseline.xml index 775fb2bdcfa..811b273fd05 100644 --- a/baseline.xml +++ b/baseline.xml @@ -10,11 +10,6 @@ public function getMessage(); - - - PDO::SQLSRV_ENCODING_BINARY - - sasql_pconnect($dsn) diff --git a/psalm.xml b/psalm.xml index 2b9fdb0d21b..93f3d2c03c8 100644 --- a/psalm.xml +++ b/psalm.xml @@ -16,6 +16,7 @@ + From 5a61341fea474990fe2c4fb5e27515c053ccf4a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 15 Apr 2020 19:27:14 +0200 Subject: [PATCH 5/8] Mark exceptions as immutable --- baseline.xml | 5 ----- lib/Doctrine/DBAL/Driver/AbstractDriverException.php | 2 ++ lib/Doctrine/DBAL/Driver/DriverException.php | 2 ++ lib/Doctrine/DBAL/Driver/Mysqli/MysqliException.php | 2 ++ lib/Doctrine/DBAL/Driver/OCI8/OCI8Exception.php | 3 +++ lib/Doctrine/DBAL/Driver/PDOException.php | 2 ++ .../DBAL/Driver/SQLAnywhere/SQLAnywhereException.php | 2 ++ lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvException.php | 3 +++ 8 files changed, 16 insertions(+), 5 deletions(-) diff --git a/baseline.xml b/baseline.xml index 811b273fd05..194eced230f 100644 --- a/baseline.xml +++ b/baseline.xml @@ -5,11 +5,6 @@ int - - - public function getMessage(); - - sasql_pconnect($dsn) diff --git a/lib/Doctrine/DBAL/Driver/AbstractDriverException.php b/lib/Doctrine/DBAL/Driver/AbstractDriverException.php index d9af92d1744..f57de38f09c 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractDriverException.php +++ b/lib/Doctrine/DBAL/Driver/AbstractDriverException.php @@ -6,6 +6,8 @@ /** * Abstract base implementation of the {@link DriverException} interface. + * + * @psalm-immutable */ abstract class AbstractDriverException extends Exception implements DriverException { diff --git a/lib/Doctrine/DBAL/Driver/DriverException.php b/lib/Doctrine/DBAL/Driver/DriverException.php index 79480ac72be..14cd5186e4d 100644 --- a/lib/Doctrine/DBAL/Driver/DriverException.php +++ b/lib/Doctrine/DBAL/Driver/DriverException.php @@ -9,6 +9,8 @@ * * Driver exceptions provide the SQLSTATE of the driver * and the driver specific error code at the time the error occurred. + * + * @psalm-immutable */ interface DriverException extends Throwable { diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliException.php b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliException.php index 1fa0c900fbd..8e8e697c4a3 100644 --- a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliException.php +++ b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliException.php @@ -6,6 +6,8 @@ /** * Exception thrown in case the mysqli driver errors. + * + * @psalm-immutable */ class MysqliException extends AbstractDriverException { diff --git a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Exception.php b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Exception.php index af3a9d1a7a9..42283e08a57 100644 --- a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Exception.php +++ b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Exception.php @@ -4,6 +4,9 @@ use Doctrine\DBAL\Driver\AbstractDriverException; +/** + * @psalm-immutable + */ class OCI8Exception extends AbstractDriverException { /** diff --git a/lib/Doctrine/DBAL/Driver/PDOException.php b/lib/Doctrine/DBAL/Driver/PDOException.php index 277d7a62500..c2571032b80 100644 --- a/lib/Doctrine/DBAL/Driver/PDOException.php +++ b/lib/Doctrine/DBAL/Driver/PDOException.php @@ -4,6 +4,8 @@ /** * Tiny wrapper for PDOException instances to implement the {@link DriverException} interface. + * + * @psalm-immutable */ class PDOException extends \PDOException implements DriverException { diff --git a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereException.php b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereException.php index 0f8bc3e57e6..022cfe2dfa7 100644 --- a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereException.php +++ b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereException.php @@ -12,6 +12,8 @@ /** * SAP Sybase SQL Anywhere driver exception. + * + * @psalm-immutable */ class SQLAnywhereException extends AbstractDriverException { diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvException.php b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvException.php index 1c1e8c472d7..5618ed73560 100644 --- a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvException.php +++ b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvException.php @@ -7,6 +7,9 @@ use function rtrim; use function sqlsrv_errors; +/** + * @psalm-immutable + */ class SQLSrvException extends AbstractDriverException { /** From 827bd2201a2d0a690cbd8c4f6a22e5163116f921 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 15 Apr 2020 20:04:47 +0200 Subject: [PATCH 6/8] Suppress errors about SqlAnywhere symbols --- baseline.xml | 51 --------------------------------------------------- psalm.xml | 12 ++++++++++++ 2 files changed, 12 insertions(+), 51 deletions(-) diff --git a/baseline.xml b/baseline.xml index 194eced230f..3d5340ab863 100644 --- a/baseline.xml +++ b/baseline.xml @@ -5,57 +5,6 @@ int - - - sasql_pconnect($dsn) - sasql_connect($dsn) - sasql_set_option($this->connection, 'verbose_errors', false) - sasql_set_option($this->connection, 'auto_commit', 'on') - sasql_set_option($this->connection, 'auto_commit', 'off') - sasql_commit($this->connection) - sasql_errorcode($this->connection) - sasql_error($this->connection) - sasql_real_query($this->connection, $statement) - sasql_affected_rows($this->connection) - sasql_insert_id($this->connection) - sasql_escape_string($this->connection, $input) - sasql_rollback($this->connection) - sasql_set_option($this->connection, 'auto_commit', 'on') - - - - - sasql_sqlstate($conn) - sasql_sqlstate() - sasql_stmt_errno($stmt) - sasql_stmt_error($stmt) - sasql_errorcode($conn) - sasql_error($conn) - sasql_errorcode() - sasql_error() - - - - - SASQL_BOTH - - - sasql_prepare($conn, $sql) - sasql_stmt_bind_param_ex($this->stmt, $column - 1, $variable, $type, $variable === null) - sasql_stmt_reset($this->stmt) - sasql_stmt_field_count($this->stmt) - sasql_stmt_errno($this->stmt) - sasql_stmt_error($this->stmt) - sasql_stmt_execute($this->stmt) - sasql_stmt_result_metadata($this->stmt) - sasql_fetch_assoc($this->result) - sasql_fetch_array($this->result, SASQL_BOTH) - sasql_fetch_object($this->result) - sasql_fetch_row($this->result) - sasql_fetch_object($this->result) - sasql_stmt_affected_rows($this->stmt) - - sqlsrv_get_field($this->stmt, 0) diff --git a/psalm.xml b/psalm.xml index 93f3d2c03c8..c9e0fdedff3 100644 --- a/psalm.xml +++ b/psalm.xml @@ -23,4 +23,16 @@ + + + + + + + + + + + + From 365b4d7d85c38c10d6cbb07a4c8bfd01c0efd300 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 15 Apr 2020 22:59:46 +0200 Subject: [PATCH 7/8] Suppress errors about unreleased stubs --- baseline.xml | 19 ------------------- psalm.xml | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/baseline.xml b/baseline.xml index 3d5340ab863..24b901585e4 100644 --- a/baseline.xml +++ b/baseline.xml @@ -5,23 +5,4 @@ int - - - sqlsrv_get_field($this->stmt, 0) - - - - - Collection - - - - - PDO::PGSQL_ATTR_DISABLE_PREPARES - PDO::PGSQL_ATTR_DISABLE_PREPARES - PDO::PGSQL_ATTR_DISABLE_PREPARES - PDO::PGSQL_ATTR_DISABLE_PREPARES - PDO::PGSQL_ATTR_DISABLE_PREPARES - - diff --git a/psalm.xml b/psalm.xml index c9e0fdedff3..ce0f988ac87 100644 --- a/psalm.xml +++ b/psalm.xml @@ -24,9 +24,23 @@ + + + + + + + + @@ -34,5 +48,11 @@ + + + + + + From bbf31dc400d3dde13199caeedaea847d38b9c6db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 15 Apr 2020 23:19:00 +0200 Subject: [PATCH 8/8] Use a proper default value null contradicts the phpdoc --- baseline.xml | 8 -------- lib/Doctrine/DBAL/Connection.php | 2 +- psalm.xml | 1 - 3 files changed, 1 insertion(+), 10 deletions(-) delete mode 100644 baseline.xml diff --git a/baseline.xml b/baseline.xml deleted file mode 100644 index 24b901585e4..00000000000 --- a/baseline.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - int - - - diff --git a/lib/Doctrine/DBAL/Connection.php b/lib/Doctrine/DBAL/Connection.php index e2d78ae1559..10da0f98f4d 100644 --- a/lib/Doctrine/DBAL/Connection.php +++ b/lib/Doctrine/DBAL/Connection.php @@ -823,7 +823,7 @@ public function quoteIdentifier($str) /** * {@inheritDoc} */ - public function quote($input, $type = null) + public function quote($input, $type = ParameterType::STRING) { $connection = $this->getWrappedConnection(); diff --git a/psalm.xml b/psalm.xml index ce0f988ac87..3db108eb2ac 100644 --- a/psalm.xml +++ b/psalm.xml @@ -6,7 +6,6 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" - errorBaseline="baseline.xml" >