Skip to content

Commit

Permalink
Update MongoDB stubs for extension version 1.20.0
Browse files Browse the repository at this point in the history
  • Loading branch information
alcaeus authored and isfedorov committed Oct 1, 2024
1 parent d407aff commit b60ab73
Show file tree
Hide file tree
Showing 12 changed files with 111 additions and 11 deletions.
9 changes: 9 additions & 0 deletions mongodb/BSON/PackedArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ final class PackedArray implements \ArrayAccess, \IteratorAggregate, \Serializab
{
private function __construct() {}

/** @since 1.20.0 */
final static public function fromJSON(string $json): PackedArray {}

final public static function fromPHP(array $value): PackedArray {}

final public function get(int $index): mixed {}
Expand All @@ -20,6 +23,12 @@ final public function has(int $index): bool {}

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

/** @since 1.20.0 */
final public function toCanonicalExtendedJSON(): string {}

/** @since 1.20.0 */
final public function toRelaxedExtendedJSON(): string {}

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

Expand Down
2 changes: 1 addition & 1 deletion mongodb/BSON/UTCDateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class UTCDateTime implements Type, UTCDateTimeInterface, \Serializable, \J
* Construct a new UTCDateTime
* @link https://php.net/manual/en/mongodb-bson-utcdatetime.construct.php
*/
final public function __construct(int|string|float|DateTimeInterface|null $milliseconds = null) {}
final public function __construct(int|string|float|DateTimeInterface|Int64|null $milliseconds = null) {}

public static function __set_state(array $properties) {}

Expand Down
6 changes: 6 additions & 0 deletions mongodb/BSON/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* @param string $bson BSON value to be converted
* @return string The converted JSON value
* @throws UnexpectedValueException
* @deprecated Use MongoDB\BSON\Document instead
*/
function toCanonicalExtendedJSON($bson) {}

Expand All @@ -25,6 +26,7 @@ function toCanonicalExtendedJSON($bson) {}
* @param string $bson BSON value to be converted
* @return string The converted JSON value
* @throws UnexpectedValueException
* @deprecated Use MongoDB\BSON\Document instead
*/
function toRelaxedExtendedJSON($bson) {}

Expand All @@ -35,6 +37,7 @@ function toRelaxedExtendedJSON($bson) {}
* @param string $json JSON value to be converted.
* @return string The serialized BSON document as a binary string.
* @throws UnexpectedValueException if the JSON value cannot be converted to BSON (e.g. due to a syntax error).
* @deprecated Use MongoDB\BSON\Document instead
*/
function fromJSON($json) {}

Expand All @@ -45,6 +48,7 @@ function fromJSON($json) {}
* @param array|object $value PHP value to be serialized.
* @return string The serialized BSON document as a binary string
* @throws UnexpectedValueException if the PHP value cannot be converted to BSON.
* @deprecated Use MongoDB\BSON\Document instead
*/
function fromPHP($value) {}

Expand All @@ -56,6 +60,7 @@ function fromPHP($value) {}
* @return string The converted JSON value.
* @see https://docs.mongodb.org/manual/reference/mongodb-extended-json/
* @throws UnexpectedValueException if the input did not contain exactly one BSON document
* @deprecated Use MongoDB\BSON\Document instead
*/
function toJSON($bson) {}

Expand All @@ -69,5 +74,6 @@ function toJSON($bson) {}
* @return object The unserialized PHP value
* @throws UnexpectedValueException if the input did not contain exactly one BSON document.
* @throws InvalidArgumentException if a class in the type map cannot be instantiated or does not implement MongoDB\BSON\Unserializable.
* @deprecated Use MongoDB\BSON\Document instead
*/
function toPHP($bson, array $typemap = []) {}
12 changes: 12 additions & 0 deletions mongodb/ClientEncryption.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,14 @@ final class ClientEncryption
*/
public const ALGORITHM_UNINDEXED = 'Unindexed';

/**
* @since 1.20.0
*/
public const ALGORITHM_RANGE = 'Range';

/**
* @since 1.16.0
* @deprecated
*/
public const ALGORITHM_RANGE_PREVIEW = 'RangePreview';

Expand All @@ -36,8 +42,14 @@ final class ClientEncryption
*/
public const QUERY_TYPE_EQUALITY = 'equality';

/**
* @since 1.20.0
*/
public const QUERY_TYPE_RANGE = 'range';

/**
* @since 1.16.0
* @deprecated
*/
public const QUERY_TYPE_RANGE_PREVIEW = 'rangePreview';

Expand Down
8 changes: 6 additions & 2 deletions mongodb/Cursor.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace MongoDB\Driver;

use MongoDB\BSON\Int64;
use MongoDB\Driver\Exception\InvalidArgumentException;

/**
Expand All @@ -26,11 +27,14 @@ final public function __wakeup() {}
public function current(): array|object|null {}

/**
* Returns the MongoDB\Driver\CursorId associated with this cursor. A cursor ID cursor uniquely identifies the cursor on the server.
* Returns the cursor ID associated with this cursor. A cursor ID cursor uniquely identifies the cursor on the server.
* Receiving a CursorId return type is deprecated and will be removed in 2.0.
*
* @param bool $asInt64 Pass true to receive the cursor as a MongoDB\BSON\Int64 instance
* @link https://php.net/manual/en/mongodb-driver-cursor.getid.php
* @throws InvalidArgumentException on argument parsing errors.
*/
final public function getId(): CursorId {}
final public function getId(bool $asInt64 = false): CursorId|Int64 {}

/**
* Returns the MongoDB\Driver\Server associated with this cursor. This is the server that executed the query or command.
Expand Down
16 changes: 8 additions & 8 deletions mongodb/CursorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace MongoDB\Driver;

use MongoDB\BSON\Int64;
use MongoDB\Driver\Exception\InvalidArgumentException;
use Traversable;

Expand All @@ -13,12 +14,12 @@
interface CursorInterface extends Traversable
{
/**
* Returns the MongoDB\Driver\CursorId associated with this cursor. A cursor ID uniquely identifies the cursor on the server.
* @return CursorId Returns the MongoDB\Driver\CursorId for this cursor.
* Returns the cursor ID associated with this cursor. A cursor ID uniquely identifies the cursor on the server.
* @return CursorId|Int64 Returns the cursor ID for this cursor.
* @throws InvalidArgumentException
* @link https://www.php.net/manual/en/mongodb-driver-cursorinterface.getid.php
*/
public function getId();
public function getId(): CursorId|Int64;

/**
* Returns the MongoDB\Driver\Server associated with this cursor.
Expand All @@ -27,30 +28,29 @@ public function getId();
* @return Server Returns the MongoDB\Driver\Server associated with this cursor.
* @throws InvalidArgumentException
*/
public function getServer();
public function getServer(): Server;

/**
* Checks whether the cursor may have additional results available to read.
* @link https://www.php.net/manual/en/mongodb-driver-cursorinterface.isdead.php
* @return bool Returns TRUE if additional results are not available, and FALSE otherwise.
* @throws InvalidArgumentException
*/
public function isDead();
public function isDead(): bool;

/**
* Sets a type map to use for BSON unserialization
* @link https://www.php.net/manual/en/mongodb-driver-cursorinterface.settypemap.php
* @param array $typemap Type map configuration.
* @return mixed
* @throws InvalidArgumentException
*/
public function setTypeMap(array $typemap);
public function setTypeMap(array $typemap): void;

/**
* Iterates the cursor and returns its results in an array.
* MongoDB\Driver\CursorInterface::setTypeMap() may be used to control how documents are unserialized into PHP values.
* @return array Returns an array containing all results for this cursor.
* @throws InvalidArgumentException
*/
public function toArray();
public function toArray(): array;
}
1 change: 1 addition & 0 deletions mongodb/Exception/SSLConnectionException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
/**
* Thrown when the driver fails to establish an SSL connection with the server.
* @link https://php.net/manual/en/class.mongodb-driver-exception-sslconnectionexception.php
* @deprecated use ConnectionException instead
*/
class SSLConnectionException extends ConnectionException implements Exception {}
1 change: 1 addition & 0 deletions mongodb/Exception/WriteException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* The exception encapsulates a MongoDB\Driver\WriteResult object.
* @link https://php.net/manual/en/class.mongodb-driver-exception-writeexception.php
* @since 1.0.0
* @deprecated use MongoDB\Driver\Exception\BulkWriteException instead
*/
abstract class WriteException extends ServerException implements Exception
{
Expand Down
19 changes: 19 additions & 0 deletions mongodb/Monitoring/CommandFailedEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ final public function getCommandName(): string {}
*/
final public function getDurationMicros(): int {}

/**
* Returns the server hostname for the command
* @link https://www.php.net/manual/en/mongodb-driver-monitoring-commandfailedevent.gethost.php
* @return string
* @throws \InvalidArgumentException on argument parsing errors.
* @since 1.20.0
*/
final public function getHost(): string {}

/**
* Returns the Exception associated with the failed command
* @link https://secure.php.net/manual/en/mongodb-driver-monitoring-commandfailedevent.geterror.php
Expand All @@ -55,6 +64,15 @@ final public function getError(): \Exception {}
*/
final public function getOperationId(): string {}

/**
* Returns the server port for the command
* @link https://www.php.net/manual/en/mongodb-driver-monitoring-commandfailedevent.getport.php
* @return int
* @throws \InvalidArgumentException on argument parsing errors.
* @since 1.20.0
*/
final public function getPort(): int {}

/**
* Returns the command reply document.
* The reply document will be converted from BSON to PHP using the default deserialization rules (e.g. BSON documents will be converted to stdClass).
Expand All @@ -80,6 +98,7 @@ final public function getRequestId(): string {}
* @link https://secure.php.net/manual/en/mongodb-driver-monitoring-commandfailedevent.getserver.php
* @return \MongoDB\Driver\Server on which the command was executed.
* @since 1.3.0
* @deprecated Use getHost and getPort instead.
*/
final public function getServer(): Server {}

Expand Down
19 changes: 19 additions & 0 deletions mongodb/Monitoring/CommandStartedEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ final public function getCommandName(): string {}
*/
final public function getDatabaseName(): string {}

/**
* Returns the server hostname for the command
* @link https://www.php.net/manual/en/mongodb-driver-monitoring-commandstartedevent.gethost.php
* @return string
* @throws \InvalidArgumentException on argument parsing errors.
* @since 1.20.0
*/
final public function getHost(): string {}

/**
* Returns the command's operation ID.
* The operation ID is generated by the driver and may be used to link events together such as bulk write operations, which may have been split across several commands at the protocol level.
Expand All @@ -55,6 +64,15 @@ final public function getDatabaseName(): string {}
*/
final public function getOperationId(): string {}

/**
* Returns the server port for the command
* @link https://www.php.net/manual/en/mongodb-driver-monitoring-commandstartedevent.getport.php
* @return int
* @throws \InvalidArgumentException on argument parsing errors.
* @since 1.20.0
*/
final public function getPort(): int {}

/**
* Returns the command's request ID.
* The request ID is generated by the driver and may be used to associate this CommandSucceededEvent with a previous CommandStartedEvent.
Expand All @@ -70,6 +88,7 @@ final public function getRequestId(): string {}
* @link https://secure.php.net/manual/en/mongodb-driver-monitoring-commandstartedevent.getserver.php
* @return \MongoDB\Driver\Server on which the command was executed.
* @since 1.3.0
* @deprecated Use getHost and getPort instead.
*/
final public function getServer(): Server {}

Expand Down
19 changes: 19 additions & 0 deletions mongodb/Monitoring/CommandSucceededEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ final public function getCommandName(): string {}
*/
final public function getDurationMicros(): int {}

/**
* Returns the server hostname for the command
* @link https://www.php.net/manual/en/mongodb-driver-monitoring-commandsucceededevent.gethost.php
* @return string
* @throws \InvalidArgumentException on argument parsing errors.
* @since 1.20.0
*/
final public function getHost(): string {}

/**
* Returns the command's operation ID.
* The operation ID is generated by the driver and may be used to link events together such as bulk write operations, which may have been split across several commands at the protocol level.
Expand All @@ -46,6 +55,15 @@ final public function getDurationMicros(): int {}
*/
final public function getOperationId(): string {}

/**
* Returns the server port for the command
* @link https://www.php.net/manual/en/mongodb-driver-monitoring-commandsucceededevent.getport.php
* @return int
* @throws \InvalidArgumentException on argument parsing errors.
* @since 1.20.0
*/
final public function getPort(): int {}

/**
* Returns the command reply document.
* The reply document will be converted from BSON to PHP using the default deserialization rules (e.g. BSON documents will be converted to stdClass).
Expand All @@ -71,6 +89,7 @@ final public function getRequestId(): string {}
* @link https://secure.php.net/manual/en/mongodb-driver-monitoring-commandsucceededevent.getserver.php
* @return \MongoDB\Driver\Server on which the command was executed.
* @since 1.3.0
* @deprecated Use getHost and getPort instead.
*/
final public function getServer(): Server {}

Expand Down
10 changes: 10 additions & 0 deletions mongodb/ReadPreference.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,19 @@
*/
final class ReadPreference implements Serializable, \Serializable
{
/** @deprecated */
public const RP_PRIMARY = 1;

/** @deprecated */
public const RP_PRIMARY_PREFERRED = 5;

/** @deprecated */
public const RP_SECONDARY = 2;

/** @deprecated */
public const RP_SECONDARY_PREFERRED = 6;

/** @deprecated */
public const RP_NEAREST = 10;

/**
Expand Down Expand Up @@ -76,6 +85,7 @@ final public function getHedge(): ?object {}
/**
* Returns the ReadPreference's "mode" option
* @link https://php.net/manual/en/mongodb-driver-readpreference.getmode.php
* @deprecated Use getModeString instead
*/
final public function getMode(): int {}

Expand Down

0 comments on commit b60ab73

Please sign in to comment.