Skip to content

Update stubs for ext-mongodb 2.0 #1729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions PhpStormStubsMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,6 @@ final class PhpStormStubsMap
'MongoDB\\Driver\\ClientEncryption' => 'mongodb/ClientEncryption.php',
'MongoDB\\Driver\\Command' => 'mongodb/Command.php',
'MongoDB\\Driver\\Cursor' => 'mongodb/Cursor.php',
'MongoDB\\Driver\\CursorId' => 'mongodb/CursorId.php',
'MongoDB\\Driver\\CursorInterface' => 'mongodb/CursorInterface.php',
'MongoDB\\Driver\\Exception\\AuthenticationException' => 'mongodb/Exception/AuthenticationException.php',
'MongoDB\\Driver\\Exception\\BulkWriteException' => 'mongodb/Exception/BulkWriteException.php',
Expand All @@ -723,11 +722,9 @@ final class PhpStormStubsMap
'MongoDB\\Driver\\Exception\\InvalidArgumentException' => 'mongodb/Exception/InvalidArgumentException.php',
'MongoDB\\Driver\\Exception\\LogicException' => 'mongodb/Exception/LogicException.php',
'MongoDB\\Driver\\Exception\\RuntimeException' => 'mongodb/Exception/RuntimeException.php',
'MongoDB\\Driver\\Exception\\SSLConnectionException' => 'mongodb/Exception/SSLConnectionException.php',
'MongoDB\\Driver\\Exception\\ServerException' => 'mongodb/Exception/ServerException.php',
'MongoDB\\Driver\\Exception\\UnexpectedValueException' => 'mongodb/Exception/UnexpectedValueException.php',
'MongoDB\\Driver\\Exception\\WriteConcernException' => 'mongodb/Exception/WriteConcernException.php',
'MongoDB\\Driver\\Exception\\WriteException' => 'mongodb/Exception/WriteException.php',
'MongoDB\\Driver\\Manager' => 'mongodb/Manager.php',
'MongoDB\\Driver\\Monitoring\\CommandFailedEvent' => 'mongodb/Monitoring/CommandFailedEvent.php',
'MongoDB\\Driver\\Monitoring\\CommandStartedEvent' => 'mongodb/Monitoring/CommandStartedEvent.php',
Expand Down Expand Up @@ -1466,12 +1463,6 @@ final class PhpStormStubsMap
'GEOSRelateMatch' => 'geos/geos.php',
'GEOSSharedPaths' => 'geos/geos.php',
'GEOSVersion' => 'geos/geos.php',
'MongoDB\\BSON\\fromJSON' => 'mongodb/BSON/functions.php',
'MongoDB\\BSON\\fromPHP' => 'mongodb/BSON/functions.php',
'MongoDB\\BSON\\toCanonicalExtendedJSON' => 'mongodb/BSON/functions.php',
'MongoDB\\BSON\\toJSON' => 'mongodb/BSON/functions.php',
'MongoDB\\BSON\\toPHP' => 'mongodb/BSON/functions.php',
'MongoDB\\BSON\\toRelaxedExtendedJSON' => 'mongodb/BSON/functions.php',
'MongoDB\\Driver\\Monitoring\\addSubscriber' => 'mongodb/Monitoring/functions.php',
'MongoDB\\Driver\\Monitoring\\removeSubscriber' => 'mongodb/Monitoring/functions.php',
'OpenTelemetry\\Instrumentation\\hook' => 'opentelemetry/opentelemetry.php',
Expand Down
30 changes: 9 additions & 21 deletions mongodb/BSON/Binary.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

use JsonSerializable;
use MongoDB\Driver\Exception\InvalidArgumentException;
use MongoDB\Driver\Exception\UnexpectedValueException;
use Stringable;

/**
* Class Binary
* @link https://php.net/manual/en/class.mongodb-bson-binary.php
*/
final class Binary implements Type, BinaryInterface, \Serializable, JsonSerializable
final class Binary implements Type, BinaryInterface, JsonSerializable, Stringable
{
public const TYPE_GENERIC = 0, TYPE_FUNCTION = 1;
public const TYPE_OLD_BINARY = 2;
Expand All @@ -27,6 +27,11 @@ final class Binary implements Type, BinaryInterface, \Serializable, JsonSerializ
* @since 1.12.0
*/
public const TYPE_COLUMN = 7;

/**
* @since 1.17.0
*/
public const TYPE_SENSITIVE = 8;
public const TYPE_USER_DEFINED = 128;

/**
Expand All @@ -47,37 +52,20 @@ final public function getData(): string {}
*/
final public function getType(): int {}

public static function __set_state(array $properties) {}
public static function __set_state(array $properties): self {}

/**
* Returns the Binary's data
* @link https://www.php.net/manual/en/mongodb-bson-binary.tostring.php
*/
final public function __toString(): string {}

/**
* Serialize a Binary
* @since 1.2.0
* @link https://www.php.net/manual/en/mongodb-bson-binary.serialize.php
* @throws InvalidArgumentException
*/
final public function serialize(): string {}

/**
* Unserialize a Binary
* @since 1.2.0
* @link https://www.php.net/manual/en/mongodb-bson-binary.unserialize.php
* @throws InvalidArgumentException on argument parsing errors or if the properties are invalid
* @throws UnexpectedValueException if the properties cannot be unserialized (i.e. serialized was malformed)
*/
final public function unserialize(string $data) {}

/**
* Returns a representation that can be converted to JSON
* @since 1.2.0
* @link https://www.php.net/manual/en/mongodb-bson-binary.jsonserialize.php
* @return mixed data which can be serialized by json_encode()
* @throws InvalidArgumentException on argument parsing errors
*/
final public function jsonSerialize() {}
final public function jsonSerialize(): mixed {}
}
6 changes: 3 additions & 3 deletions mongodb/BSON/BinaryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ interface BinaryInterface
* @link https://www.php.net/manual/en/mongodb-bson-binaryinterface.getdata.php
* @return string Returns the BinaryInterface's data
*/
public function getData();
public function getData(): string;

/**
* @link https://www.php.net/manual/en/mongodb-bson-binaryinterface.gettype.php
* @return int Returns the BinaryInterface's type.
*/
public function getType();
public function getType(): int;

/**
* This method is an alias of: MongoDB\BSON\BinaryInterface::getData().
* @link https://www.php.net/manual/en/mongodb-bson-binaryinterface.tostring.php
* @return string Returns the BinaryInterface's data.
*/
public function __toString();
public function __toString(): string;
}
29 changes: 4 additions & 25 deletions mongodb/BSON/DBPointer.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
namespace MongoDB\BSON;

use JetBrains\PhpStorm\Deprecated;
use JsonSerializable;
use MongoDB\Driver\Exception\InvalidArgumentException;
use MongoDB\Driver\Exception\UnexpectedValueException;
use Stringable;

/**
* BSON type for the "DbPointer" type. This BSON type is deprecated, and this class can not be instantiated. It will be created from a
Expand All @@ -14,40 +15,18 @@
* @link https://secure.php.net/manual/en/class.mongodb-bson-dbpointer.php
*/
#[Deprecated]
final class DBPointer implements Type, \Serializable, \JsonSerializable
final class DBPointer implements Type, JsonSerializable, Stringable
{
final private function __construct() {}

/**
* Serialize a DBPointer
*
* @link https://www.php.net/manual/en/mongodb-bson-dbpointer.serialize.php
* @return string
* @throws InvalidArgumentException
*/
final public function serialize(): string {}

/**
* Unserialize a DBPointer
*
* @link https://www.php.net/manual/en/mongodb-bson-dbpointer.unserialize.php
*
* @param string $serialized
*
* @return void
* @throws InvalidArgumentException on argument parsing errors or if the properties are invalid
* @throws UnexpectedValueException if the properties cannot be unserialized (i.e. serialized was malformed)
*/
final public function unserialize(string $data): void {}

/**
* Returns a representation that can be converted to JSON
*
* @link https://www.php.net/manual/en/mongodb-bson-dbpointer.jsonserialize.php
* @return mixed data which can be serialized by json_encode()
* @throws InvalidArgumentException on argument parsing errors
*/
final public function jsonSerialize() {}
final public function jsonSerialize(): mixed {}

/**
* Returns the Symbol as a string
Expand Down
26 changes: 4 additions & 22 deletions mongodb/BSON/Decimal128.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

use JsonSerializable;
use MongoDB\Driver\Exception\InvalidArgumentException;
use MongoDB\Driver\Exception\UnexpectedValueException;
use Stringable;

/**
* BSON type for the Decimal128 floating-point format, which supports numbers with up to 34 decimal digits (i.e. significant digits) and an exponent range of −6143 to +6144.
* @link https://php.net/manual/en/class.mongodb-bson-decimal128.php
*/
final class Decimal128 implements Type, Decimal128Interface, \Serializable, JsonSerializable
final class Decimal128 implements Type, Decimal128Interface, JsonSerializable, Stringable
{
/**
* Construct a new Decimal128
Expand All @@ -25,25 +25,7 @@ final public function __construct(string $value = '') {}
*/
final public function __toString(): string {}

public static function __set_state(array $properties) {}

/**
* Serialize a Decimal128
* @since 1.2.0
* @link https://www.php.net/manual/en/mongodb-bson-decimal128.serialize.php
* @return string
* @throws InvalidArgumentException
*/
final public function serialize(): string {}

/**
* Unserialize a Decimal128
* @since 1.2.0
* @link https://www.php.net/manual/en/mongodb-bson-decimal128.unserialize.php
* @throws InvalidArgumentException on argument parsing errors or if the properties are invalid
* @throws UnexpectedValueException if the properties cannot be unserialized (i.e. serialized was malformed)
*/
final public function unserialize(string $data): void {}
public static function __set_state(array $properties): self {}

/**
* Returns a representation that can be converted to JSON
Expand All @@ -52,5 +34,5 @@ final public function unserialize(string $data): void {}
* @return mixed data which can be serialized by json_encode()
* @throws InvalidArgumentException on argument parsing errors
*/
final public function jsonSerialize() {}
final public function jsonSerialize(): mixed {}
}
2 changes: 1 addition & 1 deletion mongodb/BSON/Decimal128Interface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ interface Decimal128Interface
* @link https://www.php.net/manual/en/mongodb-bson-decimal128interface.tostring.php
* @return string Returns the string representation of this Decimal128Interface
*/
public function __toString();
public function __toString(): string;
}
10 changes: 5 additions & 5 deletions mongodb/BSON/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

namespace MongoDB\BSON;

use ArrayAccess;
use IteratorAggregate;
use Stringable;

/**
* @since 1.16.0
* @link https://secure.php.net/manual/en/class.mongodb-bson-document.php
*/
final class Document implements \ArrayAccess, \IteratorAggregate, \Serializable
final class Document implements IteratorAggregate, ArrayAccess, Type, Stringable
{
private function __construct() {}

Expand Down Expand Up @@ -44,10 +48,6 @@ final public function __toString(): string {}

final public static function __set_state(array $properties): Document {}

final public function serialize(): string {}

final public function unserialize(string $data): void {}

final public function __unserialize(array $data): void {}

final public function __serialize(): array {}
Expand Down
24 changes: 5 additions & 19 deletions mongodb/BSON/Int64.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,30 @@

namespace MongoDB\BSON;

use JsonSerializable;
use MongoDB\Driver\Exception\InvalidArgumentException;
use MongoDB\Driver\Exception\UnexpectedValueException;
use Stringable;

/**
* BSON type for a 64-bit integer.
*
* @since 1.5.0
* @link https://secure.php.net/manual/en/class.mongodb-bson-int64.php
*/
final class Int64 implements Type, \Serializable, \JsonSerializable
final class Int64 implements Type, JsonSerializable, Stringable
{
/** @since 1.16.0 */
final public function __construct(string|int $value) {}

/**
* Serialize an Int64
* @link https://www.php.net/manual/en/mongodb-bson-int64.serialize.php
* @throws InvalidArgumentException
*/
final public function serialize(): string {}

public static function __set_state(array $properties) {}

/**
* Unserialize an Int64
* @link https://www.php.net/manual/en/mongodb-bson-int64.unserialize.php
* @throws InvalidArgumentException on argument parsing errors or if the properties are invalid
* @throws UnexpectedValueException if the properties cannot be unserialized (i.e. serialized was malformed)
*/
final public function unserialize(string $data): void {}
public static function __set_state(array $properties): self {}

/**
* Returns a representation that can be converted to JSON
* @link https://www.php.net/manual/en/mongodb-bson-int64.jsonserialize.php
* @return mixed data which can be serialized by json_encode()
* @throws InvalidArgumentException on argument parsing errors
*/
final public function jsonSerialize() {}
final public function jsonSerialize(): mixed {}

/**
* Returns the Symbol as a string
Expand Down
25 changes: 4 additions & 21 deletions mongodb/BSON/Javascript.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@

use JsonSerializable;
use MongoDB\Driver\Exception\InvalidArgumentException;
use MongoDB\Driver\Exception\UnexpectedValueException;
use Stringable;

/**
* Class Javascript
* @link https://php.net/manual/en/class.mongodb-bson-javascript.php
*/
final class Javascript implements Type, JavascriptInterface, \Serializable, JsonSerializable
final class Javascript implements Type, JavascriptInterface, JsonSerializable, Stringable
{
/**
* Construct a new Javascript
* @link https://php.net/manual/en/mongodb-bson-javascript.construct.php
*/
final public function __construct(string $javascript, array|object|null $scope = null) {}

public static function __set_state(array $properties) {}
public static function __set_state(array $properties): self {}

/**
* Returns the Javascript's code
Expand All @@ -38,29 +38,12 @@ final public function getScope(): ?object {}
*/
final public function __toString(): string {}

/**
* Serialize a Javascript
* @since 1.2.0
* @link https://www.php.net/manual/en/mongodb-bson-javascript.serialize.php
* @throws InvalidArgumentException
*/
final public function serialize(): string {}

/**
* Unserialize a Javascript
* @since 1.2.0
* @link https://www.php.net/manual/en/mongodb-bson-javascript.unserialize.php
* @throws InvalidArgumentException on argument parsing errors or if the properties are invalid
* @throws UnexpectedValueException if the properties cannot be unserialized (i.e. serialized was malformed)
*/
final public function unserialize(string $data): void {}

/**
* Returns a representation that can be converted to JSON
* @since 1.2.0
* @link https://www.php.net/manual/en/mongodb-bson-javascript.jsonserialize.php
* @return mixed data which can be serialized by json_encode()
* @throws InvalidArgumentException on argument parsing errors
*/
final public function jsonSerialize() {}
final public function jsonSerialize(): mixed {}
}
6 changes: 3 additions & 3 deletions mongodb/BSON/JavascriptInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ interface JavascriptInterface
* @link https://secure.php.net/manual/en/mongodb-bson-javascriptinterface.getcode.php
* @since 1.3.0
*/
public function getCode();
public function getCode(): string;

/**
* Returns the JavascriptInterface's scope document
* @return object|null
* @link https://secure.php.net/manual/en/mongodb-bson-javascriptinterface.getscope.php
* @since 1.3.0
*/
public function getScope();
public function getScope(): ?object;

/**
* Returns the JavascriptInterface's code
* @return string
* @link https://secure.php.net/manual/en/mongodb-bson-javascriptinterface.tostring.php
* @since 1.3.0
*/
public function __toString();
public function __toString(): string;
}
Loading
Loading