Skip to content

Commit e284de0

Browse files
committed
fix possible TypeError in MySQLiRule
1 parent 8312778 commit e284de0

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/PHPStan/Rules/MySQLi/MySQLiRule.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ private function handleMysqliCall(string $methodName, MethodCall $node, Scope $s
7373
{
7474
// TODO: normalized arguments - this doesn't work with named arguments.
7575
$args = $node->getArgs();
76+
77+
if (! isset($args[0])) {
78+
return [];
79+
}
80+
7681
$queryType = $scope->getType($args[0]->value);
7782
$result = match ($methodName) {
7883
'query' => $this->phpstanMysqliHelper->query($queryType),

tests/PHPStan/Rules/MySQLi/data/MySQLiRuleValidDataTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ private static function doInitDb(mysqli $db, string $tableName): void
4545
public function testValid(): void
4646
{
4747
$db = TestCaseHelper::getDefaultSharedConnection();
48+
$db->begin_transaction();
49+
$db->rollback();
4850

4951
$stmt = $db->prepare('SELECT 1');
5052
$stmt->execute();

0 commit comments

Comments
 (0)