Skip to content

Commit

Permalink
Create mysqli.phpstub
Browse files Browse the repository at this point in the history
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
  • Loading branch information
kamil-tekiela committed Nov 24, 2021
1 parent c4c97d3 commit d922808
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Psalm/Config.php
Expand Up @@ -1953,6 +1953,11 @@ public function visitStubFiles(Codebase $codebase, ?Progress $progress = null):
$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);
Expand Down
30 changes: 30 additions & 0 deletions stubs/mysqli.phpstub
@@ -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 {}

0 comments on commit d922808

Please sign in to comment.