Skip to content

Commit 60cf8c1

Browse files
committed
Merge pull request #369
2 parents 441a1d7 + a6e7202 commit 60cf8c1

File tree

104 files changed

+277
-395
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+277
-395
lines changed

php_bson.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@
2626
/* PHP Core stuff */
2727
#include <php.h>
2828

29-
/* Check if we are part of pecl/mongodb or standalone (pecl/bson) */
30-
#ifdef HAVE_MONGOC
31-
#define BSON_NAMESPACE "MongoDB\\BSON"
32-
#else
33-
#define BSON_NAMESPACE "BSON"
34-
#endif
35-
3629
#define BSON_UNSERIALIZE_FUNC_NAME "bsonUnserialize"
3730
#define BSON_SERIALIZE_FUNC_NAME "bsonSerialize"
3831

php_phongo.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2507,7 +2507,6 @@ PHP_MINIT_FUNCTION(mongodb)
25072507

25082508
REGISTER_STRING_CONSTANT("MONGODB_VERSION", (char *)MONGODB_VERSION_S, CONST_CS | CONST_PERSISTENT);
25092509
REGISTER_STRING_CONSTANT("MONGODB_STABILITY", (char *)MONGODB_STABILITY_S, CONST_CS | CONST_PERSISTENT);
2510-
REGISTER_STRING_CONSTANT("BSON_NAMESPACE", (char *)BSON_NAMESPACE, CONST_CS | CONST_PERSISTENT);
25112510

25122511
return SUCCESS;
25132512
}
@@ -2586,10 +2585,10 @@ ZEND_BEGIN_ARG_INFO_EX(ai_bson_fromJSON, 0, 0, 1)
25862585
ZEND_END_ARG_INFO();
25872586

25882587
const zend_function_entry mongodb_functions[] = {
2589-
ZEND_NS_FE(BSON_NAMESPACE, fromPHP, ai_bson_fromPHP)
2590-
ZEND_NS_FE(BSON_NAMESPACE, toPHP, ai_bson_toPHP)
2591-
ZEND_NS_FE(BSON_NAMESPACE, toJSON, ai_bson_toJSON)
2592-
ZEND_NS_FE(BSON_NAMESPACE, fromJSON, ai_bson_fromJSON)
2588+
ZEND_NS_FE("MongoDB\\BSON", fromPHP, ai_bson_fromPHP)
2589+
ZEND_NS_FE("MongoDB\\BSON", toPHP, ai_bson_toPHP)
2590+
ZEND_NS_FE("MongoDB\\BSON", toJSON, ai_bson_toJSON)
2591+
ZEND_NS_FE("MongoDB\\BSON", fromJSON, ai_bson_fromJSON)
25932592
PHP_FE_END
25942593
};
25952594
/* }}} */

src/BSON/Binary.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ PHP_MINIT_FUNCTION(Binary)
312312
zend_class_entry ce;
313313
(void)type;(void)module_number;
314314

315-
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "Binary", php_phongo_binary_me);
315+
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Binary", php_phongo_binary_me);
316316
php_phongo_binary_ce = zend_register_internal_class(&ce TSRMLS_CC);
317317
php_phongo_binary_ce->create_object = php_phongo_binary_create_object;
318318
PHONGO_CE_FINAL(php_phongo_binary_ce);

src/BSON/Decimal128.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ PHP_MINIT_FUNCTION(Decimal128)
267267
zend_class_entry ce;
268268
(void)type;(void)module_number;
269269

270-
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "Decimal128", php_phongo_decimal128_me);
270+
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Decimal128", php_phongo_decimal128_me);
271271
php_phongo_decimal128_ce = zend_register_internal_class(&ce TSRMLS_CC);
272272
php_phongo_decimal128_ce->create_object = php_phongo_decimal128_create_object;
273273
PHONGO_CE_FINAL(php_phongo_decimal128_ce);

src/BSON/Javascript.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ PHP_MINIT_FUNCTION(Javascript)
370370
(void)type;(void)module_number;
371371

372372

373-
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "Javascript", php_phongo_javascript_me);
373+
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Javascript", php_phongo_javascript_me);
374374
php_phongo_javascript_ce = zend_register_internal_class(&ce TSRMLS_CC);
375375
php_phongo_javascript_ce->create_object = php_phongo_javascript_create_object;
376376
PHONGO_CE_FINAL(php_phongo_javascript_ce);

src/BSON/MaxKey.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ PHP_MINIT_FUNCTION(MaxKey)
129129
(void)type;(void)module_number;
130130

131131

132-
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "MaxKey", php_phongo_maxkey_me);
132+
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "MaxKey", php_phongo_maxkey_me);
133133
php_phongo_maxkey_ce = zend_register_internal_class(&ce TSRMLS_CC);
134134
php_phongo_maxkey_ce->create_object = php_phongo_maxkey_create_object;
135135
PHONGO_CE_FINAL(php_phongo_maxkey_ce);

src/BSON/MinKey.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ PHP_MINIT_FUNCTION(MinKey)
130130
(void)type;(void)module_number;
131131

132132

133-
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "MinKey", php_phongo_minkey_me);
133+
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "MinKey", php_phongo_minkey_me);
134134
php_phongo_minkey_ce = zend_register_internal_class(&ce TSRMLS_CC);
135135
php_phongo_minkey_ce->create_object = php_phongo_minkey_create_object;
136136
PHONGO_CE_FINAL(php_phongo_minkey_ce);

src/BSON/ObjectID.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ PHP_MINIT_FUNCTION(ObjectID)
301301
zend_class_entry ce;
302302
(void)type;(void)module_number;
303303

304-
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "ObjectID", php_phongo_objectid_me);
304+
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "ObjectID", php_phongo_objectid_me);
305305
php_phongo_objectid_ce = zend_register_internal_class(&ce TSRMLS_CC);
306306
php_phongo_objectid_ce->create_object = php_phongo_objectid_create_object;
307307
PHONGO_CE_FINAL(php_phongo_objectid_ce);

src/BSON/Persistable.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ PHP_MINIT_FUNCTION(Persistable)
6363
zend_class_entry ce;
6464
(void)type;(void)module_number;
6565

66-
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "Persistable", php_phongo_persistable_me);
66+
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Persistable", php_phongo_persistable_me);
6767
php_phongo_persistable_ce = zend_register_internal_interface(&ce TSRMLS_CC);
6868
zend_class_implements(php_phongo_persistable_ce TSRMLS_CC, 2, php_phongo_unserializable_ce, php_phongo_serializable_ce);
6969

src/BSON/Regex.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ PHP_MINIT_FUNCTION(Regex)
352352
zend_class_entry ce;
353353
(void)type;(void)module_number;
354354

355-
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "Regex", php_phongo_regex_me);
355+
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Regex", php_phongo_regex_me);
356356
php_phongo_regex_ce = zend_register_internal_class(&ce TSRMLS_CC);
357357
php_phongo_regex_ce->create_object = php_phongo_regex_create_object;
358358
PHONGO_CE_FINAL(php_phongo_regex_ce);

src/BSON/Serializable.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ PHP_MINIT_FUNCTION(Serializable)
6666
zend_class_entry ce;
6767
(void)type;(void)module_number;
6868

69-
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "Serializable", php_phongo_serializable_me);
69+
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Serializable", php_phongo_serializable_me);
7070
php_phongo_serializable_ce = zend_register_internal_interface(&ce TSRMLS_CC);
7171
zend_class_implements(php_phongo_serializable_ce TSRMLS_CC, 1, php_phongo_type_ce);
7272

src/BSON/Timestamp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ PHP_MINIT_FUNCTION(Timestamp)
303303
zend_class_entry ce;
304304
(void)type;(void)module_number;
305305

306-
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "Timestamp", php_phongo_timestamp_me);
306+
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Timestamp", php_phongo_timestamp_me);
307307
php_phongo_timestamp_ce = zend_register_internal_class(&ce TSRMLS_CC);
308308
php_phongo_timestamp_ce->create_object = php_phongo_timestamp_create_object;
309309
PHONGO_CE_FINAL(php_phongo_timestamp_ce);

src/BSON/Type.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ PHP_MINIT_FUNCTION(Type)
6363
zend_class_entry ce;
6464
(void)type;(void)module_number;
6565

66-
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "Type", php_phongo_type_me);
66+
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Type", php_phongo_type_me);
6767
php_phongo_type_ce = zend_register_internal_interface(&ce TSRMLS_CC);
6868

6969
return SUCCESS;

src/BSON/UTCDateTime.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ PHP_MINIT_FUNCTION(UTCDateTime)
421421
zend_class_entry ce;
422422
(void)type;(void)module_number;
423423

424-
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "UTCDateTime", php_phongo_utcdatetime_me);
424+
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "UTCDateTime", php_phongo_utcdatetime_me);
425425
php_phongo_utcdatetime_ce = zend_register_internal_class(&ce TSRMLS_CC);
426426
php_phongo_utcdatetime_ce->create_object = php_phongo_utcdatetime_create_object;
427427
PHONGO_CE_FINAL(php_phongo_utcdatetime_ce);

src/BSON/Unserializable.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ PHP_MINIT_FUNCTION(Unserializable)
6767
zend_class_entry ce;
6868
(void)type;(void)module_number;
6969

70-
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "Unserializable", php_phongo_unserializable_me);
70+
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "Unserializable", php_phongo_unserializable_me);
7171
php_phongo_unserializable_ce = zend_register_internal_interface(&ce TSRMLS_CC);
7272

7373
return SUCCESS;

src/bson.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1552,7 +1552,7 @@ static void apply_classname_to_state(const char *classname, int classname_len, p
15521552
} else if (!PHONGO_IS_CLASS_INSTANTIATABLE(found_ce)) {
15531553
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Class %s is not instantiatable", classname);
15541554
} else if (!instanceof_function(found_ce, php_phongo_unserializable_ce TSRMLS_CC)) {
1555-
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Class %s does not implement %s\\Unserializable", classname, BSON_NAMESPACE);
1555+
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Class %s does not implement %s", classname, ZSTR_VAL(php_phongo_unserializable_ce->name));
15561556
} else {
15571557
*type = PHONGO_TYPEMAP_CLASS;
15581558
*type_ce = found_ce;

tests/bson/bson-binary-001.phpt

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
--TEST--
2-
BSON BSON\Binary #001
2+
MongoDB\BSON\Binary #001
33
--FILE--
44
<?php
55

66
require_once __DIR__ . '/../utils/tools.php';
77

8-
$classname = BSON_NAMESPACE . "\\Binary";
9-
108
$types = array(
11-
$classname::TYPE_GENERIC,
12-
$classname::TYPE_FUNCTION,
13-
$classname::TYPE_OLD_BINARY,
14-
$classname::TYPE_OLD_UUID,
15-
$classname::TYPE_UUID,
16-
$classname::TYPE_MD5,
17-
$classname::TYPE_USER_DEFINED,
18-
$classname::TYPE_USER_DEFINED+5,
9+
MongoDB\BSON\Binary::TYPE_GENERIC,
10+
MongoDB\BSON\Binary::TYPE_FUNCTION,
11+
MongoDB\BSON\Binary::TYPE_OLD_BINARY,
12+
MongoDB\BSON\Binary::TYPE_OLD_UUID,
13+
MongoDB\BSON\Binary::TYPE_UUID,
14+
MongoDB\BSON\Binary::TYPE_MD5,
15+
MongoDB\BSON\Binary::TYPE_USER_DEFINED,
16+
MongoDB\BSON\Binary::TYPE_USER_DEFINED+5,
1917
);
2018
$tests = array();
2119
foreach($types as $type) {
22-
$binary = new $classname("random binary data", $type);
20+
$binary = new MongoDB\BSON\Binary("random binary data", $type);
2321
var_dump($binary->getData() == "random binary data");
2422
var_dump($binary->getType() == $type);
2523
$tests[] = array("binary" => $binary);

tests/bson/bson-binary_error-001.phpt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
11
--TEST--
2-
BSON BSON\Binary #001 error
2+
MongoDB\BSON\Binary #001 error
33
--SKIPIF--
44
<?php if (defined("HHVM_VERSION_ID")) exit("skip HHVM handles parameter parsing differently"); ?>
55
--FILE--
66
<?php
77

88
require_once __DIR__ . '/../utils/tools.php';
99

10-
$classname = BSON_NAMESPACE . "\\Binary";
11-
12-
$binary = new $classname("random binary data", $classname::TYPE_GENERIC);
10+
$binary = new MongoDB\BSON\Binary("random binary data", MongoDB\BSON\Binary::TYPE_GENERIC);
1311
$binary->getData(2);
1412
$binary->getType(2);
1513

16-
throws(function() use($classname) {
17-
new $classname("random binary data without type");
14+
throws(function() {
15+
new MongoDB\BSON\Binary("random binary data without type");
1816
}, "MongoDB\\Driver\\Exception\\InvalidArgumentException");
1917

2018
?>
2119
===DONE===
2220
<?php exit(0); ?>
2321
--EXPECTF--
24-
Warning: %s\Binary::getData() expects exactly 0 parameters, 1 given in %s on line %d
22+
Warning: MongoDB\BSON\Binary::getData() expects exactly 0 parameters, 1 given in %s on line %d
2523

26-
Warning: %s\Binary::getType() expects exactly 0 parameters, 1 given in %s on line %d
24+
Warning: MongoDB\BSON\Binary::getType() expects exactly 0 parameters, 1 given in %s on line %d
2725
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
2826
===DONE===
2927

tests/bson/bson-binary_error-002.phpt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
--TEST--
2-
BSON BSON\Binary cannot be extended
2+
MongoDB\BSON\Binary cannot be extended
33
--FILE--
44
<?php
55

6-
use MongoDB\BSON as BSON;
7-
8-
class MyBinary extends BSON\Binary {}
6+
class MyBinary extends MongoDB\BSON\Binary {}
97

108
?>
119
===DONE===
1210
<?php exit(0); ?>
1311
--EXPECTF--
14-
Fatal error: Class MyBinary may not inherit from final class (%SBSON\Binary) in %s on line %d
12+
Fatal error: Class MyBinary may not inherit from final class (MongoDB\BSON\Binary) in %s on line %d

tests/bson/bson-binary_error-003.phpt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
--TEST--
2-
BSON BSON\Binary constructor requires unsigned 8-bit integer for type
2+
MongoDB\BSON\Binary constructor requires unsigned 8-bit integer for type
33
--FILE--
44
<?php
55

66
require_once __DIR__ . '/../utils/tools.php';
77

8-
use MongoDB\BSON as BSON;
9-
108
echo throws(function() {
11-
new BSON\Binary('foo', -1);
9+
new MongoDB\BSON\Binary('foo', -1);
1210
}, 'MongoDB\Driver\Exception\InvalidArgumentException'), "\n";
1311

1412
echo throws(function() {
15-
new BSON\Binary('foo', 256);
13+
new MongoDB\BSON\Binary('foo', 256);
1614
}, 'MongoDB\Driver\Exception\InvalidArgumentException'), "\n";
1715

1816
?>

tests/bson/bson-decimal128-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
BSON\Decimal128
2+
MongoDB\BSON\Decimal128
33
--SKIPIF--
44
<?php if (!class_exists('MongoDB\BSON\Decimal128')) { die('skip MongoDB\BSON\Decimal128 is not available'); } ?>
55
--FILE--

tests/bson/bson-decimal128-002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
BSON\Decimal128 NaN values
2+
MongoDB\BSON\Decimal128 NaN values
33
--SKIPIF--
44
<?php if (!class_exists('MongoDB\BSON\Decimal128')) { die('skip MongoDB\BSON\Decimal128 is not available'); } ?>
55
--FILE--

tests/bson/bson-decimal128-003.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
BSON\Decimal128 Infinity values
2+
MongoDB\BSON\Decimal128 Infinity values
33
--SKIPIF--
44
<?php if (!class_exists('MongoDB\BSON\Decimal128')) { die('skip MongoDB\BSON\Decimal128 is not available'); } ?>
55
--FILE--

tests/bson/bson-decimal128-004.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
BSON\Decimal128 debug handler
2+
MongoDB\BSON\Decimal128 debug handler
33
--SKIPIF--
44
<?php if (!class_exists('MongoDB\BSON\Decimal128')) { die('skip MongoDB\BSON\Decimal128 is not available'); } ?>
55
--FILE--

tests/bson/bson-decode-002.phpt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
BSON encoding: Encoding object/arrays data into user specificied classes
33
--FILE--
44
<?php
5-
use MongoDB\BSON as BSON;
65

76
require_once __DIR__ . '/../utils/tools.php';
87

9-
class MyArrayObject extends ArrayObject implements BSON\Unserializable {
8+
class MyArrayObject extends ArrayObject implements MongoDB\BSON\Unserializable {
109
function bsonUnserialize(array $data) {
1110
parent::__construct($data);
1211
}

tests/bson/bson-encode-001.phpt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
BSON encoding: Encoding data into BSON representation, and BSON into Extended JSON
33
--FILE--
44
<?php
5-
use MongoDB\BSON as BSON;
65

76
require_once __DIR__ . '/../utils/tools.php';
87

tests/bson/bson-encode-002.phpt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
BSON encoding: Encoding objects into BSON representation
33
--FILE--
44
<?php
5-
use MongoDB\BSON as BSON;
65

76
require_once __DIR__ . '/../utils/tools.php';
87

9-
class AssociativeArray implements BSON\Serializable, BSON\Unserializable
8+
class AssociativeArray implements MongoDB\BSON\Serializable, MongoDB\BSON\Unserializable
109
{
1110
public function bsonSerialize()
1211
{
@@ -20,7 +19,7 @@ class AssociativeArray implements BSON\Serializable, BSON\Unserializable
2019
}
2120
}
2221

23-
class NumericArray implements BSON\Serializable, BSON\Unserializable
22+
class NumericArray implements MongoDB\BSON\Serializable, MongoDB\BSON\Unserializable
2423
{
2524
public function bsonSerialize()
2625
{

0 commit comments

Comments
 (0)