Skip to content

Commit 8a62862

Browse files
committed
Merged pull request #73
2 parents 802b9b4 + 89caf72 commit 8a62862

File tree

9 files changed

+44
-44
lines changed

9 files changed

+44
-44
lines changed

php_phongo.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1705,7 +1705,7 @@ void php_phongo_new_javascript_from_javascript_and_scope(int init, zval *object,
17051705
intern->javascript_len = code_len;
17061706
intern->document = scope ? bson_copy(scope) : NULL;
17071707
} /* }}} */
1708-
void php_phongo_new_binary_from_binary_and_subtype(zval *object, const char *data, size_t data_len, bson_subtype_t type TSRMLS_DC) /* {{{ */
1708+
void php_phongo_new_binary_from_binary_and_type(zval *object, const char *data, size_t data_len, bson_subtype_t type TSRMLS_DC) /* {{{ */
17091709
{
17101710
php_phongo_binary_t *intern;
17111711

@@ -1714,7 +1714,7 @@ void php_phongo_new_binary_from_binary_and_subtype(zval *object, const char *dat
17141714
intern = (php_phongo_binary_t *)zend_object_store_get_object(object TSRMLS_CC);
17151715
intern->data = estrndup(data, data_len);
17161716
intern->data_len = data_len;
1717-
intern->subtype = type;
1717+
intern->type = type;
17181718
} /* }}} */
17191719
void php_phongo_new_regex_from_regex_and_options(zval *object, const char *pattern, const char *flags TSRMLS_DC) /* {{{ */
17201720
{

php_phongo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ void php_phongo_new_datetime_from_utcdatetime(zval *object, int64_t milliseconds
139139
void php_phongo_new_timestamp_from_increment_and_timestamp(zval *object, int32_t increment, int32_t timestamp TSRMLS_DC);
140140
void php_phongo_new_javascript_from_javascript(int init, zval *object, const char *code, size_t code_len TSRMLS_DC);
141141
void php_phongo_new_javascript_from_javascript_and_scope(int init, zval *object, const char *code, size_t code_len, const bson_t *scope TSRMLS_DC);
142-
void php_phongo_new_binary_from_binary_and_subtype(zval *object, const char *data, size_t data_len, bson_subtype_t type TSRMLS_DC);
142+
void php_phongo_new_binary_from_binary_and_type(zval *object, const char *data, size_t data_len, bson_subtype_t type TSRMLS_DC);
143143
void php_phongo_new_regex_from_regex_and_options(zval *object, const char *pattern, const char *flags TSRMLS_DC);
144144

145145
php_phongo_writeresult_t *php_phongo_writeresult_get_from_bulkwriteexception(zval *ex TSRMLS_DC);

php_phongo_classes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ typedef struct {
117117
zend_object std;
118118
char *data;
119119
int data_len;
120-
int subtype;
120+
int type;
121121
} php_phongo_binary_t;
122122
typedef struct {
123123
zend_object std;

src/BSON/Binary.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,29 +46,29 @@ PHONGO_API zend_class_entry *php_phongo_binary_ce;
4646

4747
zend_object_handlers php_phongo_handler_binary;
4848

49-
/* {{{ proto BSON\Binary Binary::__construct(string $data, int $subtype)
49+
/* {{{ proto BSON\Binary Binary::__construct(string $data, int $type)
5050
Construct a new BSON Binary type */
5151
PHP_METHOD(Binary, __construct)
5252
{
5353
php_phongo_binary_t *intern;
5454
zend_error_handling error_handling;
5555
char *data;
5656
int data_len;
57-
long subtype;
57+
long type;
5858

5959

6060
zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);
6161
intern = (php_phongo_binary_t *)zend_object_store_get_object(getThis() TSRMLS_CC);
6262

63-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl", &data, &data_len, &subtype) == FAILURE) {
63+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl", &data, &data_len, &type) == FAILURE) {
6464
zend_restore_error_handling(&error_handling TSRMLS_CC);
6565
return;
6666
}
6767
zend_restore_error_handling(&error_handling TSRMLS_CC);
6868

6969
intern->data = estrndup(data, data_len);
7070
intern->data_len = data_len;
71-
intern->subtype = subtype;
71+
intern->type = type;
7272
}
7373
/* }}} */
7474
/* {{{ proto string Binary::getData()
@@ -87,9 +87,9 @@ PHP_METHOD(Binary, getData)
8787
RETURN_STRINGL(intern->data, intern->data_len, 1);
8888
}
8989
/* }}} */
90-
/* {{{ proto integer Binary::getSubType()
90+
/* {{{ proto integer Binary::getType()
9191
*/
92-
PHP_METHOD(Binary, getSubType)
92+
PHP_METHOD(Binary, getType)
9393
{
9494
php_phongo_binary_t *intern;
9595

@@ -100,7 +100,7 @@ PHP_METHOD(Binary, getSubType)
100100
return;
101101
}
102102

103-
RETURN_LONG(intern->subtype);
103+
RETURN_LONG(intern->type);
104104
}
105105
/* }}} */
106106

@@ -109,20 +109,20 @@ PHP_METHOD(Binary, getSubType)
109109

110110
ZEND_BEGIN_ARG_INFO_EX(ai_Binary___construct, 0, 0, 2)
111111
ZEND_ARG_INFO(0, data)
112-
ZEND_ARG_INFO(0, subtype)
112+
ZEND_ARG_INFO(0, type)
113113
ZEND_END_ARG_INFO();
114114

115115
ZEND_BEGIN_ARG_INFO_EX(ai_Binary_getData, 0, 0, 0)
116116
ZEND_END_ARG_INFO();
117117

118-
ZEND_BEGIN_ARG_INFO_EX(ai_Binary_getSubType, 0, 0, 0)
118+
ZEND_BEGIN_ARG_INFO_EX(ai_Binary_getType, 0, 0, 0)
119119
ZEND_END_ARG_INFO();
120120

121121

122122
static zend_function_entry php_phongo_binary_me[] = {
123123
PHP_ME(Binary, __construct, ai_Binary___construct, ZEND_ACC_PUBLIC)
124124
PHP_ME(Binary, getData, ai_Binary_getData, ZEND_ACC_PUBLIC)
125-
PHP_ME(Binary, getSubType, ai_Binary_getSubType, ZEND_ACC_PUBLIC)
125+
PHP_ME(Binary, getType, ai_Binary_getType, ZEND_ACC_PUBLIC)
126126
PHP_FE_END
127127
};
128128

@@ -169,7 +169,7 @@ HashTable *php_phongo_binary_get_debug_info(zval *object, int *is_temp TSRMLS_DC
169169
array_init_size(&retval, 2);
170170

171171
add_assoc_stringl_ex(&retval, ZEND_STRS("data"), intern->data, intern->data_len, 1);
172-
add_assoc_long_ex(&retval, ZEND_STRS("subtype"), intern->subtype);
172+
add_assoc_long_ex(&retval, ZEND_STRS("type"), intern->type);
173173

174174
return Z_ARRVAL(retval);
175175
} /* }}} */

src/bson.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,13 @@ int php_phongo_binary_get_data(zval *object, char **data TSRMLS_DC)
144144
*data = intern->data;
145145
return intern->data_len;
146146
}
147-
int php_phongo_binary_get_subtype(zval *object TSRMLS_DC)
147+
int php_phongo_binary_get_type(zval *object TSRMLS_DC)
148148
{
149149
php_phongo_binary_t *intern;
150150

151151
intern = (php_phongo_binary_t *)zend_object_store_get_object(object TSRMLS_CC);
152152

153-
return intern->subtype;
153+
return intern->type;
154154
}
155155
char *php_phongo_regex_get_pattern(zval *object TSRMLS_DC)
156156
{
@@ -223,7 +223,7 @@ bool php_phongo_bson_visit_binary(const bson_iter_t *iter ARG_UNUSED, const char
223223
}
224224

225225
MAKE_STD_ZVAL(zchild);
226-
php_phongo_new_binary_from_binary_and_subtype(zchild, (const char *)v_binary, v_binary_len, v_subtype TSRMLS_CC);
226+
php_phongo_new_binary_from_binary_and_type(zchild, (const char *)v_binary, v_binary_len, v_subtype TSRMLS_CC);
227227

228228
add_assoc_zval(retval, key, zchild);
229229

@@ -677,7 +677,7 @@ void object_to_bson(zval *object, php_phongo_bson_flags_t flags, const char *key
677677
data_len = php_phongo_binary_get_data(object, (char **)&data TSRMLS_CC);
678678

679679
mongoc_log(MONGOC_LOG_LEVEL_TRACE, MONGOC_LOG_DOMAIN, "encoding Binary");
680-
bson_append_binary(bson, key, key_len, php_phongo_binary_get_subtype(object TSRMLS_CC), data, data_len);
680+
bson_append_binary(bson, key, key_len, php_phongo_binary_get_type(object TSRMLS_CC), data, data_len);
681681
return;
682682
}
683683
if (instanceof_function(Z_OBJCE_P(object), php_phongo_regex_ce TSRMLS_CC)) {

tests/bson/bson-binary-001.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ $tests = array();
2222
foreach($types as $type) {
2323
$binary = new $classname("random binary data", $type);
2424
var_dump($binary->getData() == "random binary data");
25-
var_dump($binary->getSubType() == $type);
25+
var_dump($binary->getType() == $type);
2626
$tests[] = array("binary" => $binary);
2727
}
2828

@@ -43,7 +43,7 @@ foreach($tests as $n => $test) {
4343
}
4444

4545
$binary->getData(2);
46-
$binary->getSubType(2);
46+
$binary->getType(2);
4747
?>
4848
===DONE===
4949
<?php exit(0); ?>
@@ -100,5 +100,5 @@ bool(true)
100100

101101
Warning: %s\Binary::getData() expects exactly 0 parameters, 1 given in %s on line %d
102102

103-
Warning: %s\Binary::getSubType() expects exactly 0 parameters, 1 given in %s on line %d
103+
Warning: %s\Binary::getType() expects exactly 0 parameters, 1 given in %s on line %d
104104
===DONE===

tests/bson/bson-encode-003.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ object(stdClass)#%d (1) {
6262
object(%sBSON\Binary)#%d (2) {
6363
["data"]=>
6464
string(7) "MyClass"
65-
["subtype"]=>
65+
["type"]=>
6666
int(128)
6767
}
6868
["random"]=>
@@ -86,7 +86,7 @@ object(stdClass)#%d (1) {
8686
object(%sBSON\Binary)#%d (2) {
8787
["data"]=>
8888
string(8) "MyClass2"
89-
["subtype"]=>
89+
["type"]=>
9090
int(128)
9191
}
9292
[0]=>
@@ -119,7 +119,7 @@ object(stdClass)#%d (1) {
119119
object(%sBSON\Binary)#%d (2) {
120120
["data"]=>
121121
string(7) "MyClass"
122-
["subtype"]=>
122+
["type"]=>
123123
int(128)
124124
}
125125
["random"]=>
@@ -136,7 +136,7 @@ object(stdClass)#%d (1) {
136136
object(%sBSON\Binary)#%d (2) {
137137
["data"]=>
138138
string(8) "MyClass2"
139-
["subtype"]=>
139+
["type"]=>
140140
int(128)
141141
}
142142
[0]=>

tests/bson/bson-toPHP-001.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ object(stdClass)#%d (2) {
5151
object(MongoDB\BSON\Binary)#%d (2) {
5252
["data"]=>
5353
string(18) "MyAbstractDocument"
54-
["subtype"]=>
54+
["type"]=>
5555
int(128)
5656
}
5757
}
@@ -64,7 +64,7 @@ object(stdClass)#%d (2) {
6464
object(MongoDB\BSON\Binary)#%d (2) {
6565
["data"]=>
6666
string(10) "MyDocument"
67-
["subtype"]=>
67+
["type"]=>
6868
int(128)
6969
}
7070
}
@@ -77,7 +77,7 @@ object(stdClass)#%d (2) {
7777
object(MongoDB\BSON\Binary)#%d (2) {
7878
["data"]=>
7979
string(27) "MongoDB\BSON\Unserializable"
80-
["subtype"]=>
80+
["type"]=>
8181
int(128)
8282
}
8383
}
@@ -90,7 +90,7 @@ object(stdClass)#%d (2) {
9090
object(MongoDB\BSON\Binary)#%d (2) {
9191
["data"]=>
9292
string(24) "MongoDB\BSON\Persistable"
93-
["subtype"]=>
93+
["type"]=>
9494
int(68)
9595
}
9696
}

tests/bson/bson-toPHP-003.phpt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ object(stdClass)#%d (2) {
205205
object(%SBSON\Binary)#%d (2) {
206206
["data"]=>
207207
string(7) "MyClass"
208-
["subtype"]=>
208+
["type"]=>
209209
int(128)
210210
}
211211
}
@@ -218,7 +218,7 @@ object(stdClass)#%d (2) {
218218
object(MongoDB\BSON\Binary)#%d (2) {
219219
["data"]=>
220220
string(9) "YourClass"
221-
["subtype"]=>
221+
["type"]=>
222222
int(128)
223223
}
224224
}
@@ -231,7 +231,7 @@ object(OurClass)#%d (3) {
231231
object(MongoDB\BSON\Binary)#%d (2) {
232232
["data"]=>
233233
string(8) "OurClass"
234-
["subtype"]=>
234+
["type"]=>
235235
int(128)
236236
}
237237
["unserialized"]=>
@@ -246,7 +246,7 @@ object(stdClass)#%d (2) {
246246
object(MongoDB\BSON\Binary)#%d (2) {
247247
["data"]=>
248248
string(9) "YourClass"
249-
["subtype"]=>
249+
["type"]=>
250250
int(68)
251251
}
252252
}
@@ -280,7 +280,7 @@ object(YourClass)#%d (3) {
280280
object(%SBSON\Binary)#%d (2) {
281281
["data"]=>
282282
string(27) "%SBSON\Unserializable"
283-
["subtype"]=>
283+
["type"]=>
284284
int(128)
285285
}
286286
["unserialized"]=>
@@ -298,7 +298,7 @@ object(YourClass)#%d (3) {
298298
object(%SBSON\Binary)#%d (2) {
299299
["data"]=>
300300
string(7) "MyClass"
301-
["subtype"]=>
301+
["type"]=>
302302
int(128)
303303
}
304304
["unserialized"]=>
@@ -313,7 +313,7 @@ object(OurClass)#%d (3) {
313313
object(%SBSON\Binary)#%d (2) {
314314
["data"]=>
315315
string(8) "OurClass"
316-
["subtype"]=>
316+
["type"]=>
317317
int(128)
318318
}
319319
["unserialized"]=>
@@ -328,7 +328,7 @@ object(TheirClass)#%d (3) {
328328
object(%SBSON\Binary)#%d (2) {
329329
["data"]=>
330330
string(10) "TheirClass"
331-
["subtype"]=>
331+
["type"]=>
332332
int(128)
333333
}
334334
["unserialized"]=>
@@ -343,7 +343,7 @@ object(YourClass)#%d (3) {
343343
object(MongoDB\BSON\Binary)#%d (2) {
344344
["data"]=>
345345
string(9) "YourClass"
346-
["subtype"]=>
346+
["type"]=>
347347
int(128)
348348
}
349349
["unserialized"]=>
@@ -361,7 +361,7 @@ object(TheirClass)#%d (3) {
361361
object(%SBSON\Binary)#%d (2) {
362362
["data"]=>
363363
string(10) "TheirClass"
364-
["subtype"]=>
364+
["type"]=>
365365
int(128)
366366
}
367367
["unserialized"]=>
@@ -419,7 +419,7 @@ array(2) {
419419
object(%SBSON\Binary)#%d (2) {
420420
["data"]=>
421421
string(7) "MyClass"
422-
["subtype"]=>
422+
["type"]=>
423423
int(128)
424424
}
425425
}
@@ -432,7 +432,7 @@ array(2) {
432432
object(%SBSON\Binary)#%d (2) {
433433
["data"]=>
434434
string(8) "OurClass"
435-
["subtype"]=>
435+
["type"]=>
436436
int(128)
437437
}
438438
}
@@ -448,7 +448,7 @@ object(stdClass)#%d (2) {
448448
object(%SBSON\Binary)#%d (2) {
449449
["data"]=>
450450
string(7) "MyClass"
451-
["subtype"]=>
451+
["type"]=>
452452
int(128)
453453
}
454454
}
@@ -461,7 +461,7 @@ object(stdClass)#%d (2) {
461461
object(%SBSON\Binary)#%d (2) {
462462
["data"]=>
463463
string(8) "OurClass"
464-
["subtype"]=>
464+
["type"]=>
465465
int(128)
466466
}
467467
}

0 commit comments

Comments
 (0)