PHP_METHOD(Phalcon_Validation_Validator_Date, checkDate) { zend_bool _3; zend_class_entry *_0, *_1; int ZEPHIR_LAST_CALL_STATUS; zval *value, *format, *date = NULL, *errors = NULL, *_2, *_4; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &value, &format); if (!(Z_TYPE_P(value) == IS_STRING)) { RETURN_MM_BOOL(0); } _0 = zend_fetch_class(SL("DateTime"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); ZEPHIR_CALL_CE_STATIC(&date, _0, "createfromformat", NULL, 0, format, value); zephir_check_call_status(); _1 = zend_fetch_class(SL("DateTime"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); ZEPHIR_CALL_CE_STATIC(&errors, _1, "getlasterrors", NULL, 0); zephir_check_call_status(); zephir_array_fetch_string(&_2, errors, SL("warning_count"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/date.zep", 121 TSRMLS_CC); _3 = ZEPHIR_GT_LONG(_2, 0); if (!(_3)) { zephir_array_fetch_string(&_4, errors, SL("error_count"), PH_NOISY | PH_READONLY, "phalcon/validation/validator/date.zep", 121 TSRMLS_CC); _3 = ZEPHIR_GT_LONG(_4, 0); } if (_3) { RETURN_MM_BOOL(0); } RETURN_MM_BOOL(1); }
PHP_METHOD(ADOdb_Cache, create) { zend_class_entry *_0, *_1, *_2; zval *type = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &type); if (!type) { ZEPHIR_CPY_WRT(type, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(type); } if ((Z_TYPE_P(type) == IS_NULL)) { ZEPHIR_INIT_NVAR(type); ZVAL_LONG(type, 0); } do { if (ZEPHIR_IS_LONG(type, 0)) { object_init_ex(return_value, adodb_driver_cache_memory_ce); zephir_call_method_noret(return_value, "__construct"); RETURN_MM(); } if (ZEPHIR_IS_LONG(type, 2)) { _0 = zend_fetch_class(SL("ADOdb\\Driver\\Cache\\APC"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); object_init_ex(return_value, _0); if (zephir_has_constructor(return_value TSRMLS_CC)) { zephir_call_method_noret(return_value, "__construct"); } RETURN_MM(); } if (ZEPHIR_IS_LONG(type, 3)) { _1 = zend_fetch_class(SL("ADOdb\\Driver\\Cache\\Libredis"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); object_init_ex(return_value, _1); if (zephir_has_constructor(return_value TSRMLS_CC)) { zephir_call_method_noret(return_value, "__construct"); } RETURN_MM(); } _2 = zend_fetch_class(SL("ADOdb\\Driver\\Cache\\File"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); object_init_ex(return_value, _2); if (zephir_has_constructor(return_value TSRMLS_CC)) { zephir_call_method_noret(return_value, "__construct"); } RETURN_MM(); } while(0); ZEPHIR_MM_RESTORE(); }
PHP_METHOD(Configman_BaseServiceConfig, getService) { int ZEPHIR_LAST_CALL_STATUS; zend_class_entry *_1; zval *service_param = NULL, *service_class_name, *upcase_service, *_0 = NULL; zval *service = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &service_param); zephir_get_strval(service, service_param); ZEPHIR_INIT_VAR(upcase_service); zephir_ucfirst(upcase_service, service); ZEPHIR_INIT_VAR(service_class_name); ZEPHIR_CONCAT_SVSVS(service_class_name, "\\Configman\\Service\\", upcase_service, "\\", upcase_service, "Config"); zephir_fetch_safe_class(_0, service_class_name); _1 = zend_fetch_class(Z_STRVAL_P(_0), Z_STRLEN_P(_0), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); object_init_ex(return_value, _1); if (zephir_has_constructor(return_value TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 0, service); zephir_check_call_status(); } RETURN_MM(); }
PHP_METHOD(Test_Trie, getTrieNodeByKey) { zend_class_entry *_5; zephir_nts_static zephir_fcall_cache_entry *_2 = NULL; int i, ZEPHIR_LAST_CALL_STATUS; zend_bool create; zval *key_param = NULL, *create_param = NULL, *trieNode = NULL, *keyLen, *character = NULL, _0 = zval_used_for_init, _1 = zval_used_for_init, *_3 = NULL, *_4 = NULL, *_6 = NULL, *_7; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &key_param, &create_param); zephir_get_strval(key, key_param); if (!create_param) { create = 0; } else { create = zephir_get_boolval(create_param); } ZEPHIR_OBS_VAR(trieNode); zephir_read_property_this(&trieNode, this_ptr, SL("trie"), PH_NOISY_CC); ZEPHIR_INIT_VAR(keyLen); ZVAL_LONG(keyLen, zephir_fast_strlen_ev(key)); i = 0; while (1) { if (!(ZEPHIR_GT_LONG(keyLen, i))) { break; } ZEPHIR_SINIT_NVAR(_0); ZVAL_LONG(&_0, i); ZEPHIR_SINIT_NVAR(_1); ZVAL_LONG(&_1, 1); ZEPHIR_CALL_FUNCTION(&character, "substr", &_2, key, &_0, &_1); zephir_check_call_status(); ZEPHIR_OBS_NVAR(_3); zephir_read_property(&_3, trieNode, SL("children"), PH_NOISY_CC); if (!(zephir_array_isset(_3, character))) { if (create) { ZEPHIR_INIT_LNVAR(_4); _5 = zend_fetch_class(SL("tries\\trienode"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); object_init_ex(_4, _5); if (zephir_has_constructor(_4 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, _4, "__construct", NULL); zephir_check_call_status(); } zephir_update_property_array(trieNode, SL("children"), character, _4 TSRMLS_CC); } else { RETURN_MM_BOOL(0); } } ZEPHIR_OBS_NVAR(_6); zephir_read_property(&_6, trieNode, SL("children"), PH_NOISY_CC); zephir_array_fetch(&_7, _6, character, PH_NOISY | PH_READONLY TSRMLS_CC); ZEPHIR_CPY_WRT(trieNode, _7); i += 1; } RETURN_CCTOR(trieNode); }
static PHP_METHOD(midgard_object_class, get_object_by_guid) { RETVAL_FALSE; MidgardConnection *mgd = mgd_handle(TSRMLS_C); CHECK_MGD(mgd); char *guid; int guid_length; const gchar *type_name; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &guid, &guid_length) == FAILURE) return; MidgardObject *object = midgard_schema_object_factory_get_object_by_guid(mgd, guid); if (!object) { php_midgard_error_exception_throw(mgd TSRMLS_CC); return; } type_name = G_OBJECT_TYPE_NAME(G_OBJECT(object)); zend_class_entry *ce = zend_fetch_class((gchar *)type_name, strlen(type_name), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); if (ce == NULL) { php_error(E_WARNING, "Can not find %s class", type_name); return; } php_midgard_gobject_new_with_gobject(return_value, ce, G_OBJECT(object), TRUE TSRMLS_CC); }
/** * Constructor to create a new instance of a builtin class * * @param name Name of the class to instantiate * @param base Implementation of the class */ Object::Object(const char *name, Base *base) { // does the object already have a handle? if (base->implementation()) { // the object is already instantiated, we can assign it the this object operator=(Value(base)); } else { // we need the tsrm_ls variable TSRMLS_FETCH(); // this is a brand new object that should be allocated, the C++ instance // is already there (created by the extension) but it is not yet stored // in PHP, find out the classname first auto *entry = zend_fetch_class(name, strlen(name), 0 TSRMLS_CC); if (!entry) throw Php::Exception(std::string("Unknown class name ") + name); // construct an implementation (this will also set the implementation // member in the base object) new ObjectImpl(entry, base TSRMLS_CC); // now we can store it operator=(Value(base)); } }
/** * Sets transaction manager related to the transaction * * @param Phalcon\Mvc\Model\Transaction\Manager $manager */ PHP_METHOD(Phalcon_Mvc_Model_Transaction, setTransactionManager){ zval *manager = NULL; zval *i0 = NULL; zval *r0 = NULL; zend_class_entry *ce0; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &manager) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } if (Z_TYPE_P(manager) != IS_OBJECT) { ce0 = zend_fetch_class(SL("Phalcon_Transaction_Exception"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); PHALCON_ALLOC_ZVAL_MM(i0); object_init_ex(i0, ce0); PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_CONCAT_VS(r0, manager, " must be an Object"); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(i0, "__construct", r0, PH_CHECK); phalcon_throw_exception(i0 TSRMLS_CC); return; } phalcon_update_property_zval(this_ptr, SL("_manager"), manager TSRMLS_CC); PHALCON_MM_RESTORE(); }
static PHP_METHOD(midgard_workspace_storage, list_children) { if (zend_parse_parameters_none() == FAILURE) return; guint n_objects; MidgardWorkspaceStorage *self = MIDGARD_WORKSPACE_STORAGE(__php_gobject_ptr(getThis())); MidgardWorkspaceStorage **children = midgard_workspace_storage_list_children(self, &n_objects); array_init(return_value); if (!children) return; const char *g_class_name = G_OBJECT_TYPE_NAME(children[0]); zend_class_entry *ce = zend_fetch_class((char *) g_class_name, strlen(g_class_name), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); int i; for (i = 0; i < n_objects; i++) { zval *zobject; MAKE_STD_ZVAL(zobject); php_midgard_gobject_new_with_gobject(zobject, ce, G_OBJECT(children[i]), TRUE TSRMLS_CC); zend_hash_next_index_insert(HASH_OF(return_value), &zobject, sizeof(zval *), NULL); } }
/** * Sets a Expires header to use HTTP cache * *<code> * $this->response->setExpires(new DateTime()); *</code> * * @param DateTime $datetime * @return Phalcon\Http\ResponseInterface */ PHP_METHOD(Phalcon_Http_Response, setExpires){ zval *datetime, *headers, *date, *utc_zone, *timezone; zval *format, *utc_format, *utc_date, *expires_header; zend_class_entry *ce0; PHALCON_MM_GROW(); phalcon_fetch_params(1, 1, 0, &datetime); if (Z_TYPE_P(datetime) != IS_OBJECT) { PHALCON_THROW_EXCEPTION_STR(phalcon_http_response_exception_ce, "datetime parameter must be an instance of DateTime"); return; } PHALCON_INIT_VAR(headers); phalcon_call_method(headers, this_ptr, "getheaders"); PHALCON_INIT_VAR(date); if (phalcon_clone(date, datetime TSRMLS_CC) == FAILURE) { return; } /** * All the expiration times are sent in UTC */ PHALCON_INIT_VAR(utc_zone); ZVAL_STRING(utc_zone, "UTC", 1); ce0 = zend_fetch_class(SL("DateTimeZone"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); PHALCON_INIT_VAR(timezone); object_init_ex(timezone, ce0); if (phalcon_has_constructor(timezone TSRMLS_CC)) { phalcon_call_method_p1_noret(timezone, "__construct", utc_zone); } /** * Change the timezone to utc */ phalcon_call_method_p1_noret(date, "settimezone", timezone); PHALCON_INIT_VAR(format); ZVAL_STRING(format, "D, d M Y H:i:s", 1); PHALCON_INIT_VAR(utc_format); phalcon_call_method_p1(utc_format, date, "format", format); PHALCON_INIT_VAR(utc_date); PHALCON_CONCAT_VS(utc_date, utc_format, " GMT"); /** * The 'Expires' header set this info */ PHALCON_INIT_VAR(expires_header); ZVAL_STRING(expires_header, "Expires", 1); phalcon_call_method_p2_noret(this_ptr, "setheader", expires_header, utc_date); RETURN_THIS(); }
zend_class_entry *zephir_fetch_class_str_ex(const char *class_name, size_t length, int fetch_type) { zend_class_entry *retval; zend_string *str = zend_string_init(class_name, length, 0); retval = zend_fetch_class(str, fetch_type); zend_string_release(str); return retval; }
/** * Creates an instance of the JWT bearer grant type. * * @param OAuth2\Storage\JWTBearerInterface storage A valid storage interface that implements storage hooks for the JWT bearer grant type. * @param string audience The audience to validate the token against. This is usually the full URI of the OAuth token requests endpoint. * @param OAuth2\Encryption\Jwt jwtUtil OPTONAL The class used to decode, encode and verify JWTs. */ PHP_METHOD(OAuth2_GrantType_JwtBearer, __construct) { int ZEPHIR_LAST_CALL_STATUS; zephir_nts_static zend_class_entry *_1 = NULL; zend_bool _0; zval *audience = NULL; zval *storage, *audience_param = NULL, *jwtUtil = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &storage, &audience_param, &jwtUtil); if (unlikely(Z_TYPE_P(audience_param) != IS_STRING && Z_TYPE_P(audience_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'audience' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(audience_param) == IS_STRING)) { zephir_get_strval(audience, audience_param); } else { ZEPHIR_INIT_VAR(audience); ZVAL_EMPTY_STRING(audience); } if (!jwtUtil) { ZEPHIR_CPY_WRT(jwtUtil, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(jwtUtil); } if (!(zephir_instance_of_ev(storage, oauth2_storage_jwtbearerinterface_ce TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_InvalidArgumentException, "Parameter 'storage' must be an instance of 'OAuth2\\Storage\\JwtBearerInterface'", "", 0); return; } _0 = Z_TYPE_P(jwtUtil) != IS_NULL; if (_0) { _0 = !zephir_instance_of_ev(jwtUtil, oauth2_encryption_encryptioninterface_ce TSRMLS_CC); } if (_0) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_InvalidArgumentException, "Parameter 'jwtUtil' must be an instance of 'OAuth2\\Encryption\\EncryptionInterface'", "", 0); return; } zephir_update_property_this(this_ptr, SL("storage"), storage TSRMLS_CC); zephir_update_property_this(this_ptr, SL("audience"), audience TSRMLS_CC); if (Z_TYPE_P(jwtUtil) == IS_NULL) { ZEPHIR_INIT_NVAR(jwtUtil); if (!_1) { _1 = zend_fetch_class(SL("OAuth2\\Encryption\\Jwt"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); } object_init_ex(jwtUtil, _1); if (zephir_has_constructor(jwtUtil TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, jwtUtil, "__construct", NULL); zephir_check_call_status(); } } zephir_update_property_this(this_ptr, SL("jwtUtil"), jwtUtil TSRMLS_CC); ZEPHIR_MM_RESTORE(); }
/** * Fetches a zend class entry from a zval value */ zend_class_entry *zephir_fetch_class(const zval *class_name) { if (Z_TYPE_P(class_name) == IS_STRING) { return zend_fetch_class(Z_STR_P(class_name), ZEND_FETCH_CLASS_DEFAULT TSRMLS_CC); } php_error_docref(NULL, E_WARNING, "class name must be a string"); return zephir_fetch_class_str_ex(SL("stdclass"), ZEND_FETCH_CLASS_DEFAULT); }
/** * Initializes the internal handler, calling functions on it * * @param string method * @param array arguments * @return mixed */ PHP_METHOD(Phalcon_Mvc_Micro_LazyLoader, __call) { zend_class_entry *_1$$3; zval *_3; int ZEPHIR_LAST_CALL_STATUS; zval *method_param = NULL, *arguments = NULL, *handler = NULL, *definition = NULL, *modelBinder = NULL, *bindCacheKey = NULL, *_0$$3 = NULL, *_2$$4 = NULL; zval *method = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &method_param, &arguments); if (UNEXPECTED(Z_TYPE_P(method_param) != IS_STRING && Z_TYPE_P(method_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'method' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (EXPECTED(Z_TYPE_P(method_param) == IS_STRING)) { zephir_get_strval(method, method_param); } else { ZEPHIR_INIT_VAR(method); ZVAL_EMPTY_STRING(method); } ZEPHIR_SEPARATE_PARAM(arguments); ZEPHIR_OBS_VAR(handler); zephir_read_property_this(&handler, this_ptr, SL("_handler"), PH_NOISY_CC); ZEPHIR_OBS_VAR(definition); zephir_read_property_this(&definition, this_ptr, SL("_definition"), PH_NOISY_CC); if (Z_TYPE_P(handler) != IS_OBJECT) { ZEPHIR_INIT_NVAR(handler); zephir_fetch_safe_class(_0$$3, definition); _1$$3 = zend_fetch_class(Z_STRVAL_P(_0$$3), Z_STRLEN_P(_0$$3), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); object_init_ex(handler, _1$$3); if (zephir_has_constructor(handler TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, handler, "__construct", NULL, 0); zephir_check_call_status(); } zephir_update_property_this(this_ptr, SL("_handler"), handler TSRMLS_CC); } ZEPHIR_OBS_VAR(modelBinder); zephir_read_property_this(&modelBinder, this_ptr, SL("_modelBinder"), PH_NOISY_CC); if (Z_TYPE_P(modelBinder) != IS_NULL) { ZEPHIR_INIT_VAR(bindCacheKey); ZEPHIR_CONCAT_SVSV(bindCacheKey, "_PHMB_", definition, "_", method); ZEPHIR_CALL_METHOD(&_2$$4, modelBinder, "bindtohandler", NULL, 0, handler, arguments, bindCacheKey, method); zephir_check_call_status(); ZEPHIR_CPY_WRT(arguments, _2$$4); } ZEPHIR_INIT_VAR(_3); zephir_create_array(_3, 2, 0 TSRMLS_CC); zephir_array_fast_append(_3, handler); zephir_array_fast_append(_3, method); ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, _3, arguments); zephir_check_call_status(); RETURN_MM(); }
/* Object constructor */ static PHP_METHOD(midgard_query_builder, __construct) { MidgardConnection *mgd = mgd_handle(TSRMLS_C); CHECK_MGD(mgd); char *classname; long classname_length; zval *zval_object = getThis(); GObject *gobject; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &classname, &classname_length) == FAILURE) { return; } zend_class_entry *ce = zend_fetch_class(classname, classname_length, ZEND_FETCH_CLASS_AUTO TSRMLS_CC); if (ce == NULL) { php_error(E_WARNING, "Didn't find %s class", classname); php_midgard_error_exception_force_throw(mgd, MGD_ERR_INVALID_OBJECT TSRMLS_CC); return; } zend_class_entry *base_ce = php_midgard_get_baseclass_ptr(ce); const gchar *g_base_class_name = php_class_name_to_g_class_name(base_ce->name); GType classtype = g_type_from_name(g_base_class_name); if (!g_type_is_a(classtype, MIDGARD_TYPE_DBOBJECT)) { php_error(E_WARNING, "Expected %s derived class", g_type_name(MIDGARD_TYPE_DBOBJECT)); php_midgard_error_exception_force_throw(mgd, MGD_ERR_INVALID_OBJECT TSRMLS_CC); return; } gobject = __php_gobject_ptr(zval_object); if (!gobject) { MidgardQueryBuilder *builder = midgard_query_builder_new(mgd, g_base_class_name); if (!builder) { php_midgard_error_exception_throw(mgd TSRMLS_CC); return; } MGD_PHP_SET_GOBJECT(zval_object, builder); } else { // we already have gobject injected } php_midgard_gobject *php_gobject = __php_objstore_object(zval_object); /* Set user defined class. We might need it when execute is invoked */ php_gobject->user_ce = ce; php_gobject->user_class_name = (char *)ce->name; }
/** * Detects and returns the first available cache driver. * * @return \Xpl\Cache\DriverInterface */ PHP_METHOD(Xpl_Cache_Cache, getDetectedDriver) { zend_class_entry *_7$$4; HashTable *_2; HashPosition _1; zval *driverClasses = NULL, *classname = NULL, *_0 = NULL, **_3, *_4$$3 = NULL, *_5$$3 = NULL, *_6$$4 = NULL; zephir_fcall_cache_entry *_8 = NULL; int ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(driverClasses); zephir_create_array(driverClasses, 3, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "Xpl\\Cache\\Driver\\ApcuDriver", 1); zephir_array_fast_append(driverClasses, _0); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "Xpl\\Cache\\Driver\\ApcDriver", 1); zephir_array_fast_append(driverClasses, _0); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "Xpl\\Cache\\Driver\\XCacheDriver", 1); zephir_array_fast_append(driverClasses, _0); zephir_is_iterable(driverClasses, &_2, &_1, 0, 0, "xpl/cache/cache.zep", 215); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(classname, _3); ZEPHIR_INIT_NVAR(_4$$3); ZEPHIR_INIT_LNVAR(_5$$3); ZEPHIR_CONCAT_VS(_5$$3, classname, "::isAvailable"); ZEPHIR_CALL_USER_FUNC(_4$$3, _5$$3); zephir_check_call_status(); if (ZEPHIR_IS_TRUE_IDENTICAL(_4$$3)) { zephir_fetch_safe_class(_6$$4, classname); _7$$4 = zend_fetch_class(Z_STRVAL_P(_6$$4), Z_STRLEN_P(_6$$4), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); object_init_ex(return_value, _7$$4); if (zephir_has_constructor(return_value TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", &_8, 0); zephir_check_call_status(); } RETURN_MM(); } } object_init_ex(return_value, xpl_cache_driver_memorydriver_ce); if (zephir_has_constructor(return_value TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 0); zephir_check_call_status(); } RETURN_MM(); }
PHP_METHOD(Test_InternalClasses, testStaticCall) { zend_class_entry *_0; int ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); _0 = zend_fetch_class(SL("Phalcon\\DI"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); ZEPHIR_RETURN_CALL_CE_STATIC(_0, "getdefault", NULL, 0); zephir_check_call_status(); RETURN_MM(); }
PHP_METHOD(Test_InternalClasses, testStaticCall) { int ZEPHIR_LAST_CALL_STATUS; zend_class_entry *phalcon_phalcon_di; ZEPHIR_MM_GROW(); phalcon_phalcon_di = zend_fetch_class(SL("\\Phalcon\\Di"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); ZEPHIR_RETURN_CALL_CE_STATIC(phalcon_phalcon_di, "getdefault", NULL); zephir_check_call_status(); RETURN_MM(); }
PHP_METHOD(Auryn_AbstractCachingReflector, getMethod) { zend_class_entry *_3; int ZEPHIR_LAST_CALL_STATUS; zval *methodName = NULL; zval *classNameOrInstance, *methodName_param = NULL, *className = NULL, *cacheKey, *reflectedMethod = NULL, *_0, *_1, *_2, *_4; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &classNameOrInstance, &methodName_param); if (unlikely(Z_TYPE_P(methodName_param) != IS_STRING && Z_TYPE_P(methodName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'methodName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (unlikely(Z_TYPE_P(methodName_param) == IS_STRING)) { methodName = methodName_param; } else { ZEPHIR_INIT_VAR(methodName); ZVAL_EMPTY_STRING(methodName); } if (Z_TYPE_P(classNameOrInstance) == IS_STRING) { ZEPHIR_CPY_WRT(className, classNameOrInstance); } else { ZEPHIR_INIT_VAR(className); zephir_get_class(className, classNameOrInstance, 0 TSRMLS_CC); } ZEPHIR_INIT_VAR(_0); zephir_fast_strtolower(_0, className); ZEPHIR_INIT_VAR(_1); zephir_fast_strtolower(_1, methodName); ZEPHIR_INIT_VAR(cacheKey); ZEPHIR_CONCAT_SVSV(cacheKey, "auryn.refls.methods.", _0, ".", _1); _2 = zephir_fetch_nproperty_this(this_ptr, SL("cache"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&reflectedMethod, _2, "fetch", NULL, cacheKey); zephir_check_call_status(); if (!(zephir_is_true(reflectedMethod))) { ZEPHIR_INIT_BNVAR(reflectedMethod); _3 = zend_fetch_class(SL("ReflectionMethod"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); object_init_ex(reflectedMethod, _3); ZEPHIR_CALL_METHOD(NULL, reflectedMethod, "__construct", NULL, className, methodName); zephir_check_call_status(); _4 = zephir_fetch_nproperty_this(this_ptr, SL("cache"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _4, "store", NULL, cacheKey, reflectedMethod); zephir_check_call_status(); } RETURN_CCTOR(reflectedMethod); }
PHP_METHOD(Test_UseTest, testUseNamespaceAlias) { zend_class_entry *_0; ZEPHIR_MM_GROW(); _0 = zend_fetch_class(SL("Oo\\OoConstruct"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); object_init_ex(return_value, _0); if (zephir_has_constructor(return_value TSRMLS_CC)) { zephir_call_method_noret(return_value, "__construct"); } RETURN_MM(); }
PHP_METHOD(Test_UseTest, createInstance) { zend_class_entry *_0; ZEPHIR_MM_GROW(); _0 = zend_fetch_class(SL("\\stdClass"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); object_init_ex(return_value, _0); if (zephir_has_constructor(return_value TSRMLS_CC)) { zephir_call_method_noret(return_value, "__construct"); } RETURN_MM(); }
// Create a PHP object given a typename and call the ctor, optionally passing up to 2 arguments void createObject(char* obj_typename, zval* return_value, int nargs = 0, zval* arg1 = NULL, zval* arg2 = NULL) { TSRMLS_FETCH(); size_t obj_typename_len = strlen(obj_typename); zend_class_entry* ce = zend_fetch_class(obj_typename, obj_typename_len, ZEND_FETCH_CLASS_DEFAULT TSRMLS_CC); if (! ce) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Class %s does not exist", obj_typename); RETURN_NULL(); } object_and_properties_init(return_value, ce, NULL); zend_function* constructor = zend_std_get_constructor(return_value TSRMLS_CC); zval* ctor_rv = NULL; zend_call_method(&return_value, ce, &constructor, NULL, 0, &ctor_rv, nargs, arg1, arg2 TSRMLS_CC); zval_ptr_dtor(&ctor_rv); }
PHP_METHOD(OAuth_V1_Service, getAuthorizationUri) { zend_function *_6 = NULL; HashTable *_4; HashPosition _3; zend_class_entry *_1; zval *params = NULL, *uri, *endpoint, *key = NULL, *value = NULL, *_0, *_2, **_5; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, ¶ms); if (!params) { params = ZEPHIR_GLOBAL(global_null); } if (((Z_TYPE_P(params) != IS_ARRAY) && (Z_TYPE_P(params) != IS_NULL))) { ZEPHIR_INIT_VAR(_0); _1 = zend_fetch_class(SL("InvalidArgumentException"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); object_init_ex(_0, _1); ZEPHIR_INIT_VAR(_2); ZVAL_STRING(_2, "The params must be an Array", 1); zephir_call_method_p1_noret(_0, "__construct", _2); zephir_throw_exception(_0 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(endpoint); object_init_ex(endpoint, oauth_uri_ce); zephir_call_method_noret(endpoint, "__construct"); ZEPHIR_INIT_VAR(uri); if (zephir_clone(uri, endpoint TSRMLS_CC) == FAILURE) { RETURN_MM(); } if ((Z_TYPE_P(params) != IS_ARRAY)) { zephir_is_iterable(params, &_4, &_3, 0, 0); for ( ; zend_hash_get_current_data_ex(_4, (void**) &_5, &_3) == SUCCESS ; zend_hash_move_forward_ex(_4, &_3) ) { ZEPHIR_GET_HMKEY(key, _4, _3); ZEPHIR_GET_HVALUE(value, _5); zephir_call_method_p2_cache_noret(uri, "addtoquery", &_6, key, value); } } RETURN_CCTOR(uri); }
/** * Initializes the internal handler, calling functions on it * * @param string method * @param array arguments * @return mixed */ PHP_METHOD(Phalcon_Mvc_Micro_LazyLoader, __call) { zval *_2; int ZEPHIR_LAST_CALL_STATUS; zend_class_entry *_1; zval *method_param = NULL, *arguments, *handler = NULL, *definition, *_0 = NULL; zval *method = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &method_param, &arguments); if (unlikely(Z_TYPE_P(method_param) != IS_STRING && Z_TYPE_P(method_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'method' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(method_param) == IS_STRING)) { zephir_get_strval(method, method_param); } else { ZEPHIR_INIT_VAR(method); ZVAL_EMPTY_STRING(method); } ZEPHIR_OBS_VAR(handler); zephir_read_property_this(&handler, this_ptr, SL("_handler"), PH_NOISY_CC); if (Z_TYPE_P(handler) != IS_OBJECT) { ZEPHIR_OBS_VAR(definition); zephir_read_property_this(&definition, this_ptr, SL("_definition"), PH_NOISY_CC); ZEPHIR_INIT_NVAR(handler); zephir_fetch_safe_class(_0, definition); _1 = zend_fetch_class(Z_STRVAL_P(_0), Z_STRLEN_P(_0), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); object_init_ex(handler, _1); if (zephir_has_constructor(handler TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, handler, "__construct", NULL); zephir_check_call_status(); } zephir_update_property_this(this_ptr, SL("_handler"), handler TSRMLS_CC); } ZEPHIR_INIT_VAR(_2); zephir_create_array(_2, 2, 0 TSRMLS_CC); zephir_array_fast_append(_2, handler); zephir_array_fast_append(_2, method); ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, _2, arguments); zephir_check_call_status(); RETURN_MM(); }
PHP_METHOD(Feathers_Router_MethodsCollection, getIterator) { int ZEPHIR_LAST_CALL_STATUS; zval *_1; zend_class_entry *_0; ZEPHIR_MM_GROW(); _0 = zend_fetch_class(SL("ArrayIterator"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); object_init_ex(return_value, _0); _1 = zephir_fetch_nproperty_this(this_ptr, SL("_methods"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, _1); zephir_check_call_status(); RETURN_MM(); }
PHP_METHOD(Test_Oo_OoDynamicA, getNew) { zend_class_entry *_0; zval *className, *fullClassName; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(className); zephir_call_func(className, "get_called_class"); ZEPHIR_INIT_VAR(fullClassName); ZEPHIR_CONCAT_SV(fullClassName, "\\", className); _0 = zend_fetch_class(Z_STRVAL_P(fullClassName), Z_STRLEN_P(fullClassName), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); object_init_ex(return_value, _0); RETURN_MM(); }
/** * Create internal connection to memcached */ PHP_METHOD(Phalcon_Cache_Backend_Libmemcached, _connect){ zval *options, *memcache, *servers, *client = NULL, *res = NULL; zend_string *str_key; ulong idx; zend_class_entry *ce0; PHALCON_MM_GROW(); options = phalcon_read_property(getThis(), SL("_options"), PH_NOISY); ce0 = zend_fetch_class(SSL("Memcached"), ZEND_FETCH_CLASS_AUTO); PHALCON_INIT_VAR(memcache); object_init_ex(memcache, ce0); if (phalcon_has_constructor(memcache)) { PHALCON_CALL_METHOD(NULL, memcache, "__construct"); } if (!phalcon_array_isset_str_fetch(&servers, options, SL("servers")) || Z_TYPE_P(servers) != IS_ARRAY) { PHALCON_THROW_EXCEPTION_STR(phalcon_cache_exception_ce, "Servers must be an array"); return; } phalcon_array_isset_str_fetch(&client, options, SL("client")); PHALCON_RETURN_CALL_METHOD(memcache, "addservers", servers); if (!zend_is_true(return_value)) { PHALCON_THROW_EXCEPTION_STR(phalcon_cache_exception_ce, "Cannot connect to Memcached server"); return; } if (client && Z_TYPE_P(client) == IS_ARRAY) { zval *value; ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(client), idx, str_key, value) { zval option; if (str_key) { if ((res = zend_get_constant(str_key)) != NULL) { PHALCON_CALL_METHOD(NULL, memcache, "setoption", res, value); } } else { ZVAL_LONG(&option, idx); PHALCON_CALL_METHOD(NULL, memcache, "setoption", &option, value); } } ZEND_HASH_FOREACH_END();
// Create a PHP object given a typename and call the ctor, optionally passing up to 2 arguments static void createObject(const char* obj_typename, zval* return_value, int nargs = 0, zval* arg1 = nullptr, zval* arg2 = nullptr) { /* is there a better way to do that on the stack ? */ zend_string *obj_name = zend_string_init(obj_typename, strlen(obj_typename), 0); zend_class_entry* ce = zend_fetch_class(obj_name, ZEND_FETCH_CLASS_DEFAULT); zend_string_release(obj_name); if (! ce) { php_error_docref(nullptr, E_ERROR, "Class %s does not exist", obj_typename); RETURN_NULL(); } object_and_properties_init(return_value, ce, nullptr); zend_function* constructor = zend_std_get_constructor(Z_OBJ_P(return_value)); zval ctor_rv; zend_call_method(return_value, ce, &constructor, NULL, 0, &ctor_rv, nargs, arg1, arg2); zval_dtor(&ctor_rv); }
PHP_METHOD(Owl_Log_AbstractWriter, setFormatter) { zend_class_entry *_5; int ZEPHIR_LAST_CALL_STATUS; zend_bool _0; zval *formatter, _1, *_2 = NULL, *_3, *_4 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &formatter); _0 = Z_TYPE_P(formatter) == IS_OBJECT; if (_0) { ZEPHIR_SINIT_VAR(_1); ZVAL_STRING(&_1, "\\Owl\\Log\\FormatterInterface", 0); ZEPHIR_CALL_FUNCTION(&_2, "is_subclass_of", NULL, 2, formatter, &_1); zephir_check_call_status(); _0 = zephir_is_true(_2); } if (_0) { zephir_update_property_this(this_ptr, SL("formatter"), formatter TSRMLS_CC); } else if (Z_TYPE_P(formatter) == IS_STRING) { if (!(zephir_class_exists(formatter, 1 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(owl_log_exception_invalidformatterexception_ce, "Formatter class is not exits", "owl/Log/AbstractWriter.zep", 94); return; } ZEPHIR_INIT_VAR(_3); zephir_fetch_safe_class(_4, formatter); _5 = zend_fetch_class(Z_STRVAL_P(_4), Z_STRLEN_P(_4), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); object_init_ex(_3, _5); if (zephir_has_constructor(_3 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, _3, "__construct", NULL, 0); zephir_check_call_status(); } zephir_update_property_this(this_ptr, SL("formatter"), _3 TSRMLS_CC); } else { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(owl_log_exception_invalidformatterexception_ce, "Formatter set error", "owl/Log/AbstractWriter.zep", 99); return; } ZEPHIR_MM_RESTORE(); }
/** * Create internal connection to memcached */ PHP_METHOD(Phalcon_Cache_Backend_Memcache, _connect){ zval *options, *memcache, *host, *port, *persistent; zval *success = NULL; zend_class_entry *ce0; PHALCON_MM_GROW(); PHALCON_OBS_VAR(options); phalcon_read_property(&options, this_ptr, SL("_options"), PH_NOISY_CC); ce0 = zend_fetch_class(SL("Memcache"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); PHALCON_INIT_VAR(memcache); object_init_ex(memcache, ce0); if (phalcon_has_constructor(memcache TSRMLS_CC)) { PHALCON_CALL_METHOD_NORETURN(memcache, "__construct"); } PHALCON_OBS_VAR(host); phalcon_array_fetch_string(&host, options, SL("host"), PH_NOISY_CC); PHALCON_OBS_VAR(port); phalcon_array_fetch_string(&port, options, SL("port"), PH_NOISY_CC); PHALCON_OBS_VAR(persistent); phalcon_array_fetch_string(&persistent, options, SL("persistent"), PH_NOISY_CC); if (zend_is_true(persistent)) { PHALCON_INIT_VAR(success); PHALCON_CALL_METHOD_PARAMS_2(success, memcache, "pconnect", host, port); } else { PHALCON_INIT_NVAR(success); PHALCON_CALL_METHOD_PARAMS_2(success, memcache, "connect", host, port); } if (!zend_is_true(success)) { PHALCON_THROW_EXCEPTION_STR(phalcon_cache_exception_ce, "Cannot connect to Memcached server"); return; } phalcon_update_property_zval(this_ptr, SL("_memcache"), memcache TSRMLS_CC); PHALCON_MM_RESTORE(); }
PHP_METHOD(Auryn_AbstractCachingReflector, getFunction) { zend_class_entry *_1; int ZEPHIR_LAST_CALL_STATUS; zval *functionName_param = NULL, *lowFunc, *cacheKey, *reflectedFunc = NULL, *_0, *_2; zval *functionName = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &functionName_param); if (unlikely(Z_TYPE_P(functionName_param) != IS_STRING && Z_TYPE_P(functionName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'functionName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (unlikely(Z_TYPE_P(functionName_param) == IS_STRING)) { functionName = functionName_param; } else { ZEPHIR_INIT_VAR(functionName); ZVAL_EMPTY_STRING(functionName); } ZEPHIR_INIT_VAR(lowFunc); zephir_fast_strtolower(lowFunc, functionName); ZEPHIR_INIT_VAR(cacheKey); ZEPHIR_CONCAT_SV(cacheKey, "auryn.refls.funcs.", lowFunc); _0 = zephir_fetch_nproperty_this(this_ptr, SL("cache"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&reflectedFunc, _0, "fetch", NULL, cacheKey); zephir_check_call_status(); if (!(zephir_is_true(reflectedFunc))) { ZEPHIR_INIT_BNVAR(reflectedFunc); _1 = zend_fetch_class(SL("ReflectionFunction"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); object_init_ex(reflectedFunc, _1); ZEPHIR_CALL_METHOD(NULL, reflectedFunc, "__construct", NULL, functionName); zephir_check_call_status(); _2 = zephir_fetch_nproperty_this(this_ptr, SL("cache"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, _2, "store", NULL, cacheKey, reflectedFunc); zephir_check_call_status(); } RETURN_CCTOR(reflectedFunc); }