mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Add mongodb Cursor and CursorInterface stubs and fix WriteConcern::__construct (#5813)
* Add mongodb Cursor and CursorInterface stubs * Use proper variable name * Update WriteConcern constructor Based on https://www.php.net/manual/es/mongodb-driver-writeconcern.construct.php
This commit is contained in:
parent
c69cf9a849
commit
e89f7e3960
@ -7917,7 +7917,7 @@ return [
|
||||
'mongodb\driver\session::getTransactionOptions' => ['array|null'],
|
||||
'mongodb\driver\session::getTransactionState' => ['string'],
|
||||
'mongodb\driver\session::startTransaction' => ['void', 'options'=>'array|object'],
|
||||
'MongoDB\Driver\WriteConcern::__construct' => ['void', 'wstring'=>'string', 'wtimeout='=>'int', 'journal='=>'bool', 'fsync='=>'bool'],
|
||||
'MongoDB\Driver\WriteConcern::__construct' => ['void', 'wstring'=>'string|int', 'wtimeout='=>'int', 'journal='=>'bool'],
|
||||
'MongoDB\Driver\WriteConcern::bsonSerialize' => ['object'],
|
||||
'MongoDB\Driver\WriteConcern::getJournal' => ['?bool'],
|
||||
'MongoDB\Driver\WriteConcern::getJurnal' => ['?bool'],
|
||||
|
@ -1767,13 +1767,13 @@ class Config
|
||||
}
|
||||
|
||||
if (\extension_loaded('soap')) {
|
||||
$ext_pdo_path = dirname(__DIR__, 2) . '/stubs/soap.phpstub';
|
||||
$ext_soap_path = dirname(__DIR__, 2) . '/stubs/soap.phpstub';
|
||||
|
||||
if (!file_exists($ext_pdo_path)) {
|
||||
if (!file_exists($ext_soap_path)) {
|
||||
throw new \UnexpectedValueException('Cannot locate soap classes');
|
||||
}
|
||||
|
||||
$core_generic_files[] = $ext_pdo_path;
|
||||
$core_generic_files[] = $ext_soap_path;
|
||||
}
|
||||
|
||||
if (\extension_loaded('ds')) {
|
||||
@ -1786,6 +1786,16 @@ class Config
|
||||
$core_generic_files[] = $ext_ds_path;
|
||||
}
|
||||
|
||||
if (\extension_loaded('mongodb')) {
|
||||
$ext_mongodb_path = dirname(__DIR__, 2) . '/stubs/mongodb.phpstub';
|
||||
|
||||
if (!file_exists($ext_mongodb_path)) {
|
||||
throw new \UnexpectedValueException('Cannot locate mongodb classes');
|
||||
}
|
||||
|
||||
$core_generic_files[] = $ext_mongodb_path;
|
||||
}
|
||||
|
||||
$stub_files = array_merge($core_generic_files, $this->stub_files);
|
||||
|
||||
if ($this->load_xdebug_stub) {
|
||||
|
59
stubs/mongodb.phpstub
Normal file
59
stubs/mongodb.phpstub
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace MongoDB\Driver;
|
||||
|
||||
use Iterator;
|
||||
use Traversable;
|
||||
|
||||
/**
|
||||
* @template-covariant TKey
|
||||
* @template-covariant TValue
|
||||
*
|
||||
* @template-extends Traversable<TKey, TValue>
|
||||
*/
|
||||
interface CursorInterface extends Traversable
|
||||
{
|
||||
/**
|
||||
* @return array<TValue>
|
||||
*/
|
||||
public function toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @template-covariant TValue of array|object
|
||||
*
|
||||
* @template-implements Iterator<int, TValue>
|
||||
* @template-implements CursorInterface<int, TValue>
|
||||
*/
|
||||
final class Cursor implements CursorInterface, Iterator
|
||||
{
|
||||
/**
|
||||
* @return TValue
|
||||
*/
|
||||
public function current() {}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function next() {}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function key() {}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function valid() {}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function rewind() {}
|
||||
|
||||
/**
|
||||
* @return array<TValue>
|
||||
*/
|
||||
public function toArray() {}
|
||||
}
|
Loading…
Reference in New Issue
Block a user