1515 */
1616
1717#ifdef HAVE_CONFIG_H
18- # include "config.h"
18+ # include "config.h"
1919#endif
2020
21- /* External libs */
22- #include <bson.h>
23- #include <mongoc.h>
24-
25- /* PHP Core stuff */
2621#include <php.h>
27- #include <php_ini.h>
2822#include <ext/standard/base64.h>
29- #include <ext/standard/info.h>
3023#include <Zend/zend_interfaces.h>
3124#include <Zend/zend_operators.h>
32- #include <ext/spl/spl_iterators.h>
3325#include <ext/standard/php_var.h>
3426#if PHP_VERSION_ID >= 70000
3527# include <zend_smart_str.h>
3628#else
3729# include <ext/standard/php_smart_str.h>
3830#endif
39- /* Our Compatability header */
40- #include "phongo_compat.h"
4131
42- /* Our stuffz */
32+ #include "phongo_compat.h"
4333#include "php_phongo.h"
44- #include "php_bson.h"
45-
4634
4735zend_class_entry * php_phongo_binary_ce ;
4836
49- static zend_object_handlers php_phongo_handler_binary ;
50-
5137/* Initialize the object and return whether it was successful. An exception will
5238 * be thrown on error. */
53- static bool php_phongo_binary_init (php_phongo_binary_t * intern , const char * data , phongo_zpp_char_len data_len , phongo_long type TSRMLS_DC )
39+ static bool php_phongo_binary_init (php_phongo_binary_t * intern , const char * data , phongo_zpp_char_len data_len , phongo_long type TSRMLS_DC ) /* {{{ */
5440{
5541 if (type < 0 || type > UINT8_MAX ) {
5642 phongo_throw_exception (PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC , "Expected type to be an unsigned 8-bit integer, %" PHONGO_LONG_FORMAT " given" , type );
@@ -62,11 +48,11 @@ static bool php_phongo_binary_init(php_phongo_binary_t *intern, const char *data
6248 intern -> type = (uint8_t ) type ;
6349
6450 return true;
65- }
51+ } /* }}} */
6652
6753/* Initialize the object from a HashTable and return whether it was successful.
6854 * An exception will be thrown on error. */
69- static bool php_phongo_binary_init_from_hash (php_phongo_binary_t * intern , HashTable * props TSRMLS_DC )
55+ static bool php_phongo_binary_init_from_hash (php_phongo_binary_t * intern , HashTable * props TSRMLS_DC ) /* {{{ */
7056{
7157#if PHP_VERSION_ID >= 70000
7258 zval * data , * type ;
@@ -86,9 +72,9 @@ static bool php_phongo_binary_init_from_hash(php_phongo_binary_t *intern, HashTa
8672
8773 phongo_throw_exception (PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC , "%s initialization requires \"data\" string and \"type\" integer fields" , ZSTR_VAL (php_phongo_binary_ce -> name ));
8874 return false;
89- }
75+ } /* }}} */
9076
91- /* {{{ proto void Binary::__construct(string $data, int $type)
77+ /* {{{ proto void MongoDB\BSON\ Binary::__construct(string $data, int $type)
9278 Construct a new BSON binary type */
9379static PHP_METHOD (Binary , __construct )
9480{
@@ -109,10 +95,9 @@ static PHP_METHOD(Binary, __construct)
10995 zend_restore_error_handling (& error_handling TSRMLS_CC );
11096
11197 php_phongo_binary_init (intern , data , data_len , type TSRMLS_CC );
112- }
113- /* }}} */
98+ } /* }}} */
11499
115- /* {{{ proto void Binary::__set_state(array $properties)
100+ /* {{{ proto void MongoDB\BSON\ Binary::__set_state(array $properties)
116101*/
117102static PHP_METHOD (Binary , __set_state )
118103{
@@ -130,10 +115,9 @@ static PHP_METHOD(Binary, __set_state)
130115 props = Z_ARRVAL_P (array );
131116
132117 php_phongo_binary_init_from_hash (intern , props TSRMLS_CC );
133- }
134- /* }}} */
118+ } /* }}} */
135119
136- /* {{{ proto string Binary::__toString()
120+ /* {{{ proto string MongoDB\BSON\ Binary::__toString()
137121 Return the Binary's data string. */
138122static PHP_METHOD (Binary , __toString )
139123{
@@ -146,10 +130,9 @@ static PHP_METHOD(Binary, __toString)
146130 intern = Z_BINARY_OBJ_P (getThis ());
147131
148132 PHONGO_RETURN_STRINGL (intern -> data , intern -> data_len );
149- }
150- /* }}} */
133+ } /* }}} */
151134
152- /* {{{ proto string Binary::getData()
135+ /* {{{ proto string MongoDB\BSON\ Binary::getData()
153136*/
154137static PHP_METHOD (Binary , getData )
155138{
@@ -163,10 +146,9 @@ static PHP_METHOD(Binary, getData)
163146 }
164147
165148 PHONGO_RETURN_STRINGL (intern -> data , intern -> data_len );
166- }
167- /* }}} */
149+ } /* }}} */
168150
169- /* {{{ proto integer Binary::getType()
151+ /* {{{ proto integer MongoDB\BSON\ Binary::getType()
170152*/
171153static PHP_METHOD (Binary , getType )
172154{
@@ -180,10 +162,9 @@ static PHP_METHOD(Binary, getType)
180162 }
181163
182164 RETURN_LONG (intern -> type );
183- }
184- /* }}} */
165+ } /* }}} */
185166
186- /* {{{ proto array Binary::jsonSerialize()
167+ /* {{{ proto array MongoDB\BSON\ Binary::jsonSerialize()
187168*/
188169static PHP_METHOD (Binary , jsonSerialize )
189170{
@@ -216,10 +197,9 @@ static PHP_METHOD(Binary, jsonSerialize)
216197
217198 type_len = snprintf (type , sizeof (type ), "%02x" , intern -> type );
218199 ADD_ASSOC_STRINGL (return_value , "$type" , type , type_len );
219- }
220- /* }}} */
200+ } /* }}} */
221201
222- /* {{{ proto string Binary::serialize()
202+ /* {{{ proto string MongoDB\BSON\ Binary::serialize()
223203*/
224204static PHP_METHOD (Binary , serialize )
225205{
@@ -258,10 +238,9 @@ static PHP_METHOD(Binary, serialize)
258238
259239 smart_str_free (& buf );
260240 zval_ptr_dtor (& retval );
261- }
262- /* }}} */
241+ } /* }}} */
263242
264- /* {{{ proto string Binary::unserialize(string $serialized)
243+ /* {{{ proto void MongoDB\BSON\ Binary::unserialize(string $serialized)
265244*/
266245static PHP_METHOD (Binary , unserialize )
267246{
@@ -305,12 +284,9 @@ static PHP_METHOD(Binary, unserialize)
305284 php_phongo_binary_init_from_hash (intern , HASH_OF (props ) TSRMLS_CC );
306285#endif
307286 zval_ptr_dtor (& props );
308- }
309- /* }}} */
310-
311-
312- /* {{{ BSON\Binary */
287+ } /* }}} */
313288
289+ /* {{{ MongoDB\BSON\Binary function entries */
314290ZEND_BEGIN_ARG_INFO_EX (ai_Binary___construct , 0 , 0 , 2 )
315291 ZEND_ARG_INFO (0 , data )
316292 ZEND_ARG_INFO (0 , type )
@@ -338,11 +314,11 @@ static zend_function_entry php_phongo_binary_me[] = {
338314 PHP_ME (Binary , getType , ai_Binary_void , ZEND_ACC_PUBLIC |ZEND_ACC_FINAL )
339315 PHP_FE_END
340316};
341-
342317/* }}} */
343318
319+ /* {{{ MongoDB\BSON\Binary object handlers */
320+ static zend_object_handlers php_phongo_handler_binary ;
344321
345- /* {{{ php_phongo_binary_t object handlers */
346322static void php_phongo_binary_free_object (phongo_free_object_arg * object TSRMLS_DC ) /* {{{ */
347323{
348324 php_phongo_binary_t * intern = Z_OBJ_BINARY (object );
0 commit comments