Skip to content

Commit

Permalink
Update MongoDB stubs for 1.17
Browse files Browse the repository at this point in the history
  • Loading branch information
alcaeus authored and isfedorov committed Nov 24, 2023
1 parent 37fa92c commit a4fa997
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 7 deletions.
1 change: 1 addition & 0 deletions PhpStormStubsMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,7 @@ final class PhpStormStubsMap
'MongoDB\\Driver\\Monitoring\\CommandStartedEvent' => 'mongodb/Monitoring/CommandStartedEvent.php',
'MongoDB\\Driver\\Monitoring\\CommandSubscriber' => 'mongodb/Monitoring/CommandSubscriber.php',
'MongoDB\\Driver\\Monitoring\\CommandSucceededEvent' => 'mongodb/Monitoring/CommandSucceededEvent.php',
'MongoDB\\Driver\\Monitoring\\LogSubscriber' => 'mongodb/Monitoring/LogSubscriber.php',
'MongoDB\\Driver\\Monitoring\\SDAMSubscriber' => 'mongodb/Monitoring/SDAMSubscriber.php',
'MongoDB\\Driver\\Monitoring\\ServerChangedEvent' => 'mongodb/Monitoring/ServerChangedEvent.php',
'MongoDB\\Driver\\Monitoring\\ServerClosedEvent' => 'mongodb/Monitoring/ServerClosedEvent.php',
Expand Down
12 changes: 12 additions & 0 deletions mongodb/BSON/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ final public function toCanonicalExtendedJSON(): string {}

final public function toRelaxedExtendedJSON(): string {}

/** @since 1.17.0 */
public function offsetExists(mixed $offset): bool {}

/** @since 1.17.0 */
public function offsetGet(mixed $offset): mixed {}

/** @since 1.17.0 */
public function offsetSet(mixed $offset, mixed $value): void {}

/** @since 1.17.0 */
public function offsetUnset(mixed $offset): void {}

final public function __toString(): string {}

final public static function __set_state(array $properties): Document {}
Expand Down
12 changes: 12 additions & 0 deletions mongodb/BSON/PackedArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ final public function has(int $index): bool {}

final public function toPHP(?array $typeMap = null): array|object {}

/** @since 1.17.0 */
public function offsetExists(mixed $offset): bool {}

/** @since 1.17.0 */
public function offsetGet(mixed $offset): mixed {}

/** @since 1.17.0 */
public function offsetSet(mixed $offset, mixed $value): void {}

/** @since 1.17.0 */
public function offsetUnset(mixed $offset): void {}

final public function __toString(): string {}

final public static function __set_state(array $properties): PackedArray {}
Expand Down
8 changes: 7 additions & 1 deletion mongodb/BSON/Persistable.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@

namespace MongoDB\BSON;

use stdClass;

/**
* Classes may implement this interface to take advantage of automatic ODM (object document mapping) behavior in the driver.
* @link https://php.net/manual/en/class.mongodb-bson-persistable.php
*/
interface Persistable extends Unserializable, Serializable {}
interface Persistable extends Unserializable, Serializable
{
/** @since 1.17.0 */
public function bsonSerialize(): array|stdClass|Document;
}
5 changes: 3 additions & 2 deletions mongodb/BSON/Serializable.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace MongoDB\BSON;

use stdClass;

/**
* Classes that implement this interface may return data to be serialized as a BSON array or document in lieu of the object's public properties
* @link https://php.net/manual/en/class.mongodb-bson-serializable.php
Expand All @@ -14,7 +16,6 @@ interface Serializable extends Type
* Root documents (e.g. a MongoDB\BSON\Serializable passed to MongoDB\BSON\fromPHP()) will always be serialized as a BSON document.
* For field values, associative arrays and stdClass instances will be serialized as a BSON document and sequential arrays (i.e. sequential, numeric indexes starting at 0) will be serialized as a BSON array.
* @link https://php.net/manual/en/mongodb-bson-serializable.bsonserialize.php
* @return array|object An array or stdClass to be serialized as a BSON array or document.
*/
public function bsonSerialize();
public function bsonSerialize(): array|stdClass|Document|PackedArray;
}
23 changes: 23 additions & 0 deletions mongodb/Monitoring/LogSubscriber.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace MongoDB\Driver\Monitoring;

/**
* @since 1.17.0
* @link https://www.php.net/manual/en/class.mongodb-driver-monitoring-logsubscriber.php
*/
interface LogSubscriber extends Subscriber
{
public const LEVEL_ERROR = 0;
public const LEVEL_CRITICAL = 1;
public const LEVEL_WARNING = 2;
public const LEVEL_MESSAGE = 3;
public const LEVEL_INFO = 4;
public const LEVEL_DEBUG = 5;

/* MONGOC_LOG_LEVEL_TRACE is intentionally omitted. Trace logs are only
* reported via streams (i.e. mongodb.debug INI), so the constant is not
* relevant to LogSubscriber implementations. */

public function log(int $level, string $domain, string $message): void;
}
3 changes: 2 additions & 1 deletion mongodb/ReadConcern.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use MongoDB\BSON\Serializable;
use MongoDB\Driver\Exception\InvalidArgumentException;
use MongoDB\Driver\Exception\UnexpectedValueException;
use stdClass;

/**
* MongoDB\Driver\ReadConcern controls the level of isolation for read operations for replica sets and replica set shards. This option requires the WiredTiger storage engine and MongoDB 3.2 or later.
Expand Down Expand Up @@ -51,7 +52,7 @@ final public function getLevel(): ?string {}
* @link https://php.net/manual/en/mongodb-driver-readconcern.bsonserialize.php
* @since 1.2.0
*/
final public function bsonSerialize(): array|object {}
final public function bsonSerialize(): stdClass {}

/**
* Checks if this is the default read concern
Expand Down
3 changes: 2 additions & 1 deletion mongodb/ReadPreference.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use MongoDB\BSON\Serializable;
use MongoDB\Driver\Exception\InvalidArgumentException;
use MongoDB\Driver\Exception\UnexpectedValueException;
use stdClass;

/**
* Class ReadPreference
Expand Down Expand Up @@ -99,7 +100,7 @@ final public function getTagSets(): array {}
* @return object Returns an object for serializing the WriteConcern as BSON.
* @throws InvalidArgumentException
*/
final public function bsonSerialize(): array|object {}
final public function bsonSerialize(): stdClass {}

/**
* Serialize a ReadPreference
Expand Down
4 changes: 3 additions & 1 deletion mongodb/ServerApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace MongoDB\Driver;

use stdClass;

final class ServerApi implements \MongoDB\BSON\Serializable, \Serializable
{
public const V1 = 1;
Expand All @@ -14,5 +16,5 @@ final public function unserialize(string $data): void {}

final public function serialize(): string {}

final public function bsonSerialize(): array|object {}
final public function bsonSerialize(): stdClass {}
}
3 changes: 2 additions & 1 deletion mongodb/WriteConcern.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use MongoDB\BSON\Serializable;
use MongoDB\Driver\Exception\InvalidArgumentException;
use MongoDB\Driver\Exception\UnexpectedValueException;
use stdClass;

/**
* WriteConcern controls the acknowledgment of a write operation, specifies the level of write guarantee for Replica Sets.
Expand Down Expand Up @@ -53,7 +54,7 @@ final public function getWtimeout(): int {}
* @return array|object Returns an object for serializing the WriteConcern as BSON.
* @throws InvalidArgumentException
*/
final public function bsonSerialize(): array|object {}
final public function bsonSerialize(): stdClass {}

/**
* Serialize a WriteConcern
Expand Down

0 comments on commit a4fa997

Please sign in to comment.