Skip to content

Commit

Permalink
PHPC-2458: Deprecate float arg for UTCDateTime constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
jmikola committed Sep 25, 2024
1 parent 25de213 commit 728a4ac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/BSON/UTCDateTime.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ static PHP_METHOD(MongoDB_BSON_UTCDateTime, __construct)
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;

Expand Down
5 changes: 5 additions & 0 deletions tests/bson/bson-utcdatetime-007.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ foreach ($tests as $test) {
===DONE===
<?php exit(0); ?>
--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"
Expand Down

0 comments on commit 728a4ac

Please sign in to comment.