Unverified Commit 80306bce authored by Grégoire Paris's avatar Grégoire Paris

Merge branch '2.11.x' into 3.0.x

parents 34b17f27 50927b6b
......@@ -8,9 +8,26 @@ jobs:
static-analysis-psalm:
name: Static Analysis with Psalm
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: "Install PHP"
uses: "shivammathur/setup-php@1.8.1"
with:
coverage: "none"
php-version: "7.4"
- name: "Cache dependencies installed with composer"
uses: "actions/cache@v1.0.3"
with:
path: "~/.composer/cache"
key: "composer-${{ hashFiles('composer.json') }}"
restore-keys: "composer-"
- name: "Install dependencies with composer"
run: "composer update --no-interaction --no-progress --no-suggest"
- name: Psalm
uses: docker://vimeo/psalm-github-actions
run: "vendor/bin/psalm"
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="3.11.2@d470903722cfcbc1cd04744c5491d3e6d13ec3d9">
<file src="src/Driver/Connection.php">
<InvalidParamDefault occurrences="1">
<code>int</code>
</InvalidParamDefault>
</file>
<file src="src/Driver/DriverException.php">
<MissingImmutableAnnotation occurrences="1">
<code>public function getMessage();</code>
</MissingImmutableAnnotation>
</file>
<file src="src/Driver/PDOSqlsrv/Statement.php">
<UndefinedConstant occurrences="1">
<code>PDO::SQLSRV_ENCODING_BINARY</code>
</UndefinedConstant>
</file>
<file src="src/Driver/SQLAnywhere/SQLAnywhereConnection.php">
<UndefinedFunction occurrences="14">
<code>sasql_pconnect($dsn)</code>
<code>sasql_connect($dsn)</code>
<code>sasql_set_option($this-&gt;connection, 'verbose_errors', false)</code>
<code>sasql_set_option($this-&gt;connection, 'auto_commit', 'on')</code>
<code>sasql_set_option($this-&gt;connection, 'auto_commit', 'off')</code>
<code>sasql_commit($this-&gt;connection)</code>
<code>sasql_errorcode($this-&gt;connection)</code>
<code>sasql_error($this-&gt;connection)</code>
<code>sasql_real_query($this-&gt;connection, $statement)</code>
<code>sasql_affected_rows($this-&gt;connection)</code>
<code>sasql_insert_id($this-&gt;connection)</code>
<code>sasql_escape_string($this-&gt;connection, $input)</code>
<code>sasql_rollback($this-&gt;connection)</code>
<code>sasql_set_option($this-&gt;connection, 'auto_commit', 'on')</code>
</UndefinedFunction>
</file>
<file src="src/Driver/SQLAnywhere/SQLAnywhereException.php">
<UndefinedFunction occurrences="8">
<code>sasql_sqlstate($conn)</code>
<code>sasql_sqlstate()</code>
<code>sasql_stmt_errno($stmt)</code>
<code>sasql_stmt_error($stmt)</code>
<code>sasql_errorcode($conn)</code>
<code>sasql_error($conn)</code>
<code>sasql_errorcode()</code>
<code>sasql_error()</code>
</UndefinedFunction>
</file>
<file src="src/Driver/SQLAnywhere/SQLAnywhereStatement.php">
<UndefinedConstant occurrences="1">
<code>SASQL_BOTH</code>
</UndefinedConstant>
<UndefinedFunction occurrences="12">
<code>sasql_prepare($conn, $sql)</code>
<code>sasql_stmt_bind_param_ex($this-&gt;stmt, $column - 1, $variable, $type, $variable === null)</code>
<code>sasql_stmt_reset($this-&gt;stmt)</code>
<code>sasql_stmt_field_count($this-&gt;stmt)</code>
<code>sasql_stmt_errno($this-&gt;stmt)</code>
<code>sasql_stmt_error($this-&gt;stmt)</code>
<code>sasql_stmt_execute($this-&gt;stmt)</code>
<code>sasql_stmt_result_metadata($this-&gt;stmt)</code>
<code>sasql_fetch_assoc($this-&gt;result)</code>
<code>sasql_fetch_array($this-&gt;result, SASQL_BOTH)</code>
<code>sasql_fetch_row($this-&gt;result)</code>
<code>sasql_stmt_affected_rows($this-&gt;stmt)</code>
</UndefinedFunction>
</file>
<file src="src/Driver/SQLSrv/SQLSrvStatement.php">
<TooFewArguments occurrences="1">
<code>sqlsrv_get_field($this-&gt;stmt, 0)</code>
</TooFewArguments>
</file>
<file src="src/Platforms/AbstractPlatform.php">
<InvalidParamDefault occurrences="1">
<code>int</code>
</InvalidParamDefault>
</file>
<file src="src/Schema/AbstractSchemaManager.php">
<InvalidParamDefault occurrences="1">
<code>string</code>
</InvalidParamDefault>
</file>
<file src="src/Tools/Dumper.php">
<UndefinedClass occurrences="1">
<code>Collection</code>
</UndefinedClass>
</file>
<file src="tests/Driver/PDOPgSql/DriverTest.php">
<UndefinedConstant occurrences="5">
<code>PDO::PGSQL_ATTR_DISABLE_PREPARES</code>
<code>PDO::PGSQL_ATTR_DISABLE_PREPARES</code>
<code>PDO::PGSQL_ATTR_DISABLE_PREPARES</code>
<code>PDO::PGSQL_ATTR_DISABLE_PREPARES</code>
<code>PDO::PGSQL_ATTR_DISABLE_PREPARES</code>
</UndefinedConstant>
</file>
<file src="tests/Platforms/AbstractMySQLPlatformTestCase.php">
<UndefinedDocblockClass occurrences="93">
<code>MySqlPlatform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
</UndefinedDocblockClass>
</file>
<file src="tests/Platforms/MariaDb1027PlatformTest.php">
<UndefinedDocblockClass occurrences="4">
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
</UndefinedDocblockClass>
</file>
<file src="tests/Platforms/MySQL57PlatformTest.php">
<UndefinedDocblockClass occurrences="4">
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
<code>$this-&gt;platform</code>
</UndefinedDocblockClass>
</file>
<file src="tests/Platforms/MySqlPlatformTest.php">
<UndefinedDocblockClass occurrences="1">
<code>$this-&gt;platform</code>
</UndefinedDocblockClass>
</file>
</files>
......@@ -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": "2bfb777be05719fd36dcceba620f8892",
"content-hash": "b1aaf618f2a43579f70e9429ed20a75c",
"packages": [
{
"name": "doctrine/cache",
......
......@@ -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"
>
<projectFiles>
<directory name="src" />
......@@ -16,10 +15,43 @@
</ignoreFiles>
</projectFiles>
<stubs>
<file name="vendor/jetbrains/phpstorm-stubs/PDO/PDO.php" />
<file name="vendor/jetbrains/phpstorm-stubs/ibm_db2/ibm_db2.php" />
<file name="vendor/jetbrains/phpstorm-stubs/mysqli/mysqli.php" />
<file name="vendor/jetbrains/phpstorm-stubs/oci8/oci8.php" />
<file name="vendor/jetbrains/phpstorm-stubs/pgsql/pgsql.php" />
<file name="vendor/jetbrains/phpstorm-stubs/sqlsrv/sqlsrv.php" />
</stubs>
<issueHandlers>
<TooFewArguments>
<errorLevel type="suppress">
<!--
Requires a release of
https://github.com/JetBrains/phpstorm-stubs/pull/727
-->
<file name="src/Driver/SQLSrv/SQLSrvStatement.php"/>
</errorLevel>
</TooFewArguments>
<UndefinedConstant>
<errorLevel type="suppress">
<directory name="src/Driver/SQLAnywhere"/>
<!--
Requires a release of
https://github.com/JetBrains/phpstorm-stubs/pull/732
-->
<file name="tests/Driver/PDOPgSql/DriverTest.php" />
</errorLevel>
</UndefinedConstant>
<UndefinedFunction>
<errorLevel type="suppress">
<directory name="src/Driver/SQLAnywhere"/>
</errorLevel>
</UndefinedFunction>
<UndefinedClass>
<errorLevel type="suppress">
<!-- Contains references to optional dependencies -->
<file name="src/Tools/Dumper.php"/>
</errorLevel>
</UndefinedClass>
</issueHandlers>
</psalm>
......@@ -4,6 +4,9 @@ namespace Doctrine\DBAL\Cache;
use Doctrine\DBAL\DBALException;
/**
* @psalm-immutable
*/
class CacheException extends DBALException
{
/**
......
......@@ -816,7 +816,7 @@ class Connection implements DriverConnection
/**
* {@inheritDoc}
*/
public function quote($input, $type = null)
public function quote($input, $type = ParameterType::STRING)
{
$connection = $this->getWrappedConnection();
......
......@@ -2,6 +2,9 @@
namespace Doctrine\DBAL;
/**
* @psalm-immutable
*/
class ConnectionException extends DBALException
{
/**
......
......@@ -23,6 +23,9 @@ use function preg_replace;
use function spl_object_hash;
use function sprintf;
/**
* @psalm-immutable
*/
class DBALException extends Exception
{
/**
......
......@@ -6,6 +6,8 @@ use Exception;
/**
* Abstract base implementation of the {@link DriverException} interface.
*
* @psalm-immutable
*/
abstract class AbstractDriverException extends Exception implements DriverException
{
......
......@@ -9,6 +9,8 @@ use Throwable;
*
* 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
{
......
......@@ -4,6 +4,9 @@ namespace Doctrine\DBAL\Driver\IBMDB2;
use Exception;
/**
* @psalm-immutable
*/
class DB2Exception extends Exception
{
}
......@@ -6,6 +6,8 @@ namespace Doctrine\DBAL\Driver\Mysqli;
/**
* @internal
*
* @psalm-immutable
*/
final class HostRequired extends MysqliException
{
......
......@@ -6,6 +6,8 @@ use Doctrine\DBAL\Driver\AbstractDriverException;
/**
* Exception thrown in case the mysqli driver errors.
*
* @psalm-immutable
*/
class MysqliException extends AbstractDriverException
{
......
......@@ -4,6 +4,9 @@ namespace Doctrine\DBAL\Driver\OCI8;
use Doctrine\DBAL\Driver\AbstractDriverException;
/**
* @psalm-immutable
*/
class OCI8Exception extends AbstractDriverException
{
/**
......
......@@ -4,6 +4,8 @@ namespace Doctrine\DBAL\Driver;
/**
* Tiny wrapper for PDOException instances to implement the {@link DriverException} interface.
*
* @psalm-immutable
*/
class PDOException extends \PDOException implements DriverException
{
......
......@@ -12,6 +12,8 @@ use function sasql_stmt_error;
/**
* SAP Sybase SQL Anywhere driver exception.
*
* @psalm-immutable
*/
class SQLAnywhereException extends AbstractDriverException
{
......
......@@ -7,6 +7,9 @@ use const SQLSRV_ERR_ERRORS;
use function rtrim;
use function sqlsrv_errors;
/**
* @psalm-immutable
*/
class SQLSrvException extends AbstractDriverException
{
/**
......
......@@ -4,6 +4,8 @@ namespace Doctrine\DBAL\Exception;
/**
* Base class for all connection related errors detected in the driver.
*
* @psalm-immutable
*/
class ConnectionException extends DriverException
{
......
......@@ -4,6 +4,8 @@ namespace Doctrine\DBAL\Exception;
/**
* Base class for all constraint violation related errors detected in the driver.
*
* @psalm-immutable
*/
class ConstraintViolationException extends ServerException
{
......
......@@ -8,6 +8,8 @@ namespace Doctrine\DBAL\Exception;
* A database object is considered any asset that can be created in a database
* such as schemas, tables, views, sequences, triggers, constraints, indexes,
* functions, stored procedures etc.
*
* @psalm-immutable
*/
class DatabaseObjectExistsException extends ServerException
{
......
......@@ -8,6 +8,8 @@ namespace Doctrine\DBAL\Exception;
* A database object is considered any asset that can be created in a database
* such as schemas, tables, views, sequences, triggers, constraints, indexes,
* functions, stored procedures etc.
*
* @psalm-immutable
*/
class DatabaseObjectNotFoundException extends ServerException
{
......
......@@ -4,6 +4,8 @@ namespace Doctrine\DBAL\Exception;
/**
* Exception for a deadlock error of a transaction detected in the driver.
*
* @psalm-immutable
*/
class DeadlockException extends ServerException implements RetryableException
{
......
......@@ -7,6 +7,8 @@ use Exception;
/**
* Base class for all errors detected in the driver.
*
* @psalm-immutable
*/
class DriverException extends DBALException
{
......
......@@ -4,6 +4,8 @@ namespace Doctrine\DBAL\Exception;
/**
* Exception for a foreign key constraint violation detected in the driver.
*
* @psalm-immutable
*/
class ForeignKeyConstraintViolationException extends ConstraintViolationException
{
......
......@@ -6,6 +6,8 @@ use Doctrine\DBAL\DBALException;
/**
* Exception to be thrown when invalid arguments are passed to any DBAL API
*
* @psalm-immutable
*/
class InvalidArgumentException extends DBALException
{
......
......@@ -4,6 +4,8 @@ namespace Doctrine\DBAL\Exception;
/**
* Exception for an invalid specified field name in a statement detected in the driver.
*
* @psalm-immutable
*/
class InvalidFieldNameException extends ServerException
{
......
......@@ -4,6 +4,8 @@ namespace Doctrine\DBAL\Exception;
/**
* Exception for a lock wait timeout error of a transaction detected in the driver.
*
* @psalm-immutable
*/
class LockWaitTimeoutException extends ServerException implements RetryableException
{
......
......@@ -4,6 +4,8 @@ namespace Doctrine\DBAL\Exception;
/**
* Exception for a non-unique/ambiguous specified field name in a statement detected in the driver.
*
* @psalm-immutable
*/
class NonUniqueFieldNameException extends ServerException
{
......
......@@ -4,6 +4,8 @@ namespace Doctrine\DBAL\Exception;
/**
* Exception for a NOT NULL constraint violation detected in the driver.
*
* @psalm-immutable
*/
class NotNullConstraintViolationException extends ConstraintViolationException
{
......
......@@ -4,6 +4,8 @@ namespace Doctrine\DBAL\Exception;
/**
* Exception for a write operation attempt on a read-only database element detected in the driver.
*
* @psalm-immutable
*/
class ReadOnlyException extends ServerException
{
......
......@@ -4,6 +4,8 @@ namespace Doctrine\DBAL\Exception;
/**
* Base class for all server related errors detected in the driver.
*
* @psalm-immutable
*/
class ServerException extends DriverException
{
......
......@@ -4,6 +4,8 @@ namespace Doctrine\DBAL\Exception;
/**
* Exception for a syntax error in a statement detected in the driver.
*
* @psalm-immutable
*/
class SyntaxErrorException extends ServerException
{
......
......@@ -4,6 +4,8 @@ namespace Doctrine\DBAL\Exception;
/**
* Exception for an already existing table referenced in a statement detected in the driver.
*
* @psalm-immutable
*/
class TableExistsException extends DatabaseObjectExistsException
{
......
......@@ -4,6 +4,8 @@ namespace Doctrine\DBAL\Exception;
/**
* Exception for an unknown table referenced in a statement detected in the driver.
*
* @psalm-immutable
*/
class TableNotFoundException extends DatabaseObjectNotFoundException
{
......
......@@ -4,6 +4,8 @@ namespace Doctrine\DBAL\Exception;
/**
* Exception for a unique constraint violation detected in the driver.
*
* @psalm-immutable
*/
class UniqueConstraintViolationException extends ConstraintViolationException
{
......
......@@ -806,6 +806,8 @@ class SqlitePlatform extends AbstractPlatform
/**
* {@inheritDoc}
*
* @param int|null $createFlags
*/
public function getCreateTableSQL(Table $table, $createFlags = null)
{
......
......@@ -5,6 +5,9 @@ namespace Doctrine\DBAL\Query;
use Doctrine\DBAL\DBALException;
use function implode;
/**
* @psalm-immutable
*/
class QueryException extends DBALException
{
/**
......
......@@ -6,6 +6,8 @@ use function sprintf;
/**
* Doctrine\DBAL\ConnectionException
*
* @psalm-immutable
*/
class SQLParserUtilsException extends DBALException
{
......
......@@ -287,6 +287,8 @@ class OracleSchemaManager extends AbstractSchemaManager
/**
* {@inheritdoc}
*
* @param string|null $database
*
* Calling this method without an argument or by passing NULL is deprecated.
*/
public function createDatabase($database = null)
......
......@@ -6,6 +6,9 @@ use Doctrine\DBAL\DBALException;
use function implode;
use function sprintf;
/**
* @psalm-immutable
*/
class SchemaException extends DBALException
{
public const TABLE_DOESNT_EXIST = 10;
......
......@@ -15,6 +15,8 @@ use function substr;
/**
* Conversion Exception is thrown when the database to PHP conversion fails.
*
* @psalm-immutable
*/
class ConversionException extends DBALException
{
......
<?php
namespace Doctrine\DBAL\Tests\Functional;
use Doctrine\DBAL\Logging\SQLLogger;
use Doctrine\DBAL\Tests\FunctionalTestCase;
class LoggingTest extends FunctionalTestCase
{
public function testLogExecuteQuery() : void
{
$sql = $this->connection->getDatabasePlatform()->getDummySelectSQL();
$logMock = $this->createMock(SQLLogger::class);
$logMock->expects(self::at(0))
->method('startQuery')
->with(self::equalTo($sql), self::equalTo([]), self::equalTo([]));
$logMock->expects(self::at(1))
->method('stopQuery');
$this->connection->getConfiguration()->setSQLLogger($logMock);
$this->connection->executeQuery($sql, []);
}
public function testLogExecuteUpdate() : void
{
$this->markTestSkipped('Test breaks MySQL but works on all other platforms (Unbuffered Queries stuff).');
$sql = $this->connection->getDatabasePlatform()->getDummySelectSQL();
$logMock = $this->createMock(SQLLogger::class);
$logMock->expects(self::at(0))
->method('startQuery')
->with(self::equalTo($sql), self::equalTo([]), self::equalTo([]));
$logMock->expects(self::at(1))
->method('stopQuery');
$this->connection->getConfiguration()->setSQLLogger($logMock);
$this->connection->executeUpdate($sql, []);
}
public function testLogPrepareExecute() : void
{
$sql = $this->connection->getDatabasePlatform()->getDummySelectSQL();
$logMock = $this->createMock(SQLLogger::class);
$logMock->expects(self::once())
->method('startQuery')
->with(self::equalTo($sql), self::equalTo([]));
$logMock->expects(self::at(1))
->method('stopQuery');
$this->connection->getConfiguration()->setSQLLogger($logMock);
$stmt = $this->connection->prepare($sql);
$stmt->execute();
}
}
......@@ -3,6 +3,7 @@
namespace Doctrine\DBAL\Tests\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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment