static int pdo_dblib_handle_factory(pdo_dbh_t *dbh, zval *driver_options) { pdo_dblib_db_handle *H; int i, nvars, nvers, ret = 0; const pdo_dblib_keyval tdsver[] = { {"4.2",DBVERSION_42} ,{"4.6",DBVERSION_46} ,{"5.0",DBVERSION_70} /* FIXME: This does not work with Sybase, but environ will */ ,{"6.0",DBVERSION_70} ,{"7.0",DBVERSION_70} #ifdef DBVERSION_71 ,{"7.1",DBVERSION_71} #endif #ifdef DBVERSION_72 ,{"7.2",DBVERSION_72} ,{"8.0",DBVERSION_72} #endif #ifdef DBVERSION_73 ,{"7.3",DBVERSION_73} #endif #ifdef DBVERSION_74 ,{"7.4",DBVERSION_74} #endif ,{"10.0",DBVERSION_100} ,{"auto",0} /* Only works with FreeTDS. Other drivers will bork */ }; struct pdo_data_src_parser vars[] = { { "charset", NULL, 0 } ,{ "appname", "PHP " PDO_DBLIB_FLAVOUR, 0 } ,{ "host", "127.0.0.1", 0 } ,{ "dbname", NULL, 0 } ,{ "secure", NULL, 0 } /* DBSETLSECURE */ ,{ "version", NULL, 0 } /* DBSETLVERSION */ }; nvars = sizeof(vars)/sizeof(vars[0]); nvers = sizeof(tdsver)/sizeof(tdsver[0]); php_pdo_parse_data_source(dbh->data_source, dbh->data_source_len, vars, nvars); H = pecalloc(1, sizeof(*H), dbh->is_persistent); H->login = dblogin(); H->err.sqlstate = dbh->error_code; H->assume_national_character_set_strings = 0; H->stringify_uniqueidentifier = 0; H->skip_empty_rowsets = 0; if (!H->login) { goto cleanup; } if (driver_options) { int connect_timeout = pdo_attr_lval(driver_options, PDO_DBLIB_ATTR_CONNECTION_TIMEOUT, -1); int query_timeout = pdo_attr_lval(driver_options, PDO_DBLIB_ATTR_QUERY_TIMEOUT, -1); int timeout = pdo_attr_lval(driver_options, PDO_ATTR_TIMEOUT, 30); if (connect_timeout == -1) { connect_timeout = timeout; } if (query_timeout == -1) { query_timeout = timeout; } dbsetlogintime(connect_timeout); /* Connection/Login Timeout */ dbsettime(query_timeout); /* Statement Timeout */ H->assume_national_character_set_strings = pdo_attr_lval(driver_options, PDO_ATTR_DEFAULT_STR_PARAM, 0) == PDO_PARAM_STR_NATL ? 1 : 0; H->stringify_uniqueidentifier = pdo_attr_lval(driver_options, PDO_DBLIB_ATTR_STRINGIFY_UNIQUEIDENTIFIER, 0); H->skip_empty_rowsets = pdo_attr_lval(driver_options, PDO_DBLIB_ATTR_SKIP_EMPTY_ROWSETS, 0); } DBERRHANDLE(H->login, (EHANDLEFUNC) pdo_dblib_error_handler); DBMSGHANDLE(H->login, (MHANDLEFUNC) pdo_dblib_msg_handler); if(vars[5].optval) { for(i=0;i<nvers;i++) { if(strcmp(vars[5].optval,tdsver[i].key) == 0) { if(FAIL==dbsetlversion(H->login, tdsver[i].value)) { pdo_raise_impl_error(dbh, NULL, "HY000", "PDO_DBLIB: Failed to set version specified in connection string."); goto cleanup; } break; } } if (i==nvers) { printf("Invalid version '%s'\n", vars[5].optval); pdo_raise_impl_error(dbh, NULL, "HY000", "PDO_DBLIB: Invalid version specified in connection string."); goto cleanup; /* unknown version specified */ } } if (dbh->username) { if(FAIL == DBSETLUSER(H->login, dbh->username)) { goto cleanup; } } if (dbh->password) { if(FAIL == DBSETLPWD(H->login, dbh->password)) { goto cleanup; } } #if !PHP_DBLIB_IS_MSSQL if (vars[0].optval) { DBSETLCHARSET(H->login, vars[0].optval); } #endif DBSETLAPP(H->login, vars[1].optval); /* DBSETLDBNAME is only available in FreeTDS 0.92 or above */ #ifdef DBSETLDBNAME if (vars[3].optval) { if(FAIL == DBSETLDBNAME(H->login, vars[3].optval)) goto cleanup; } #endif H->link = dbopen(H->login, vars[2].optval); if (!H->link) { goto cleanup; } /* * FreeTDS < 0.92 does not support the DBSETLDBNAME option * Send use database here after login (Will not work with SQL Azure) */ #ifndef DBSETLDBNAME if (vars[3].optval) { if(FAIL == dbuse(H->link, vars[3].optval)) goto cleanup; } #endif #if PHP_DBLIB_IS_MSSQL /* dblib do not return more than this length from text/image */ DBSETOPT(H->link, DBTEXTLIMIT, "2147483647"); #endif /* limit text/image from network */ DBSETOPT(H->link, DBTEXTSIZE, "2147483647"); /* allow double quoted indentifiers */ DBSETOPT(H->link, DBQUOTEDIDENT, "1"); ret = 1; dbh->max_escaped_char_length = 2; dbh->alloc_own_columns = 1; cleanup: for (i = 0; i < nvars; i++) { if (vars[i].freeme) { efree(vars[i].optval); } } dbh->methods = &dblib_methods; dbh->driver_data = H; if (!ret) { zend_throw_exception_ex(php_pdo_get_exception(), DBLIB_G(err).dberr, "SQLSTATE[%s] %s (severity %d)", DBLIB_G(err).sqlstate, DBLIB_G(err).dberrstr, DBLIB_G(err).severity); } return ret; }
/** * This method scales the images using liquid rescaling method. Only support Imagick * * @param int $width new width * @param int $height new height * @param int $delta_x How much the seam can traverse on x-axis. Passing 0 causes the seams to be straight. * @param int $rigidity Introduces a bias for non-straight seams. This parameter is typically 0. * @return Phalcon\Image\Adapter */ PHP_METHOD(Phalcon_Image_Adapter_GD, _liquidRescale){ zend_throw_exception_ex(phalcon_image_exception_ce, 0, "The GD does not support liquidRescale"); }
/* {{{ proto MongoGridFS::__construct(MongoDB db [, string prefix = "fs"]) Creates a new MongoGridFS object */ PHP_METHOD(MongoGridFS, __construct) { zval *zdb, *files = NULL, *chunks = NULL, *zchunks; zval *z_w = NULL; /* chunks is deprecated */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|zz", &zdb, mongo_ce_DB, &files, &chunks) == FAILURE) { zval *object = getThis(); ZVAL_NULL(object); return; } if (chunks) { php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "The 'chunks' argument is deprecated and ignored"); } if (files) { zval *temp_file; char *temp; if (Z_TYPE_P(files) != IS_STRING || Z_STRLEN_P(files) == 0 ) { zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 2 TSRMLS_CC, "MongoGridFS::__construct(): invalid prefix"); return; } MAKE_STD_ZVAL(chunks); spprintf(&temp, 0, "%s.chunks", Z_STRVAL_P(files)); ZVAL_STRING(chunks, temp, 0); MAKE_STD_ZVAL(temp_file); spprintf(&temp, 0, "%s.files", Z_STRVAL_P(files)); ZVAL_STRING(temp_file, temp, 0); files = temp_file; } else { MAKE_STD_ZVAL(files); ZVAL_STRING(files, "fs.files", 1); MAKE_STD_ZVAL(chunks); ZVAL_STRING(chunks, "fs.chunks", 1); } /* create files collection */ MONGO_METHOD2(MongoCollection, __construct, return_value, getThis(), zdb, files); /* create chunks collection */ MAKE_STD_ZVAL(zchunks); object_init_ex(zchunks, mongo_ce_Collection); MONGO_METHOD2(MongoCollection, __construct, return_value, zchunks, zdb, chunks); /* add chunks collection as a property */ zend_update_property(mongo_ce_GridFS, getThis(), "chunks", strlen("chunks"), zchunks TSRMLS_CC); zend_update_property(mongo_ce_GridFS, getThis(), "filesName", strlen("filesName"), files TSRMLS_CC); zend_update_property(mongo_ce_GridFS, getThis(), "chunksName", strlen("chunksName"), chunks TSRMLS_CC); /* GridFS is forced in our codebase to be w=1 so this property doesn't actually mean * anything, but we can't lie to the user so we have to overwrite it if the MongoDB * object that created this object was w=0. * This property is initialized in the MongoCollection (which we extend) ctor */ z_w = zend_read_property(mongo_ce_GridFS, getThis(), "w", strlen("w"), NOISY TSRMLS_CC); if (Z_TYPE_P(z_w) != IS_STRING) { convert_to_long(z_w); if (Z_LVAL_P(z_w) < 2) { zend_update_property_long(mongo_ce_GridFS, getThis(), "w", strlen("w"), 1 TSRMLS_CC); } } /* cleanup */ zval_ptr_dtor(&zchunks); zval_ptr_dtor(&files); zval_ptr_dtor(&chunks); }
/** * Execute a save. * * @param string $file * @param int $quality * @return boolean */ PHP_METHOD(Phalcon_Image_Adapter_GD, _save) { zval *file, *quality = NULL, *interlacing = NULL, ret = {}, extension = {}, type = {}, mime = {}, constant = {}, image = {}, tmp = {}; const char *func_name = "imagegif"; char *ext; phalcon_fetch_params(0, 1, 2, &file, &quality, &interlacing); if (!phalcon_get_constant(&constant, SL("PATHINFO_EXTENSION"))) { return; } PHALCON_CALL_FUNCTIONW(&ret, "pathinfo", file, &constant); phalcon_fast_strtolower(&extension, &ret); ext = Z_STRVAL(extension); phalcon_return_property(&image, getThis(), SL("_image")); if (strcmp(ext, "gif") == 0) { ZVAL_LONG(&type, 1); func_name = "imagegif"; } else if (strcmp(ext, "jpg") == 0 || strcmp(ext, "jpeg") == 0) { ZVAL_LONG(&type, 2); func_name = "imagejpeg"; } else if (strcmp(ext, "png") == 0) { ZVAL_LONG(&type, 3); func_name = "imagepng"; } else { zend_throw_exception_ex(phalcon_image_exception_ce, 0, "Installed GD does not support '%s' images", Z_STRVAL(extension)); return; } if (interlacing && Z_TYPE_P(interlacing) >= IS_NULL && Z_LVAL(type) > 1) { if (zend_is_true(interlacing)) { PHALCON_CALL_FUNCTIONW(&ret, "imageinterlace", &image, &PHALCON_GLOBAL(z_one)); } else { PHALCON_CALL_FUNCTIONW(&ret, "imageinterlace", &image, &PHALCON_GLOBAL(z_zero)); } } if (!quality || Z_TYPE_P(quality) == IS_NULL) { PHALCON_CALL_FUNCTIONW(NULL, func_name, &image, file); } else { if (Z_LVAL(type) == 3) { ZVAL_LONG(&tmp, ceil(Z_LVAL_P(quality)/100*9)); PHALCON_CALL_FUNCTIONW(&ret, func_name, &image, file, &tmp); } else { PHALCON_CALL_FUNCTIONW(&ret, func_name, &image, file, quality); } } if (zend_is_true(&ret)) { phalcon_update_property_zval(getThis(), SL("_type"), &type); PHALCON_CALL_FUNCTIONW(&mime, "image_type_to_mime_type", &type); phalcon_update_property_zval(getThis(), SL("_mime"), &mime); RETVAL_TRUE; } else { RETVAL_FALSE; } }
/** * Phalcon\Image\GD constructor * * @param string $file */ PHP_METHOD(Phalcon_Image_Adapter_GD, __construct){ zval *file, *width = NULL, *height = NULL, exception_message = {}, checked = {}, realpath = {}, img_width = {}, img_height = {}, type = {}, mime = {}, format = {}, image = {}, imageinfo = {}, saveflag = {}, blendmode = {}; phalcon_fetch_params(0, 1, 2, &file, &width, &height); if (Z_TYPE_P(file) != IS_STRING) { PHALCON_THROW_EXCEPTION_STRW(phalcon_image_exception_ce, "file parameter should be a string"); return; } phalcon_return_static_property_ce(&checked, phalcon_image_adapter_gd_ce, SL("_checked")); if (!zend_is_true(&checked)) { PHALCON_CALL_CE_STATICW(NULL, phalcon_image_adapter_gd_ce, "check"); } phalcon_update_property_zval(getThis(), SL("_file"), file); if (phalcon_file_exists(file) != FAILURE) { phalcon_file_realpath(&realpath, file); if (unlikely(Z_TYPE(realpath) != IS_STRING)) { convert_to_string(&realpath); } phalcon_update_property_zval(getThis(), SL("_realpath"), &realpath); PHALCON_CALL_FUNCTIONW(&imageinfo, "getimagesize", &realpath); if (phalcon_array_isset_fetch_long(&img_width, &imageinfo, 0)) { phalcon_update_property_zval(getThis(), SL("_width"), &img_width); } if (phalcon_array_isset_fetch_long(&img_height, &imageinfo, 1)) { phalcon_update_property_zval(getThis(), SL("_height"), &img_height); } if (phalcon_array_isset_fetch_long(&type, &imageinfo, 2)) { convert_to_long(&type); phalcon_update_property_zval(getThis(), SL("_type"), &type); } else { ZVAL_LONG(&type, -1); } if (phalcon_array_isset_fetch_str(&mime, &imageinfo, SL("mime"))) { convert_to_string(&mime); phalcon_update_property_zval(getThis(), SL("_mime"), &mime); } assert(Z_TYPE(type) == IS_LONG); switch (Z_LVAL(type)) { case 1: // GIF ZVAL_STRING(&format, "gif"); PHALCON_CALL_FUNCTIONW(&image, "imagecreatefromgif", &realpath); break; case 2: // JPEG ZVAL_STRING(&format, "jpg"); PHALCON_CALL_FUNCTIONW(&image, "imagecreatefromjpeg", &realpath); break; case 3: // PNG ZVAL_STRING(&format, "png"); PHALCON_CALL_FUNCTIONW(&image, "imagecreatefrompng", &realpath); break; default: if (PHALCON_IS_NOT_EMPTY(&mime)) { zend_throw_exception_ex(phalcon_image_exception_ce, 0, "Installed GD does not support '%s' images", Z_STRVAL(mime)); } else { zend_throw_exception_ex(phalcon_image_exception_ce, 0, "Installed GD does not support such images"); } return; } if (Z_TYPE(image) != IS_RESOURCE) { assert(Z_TYPE(realpath) == IS_STRING); zend_throw_exception_ex(phalcon_image_exception_ce, 0, "Failed to create image from file '%s'", Z_STRVAL(realpath)); return; } phalcon_update_property_zval(getThis(), SL("_format"), &format); ZVAL_TRUE(&saveflag); PHALCON_CALL_FUNCTIONW(NULL, "imagesavealpha", &image, &saveflag); } else if (width && height) { PHALCON_CALL_FUNCTIONW(&image, "imagecreatetruecolor", width, height); if (Z_TYPE(image) != IS_RESOURCE) { PHALCON_THROW_EXCEPTION_STRW(phalcon_image_exception_ce, "imagecreatetruecolor() failed"); return; } ZVAL_TRUE(&blendmode); ZVAL_TRUE(&saveflag); PHALCON_CALL_FUNCTIONW(NULL, "imagealphablending", &image, &blendmode); PHALCON_CALL_FUNCTIONW(NULL, "imagesavealpha", &image, &saveflag); phalcon_update_property_zval(getThis(), SL("_realpath"), file); phalcon_update_property_zval(getThis(), SL("_width"), width); phalcon_update_property_zval(getThis(), SL("_height"), height); ZVAL_LONG(&type, 3); phalcon_update_property_zval(getThis(), SL("_type"), &type); ZVAL_STRING(&format, "png"); phalcon_update_property_zval(getThis(), SL("_format"), &format); ZVAL_STRING(&mime, "image/png"); phalcon_update_property_zval(getThis(), SL("_mime"), &mime); } else { PHALCON_CONCAT_SVS(&exception_message, "Failed to create image from file '", file, "'"); PHALCON_THROW_EXCEPTION_ZVALW(phalcon_image_exception_ce, &exception_message); return; } phalcon_update_property_zval(getThis(), SL("_image"), &image); }
/* {{{ _pdo_mysql_error */ int _pdo_mysql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *file, int line TSRMLS_DC) /* {{{ */ { pdo_mysql_db_handle *H = (pdo_mysql_db_handle *)dbh->driver_data; pdo_error_type *pdo_err; pdo_mysql_error_info *einfo; pdo_mysql_stmt *S = NULL; PDO_DBG_ENTER("_pdo_mysql_error"); PDO_DBG_INF_FMT("file=%s line=%d", file, line); if (stmt) { S = (pdo_mysql_stmt*)stmt->driver_data; pdo_err = &stmt->error_code; einfo = &S->einfo; } else { pdo_err = &dbh->error_code; einfo = &H->einfo; } #if HAVE_MYSQL_STMT_PREPARE || PDO_USE_MYSQLND if (S && S->stmt) { einfo->errcode = mysql_stmt_errno(S->stmt); } else #endif { einfo->errcode = mysql_errno(H->server); } einfo->file = file; einfo->line = line; if (einfo->errmsg) { pefree(einfo->errmsg, dbh->is_persistent); einfo->errmsg = NULL; } if (einfo->errcode) { if (einfo->errcode == 2014) { einfo->errmsg = pestrdup( "Cannot execute queries while other unbuffered queries are active. " "Consider using PDOStatement::fetchAll(). Alternatively, if your code " "is only ever going to run against mysql, you may enable query " "buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.", dbh->is_persistent); } else if (einfo->errcode == 2057) { einfo->errmsg = pestrdup( "A stored procedure returning result sets of different size was called. " "This is not supported by libmysql", dbh->is_persistent); } else { einfo->errmsg = pestrdup(mysql_error(H->server), dbh->is_persistent); } } else { /* no error */ strcpy(*pdo_err, PDO_ERR_NONE); PDO_DBG_RETURN(0); } #if HAVE_MYSQL_SQLSTATE || PDO_USE_MYSQLND # if HAVE_MYSQL_STMT_PREPARE || PDO_USE_MYSQLND if (S && S->stmt) { strcpy(*pdo_err, mysql_stmt_sqlstate(S->stmt)); } else # endif { strcpy(*pdo_err, mysql_sqlstate(H->server)); } #else strcpy(*pdo_err, pdo_mysql_get_sqlstate(einfo->errcode)); #endif if (!dbh->methods) { PDO_DBG_INF("Throwing exception"); zend_throw_exception_ex(php_pdo_get_exception(), einfo->errcode TSRMLS_CC, "SQLSTATE[%s] [%d] %s", *pdo_err, einfo->errcode, einfo->errmsg); } PDO_DBG_RETURN(einfo->errcode); }
/** * Sets a translation value * * @param string $offset * @param string $value */ PHP_METHOD(Phalcon_Translate_Adapter, offsetSet){ zend_throw_exception_ex(phalcon_translate_exception_ce, 0, "'%s' is an immutable ArrayAccess object", "Phalcon\\Translate\\Adapter"); }
/** * Handles a MVC request * * @param string $uri * @return Phalcon\Http\ResponseInterface */ PHP_METHOD(Phalcon_Mvc_JsonRpc, handle){ zval *uri = NULL, *dependency_injector, *events_manager; zval *status = NULL, *service = NULL, *request = NULL, *response = NULL; zval *json = NULL, *data = NULL, *jsonrpc_message, *jsonrpc_error, *jsonrpc_result = NULL; zval *jsonrpc_method, *jsonrpc_params, *jsonrpc_id; zval *url = NULL, *router = NULL, *module_name = NULL; zval *module_object = NULL, *modules; zval *module, *class_name = NULL, *module_params; zval *namespace_name = NULL; zval *controller_name = NULL, *action_name = NULL, *params = NULL, *exact = NULL; zval *dispatcher = NULL, *controller = NULL, *returned_response = NULL; zval *path; PHALCON_MM_GROW(); dependency_injector = phalcon_read_property(getThis(), SL("_dependencyInjector"), PH_NOISY); if (Z_TYPE_P(dependency_injector) != IS_OBJECT) { PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_jsonrpc_exception_ce, "A dependency injection object is required to access internal services"); return; } events_manager = phalcon_read_property(getThis(), SL("_eventsManager"), PH_NOISY); if (Z_TYPE_P(events_manager) != IS_OBJECT) { events_manager = NULL; } else { PHALCON_VERIFY_INTERFACE_EX(events_manager, phalcon_events_managerinterface_ce, phalcon_mvc_jsonrpc_exception_ce, 1); } /* Call boot event, this allows the developer to perform initialization actions */ if (FAILURE == phalcon_mvc_jsonrpc_fire_event(events_manager, "jsonrpc:boot", getThis(), NULL)) { RETURN_MM_FALSE; } /* Deserializer Json */ PHALCON_INIT_NVAR(service); ZVAL_STR(service, IS(request)); PHALCON_CALL_METHOD(&request, dependency_injector, "getshared", service); PHALCON_VERIFY_INTERFACE(request, phalcon_http_requestinterface_ce); PHALCON_CALL_METHOD(&json, request, "getrawbody"); PHALCON_CALL_FUNCTION(&data, "json_decode", json, &PHALCON_GLOBAL(z_true)); PHALCON_INIT_NVAR(service); ZVAL_STR(service, IS(response)); PHALCON_CALL_METHOD(&response, dependency_injector, "getshared", service); PHALCON_VERIFY_INTERFACE(response, phalcon_http_responseinterface_ce); PHALCON_INIT_VAR(jsonrpc_message); array_init(jsonrpc_message); PHALCON_INIT_VAR(jsonrpc_error); array_init(jsonrpc_error); if (PHALCON_IS_EMPTY(data)) { phalcon_array_update_str_long(jsonrpc_error, SL("code"), __LINE__, 0); phalcon_array_update_str_str(jsonrpc_error, SL("message"), SL("Parse error"), PH_COPY); } else if (Z_TYPE_P(data) != IS_ARRAY) { phalcon_array_update_str_long(jsonrpc_error, SL("code"), __LINE__, 0); phalcon_array_update_str_str(jsonrpc_error, SL("message"), SL("Parse error"), PH_COPY); } else if (!phalcon_array_isset_str(data, SL("jsonrpc"))) { phalcon_array_update_str_long(jsonrpc_error, SL("code"), __LINE__, 0); phalcon_array_update_str_str(jsonrpc_error, SL("message"), SL("Invalid Request"), PH_COPY); } else if (!phalcon_array_isset_str(data, SL("method"))) { phalcon_array_update_str_long(jsonrpc_error, SL("code"), __LINE__, 0); phalcon_array_update_str_str(jsonrpc_error, SL("message"), SL("Invalid Request"), PH_COPY); } else { PHALCON_OBS_VAR(jsonrpc_method); phalcon_array_fetch_str(&jsonrpc_method, data, SL("method"), PH_NOISY); if (phalcon_array_isset_str(data, SL("params"))) { PHALCON_OBS_VAR(jsonrpc_params); phalcon_array_fetch_str(&jsonrpc_params, data, SL("params"), PH_NOISY); } else { PHALCON_INIT_VAR(jsonrpc_params); array_init(jsonrpc_params); } PHALCON_INIT_NVAR(service); ZVAL_STR(service, IS(url)); PHALCON_CALL_METHOD(&url, dependency_injector, "getshared", service); PHALCON_VERIFY_INTERFACE(url, phalcon_mvc_urlinterface_ce); PHALCON_CALL_METHOD(&uri, url, "get", jsonrpc_method); PHALCON_INIT_NVAR(service); ZVAL_STR(service, IS(router)); PHALCON_CALL_METHOD(&router, dependency_injector, "getshared", service); PHALCON_VERIFY_INTERFACE(router, phalcon_mvc_routerinterface_ce); /* Handle the URI pattern (if any) */ PHALCON_CALL_METHOD(NULL, router, "handle", uri); /* Load module config */ PHALCON_CALL_METHOD(&module_name, router, "getmodulename"); /* Load module config */ PHALCON_CALL_METHOD(&module_name, router, "getmodulename"); /* If the router doesn't return a valid module we use the default module */ if (!zend_is_true(module_name)) { module_name = phalcon_read_property(getThis(), SL("_defaultModule"), PH_NOISY); } /** * Process the module definition */ if (zend_is_true(module_name)) { if (FAILURE == phalcon_mvc_jsonrpc_fire_event(events_manager, "jsonrpc:beforeStartModule", getThis(), module_name)) { RETURN_MM_FALSE; } /** * Check if the module passed by the router is registered in the modules container */ modules = phalcon_read_property(getThis(), SL("_modules"), PH_NOISY); if (!phalcon_array_isset_fetch(&module, modules, module_name)) { convert_to_string(module_name); zend_throw_exception_ex(phalcon_mvc_jsonrpc_exception_ce, 0, "Module %s is not registered in the jsonrpc container", Z_STRVAL_P(module_name)); RETURN_MM(); } /** * A module definition must be an array or an object */ if (Z_TYPE_P(module) != IS_ARRAY && Z_TYPE_P(module) != IS_OBJECT) { PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_jsonrpc_exception_ce, "Invalid module definition"); return; } /* An array module definition contains a path to a module definition class */ if (Z_TYPE_P(module) == IS_ARRAY) { /* Class name used to load the module definition */ if (phalcon_array_isset_str(module, SL("className"))) { PHALCON_OBS_VAR(class_name); phalcon_array_fetch_str(&class_name, module, SL("className"), PH_NOISY); } else { PHALCON_INIT_NVAR(class_name); ZVAL_STRING(class_name, "Module"); } /* If the developer has specified a path, try to include the file */ if (phalcon_array_isset_str(module, SL("path"))) { PHALCON_OBS_VAR(path); phalcon_array_fetch_str(&path, module, SL("path"), PH_NOISY); convert_to_string_ex(path); if (Z_TYPE_P(class_name) != IS_STRING || phalcon_class_exists(class_name, 0) == NULL) { if (phalcon_file_exists(path) == SUCCESS) { RETURN_MM_ON_FAILURE(phalcon_require(Z_STRVAL_P(path))); } else { zend_throw_exception_ex(phalcon_mvc_jsonrpc_exception_ce, 0, "Module definition path '%s' does not exist", Z_STRVAL_P(path)); RETURN_MM(); } } } PHALCON_CALL_METHOD(&module_object, dependency_injector, "get", class_name); /** * 'registerAutoloaders' and 'registerServices' are automatically called */ PHALCON_CALL_METHOD(NULL, module_object, "registerautoloaders", dependency_injector); PHALCON_CALL_METHOD(NULL, module_object, "registerservices", dependency_injector); } else if (Z_TYPE_P(module) == IS_OBJECT && instanceof_function(Z_OBJCE_P(module), zend_ce_closure)) { /* A module definition object, can be a Closure instance */ PHALCON_INIT_VAR(module_params); array_init_size(module_params, 1); phalcon_array_append(module_params, dependency_injector, PH_COPY); PHALCON_CALL_USER_FUNC_ARRAY(&status, module, module_params); } else { PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_jsonrpc_exception_ce, "Invalid module definition"); return; } /* Calling afterStartModule event */ if (events_manager) { if (!module_object) { module_object = &PHALCON_GLOBAL(z_null); } phalcon_update_property_this(getThis(), SL("_moduleObject"), module_object); if (FAILURE == phalcon_mvc_jsonrpc_fire_event(events_manager, "jsonrpc:afterStartModule", getThis(), module_name)) { RETURN_MM_FALSE; } } } /* We get the parameters from the router and assign them to the dispatcher */ PHALCON_CALL_METHOD(&module_name, router, "getmodulename"); PHALCON_CALL_METHOD(&namespace_name, router, "getnamespacename"); PHALCON_CALL_METHOD(&controller_name, router, "getcontrollername"); PHALCON_CALL_METHOD(&action_name, router, "getactionname"); PHALCON_CALL_METHOD(¶ms, router, "getparams"); PHALCON_CALL_METHOD(&exact, router, "isexactcontrollername"); PHALCON_INIT_NVAR(service); ZVAL_STR(service, IS(dispatcher)); PHALCON_CALL_METHOD(&dispatcher, dependency_injector, "getshared", service); PHALCON_VERIFY_INTERFACE(dispatcher, phalcon_dispatcherinterface_ce); /* Assign the values passed from the router */ PHALCON_CALL_METHOD(NULL, dispatcher, "setmodulename", module_name); PHALCON_CALL_METHOD(NULL, dispatcher, "setnamespacename", namespace_name); PHALCON_CALL_METHOD(NULL, dispatcher, "setcontrollername", controller_name, exact); PHALCON_CALL_METHOD(NULL, dispatcher, "setactionname", action_name); PHALCON_CALL_METHOD(NULL, dispatcher, "setparams", jsonrpc_params); /* Calling beforeHandleRequest */ RETURN_MM_ON_FAILURE(phalcon_mvc_jsonrpc_fire_event(events_manager, "jsonrpc:beforeHandleRequest", getThis(), dispatcher)); /* The dispatcher must return an object */ PHALCON_CALL_METHOD(&controller, dispatcher, "dispatch"); PHALCON_INIT_VAR(returned_response); /* Get the latest value returned by an action */ PHALCON_CALL_METHOD(&jsonrpc_result, dispatcher, "getreturnedvalue"); } /* Calling afterHandleRequest */ if (FAILURE == phalcon_mvc_jsonrpc_fire_event(events_manager, "jsonrpc:afterHandleRequest", getThis(), controller) && EG(exception)) { RETURN_MM(); } phalcon_array_update_str_str(jsonrpc_message, SL("jsonrpc"), SL("2.0"), PH_COPY); if (PHALCON_IS_NOT_EMPTY(jsonrpc_error)) { phalcon_array_update_str(jsonrpc_message, SL("error"), jsonrpc_error, PH_COPY); } if (jsonrpc_result != NULL) { phalcon_array_update_str(jsonrpc_message, SL("result"), jsonrpc_result, PH_COPY); } if (phalcon_array_isset_str_fetch(&jsonrpc_id, data, SL("id"))) { phalcon_array_update_str(jsonrpc_message, SL("id"), jsonrpc_id, PH_COPY); } else { phalcon_array_update_str(jsonrpc_message, SL("id"), &PHALCON_GLOBAL(z_null), PH_COPY); } PHALCON_CALL_METHOD(NULL, response, "setjsoncontent", jsonrpc_message); /* Calling beforeSendResponse */ if (FAILURE == phalcon_mvc_jsonrpc_fire_event(events_manager, "jsonrpc:beforeSendResponse", getThis(), response) && EG(exception)) { RETURN_MM(); } /* Headers are automatically sent */ PHALCON_CALL_METHOD(NULL, response, "sendheaders"); /* Cookies are automatically sent */ PHALCON_CALL_METHOD(NULL, response, "sendcookies"); /* Return the response */ RETURN_CCTOR(response); }
/* {{{ proto string connect() Connection apple apple_push service */ PHP_METHOD(apple_push, init) { zend_class_entry * _this_ce; zval * _this_zval = NULL; const char * x = NULL; int x_len = 0; const char * y = NULL; int y_len = 0; BIO *bio; SSL_CTX *ssl_ctx; SSL_library_init(); char *certificate_dir,*passphraseStr,*gatewayurl; zval *certificate = zend_read_static_property(apple_push_ce_ptr, ZEND_STRL("certificate"), sizeof ("certificate")); spprintf(&certificate_dir, 0, "%s", Z_STRVAL_P(certificate)); zval *passphrase = zend_read_static_property(apple_push_ce_ptr, ZEND_STRL("passphrase"), sizeof ("passphrase")); spprintf(&passphraseStr, 0, "%s", Z_STRVAL_P(passphrase)); zval *gateway = zend_read_static_property(apple_push_ce_ptr, ZEND_STRL("gateway"), sizeof ("gateway")); spprintf(&gatewayurl, 0, "%s", Z_STRVAL_P(gateway)); ssl_ctx = SSL_CTX_new(SSLv23_method()); if (ssl_ctx == NULL) { zend_throw_exception_ex(apple_push_ce_ptr, 0 TSRMLS_CC, "SSL_INIT_FAIL", 2 TSRMLS_CC); return ; } if (SSL_CTX_use_certificate_chain_file(ssl_ctx, certificate_dir) != 1) { zend_throw_exception_ex(apple_push_ce_ptr, 0 TSRMLS_CC, "CERTIFICATE_NOT_FOUNT", 2 TSRMLS_CC); return ; } SSL_CTX_set_default_passwd_cb_userdata(ssl_ctx,passphraseStr); if (SSL_CTX_use_PrivateKey_file(ssl_ctx, certificate_dir, SSL_FILETYPE_PEM) != 1) { zend_throw_exception_ex(apple_push_ce_ptr, 0 TSRMLS_CC, "CERTIFICATE_PASSWORD_FAIL", 2 TSRMLS_CC); return ; } bio = BIO_new_connect(gatewayurl); if(!bio) { zend_throw_exception_ex(apple_push_ce_ptr, 0 TSRMLS_CC, "SSL_CONNECT_FAIL", 2 TSRMLS_CC); return ; } if (BIO_do_connect(bio) <= 0) { zend_throw_exception_ex(apple_push_ce_ptr, 0 TSRMLS_CC, "SSL_CONNECT_FAIL", 2 TSRMLS_CC); return ; } if (!(ssl = SSL_new(ssl_ctx))) { zend_throw_exception_ex(apple_push_ce_ptr, 0 TSRMLS_CC, "SSL_CONNECT_FAIL", 2 TSRMLS_CC); return ; } SSL_set_bio(ssl, bio, bio); if (SSL_connect(ssl) <= 0) { zend_throw_exception_ex(apple_push_ce_ptr, 0 TSRMLS_CC, "SSL_CONNECT_FAIL", 2 TSRMLS_CC); return ; } RETURN_TRUE; }
ZEND_API int zend_class_unserialize_deny(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data) /* {{{ */ { zend_throw_exception_ex(NULL, 0, "Unserialization of '%s' is not allowed", ZSTR_VAL(ce->name)); return FAILURE; }
ZEND_API int zend_class_serialize_deny(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data) /* {{{ */ { zend_class_entry *ce = Z_OBJCE_P(object); zend_throw_exception_ex(NULL, 0, "Serialization of '%s' is not allowed", ZSTR_VAL(ce->name)); return FAILURE; }
/** * Handle the command-line arguments. * * * <code> * $arguments = array( * 'task' => 'taskname', * 'action' => 'action', * 'params' => array('parameter1', 'parameter2') * ); * $console->handle($arguments); * </code> * * @param array $arguments * @return mixed */ PHP_METHOD(Phalcon_CLI_Console, handle){ zval *_arguments = NULL, arguments = {}, dependency_injector = {}, events_manager = {}, event_name = {}, service = {}, router = {}, module_name = {}; zval status = {}, *modules, exception_msg = {}, module = {}, path = {}, class_name = {}, module_object = {}; zval namespace_name = {}, task_name = {}, action_name = {}, params = {}, dispatcher = {}; phalcon_fetch_params(0, 0, 1, &_arguments); if (!_arguments) { array_init(&arguments); } else { PHALCON_CPY_WRT(&arguments, _arguments); } phalcon_return_property(&events_manager, getThis(), SL("_eventsManager")); ZVAL_STRING(&service, ISV(router)); PHALCON_CALL_METHODW(&dependency_injector, getThis(), "getdi"); if (Z_TYPE(dependency_injector) != IS_OBJECT) { PHALCON_THROW_EXCEPTION_FORMATW(phalcon_cli_console_exception_ce, "A dependency injection container is required to access the '%s' service", Z_STRVAL(service)); return; } PHALCON_CALL_METHODW(&router, &dependency_injector, "getshared", &service); PHALCON_VERIFY_CLASSW(&router, phalcon_cli_router_ce); PHALCON_CALL_METHODW(NULL, &router, "handle", &arguments); PHALCON_CALL_METHODW(&module_name, &router, "getmodulename"); if (zend_is_true(&module_name)) { if (Z_TYPE(events_manager) == IS_OBJECT) { ZVAL_STRING(&event_name, "console:beforeStartModule"); PHALCON_CALL_METHODW(&status, &events_manager, "fire", &event_name, getThis(), &module_name); if (PHALCON_IS_FALSE(&status)) { RETURN_FALSE; } } modules = phalcon_read_property(getThis(), SL("_modules"), PH_NOISY); if (!phalcon_array_isset_fetch(&module, modules, &module_name)) { PHALCON_CONCAT_SVS(&exception_msg, "Module '", &module_name, "' isn't registered in the console container"); PHALCON_THROW_EXCEPTION_ZVALW(phalcon_cli_console_exception_ce, &exception_msg); return; } if (Z_TYPE_P(&module) != IS_ARRAY) { PHALCON_THROW_EXCEPTION_STRW(phalcon_cli_console_exception_ce, "Invalid module definition path"); return; } if (phalcon_array_isset_fetch_str(&path, &module, SL("path"))) { convert_to_string_ex(&path); if (phalcon_file_exists(&path) == SUCCESS) { RETURN_ON_FAILURE(phalcon_require(Z_STRVAL(path))); } else { zend_throw_exception_ex(phalcon_cli_console_exception_ce, 0, "Modules definition path '%s' does not exist", Z_STRVAL(path)); return; } } if (!phalcon_array_isset_fetch_str(&class_name, &module, SL("className"))) { ZVAL_STRING(&class_name, "Module"); } PHALCON_CALL_METHODW(&module_object, &dependency_injector, "getshared", &class_name); PHALCON_CALL_METHODW(NULL, &module_object, "registerautoloaders"); PHALCON_CALL_METHODW(NULL, &module_object, "registerservices", &dependency_injector); if (Z_TYPE(events_manager) == IS_OBJECT) { phalcon_update_property_this(getThis(), SL("_moduleObject"), &module_object); ZVAL_STRING(&event_name, "console:afterStartModule"); PHALCON_CALL_METHODW(&status, &events_manager, "fire", &event_name, getThis(), &module_name); if (PHALCON_IS_FALSE(&status)) { RETURN_FALSE; } } } PHALCON_CALL_METHODW(&namespace_name, &router, "getnamespacename"); PHALCON_CALL_METHODW(&task_name, &router, "gettaskname"); PHALCON_CALL_METHODW(&action_name, &router, "getactionname"); PHALCON_CALL_METHODW(¶ms, &router, "getparams"); ZVAL_STRING(&service, ISV(dispatcher)); PHALCON_CALL_METHODW(&dispatcher, &dependency_injector, "getshared", &service); PHALCON_VERIFY_INTERFACEW(&dispatcher, phalcon_dispatcherinterface_ce); PHALCON_CALL_METHODW(NULL, &dispatcher, "setnamespacename", &namespace_name); PHALCON_CALL_METHODW(NULL, &dispatcher, "settaskname", &task_name); PHALCON_CALL_METHODW(NULL, &dispatcher, "setactionname", &action_name); PHALCON_CALL_METHODW(NULL, &dispatcher, "setparams", ¶ms); if (Z_TYPE(events_manager) == IS_OBJECT) { ZVAL_STRING(&event_name, "console:beforeHandleTask"); PHALCON_CALL_METHODW(&status, &events_manager, "fire", &event_name, getThis(), &dispatcher); if (PHALCON_IS_FALSE(&status)) { RETURN_FALSE; } } PHALCON_CALL_METHODW(&status, &dispatcher, "dispatch"); if (Z_TYPE(events_manager) == IS_OBJECT) { ZVAL_STRING(&event_name, "console:afterHandleTask"); PHALCON_CALL_METHODW(NULL, &events_manager, "fire", &event_name, getThis(), &status); } RETURN_CTORW(&status); }
void __function_invoke(zend_fcall_info_cache fcc, zval *obj, zval *return_value, zend_bool dtor TSRMLS_DC, const char *params_format, ...) { #if PHP_MAJOR_VERSION < 7 zval *retval_ptr = NULL; zval ***params = NULL; #else zval retval; zval *params = NULL; #endif int i; int result; int argc; zend_fcall_info fci; argc = strlen(params_format); if (argc) { #if PHP_MAJOR_VERSION < 7 params = safe_emalloc(sizeof(zval **), argc, 0); va_list ap; va_start(ap, params_format); for (i = 0; i < argc; ++i) { params[i] = emalloc(sizeof(zval *)); switch (params_format[i]) { case 's': { char *str = va_arg(ap, char *); long len = va_arg(ap, long); MAKE_STD_ZVAL(*params[i]); ZVAL_STRINGL(*params[i], str, len, 0); break; } case 'l': { long l = va_arg(ap, long); MAKE_STD_ZVAL(*params[i]); ZVAL_LONG(*params[i], l); break; } case 'd': { double d = va_arg(ap, double); MAKE_STD_ZVAL(*params[i]); ZVAL_DOUBLE(*params[i], d); break; } case 'n': { MAKE_STD_ZVAL(*params[i]); ZVAL_NULL(*params[i]); break; } case 'b': { zend_bool b = va_arg(ap, int); MAKE_STD_ZVAL(*params[i]); ZVAL_BOOL(*params[i], b); break; } case 'z': { zval *v = va_arg(ap, zval *); if (v) { Z_ADDREF_P(v); *params[i] = v; } else { MAKE_STD_ZVAL(*params[i]); ZVAL_NULL(*params[i]); } break; } default: zend_throw_exception_ex( NULL, 0 TSRMLS_CC, "Unsupported type:%c in function_invoke", params_format[i]); return; } } va_end(ap); #else params = safe_emalloc(sizeof(zval), argc, 0); va_list ap; va_start(ap, params_format); for (i = 0; i < argc; ++i) { switch (params_format[i]) { case 's': { char *str = va_arg(ap, char *); long len = va_arg(ap, long); ZVAL_STRINGL(¶ms[i], str, len); break; } case 'l': { long l = va_arg(ap, long); ZVAL_LONG(¶ms[i], l); break; } case 'd': { double d = va_arg(ap, double); ZVAL_DOUBLE(¶ms[i], d); break; } case 'n': { ZVAL_NULL(¶ms[i]); break; } case 'b': { zend_bool b = va_arg(ap, int); ZVAL_BOOL(¶ms[i], b); break; } case 'z': { zval *v = va_arg(ap, zval *); if (v) { ZVAL_COPY(¶ms[i], v); } else { ZVAL_NULL(¶ms[i]); } break; } default: zend_throw_exception_ex( NULL, 0, "Unsupported type:%c in function_invoke", params_format[i]); return; } } va_end(ap); #endif } fci.size = sizeof(fci); fci.function_table = NULL; #if PHP_MAJOR_VERSION < 7 fci.function_name = NULL; fci.retval_ptr_ptr = &retval_ptr; #else ZVAL_UNDEF(&fci.function_name); fci.retval = &retval; #endif fci.symbol_table = NULL; fci.param_count = argc; fci.params = params; fci.no_separation = 1; if (obj != NULL && Z_TYPE_P(obj) == IS_OBJECT) { #if PHP_API_VERSION < 20090626 fci.object_pp = &obj; fcc.object_pp = &obj; #elif PHP_MAJOR_VERSION < 7 fci.object_ptr = obj; fcc.object_ptr = obj; #else fci.object = Z_OBJ_P(obj); fcc.object = Z_OBJ_P(obj); #endif fcc.calling_scope = Z_OBJCE_P(obj); } else { #if PHP_API_VERSION < 20090626 fci.object_pp = fcc.object_pp; #elif PHP_MAJOR_VERSION < 7 fci.object_ptr = fcc.object_ptr; #else fci.object = fcc.object; #endif } #if PHP_MAJOR_VERSION < 7 result = zend_call_function(&fci, &fcc TSRMLS_CC); for (i = 0; i < argc; i++) { if (params_format[i] == 's') { ZVAL_EMPTY_STRING(*params[i]); } zval_ptr_dtor(params[i]); efree(params[i]); } if (argc) { efree(params); } if (result == FAILURE) { zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Invocation of function %s() failed", fcc.function_handler->common.function_name); return; } if (retval_ptr) { if (return_value) { if (return_value != retval_ptr) { if (dtor) { zval_dtor(return_value); } COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr); } else { if (dtor) { zval_ptr_dtor(&retval_ptr); } } } else { zval_ptr_dtor(&retval_ptr); } } #else result = zend_call_function(&fci, &fcc); for (i = 0; i < argc; i++) { zval_ptr_dtor(¶ms[i]); } if (argc) { efree(params); } if (result == FAILURE) { zend_throw_exception_ex(NULL, 0, "Invocation of function %s() failed", fcc.function_handler->common.function_name->val); return; } if (Z_TYPE(retval) != IS_UNDEF) { if (return_value) { if (dtor) { zval_ptr_dtor(return_value); } ZVAL_COPY_VALUE(return_value, &retval); } else { zval_ptr_dtor(&retval); } } #endif }
/** * Reads annotations from the class dockblocks, its methods and/or properties * * @param string $className * @return array */ PHP_METHOD(Phalcon_Annotations_Reader, parse){ zval *class_name, *annotations; zval *class_annotations, *annotations_properties, *annotations_methods; zend_class_entry *class_ce; const char *file; zend_uint line; phalcon_fetch_params(0, 1, 0, &class_name); if (unlikely(Z_TYPE_P(class_name) != IS_STRING)) { PHALCON_THROW_EXCEPTION_STRW(phalcon_annotations_exception_ce, "The class name must be a string"); return; } class_ce = zend_fetch_class(Z_STRVAL_P(class_name), Z_STRLEN_P(class_name), ZEND_FETCH_CLASS_AUTO | ZEND_FETCH_CLASS_SILENT TSRMLS_CC); if (!class_ce) { zend_throw_exception_ex(phalcon_annotations_exception_ce, 0 TSRMLS_CC, "Class %s does not exist", Z_STRVAL_P(class_name)); return; } if (class_ce->type != ZEND_USER_CLASS) { array_init(return_value); return; } PHALCON_MM_GROW(); PHALCON_INIT_VAR(annotations); array_init(annotations); file = phalcon_get_class_filename(class_ce); if (!file) { file = "(unknown)"; } /* Class info */ { const char *cmt; zend_uint cmt_len; if (phalcon_get_class_doc_comment(class_ce, &cmt, &cmt_len)) { line = phalcon_get_class_startline(class_ce); PHALCON_INIT_VAR(class_annotations); RETURN_MM_ON_FAILURE(phannot_parse_annotations(class_annotations, cmt, cmt_len, file, line TSRMLS_CC)); if (Z_TYPE_P(class_annotations) == IS_ARRAY) { phalcon_array_update_string(&annotations, SL("class"), class_annotations, PH_COPY); } } } /* Get class properties */ { HashTable *props = &class_ce->properties_info; if (zend_hash_num_elements(props) > 0) { HashPosition hp; zend_property_info *property; PHALCON_INIT_VAR(annotations_properties); array_init_size(annotations_properties, zend_hash_num_elements(props)); for ( zend_hash_internal_pointer_reset_ex(props, &hp); zend_hash_get_current_data_ex(props, (void**)&property, &hp) != FAILURE; zend_hash_move_forward_ex(props, &hp) ) { const char *cmt; zend_uint cmt_len; if (phalcon_get_property_doc_comment(property, &cmt, &cmt_len)) { zval *property_annotations; MAKE_STD_ZVAL(property_annotations); if (FAILURE == phannot_parse_annotations(property_annotations, cmt, cmt_len, file, 0 TSRMLS_CC)) { zval_ptr_dtor(&property_annotations); RETURN_MM(); } if (Z_TYPE_P(property_annotations) == IS_ARRAY) { #if PHP_VERSION_ID >= 50400 { const char *prop_name, *class_name; if (zend_unmangle_property_name(property->name, property->name_length - 1, &class_name, &prop_name) == SUCCESS) { add_assoc_zval_ex(annotations_properties, prop_name, strlen(prop_name) + 1, property_annotations); } } #else { char *prop_name, *class_name; if (zend_unmangle_property_name(property->name, property->name_length - 1, &class_name, &prop_name) == SUCCESS) { add_assoc_zval_ex(annotations_properties, prop_name, strlen(prop_name) + 1, property_annotations); } } #endif } else { zval_ptr_dtor(&property_annotations); } } } if (zend_hash_num_elements(Z_ARRVAL_P(annotations_properties))) { phalcon_array_update_string(&annotations, SL("properties"), annotations_properties, PH_COPY); } } } /* Get class methods */ { HashTable *methods = &class_ce->function_table; if (zend_hash_num_elements(methods) > 0) { HashPosition hp; zend_function *method; PHALCON_INIT_VAR(annotations_methods); array_init_size(annotations_methods, zend_hash_num_elements(methods)); for ( zend_hash_internal_pointer_reset_ex(methods, &hp); zend_hash_get_current_data_ex(methods, (void**)&method, &hp) != FAILURE; zend_hash_move_forward_ex(methods, &hp) ) { const char *cmt; zend_uint cmt_len; if (phalcon_get_function_doc_comment(method, &cmt, &cmt_len)) { zval *method_annotations; line = phalcon_get_function_startline(method); MAKE_STD_ZVAL(method_annotations); if (FAILURE == phannot_parse_annotations(method_annotations, cmt, cmt_len, file, line TSRMLS_CC)) { zval_ptr_dtor(&method_annotations); RETURN_MM(); } if (Z_TYPE_P(method_annotations) == IS_ARRAY) { add_assoc_zval_ex(annotations_methods, method->common.function_name, strlen(method->common.function_name) + 1, method_annotations); } else { zval_ptr_dtor(&method_annotations); } } } if (zend_hash_num_elements(Z_ARRVAL_P(annotations_methods))) { phalcon_array_update_string(&annotations, SL("methods"), annotations_methods, PH_COPY); } } } RETURN_CTOR(annotations); }