1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Create mysqli.phpstub

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
This commit is contained in:
Kamil Tekiela 2021-11-24 22:18:48 +00:00
parent c4c97d3018
commit d922808e8f
2 changed files with 35 additions and 0 deletions

View File

@ -1953,6 +1953,11 @@ class Config
$this->internal_stubs[] = $xdebug_stub_path;
}
if (\extension_loaded('mysqli')) {
$ext_mysqli_path = $dir_lvl_2 . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR . 'mysqli.phpstub';
$this->internal_stubs[] = $ext_mysqli_path;
}
foreach ($this->internal_stubs as $stub_path) {
if (!file_exists($stub_path)) {
throw new \UnexpectedValueException('Cannot locate ' . $stub_path);

30
stubs/mysqli.phpstub Normal file
View File

@ -0,0 +1,30 @@
<?php
/**
* @template TValue
*
* @template-implements Traversable<int, TValue>
*/
class mysqli_result implements Traversable
{
/**
* @psalm-taint-sink callable $class
* @template T of object
* @param class-string<T> $class
* @param array $constructor_args
* @return T|null|false
*/
function fetch_object(string $class = stdClass::class, array $constructor_args = []): object|false|null {}
}
/**
* @psalm-taint-sink callable $class
* @template T of object
* @param class-string<T> $class
* @param array $constructor_args
* @return T|null|false
*/
function mysqli_fetch_object(mysqli_result $result, string $class = stdClass::class, array $constructor_args = []): object|false|null {}