Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions stubs/mysqli.stub
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class mysqli_stmt
{

/**
* @var int|string
* @var int<-1,max>|numeric-string
*/
public $affected_rows;

Expand Down Expand Up @@ -34,7 +34,7 @@ class mysqli_stmt
public $insert_id;

/**
* @var 0|positive-int
* @var int<0,max>|numeric-string
*/
public $num_rows;

Expand Down
1 change: 1 addition & 0 deletions tests/PHPStan/Analyser/NodeScopeResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1198,6 +1198,7 @@ public function dataFileAsserts(): iterable
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-8775.php');
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-8752.php');
yield from $this->gatherAssertTypes(__DIR__ . '/data/trait-instance-of.php');
yield from $this->gatherAssertTypes(__DIR__ . '/data/mysql-stmt.php');
}

/**
Expand Down
20 changes: 20 additions & 0 deletions tests/PHPStan/Analyser/data/mysql-stmt.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace MySQLiStmt;

use mysqli;
use function PHPStan\Testing\assertType;

final class Foo {
public function bar(): void
{
$mysqli = new mysqli();
$stmt = $mysqli->prepare('SELECT x FROM z;');
$stmt->execute();
assertType('int<0, max>|numeric-string', $stmt->num_rows);

$stmt = $mysqli->prepare('DELETE FROM z;');
$stmt->execute();
assertType('int<-1, max>|numeric-string', $stmt->affected_rows);
}
}