diff --git a/UPGRADE-2.0.md b/UPGRADE-2.0.md index 6f1e309af..e2a062c8c 100644 --- a/UPGRADE-2.0.md +++ b/UPGRADE-2.0.md @@ -27,8 +27,8 @@ UPGRADE FROM 1.x to 2.0 removed. Use `--with-mongodb-system-libs` instead. * All classes that previously implemented the `Serializable` interface no longer implement this interface. - * The constructor of `MongoDB\BSON\UTCDateTime` no longer accepts a `string` - argument. To pass 64-bit integers on 32-bit platforms, use the + * The constructor of `MongoDB\BSON\UTCDateTime` no longer accepts a `string` or + `float` argument. To pass 64-bit integers on 32-bit platforms, use the `MongoDB\BSON\Int64` class instead. * The `--with-openssl-dir` configure option has been removed. If using OpenSSL, ensure that it is detected by `pkg-config`. diff --git a/src/BSON/UTCDateTime.c b/src/BSON/UTCDateTime.c index 6790e02af..0bff7eaf2 100644 --- a/src/BSON/UTCDateTime.c +++ b/src/BSON/UTCDateTime.c @@ -121,16 +121,6 @@ static bool php_phongo_utcdatetime_init_from_object(php_phongo_utcdatetime_t* in return false; } -static bool php_phongo_utcdatetime_init_from_double(php_phongo_utcdatetime_t* intern, double milliseconds) -{ - char tmp[24]; - int tmp_len; - - tmp_len = snprintf(tmp, sizeof(tmp), "%.0f", milliseconds > 0 ? floor(milliseconds) : ceil(milliseconds)); - - return php_phongo_utcdatetime_init_from_string(intern, tmp, tmp_len); -} - static HashTable* php_phongo_utcdatetime_get_properties_hash(zend_object* object, bool is_temp) { php_phongo_utcdatetime_t* intern; @@ -214,12 +204,6 @@ static PHP_METHOD(MongoDB_BSON_UTCDateTime, __construct) case IS_LONG: php_phongo_utcdatetime_init(intern, Z_LVAL_P(milliseconds)); return; - - case IS_DOUBLE: - php_error_docref(NULL, E_DEPRECATED, "Creating a %s instance with a float is deprecated and will be removed in ext-mongodb 2.0", ZSTR_VAL(php_phongo_utcdatetime_ce->name)); - - php_phongo_utcdatetime_init_from_double(intern, Z_DVAL_P(milliseconds)); - return; } phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "Expected integer or object, %s given", PHONGO_ZVAL_CLASS_OR_TYPE_NAME_P(milliseconds)); diff --git a/src/BSON/UTCDateTime.stub.php b/src/BSON/UTCDateTime.stub.php index 68104fabb..1c512a0e5 100644 --- a/src/BSON/UTCDateTime.stub.php +++ b/src/BSON/UTCDateTime.stub.php @@ -9,7 +9,7 @@ final class UTCDateTime implements UTCDateTimeInterface, \JsonSerializable, Type, \Stringable { - final public function __construct(int|float|\DateTimeInterface|Int64|null $milliseconds = null) {} + final public function __construct(int|\DateTimeInterface|Int64|null $milliseconds = null) {} final public function toDateTime(): \DateTime {} diff --git a/src/BSON/UTCDateTime_arginfo.h b/src/BSON/UTCDateTime_arginfo.h index e018df90c..56500089f 100644 --- a/src/BSON/UTCDateTime_arginfo.h +++ b/src/BSON/UTCDateTime_arginfo.h @@ -1,8 +1,8 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: e84944a701ed49a361960aac405d42a736037aa2 */ + * Stub hash: b5033645ba31d4b4e5040548ea979cef5e3e8adb */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_BSON_UTCDateTime___construct, 0, 0, 0) - ZEND_ARG_OBJ_TYPE_MASK(0, milliseconds, DateTimeInterface|MongoDB\\BSON\\Int64, MAY_BE_LONG|MAY_BE_DOUBLE|MAY_BE_NULL, "null") + ZEND_ARG_OBJ_TYPE_MASK(0, milliseconds, DateTimeInterface|MongoDB\\BSON\\Int64, MAY_BE_LONG|MAY_BE_NULL, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_BSON_UTCDateTime_toDateTime, 0, 0, DateTime, 0) diff --git a/tests/bson/bson-utcdatetime-007.phpt b/tests/bson/bson-utcdatetime-007.phpt deleted file mode 100644 index 9b4cbcd1c..000000000 --- a/tests/bson/bson-utcdatetime-007.phpt +++ /dev/null @@ -1,37 +0,0 @@ ---TEST-- -MongoDB\BSON\UTCDateTime constructor truncates floating point values ---FILE-- - -===DONE=== - ---EXPECTF-- -Deprecated: MongoDB\BSON\UTCDateTime::__construct(): Creating a MongoDB\BSON\UTCDateTime instance with a float is deprecated and will be removed in ext-mongodb 2.0 in %s on line %d - -Deprecated: MongoDB\BSON\UTCDateTime::__construct(): Creating a MongoDB\BSON\UTCDateTime instance with a float is deprecated and will be removed in ext-mongodb 2.0 in %s on line %d - -Deprecated: MongoDB\BSON\UTCDateTime::__construct(): Creating a MongoDB\BSON\UTCDateTime instance with a float is deprecated and will be removed in ext-mongodb 2.0 in %s on line %d -object(MongoDB\BSON\UTCDateTime)#%d (%d) { - ["milliseconds"]=> - string(13) "1416445411987" -} -object(MongoDB\BSON\UTCDateTime)#%d (%d) { - ["milliseconds"]=> - string(10) "2147483647" -} -object(MongoDB\BSON\UTCDateTime)#%d (%d) { - ["milliseconds"]=> - string(4) "1234" -} -===DONE=== diff --git a/tests/bson/bson-utcdatetime_error-001.phpt b/tests/bson/bson-utcdatetime_error-001.phpt deleted file mode 100644 index 7dc837507..000000000 --- a/tests/bson/bson-utcdatetime_error-001.phpt +++ /dev/null @@ -1,18 +0,0 @@ ---TEST-- -MongoDB\BSON\UTCDateTime requires object argument to implement DateTimeInterface ---FILE-- - -===DONE=== - ---EXPECT-- -OK: Got MongoDB\Driver\Exception\InvalidArgumentException -Expected instance of DateTimeInterface or MongoDB\BSON\Int64, stdClass given -===DONE=== diff --git a/tests/bson/bson-utcdatetime_error-004.phpt b/tests/bson/bson-utcdatetime_error-004.phpt index 9e8798050..7b9c9434f 100644 --- a/tests/bson/bson-utcdatetime_error-004.phpt +++ b/tests/bson/bson-utcdatetime_error-004.phpt @@ -1,19 +1,20 @@ --TEST-- -MongoDB\BSON\UTCDateTime constructor requires integer or string argument +MongoDB\BSON\UTCDateTime constructor type validation --FILE--