Skip to content

Commit 728a4ac

Browse files
committed
PHPC-2458: Deprecate float arg for UTCDateTime constructor
1 parent 25de213 commit 728a4ac

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/BSON/UTCDateTime.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ static PHP_METHOD(MongoDB_BSON_UTCDateTime, __construct)
218218
return;
219219

220220
case IS_DOUBLE:
221+
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));
222+
221223
php_phongo_utcdatetime_init_from_double(intern, Z_DVAL_P(milliseconds));
222224
return;
223225

tests/bson/bson-utcdatetime-007.phpt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ foreach ($tests as $test) {
1717
===DONE===
1818
<?php exit(0); ?>
1919
--EXPECTF--
20+
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
21+
22+
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
23+
24+
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
2025
object(MongoDB\BSON\UTCDateTime)#%d (%d) {
2126
["milliseconds"]=>
2227
string(13) "1416445411987"

0 commit comments

Comments
 (0)