diff --git a/PhpStormStubsMap.php b/PhpStormStubsMap.php index 04ecae0a6..d1fc25f87 100644 --- a/PhpStormStubsMap.php +++ b/PhpStormStubsMap.php @@ -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', @@ -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', @@ -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', diff --git a/meta/.phpstorm.meta.php b/meta/.phpstorm.meta.php index 30ef2ed14..b63fffef6 100644 --- a/meta/.phpstorm.meta.php +++ b/meta/.phpstorm.meta.php @@ -236,7 +236,7 @@ function argumentsSet($setName) { expectedArguments(\MemcachePool::set(), 2, MEMCACHE_COMPRESSED); expectedArguments(\MemcachePool::replace(), 2, MEMCACHE_COMPRESSED); - expectedArguments(\MongoDB\Driver\ReadPreference::__construct(), 0, \MongoDB\Driver\ReadPreference::RP_PRIMARY,\MongoDB\Driver\ReadPreference::RP_PRIMARY_PREFERRED,\MongoDB\Driver\ReadPreference::RP_SECONDARY,\MongoDB\Driver\ReadPreference::RP_SECONDARY_PREFERRED,\MongoDB\Driver\ReadPreference::RP_NEAREST); + expectedArguments(\MongoDB\Driver\ReadPreference::__construct(), 0, \MongoDB\Driver\ReadPreference::PRIMARY,\MongoDB\Driver\ReadPreference::PRIMARY_PREFERRED,\MongoDB\Driver\ReadPreference::SECONDARY,\MongoDB\Driver\ReadPreference::SECONDARY_PREFERRED,\MongoDB\Driver\ReadPreference::NEAREST); expectedArguments(\mysqli::begin_transaction(), 0, MYSQLI_TRANS_START_READ_ONLY,MYSQLI_TRANS_START_READ_WRITE,MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT); expectedArguments(\mysqli::commit(), 0, MYSQLI_TRANS_COR_AND_CHAIN|MYSQLI_TRANS_COR_AND_NO_CHAIN|MYSQLI_TRANS_COR_NO_RELEASE|MYSQLI_TRANS_COR_RELEASE); expectedArguments(\mysqli::real_connect(), 6, MYSQLI_CLIENT_COMPRESS|MYSQLI_CLIENT_FOUND_ROWS|MYSQLI_CLIENT_IGNORE_SPACE|MYSQLI_CLIENT_INTERACTIVE|MYSQLI_CLIENT_SSL|MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT); diff --git a/mongodb/BSON/Binary.php b/mongodb/BSON/Binary.php index 836e26655..4bf5a979a 100644 --- a/mongodb/BSON/Binary.php +++ b/mongodb/BSON/Binary.php @@ -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; @@ -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; /** @@ -47,7 +52,7 @@ 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 @@ -55,23 +60,6 @@ public static function __set_state(array $properties) {} */ 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 @@ -79,5 +67,5 @@ final public function unserialize(string $data) {} * @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 {} } diff --git a/mongodb/BSON/BinaryInterface.php b/mongodb/BSON/BinaryInterface.php index ec804ab1d..237a89a56 100644 --- a/mongodb/BSON/BinaryInterface.php +++ b/mongodb/BSON/BinaryInterface.php @@ -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; } diff --git a/mongodb/BSON/DBPointer.php b/mongodb/BSON/DBPointer.php index d383ecbbb..bbaa719f5 100644 --- a/mongodb/BSON/DBPointer.php +++ b/mongodb/BSON/DBPointer.php @@ -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 @@ -14,32 +15,10 @@ * @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 * @@ -47,7 +26,7 @@ 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 {} /** * Returns the Symbol as a string diff --git a/mongodb/BSON/Decimal128.php b/mongodb/BSON/Decimal128.php index 5936979d8..e3f117655 100644 --- a/mongodb/BSON/Decimal128.php +++ b/mongodb/BSON/Decimal128.php @@ -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 @@ -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 @@ -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 {} } diff --git a/mongodb/BSON/Decimal128Interface.php b/mongodb/BSON/Decimal128Interface.php index 6741439fd..a128815cb 100644 --- a/mongodb/BSON/Decimal128Interface.php +++ b/mongodb/BSON/Decimal128Interface.php @@ -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; } diff --git a/mongodb/BSON/Document.php b/mongodb/BSON/Document.php index 13a3ae0da..d19a91af6 100644 --- a/mongodb/BSON/Document.php +++ b/mongodb/BSON/Document.php @@ -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() {} @@ -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 {} diff --git a/mongodb/BSON/Int64.php b/mongodb/BSON/Int64.php index ba2145f17..45eff1311 100644 --- a/mongodb/BSON/Int64.php +++ b/mongodb/BSON/Int64.php @@ -2,8 +2,9 @@ namespace MongoDB\BSON; +use JsonSerializable; use MongoDB\Driver\Exception\InvalidArgumentException; -use MongoDB\Driver\Exception\UnexpectedValueException; +use Stringable; /** * BSON type for a 64-bit integer. @@ -11,27 +12,12 @@ * @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 @@ -39,7 +25,7 @@ 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 {} /** * Returns the Symbol as a string diff --git a/mongodb/BSON/Javascript.php b/mongodb/BSON/Javascript.php index 6201b7df8..c429909ee 100644 --- a/mongodb/BSON/Javascript.php +++ b/mongodb/BSON/Javascript.php @@ -4,13 +4,13 @@ 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 @@ -18,7 +18,7 @@ final class Javascript implements Type, JavascriptInterface, \Serializable, Json */ 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 @@ -38,23 +38,6 @@ 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 @@ -62,5 +45,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 {} } diff --git a/mongodb/BSON/JavascriptInterface.php b/mongodb/BSON/JavascriptInterface.php index 43d95ead6..7f7409a47 100644 --- a/mongodb/BSON/JavascriptInterface.php +++ b/mongodb/BSON/JavascriptInterface.php @@ -16,7 +16,7 @@ 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 @@ -24,7 +24,7 @@ public function getCode(); * @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 @@ -32,5 +32,5 @@ public function getScope(); * @link https://secure.php.net/manual/en/mongodb-bson-javascriptinterface.tostring.php * @since 1.3.0 */ - public function __toString(); + public function __toString(): string; } diff --git a/mongodb/BSON/MaxKey.php b/mongodb/BSON/MaxKey.php index c9c65927a..f463243c1 100644 --- a/mongodb/BSON/MaxKey.php +++ b/mongodb/BSON/MaxKey.php @@ -4,32 +4,14 @@ use JsonSerializable; use MongoDB\Driver\Exception\InvalidArgumentException; -use MongoDB\Driver\Exception\UnexpectedValueException; /** * Class MaxKey * @link https://php.net/manual/en/class.mongodb-bson-maxkey.php */ -final class MaxKey implements Type, MaxKeyInterface, \Serializable, JsonSerializable +final class MaxKey implements Type, MaxKeyInterface, JsonSerializable { - public static function __set_state(array $properties) {} - - /** - * Serialize a MaxKey - * @since 1.2.0 - * @link https://www.php.net/manual/en/mongodb-bson-maxkey.serialize.php - * @throws InvalidArgumentException - */ - final public function serialize(): string {} - - /** - * Unserialize a MaxKey - * @since 1.2.0 - * @link https://www.php.net/manual/en/mongodb-bson-maxkey.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 @@ -38,5 +20,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 {} } diff --git a/mongodb/BSON/MinKey.php b/mongodb/BSON/MinKey.php index c09e3846e..80d380c14 100644 --- a/mongodb/BSON/MinKey.php +++ b/mongodb/BSON/MinKey.php @@ -4,32 +4,14 @@ use JsonSerializable; use MongoDB\Driver\Exception\InvalidArgumentException; -use MongoDB\Driver\Exception\UnexpectedValueException; /** * Class MinKey * @link https://php.net/manual/en/class.mongodb-bson-minkey.php */ -final class MinKey implements Type, MinKeyInterface, \Serializable, JsonSerializable +final class MinKey implements Type, MinKeyInterface, JsonSerializable { - public static function __set_state(array $properties) {} - - /** - * Serialize a MinKey - * @since 1.2.0 - * @link https://www.php.net/manual/en/mongodb-bson-minkey.serialize.php - * @throws InvalidArgumentException - */ - final public function serialize(): string {} - - /** - * Unserialize a MinKey - * @since 1.2.0 - * @link https://www.php.net/manual/en/mongodb-bson-minkey.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 @@ -38,5 +20,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 {} } diff --git a/mongodb/BSON/ObjectId.php b/mongodb/BSON/ObjectId.php index 44d45301f..84d8c3af4 100644 --- a/mongodb/BSON/ObjectId.php +++ b/mongodb/BSON/ObjectId.php @@ -4,12 +4,13 @@ use JsonSerializable; use MongoDB\Driver\Exception\InvalidArgumentException; +use Stringable; /** * Class ObjectId * @link https://php.net/manual/en/class.mongodb-bson-objectid.php */ -final class ObjectId implements Type, ObjectIdInterface, \Serializable, JsonSerializable +final class ObjectId implements Type, ObjectIdInterface, JsonSerializable, Stringable { /** * Construct a new ObjectId @@ -25,7 +26,7 @@ final public function __construct(?string $id = null) {} */ final public function __toString(): string {} - public static function __set_state(array $properties) {} + public static function __set_state(array $properties): self {} /** * Returns the timestamp component of this ObjectId @@ -41,19 +42,5 @@ final public function getTimestamp(): int {} * @link https://secure.php.net/manual/en/mongodb-bson-objectid.jsonserialize.php * @return mixed data which can be serialized by json_encode() */ - final public function jsonSerialize() {} - - /** - * Serialize an ObjectId - * @since 1.2.0 - * @link https://secure.php.net/manual/en/mongodb-bson-objectid.serialize.php - */ - final public function serialize(): string {} - - /** - * Unserialize an ObjectId - * @since 1.2.0 - * @link https://secure.php.net/manual/en/mongodb-bson-objectid.unserialize.php - */ - final public function unserialize(string $data): void {} + final public function jsonSerialize(): mixed {} } diff --git a/mongodb/BSON/ObjectIdInterface.php b/mongodb/BSON/ObjectIdInterface.php index 7ed44afe0..6bf76e999 100644 --- a/mongodb/BSON/ObjectIdInterface.php +++ b/mongodb/BSON/ObjectIdInterface.php @@ -12,12 +12,12 @@ interface ObjectIdInterface * @link https://www.php.net/manual/en/mongodb-bson-objectidinterface.gettimestamp.php * @return int Returns the timestamp component of this ObjectIdInterface. */ - public function getTimestamp(); + public function getTimestamp(): int; /** * Returns the hexadecimal representation of this ObjectId * @link https://www.php.net/manual/en/mongodb-bson-objectid.tostring.php * @return string Returns the hexadecimal representation of this ObjectId */ - public function __toString(); + public function __toString(): string; } diff --git a/mongodb/BSON/PackedArray.php b/mongodb/BSON/PackedArray.php index af3c1377f..e161048d3 100644 --- a/mongodb/BSON/PackedArray.php +++ b/mongodb/BSON/PackedArray.php @@ -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-packedarray.php */ -final class PackedArray implements \ArrayAccess, \IteratorAggregate, \Serializable +final class PackedArray implements IteratorAggregate, ArrayAccess, Type, Stringable { private function __construct() {} @@ -45,10 +49,6 @@ final public function __toString(): string {} final public static function __set_state(array $properties): PackedArray {} - final public function serialize(): string {} - - final public function unserialize(string $data): void {} - final public function __unserialize(array $data): void {} final public function __serialize(): array {} diff --git a/mongodb/BSON/Regex.php b/mongodb/BSON/Regex.php index 47ae2060f..11be1386a 100644 --- a/mongodb/BSON/Regex.php +++ b/mongodb/BSON/Regex.php @@ -4,13 +4,13 @@ use JsonSerializable; use MongoDB\Driver\Exception\InvalidArgumentException; -use MongoDB\Driver\Exception\UnexpectedValueException; +use Stringable; /** * Class Regex * @link https://php.net/manual/en/class.mongodb-bson-regex.php */ -final class Regex implements Type, RegexInterface, \Serializable, JsonSerializable +final class Regex implements RegexInterface, JsonSerializable, Type, Stringable { /** * Construct a new Regex @@ -36,24 +36,7 @@ final public function getPattern(): string {} */ final public function __toString(): string {} - public static function __set_state(array $properties) {} - - /** - * Serialize a Regex - * @since 1.2.0 - * @link https://www.php.net/manual/en/mongodb-bson-regex.serialize.php - * @throws InvalidArgumentException - */ - final public function serialize(): string {} - - /** - * Unserialize a Regex - * @since 1.2.0 - * @link https://www.php.net/manual/en/mongodb-bson-regex.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 @@ -62,5 +45,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 {} } diff --git a/mongodb/BSON/RegexInterface.php b/mongodb/BSON/RegexInterface.php index de6cf6d34..086bfe493 100644 --- a/mongodb/BSON/RegexInterface.php +++ b/mongodb/BSON/RegexInterface.php @@ -12,18 +12,18 @@ interface RegexInterface * @link https://www.php.net/manual/en/mongodb-bson-regexinterface.getflags.php * @return string Returns the RegexInterface's flags. */ - public function getFlags(); + public function getFlags(): string; /** * @link https://www.php.net/manual/en/mongodb-bson-regexinterface.getpattern.php * @return string Returns the RegexInterface's pattern. */ - public function getPattern(); + public function getPattern(): string; /** * Returns the string representation of this RegexInterface * @link https://www.php.net/manual/en/mongodb-bson-regexinterface.tostring.php * @return string */ - public function __toString(); + public function __toString(): string; } diff --git a/mongodb/BSON/Symbol.php b/mongodb/BSON/Symbol.php index a49cb54e4..a9fbb1b03 100644 --- a/mongodb/BSON/Symbol.php +++ b/mongodb/BSON/Symbol.php @@ -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 "Symbol" type. This BSON type is deprecated, and this class can not be instantiated. It will be created from a @@ -13,27 +14,10 @@ * @link https://secure.php.net/manual/en/class.mongodb-bson-symbol.php */ #[Deprecated] -final class Symbol implements Type, \Serializable, \JsonSerializable +final class Symbol implements JsonSerializable, Type, Stringable { final private function __construct() {} - /** - * Serialize a Symbol - * @since 1.2.0 - * @link https://www.php.net/manual/en/mongodb-bson-symbol.serialize.php - * @throws InvalidArgumentException - */ - final public function serialize(): string {} - - /** - * Unserialize a Symbol - * @since 1.2.0 - * @link https://www.php.net/manual/en/mongodb-bson-symbol.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 @@ -41,7 +25,7 @@ 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 {} /** * Returns the Symbol as a string diff --git a/mongodb/BSON/Timestamp.php b/mongodb/BSON/Timestamp.php index 47263fee3..55c2579bb 100644 --- a/mongodb/BSON/Timestamp.php +++ b/mongodb/BSON/Timestamp.php @@ -4,13 +4,13 @@ use JsonSerializable; use MongoDB\Driver\Exception\InvalidArgumentException; -use MongoDB\Driver\Exception\UnexpectedValueException; +use Stringable; /** * Represents a BSON timestamp, which is an internal MongoDB type not intended for general date storage. * @link https://php.net/manual/en/class.mongodb-bson-timestamp.php */ -final class Timestamp implements TimestampInterface, Type, \Serializable, JsonSerializable +final class Timestamp implements TimestampInterface, JsonSerializable, Type, Stringable { /** * Construct a new Timestamp @@ -24,7 +24,7 @@ final public function __construct(int $increment, int $timestamp) {} */ final public function __toString(): string {} - public static function __set_state(array $properties) {} + public static function __set_state(array $properties): self {} /** * Returns the increment component of this TimestampInterface @@ -40,23 +40,6 @@ final public function getIncrement(): int {} */ final public function getTimestamp(): int {} - /** - * Serialize a Timestamp - * @since 1.2.0 - * @link https://www.php.net/manual/en/mongodb-bson-timestamp.serialize.php - * @throws InvalidArgumentException - */ - final public function serialize(): string {} - - /** - * Unserialize a Timestamp - * @since 1.2.0 - * @link https://www.php.net/manual/en/mongodb-bson-timestamp.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 @@ -64,5 +47,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 {} } diff --git a/mongodb/BSON/TimestampInterface.php b/mongodb/BSON/TimestampInterface.php index 85dfa7c10..e4ca522ed 100644 --- a/mongodb/BSON/TimestampInterface.php +++ b/mongodb/BSON/TimestampInterface.php @@ -16,7 +16,7 @@ interface TimestampInterface * @return int * @since 1.3.0 */ - public function getIncrement(); + public function getIncrement(): int; /** * Returns the timestamp component of this TimestampInterface @@ -24,7 +24,7 @@ public function getIncrement(); * @return int * @since 1.3.0 */ - public function getTimestamp(); + public function getTimestamp(): int; /** * Returns the string representation of this TimestampInterface @@ -32,5 +32,5 @@ public function getTimestamp(); * @return string * @since 1.3.0 */ - public function __toString(); + public function __toString(): string; } diff --git a/mongodb/BSON/UTCDateTime.php b/mongodb/BSON/UTCDateTime.php index 81a4d16a2..88ed17712 100644 --- a/mongodb/BSON/UTCDateTime.php +++ b/mongodb/BSON/UTCDateTime.php @@ -3,22 +3,23 @@ namespace MongoDB\BSON; use DateTimeInterface; +use JsonSerializable; use MongoDB\Driver\Exception\InvalidArgumentException; -use MongoDB\Driver\Exception\UnexpectedValueException; +use Stringable; /** * Represents a BSON date. * @link https://php.net/manual/en/class.mongodb-bson-utcdatetime.php */ -final class UTCDateTime implements Type, UTCDateTimeInterface, \Serializable, \JsonSerializable +final class UTCDateTime implements UTCDateTimeInterface, JsonSerializable, Type, Stringable { /** * Construct a new UTCDateTime * @link https://php.net/manual/en/mongodb-bson-utcdatetime.construct.php */ - final public function __construct(int|string|float|DateTimeInterface|Int64|null $milliseconds = null) {} + final public function __construct(int|DateTimeInterface|Int64|null $milliseconds = null) {} - public static function __set_state(array $properties) {} + public static function __set_state(array $properties): self {} /** * Returns the DateTime representation of this UTCDateTime @@ -39,23 +40,6 @@ final public function toDateTimeImmutable(): \DateTimeImmutable {} */ final public function __toString(): string {} - /** - * Serialize a UTCDateTime - * @since 1.2.0 - * @link https://www.php.net/manual/en/mongodb-bson-utcdatetime.serialize.php - * @throws InvalidArgumentException - */ - final public function serialize(): string {} - - /** - * Unserialize a UTCDateTime - * @since 1.2.0 - * @link https://www.php.net/manual/en/mongodb-bson-utcdatetime.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 @@ -63,5 +47,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 {} } diff --git a/mongodb/BSON/UTCDateTimeInterface.php b/mongodb/BSON/UTCDateTimeInterface.php index 09f4027eb..55bf2701f 100644 --- a/mongodb/BSON/UTCDateTimeInterface.php +++ b/mongodb/BSON/UTCDateTimeInterface.php @@ -3,6 +3,7 @@ namespace MongoDB\BSON; use DateTime; +use DateTimeImmutable; /** * This interface is implemented by MongoDB\BSON\UTCDateTime but may also be used for type-hinting and userland classes. @@ -12,14 +13,20 @@ interface UTCDateTimeInterface { /** * @link https://www.php.net/manual/en/mongodb-bson-utcdatetimeinterface.todatetime.php - * @return DateTime Returns the DateTime representation of this UTCDateTimeInterface. The returned DateTime should use the UTC time zone. + * @return DateTime Returns the DateTime representation of this UTCDateTimeInterface. The returned DateTime uses the UTC time zone. */ - public function toDateTime(); + public function toDateTime(): DateTime; + + /** + * @link https://www.php.net/manual/en/mongodb-bson-utcdatetimeinterface.todatetimeimmutable.php + * @return DateTimeImmutable Returns the DateTimeImmutable representation of this UTCDateTimeInterface. The returned DateTime uses the UTC time zone. + */ + public function toDateTimeImmutable(): DateTimeImmutable; /** * Returns the string representation of this UTCDateTimeInterface * @link https://www.php.net/manual/en/mongodb-bson-utcdatetimeinterface.tostring.php * @return string */ - public function __toString(); + public function __toString(): string; } diff --git a/mongodb/BSON/Undefined.php b/mongodb/BSON/Undefined.php index 9b69ad691..0e0f07ac6 100644 --- a/mongodb/BSON/Undefined.php +++ b/mongodb/BSON/Undefined.php @@ -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 "Undefined" type. This BSON type is deprecated, and this class can not be instantiated. It will be created @@ -13,27 +14,10 @@ * @link https://secure.php.net/manual/en/class.mongodb-bson-undefined.php */ #[Deprecated] -final class Undefined implements Type, \Serializable, \JsonSerializable +final class Undefined implements JsonSerializable, Type, Stringable { final private function __construct() {} - /** - * Serialize an Undefined - * @since 1.2.0 - * @link https://www.php.net/manual/en/mongodb-bson-undefined.serialize.php - * @throws InvalidArgumentException - */ - final public function serialize(): string {} - - /** - * Unserialize an Undefined - * @since 1.2.0 - * @link https://www.php.net/manual/en/mongodb-bson-undefined.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 @@ -41,7 +25,7 @@ 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 {} /** * Returns the Undefined as a string diff --git a/mongodb/BSON/Unserializable.php b/mongodb/BSON/Unserializable.php index 1dc8f3e9f..c0b885e23 100644 --- a/mongodb/BSON/Unserializable.php +++ b/mongodb/BSON/Unserializable.php @@ -15,5 +15,5 @@ interface Unserializable extends Type * @link https://php.net/manual/en/mongodb-bson-unserializable.bsonunserialize.php * @param array $data Properties within the BSON array or document. */ - public function bsonUnserialize(array $data); + public function bsonUnserialize(array $data): void; } diff --git a/mongodb/BSON/functions.php b/mongodb/BSON/functions.php deleted file mode 100644 index 9792b36ee..000000000 --- a/mongodb/BSON/functions.php +++ /dev/null @@ -1,79 +0,0 @@ -