Variable method call on an object

parent e6765782
...@@ -103,5 +103,12 @@ parameters: ...@@ -103,5 +103,12 @@ parameters:
message: '~^Variable property access on object\.~' message: '~^Variable property access on object\.~'
paths: paths:
- %currentWorkingDirectory%/src/Driver/*/*Statement.php - %currentWorkingDirectory%/src/Driver/*/*Statement.php
# Some APIs use variable method calls internally
-
message: '~^Variable method call on .*~'
paths:
- %currentWorkingDirectory%/src/Schema/AbstractSchemaManager.php
- %currentWorkingDirectory%/src/Schema/Column.php
includes: includes:
- vendor/phpstan/phpstan-strict-rules/rules.neon - vendor/phpstan/phpstan-strict-rules/rules.neon
...@@ -183,7 +183,7 @@ class ConnectionTest extends TestCase ...@@ -183,7 +183,7 @@ class ConnectionTest extends TestCase
* @requires extension pdo_sqlite * @requires extension pdo_sqlite
* @dataProvider getQueryMethods * @dataProvider getQueryMethods
*/ */
public function testDriverExceptionIsWrapped(string $method) : void public function testDriverExceptionIsWrapped(callable $callback) : void
{ {
$this->expectException(DBALException::class); $this->expectException(DBALException::class);
$this->expectExceptionMessage("An exception occurred while executing 'MUUHAAAAHAAAA':\n\nSQLSTATE[HY000]: General error: 1 near \"MUUHAAAAHAAAA\""); $this->expectExceptionMessage("An exception occurred while executing 'MUUHAAAAHAAAA':\n\nSQLSTATE[HY000]: General error: 1 near \"MUUHAAAAHAAAA\"");
...@@ -193,20 +193,42 @@ class ConnectionTest extends TestCase ...@@ -193,20 +193,42 @@ class ConnectionTest extends TestCase
'memory' => true, 'memory' => true,
]); ]);
$connection->$method('MUUHAAAAHAAAA'); $callback($connection, 'MUUHAAAAHAAAA');
} }
/** /**
* @return array<int, array<int, mixed>> * @return iterable<string, array<int, callable>>
*/ */
public static function getQueryMethods() : iterable public static function getQueryMethods() : iterable
{ {
return [ yield 'exec' => [
['exec'], static function (Connection $connection, string $statement) : void {
['query'], $connection->exec($statement);
['executeQuery'], },
['executeUpdate'], ];
['prepare'],
yield 'query' => [
static function (Connection $connection, string $statement) : void {
$connection->query($statement);
},
];
yield 'executeQuery' => [
static function (Connection $connection, string $statement) : void {
$connection->executeQuery($statement);
},
];
yield 'executeUpdate' => [
static function (Connection $connection, string $statement) : void {
$connection->executeUpdate($statement);
},
];
yield 'prepare' => [
static function (Connection $connection, string $statement) : void {
$connection->prepare($statement);
},
]; ];
} }
......
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