MCPcopy Create free account
hub / github.com/apache/thrift / createObject

Function createObject

lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp:395–417  ·  view source on GitHub ↗

Create a PHP object given a typename and call the ctor, optionally passing up to 2 arguments

Source from the content-addressed store, hash-verified

393
394// Create a PHP object given a typename and call the ctor, optionally passing up to 2 arguments
395static
396void createObject(const char* obj_typename, zval* return_value, int nargs = 0, zval* arg1 = nullptr, zval* arg2 = nullptr) {
397 /* is there a better way to do that on the stack ? */
398 zend_string *obj_name = zend_string_init(obj_typename, strlen(obj_typename), 0);
399 zend_class_entry* ce = zend_fetch_class(obj_name, ZEND_FETCH_CLASS_DEFAULT);
400 zend_string_release(obj_name);
401
402 if (! ce) {
403 php_error_docref(nullptr, E_ERROR, "Class %s does not exist", obj_typename);
404 RETURN_NULL();
405 }
406
407 object_and_properties_init(return_value, ce, nullptr);
408 zend_function* constructor = zend_std_get_constructor(Z_OBJ_P(return_value));
409 zval ctor_rv;
410 zend_call_method(Z4_OBJ_P(return_value), ce, &constructor, nullptr, 0, &ctor_rv, nargs, arg1, arg2);
411 zval_dtor(&ctor_rv);
412 if (EG(exception)) {
413 zend_object *ex = EG(exception);
414 EG(exception) = nullptr;
415 throw PHPExceptionWrapper(ex);
416 }
417}
418
419static
420void throw_tprotocolexception(const char* what, long errorcode) {

Callers 3

throw_tprotocolexceptionFunction · 0.85
binary_deserializeFunction · 0.85
PHP_FUNCTIONFunction · 0.85

Calls 1

PHPExceptionWrapperClass · 0.85

Tested by

no test coverage detected