Пример #1
0
/**
 * @inheritdoc
 */
PHP_METHOD(Owl_Log_Formatter_Json, format) {

	int ZEPHIR_LAST_CALL_STATUS;
	zephir_fcall_cache_entry *_2 = NULL;
	zval *_0;
	zval *record, *_1 = NULL, *_3, *_4 = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &record);



	ZEPHIR_INIT_VAR(_0);
	zephir_create_array(_0, 3, 0 TSRMLS_CC);
	ZEPHIR_OBS_VAR(_3);
	zephir_read_property(&_3, record, SL("level"), PH_NOISY_CC);
	ZEPHIR_CALL_CE_STATIC(&_1, owl_log_logger_ce, "getleveltitle", &_2, 18, _3);
	zephir_check_call_status();
	zephir_array_update_string(&_0, SL("type"), &_1, PH_COPY | PH_SEPARATE);
	ZEPHIR_OBS_VAR(_4);
	zephir_read_property(&_4, record, SL("message"), PH_NOISY_CC);
	zephir_array_update_string(&_0, SL("message"), &_4, PH_COPY | PH_SEPARATE);
	ZEPHIR_OBS_NVAR(_4);
	zephir_read_property(&_4, record, SL("timestamp"), PH_NOISY_CC);
	zephir_array_update_string(&_0, SL("timestamp"), &_4, PH_COPY | PH_SEPARATE);
	zephir_json_encode(return_value, &(return_value), _0, 0  TSRMLS_CC);
	RETURN_MM();

}
Пример #2
0
PHP_METHOD(Test_Json, testEncodeOptions) {

	zval *arr, *_0 = NULL, _1;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(arr);
	array_init_size(arr, 7);
	ZEPHIR_INIT_VAR(_0);
	ZVAL_STRING(_0, "<foo>", 1);
	zephir_array_fast_append(arr, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_STRING(_0, "'bar'", 1);
	zephir_array_fast_append(arr, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_STRING(_0, "&blong&", 1);
	zephir_array_fast_append(arr, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_STRING(_0, "\xc3\xa9", 1);
	zephir_array_fast_append(arr, _0);
	ZEPHIR_SINIT_VAR(_1);
	ZVAL_LONG(&_1, 1);
	zephir_json_encode(return_value, &(return_value), arr, zephir_get_intval(&_1)  TSRMLS_CC);
	RETURN_MM();

}
Пример #3
0
/**
 * Applies a format to a message before sent it to the internal log
 *
 * @param <Item> item
 *
 * @return string
 */
PHP_METHOD(Phalcon_Logger_Formatter_Json, format) {

	zval _4;
	zend_long ZEPHIR_LAST_CALL_STATUS;
	zval *item, item_sub, message, _0, _3, _5, _6, _7, _8, _1$$3, _2$$3;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&item_sub);
	ZVAL_UNDEF(&message);
	ZVAL_UNDEF(&_0);
	ZVAL_UNDEF(&_3);
	ZVAL_UNDEF(&_5);
	ZVAL_UNDEF(&_6);
	ZVAL_UNDEF(&_7);
	ZVAL_UNDEF(&_8);
	ZVAL_UNDEF(&_1$$3);
	ZVAL_UNDEF(&_2$$3);
	ZVAL_UNDEF(&_4);

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &item);



	ZEPHIR_CALL_METHOD(&_0, item, "getcontext", NULL, 0);
	zephir_check_call_status();
	if (Z_TYPE_P(&_0) == IS_ARRAY) {
		ZEPHIR_CALL_METHOD(&_1$$3, item, "getmessage", NULL, 0);
		zephir_check_call_status();
		ZEPHIR_CALL_METHOD(&_2$$3, item, "getcontext", NULL, 0);
		zephir_check_call_status();
		ZEPHIR_CALL_METHOD(&message, this_ptr, "interpolate", NULL, 0, &_1$$3, &_2$$3);
		zephir_check_call_status();
	} else {
		ZEPHIR_CALL_METHOD(&message, item, "getmessage", NULL, 0);
		zephir_check_call_status();
	}
	ZEPHIR_INIT_VAR(&_3);
	ZEPHIR_INIT_VAR(&_4);
	zephir_create_array(&_4, 3, 0 TSRMLS_CC);
	ZEPHIR_CALL_METHOD(&_5, item, "getname", NULL, 0);
	zephir_check_call_status();
	zephir_array_update_string(&_4, SL("type"), &_5, PH_COPY | PH_SEPARATE);
	zephir_array_update_string(&_4, SL("message"), &message, PH_COPY | PH_SEPARATE);
	zephir_read_property(&_6, this_ptr, SL("dateFormat"), PH_NOISY_CC | PH_READONLY);
	ZEPHIR_CALL_METHOD(&_5, item, "gettime", NULL, 0);
	zephir_check_call_status();
	ZEPHIR_CALL_FUNCTION(&_7, "date", NULL, 294, &_6, &_5);
	zephir_check_call_status();
	zephir_array_update_string(&_4, SL("timestamp"), &_7, PH_COPY | PH_SEPARATE);
	zephir_json_encode(&_3, &_4, 0 );
	ZEPHIR_INIT_VAR(&_8);
	ZEPHIR_GET_CONSTANT(&_8, "PHP_EOL");
	ZEPHIR_CONCAT_VV(return_value, &_3, &_8);
	RETURN_MM();

}
Пример #4
0
/**
 * Serializes the given data.
 *
 * @param mixed data
 *
 * @return string
 */
PHP_METHOD(Xpl_Serializer_Json, serialize) {

	zval *data;

	zephir_fetch_params(0, 1, 0, &data);



	zephir_json_encode(return_value, &(return_value), data, 0  TSRMLS_CC);
	return;

}
Пример #5
0
/**
 * Returns an JSON string of information about a single variable.
 *
 * <code>
 *    $foo = ["key" => "value"];
 *    echo (new \Phalcon\Debug\Dump())->toJson($foo);
 *    $foo = new stdClass();
 *    $foo->bar = 'buz';
 *    echo (new \Phalcon\Debug\Dump())->toJson($foo);
 * </code>
 *
 * @param mixed variable
 */
PHP_METHOD(Phalcon_Debug_Dump, toJson) {

	zval *variable, _0;

	zephir_fetch_params(0, 1, 0, &variable);



	ZEPHIR_SINIT_VAR(_0);
	ZVAL_LONG(&_0, ((128 | 64) | 256));
	zephir_json_encode(return_value, &(return_value), variable, zephir_get_intval(&_0)  TSRMLS_CC);
	return;

}
Пример #6
0
PHP_METHOD(Test_Json, testEncodeObject) {

	zval *obj;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(obj);
	array_init_size(obj, 5);
	add_assoc_stringl_ex(obj, SS("a"), SL("hello"), 1);
	add_assoc_stringl_ex(obj, SS("b"), SL("world"), 1);
	add_assoc_long_ex(obj, SS("c"), 128);
	zephir_json_encode(return_value, &(return_value), obj, 0  TSRMLS_CC);
	RETURN_MM();

}
Пример #7
0
PHP_METHOD(Yb_Task_TaskManagerAbstract, serializeTask) {

	zval *task_param = NULL;
	zval *task = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &task_param);

	zephir_get_arrval(task, task_param);


	zephir_json_encode(return_value, &(return_value), task, 0  TSRMLS_CC);
	RETURN_MM();

}
Пример #8
0
PHP_METHOD(Owl_Http_Response_Json, setContent) {

	zval *content, *_0;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &content);



	ZEPHIR_INIT_VAR(_0);
	zephir_json_encode(_0, &(_0), content, 0  TSRMLS_CC);
	zephir_update_property_this(this_ptr, SL("content"), _0 TSRMLS_CC);
	ZEPHIR_MM_RESTORE();

}
Пример #9
0
/**
 * Returns an JSON string of information about a single variable.
 *
 * <code>
 * $foo = [
 *     "key" => "value",
 * ];
 *
 * echo (new \Phalcon\Debug\Dump())->toJson($foo);
 *
 * $foo = new stdClass();
 * $foo->bar = "buz";
 *
 * echo (new \Phalcon\Debug\Dump())->toJson($foo);
 * </code>
 */
PHP_METHOD(Phalcon_Debug_Dump, toJson) {

	zval *variable, variable_sub, _0;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&variable_sub);
	ZVAL_UNDEF(&_0);

	zephir_fetch_params(0, 1, 0, &variable);



	ZVAL_LONG(&_0, ((128 | 64) | 256));
	zephir_json_encode(return_value, variable, zephir_get_intval(&_0) );
	return;

}
Пример #10
0
/**
 * Applies a format to a message before sent it to the internal log
 *
 * @param string message
 * @param int type
 * @param int timestamp
 * @param array $context
 * @return string
 */
PHP_METHOD(Phalcon_Logger_Formatter_Json, format) {

	zval *_2;
	int type, timestamp, ZEPHIR_LAST_CALL_STATUS;
	zval *message_param = NULL, *type_param = NULL, *timestamp_param = NULL, *context = NULL, *_0$$3 = NULL, *_1, *_3 = NULL, *_4 = NULL;
	zval *message = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 3, 1, &message_param, &type_param, &timestamp_param, &context);

	zephir_get_strval(message, message_param);
	type = zephir_get_intval(type_param);
	timestamp = zephir_get_intval(timestamp_param);
	if (!context) {
		context = ZEPHIR_GLOBAL(global_null);
	}


	if (Z_TYPE_P(context) == IS_ARRAY) {
		ZEPHIR_CALL_METHOD(&_0$$3, this_ptr, "interpolate", NULL, 0, message, context);
		zephir_check_call_status();
		zephir_get_strval(message, _0$$3);
	}
	ZEPHIR_INIT_VAR(_1);
	ZEPHIR_INIT_VAR(_2);
	zephir_create_array(_2, 3, 0 TSRMLS_CC);
	ZEPHIR_INIT_VAR(_4);
	ZVAL_LONG(_4, type);
	ZEPHIR_CALL_METHOD(&_3, this_ptr, "gettypestring", NULL, 0, _4);
	zephir_check_call_status();
	zephir_array_update_string(&_2, SL("type"), &_3, PH_COPY | PH_SEPARATE);
	zephir_array_update_string(&_2, SL("message"), &message, PH_COPY | PH_SEPARATE);
	ZEPHIR_INIT_NVAR(_4);
	ZVAL_LONG(_4, timestamp);
	zephir_array_update_string(&_2, SL("timestamp"), &_4, PH_COPY | PH_SEPARATE);
	zephir_json_encode(_1, &(_1), _2, 0  TSRMLS_CC);
	ZEPHIR_INIT_NVAR(_4);
	ZEPHIR_GET_CONSTANT(_4, "PHP_EOL");
	ZEPHIR_CONCAT_VV(return_value, _1, _4);
	RETURN_MM();

}
Пример #11
0
/**
 * JSON-encodes data.
 *
 * @param mixed data
 * @param int options [Optional]
 * @return string
 */
PHP_METHOD(Xpl_Json, encode) {

	int options;
	zval *data, *options_param = NULL, _0;

	zephir_fetch_params(0, 1, 1, &data, &options_param);

	if (!options_param) {
		options = 0;
	} else {
		options = zephir_get_intval(options_param);
	}


	ZEPHIR_SINIT_VAR(_0);
	ZVAL_LONG(&_0, options);
	zephir_json_encode(return_value, &(return_value), data, zephir_get_intval(&_0)  TSRMLS_CC);
	return;

}
Пример #12
0
/**
 * @param \Ouchbase\Entity entity
 * @return this
 */
PHP_METHOD(Ouchbase_Repository, insert) {

	zval *_0;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *entity, *data = NULL, *_1 = NULL, *_2 = NULL, *_3, *_4, *_5;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &entity);



	if (!(zephir_instance_of_ev(entity, ouchbase_entity_ce TSRMLS_CC))) {
		ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_InvalidArgumentException, "Parameter 'entity' must be an instance of 'Ouchbase\\Entity'", "", 0);
		return;
	}
	ZEPHIR_CALL_METHOD(&data, this_ptr, "toarray", NULL, entity);
	zephir_check_call_status();
	ZEPHIR_INIT_VAR(_0);
	array_init_size(_0, 3);
	ZEPHIR_CALL_METHOD(&_2, entity, "getid",  NULL);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(&_1, this_ptr, "getkey", NULL, _2);
	zephir_check_call_status();
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_VAR(_3);
	zephir_json_encode(_3, &(_3), data, 0  TSRMLS_CC);
	zephir_array_fast_append(_0, _3);
	ZEPHIR_INIT_BNVAR(_3);
	ZVAL_STRING(_3, "set", 0);
	ZEPHIR_CALL_METHOD(NULL, this_ptr, "executewithouttimeouts", NULL, _3, _0);
	zephir_check_temp_parameter(_3);
	zephir_check_call_status();
	_4 = zephir_fetch_nproperty_this(this_ptr, SL("uow"), PH_NOISY_CC);
	ZEPHIR_CALL_METHOD(NULL, _4, "persist", NULL, entity);
	zephir_check_call_status();
	_5 = zephir_fetch_nproperty_this(this_ptr, SL("im"), PH_NOISY_CC);
	ZEPHIR_CALL_METHOD(NULL, _5, "updateoriginaldata", NULL, entity, data);
	zephir_check_call_status();
	RETURN_THIS();

}
Пример #13
0
PHP_METHOD(Test_Json, testEncodeArray) {

	zval *arr, *_0 = NULL;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(arr);
	array_init_size(arr, 5);
	ZEPHIR_INIT_VAR(_0);
	ZVAL_LONG(_0, 1);
	zephir_array_fast_append(arr, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 2);
	zephir_array_fast_append(arr, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 3);
	zephir_array_fast_append(arr, _0);
	zephir_json_encode(return_value, &(return_value), arr, 0  TSRMLS_CC);
	RETURN_MM();

}
Пример #14
0
/**
 * Sets HTTP response body. The parameter is automatically converted to JSON
 *
 *<code>
 *	$response->setJsonContent(array("status" => "OK"));
 *</code>
 *
 * @param mixed content
 * @param int jsonOptions
 * @return \Phalcon\Http\Response
 */
PHP_METHOD(Phalcon_Http_Response, setJsonContent) {

	zval *content, *jsonOptions = NULL, *depth = NULL, *_0;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 2, &content, &jsonOptions, &depth);

	if (!jsonOptions) {
		ZEPHIR_INIT_VAR(jsonOptions);
		ZVAL_LONG(jsonOptions, 0);
	}
	if (!depth) {
		ZEPHIR_INIT_VAR(depth);
		ZVAL_LONG(depth, 512);
	}


	ZEPHIR_INIT_VAR(_0);
	zephir_json_encode(_0, &(_0), content, zephir_get_intval(jsonOptions)  TSRMLS_CC);
	zephir_update_property_this(this_ptr, SL("_content"), _0 TSRMLS_CC);
	RETURN_THIS();

}
Пример #15
0
PHP_METHOD(PhalconPlus_Db_Mysql, getConnection) {

	zval __$true, __$false, tryTimes, e, _0, _1$$4, _2$$4, _4$$3, _5$$5, _6$$5, _7$$5, _9$$5, _12$$6, _14$$6, _15$$6, _16$$6, _17$$6, _18$$7, _19$$7, _20$$7;
	zephir_fcall_cache_entry *_3 = NULL, *_8 = NULL, *_10 = NULL, *_13 = NULL;
	zend_long ZEPHIR_LAST_CALL_STATUS, _11$$5;
	zval *this_ptr = getThis();

	ZVAL_BOOL(&__$true, 1);
	ZVAL_BOOL(&__$false, 0);
	ZVAL_UNDEF(&tryTimes);
	ZVAL_UNDEF(&e);
	ZVAL_UNDEF(&_0);
	ZVAL_UNDEF(&_1$$4);
	ZVAL_UNDEF(&_2$$4);
	ZVAL_UNDEF(&_4$$3);
	ZVAL_UNDEF(&_5$$5);
	ZVAL_UNDEF(&_6$$5);
	ZVAL_UNDEF(&_7$$5);
	ZVAL_UNDEF(&_9$$5);
	ZVAL_UNDEF(&_12$$6);
	ZVAL_UNDEF(&_14$$6);
	ZVAL_UNDEF(&_15$$6);
	ZVAL_UNDEF(&_16$$6);
	ZVAL_UNDEF(&_17$$6);
	ZVAL_UNDEF(&_18$$7);
	ZVAL_UNDEF(&_19$$7);
	ZVAL_UNDEF(&_20$$7);

	ZEPHIR_MM_GROW();

	ZEPHIR_OBS_VAR(&tryTimes);
	zephir_read_property(&tryTimes, this_ptr, SL("retryTimes"), PH_NOISY_CC);
	while (1) {
		zephir_read_property(&_0, this_ptr, SL("connected"), PH_NOISY_CC | PH_READONLY);
		if (!(!(zephir_is_true(&_0)))) {
			break;
		}

		/* try_start_1: */

			ZEPHIR_INIT_NVAR(&_1$$4);
			object_init_ex(&_1$$4, zephir_get_internal_ce(SL("phalcon\\db\\adapter\\pdo\\mysql")));
			zephir_read_property(&_2$$4, this_ptr, SL("descriptor"), PH_NOISY_CC | PH_READONLY);
			ZEPHIR_CALL_METHOD(NULL, &_1$$4, "__construct", &_3, 0, &_2$$4);
			zephir_check_call_status_or_jump(try_end_1);
			zephir_update_property_zval(this_ptr, SL("connection"), &_1$$4);
			if (1) {
				zephir_update_property_zval(this_ptr, SL("connected"), &__$true);
			} else {
				zephir_update_property_zval(this_ptr, SL("connected"), &__$false);
			}

		try_end_1:

		if (EG(exception)) {
			ZEPHIR_INIT_NVAR(&_4$$3);
			ZVAL_OBJ(&_4$$3, EG(exception));
			Z_ADDREF_P(&_4$$3);
			if (zephir_instance_of_ev(&_4$$3, zend_exception_get_default(TSRMLS_C) TSRMLS_CC)) {
				zend_clear_exception(TSRMLS_C);
				ZEPHIR_CPY_WRT(&e, &_4$$3);
				ZEPHIR_INIT_NVAR(&_5$$5);
				zephir_read_property(&_6$$5, this_ptr, SL("descriptor"), PH_NOISY_CC | PH_READONLY);
				zephir_json_encode(&_5$$5, &_6$$5, 0 );
				ZEPHIR_CALL_FUNCTION(&_7$$5, "strval", &_8, 27, &tryTimes);
				zephir_check_call_status();
				ZEPHIR_INIT_LNVAR(_9$$5);
				ZEPHIR_CONCAT_SVSVS(&_9$$5, "PHP Fatal error:  PhalconPlus::Db::MySQL::connect() failed to connect to MySQL. Detail: ", &_5$$5, ". We will try ", &_7$$5, " times for you.");
				ZEPHIR_CALL_FUNCTION(NULL, "error_log", &_10, 50, &_9$$5);
				zephir_check_call_status();
				_11$$5 = (zephir_get_numberval(&tryTimes) - 1);
				ZEPHIR_INIT_NVAR(&tryTimes);
				ZVAL_LONG(&tryTimes, _11$$5);
				if (ZEPHIR_GT_LONG(&tryTimes, 0)) {
					zephir_read_property(&_12$$6, this_ptr, SL("retryInterval"), PH_NOISY_CC | PH_READONLY);
					ZEPHIR_CALL_FUNCTION(NULL, "usleep", &_13, 57, &_12$$6);
					zephir_check_call_status();
					zephir_read_property(&_14$$6, this_ptr, SL("retryTimes"), PH_NOISY_CC | PH_READONLY);
					ZEPHIR_SINIT_NVAR(_15$$6);
					zephir_sub_function(&_15$$6, &_14$$6, &tryTimes);
					ZEPHIR_CALL_FUNCTION(&_16$$6, "strval", &_8, 27, &_15$$6);
					zephir_check_call_status();
					ZEPHIR_INIT_LNVAR(_17$$6);
					ZEPHIR_CONCAT_SVS(&_17$$6, "PHP Notice:  PhalconPlus::Db::MySQL::connnect() retry to connect to MySQL for the ", &_16$$6, " time ... ");
					ZEPHIR_CALL_FUNCTION(NULL, "error_log", &_10, 50, &_17$$6);
					zephir_check_call_status();
				} else {
					ZEPHIR_INIT_NVAR(&_18$$7);
					zephir_read_property(&_19$$7, this_ptr, SL("descriptor"), PH_NOISY_CC | PH_READONLY);
					zephir_json_encode(&_18$$7, &_19$$7, 0 );
					ZEPHIR_INIT_LNVAR(_20$$7);
					ZEPHIR_CONCAT_SV(&_20$$7, "PHP Fatal error:  PhalconPlus::Db::MySQL::connect() finally failed to connect to MySQL. Detail: ", &_18$$7);
					ZEPHIR_CALL_FUNCTION(NULL, "error_log", &_10, 50, &_20$$7);
					zephir_check_call_status();
					zephir_throw_exception_debug(&e, "phalconplus/Db/Mysql.zep", 77 TSRMLS_CC);
					ZEPHIR_MM_RESTORE();
					return;
				}
			}
		}
	}
	RETURN_MM_MEMBER(getThis(), "connection");

}
Пример #16
0
/**
 *
 * @param array rawData
 * <code> 
 *     rawData = ["service":"Demo", "method":"demo", "args": <ProtoBuffer>]
 * </code>
 * @return <ProtoBuffer>
 * @throw \Exception
 *
 */
PHP_METHOD(PhalconPlus_RPC_Server_AbstractServer, callByObject) {

	zend_bool _3;
	zephir_nts_static zephir_fcall_cache_entry *_2 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *rawData_param = NULL, *service = NULL, *method = NULL, *request, *response = NULL, *logId = NULL, *message = NULL, *_0 = NULL, *_1 = NULL, *_4, *_5 = NULL, *_6, *_7 = NULL, *_8 = NULL, *_9, *_10 = NULL;
	zval *rawData = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &rawData_param);

	zephir_get_arrval(rawData, rawData_param);
	ZEPHIR_INIT_VAR(logId);
	ZVAL_STRING(logId, "", 1);
	ZEPHIR_INIT_VAR(message);
	ZVAL_STRING(message, "", 1);


	ZEPHIR_OBS_VAR(service);
	if (!(zephir_array_isset_string_fetch(&service, rawData, SS("service"), 0 TSRMLS_CC))) {
		ZEPHIR_INIT_VAR(_0);
		object_init_ex(_0, zend_exception_get_default(TSRMLS_C));
		ZEPHIR_INIT_VAR(_1);
		ZEPHIR_CONCAT_SVS(_1, "service ", service, " not exists");
		ZEPHIR_CALL_METHOD(NULL, _0, "__construct", &_2, _1);
		zephir_check_call_status();
		zephir_throw_exception_debug(_0, "phalconplus/RPC/Server/AbstractServer.zep", 78 TSRMLS_CC);
		ZEPHIR_MM_RESTORE();
		return;
	}
	ZEPHIR_OBS_VAR(method);
	if (!(zephir_array_isset_string_fetch(&method, rawData, SS("method"), 0 TSRMLS_CC))) {
		ZEPHIR_INIT_NVAR(_0);
		object_init_ex(_0, zend_exception_get_default(TSRMLS_C));
		ZEPHIR_INIT_LNVAR(_1);
		ZEPHIR_CONCAT_SVS(_1, "method ", method, " not exists");
		ZEPHIR_CALL_METHOD(NULL, _0, "__construct", &_2, _1);
		zephir_check_call_status();
		zephir_throw_exception_debug(_0, "phalconplus/RPC/Server/AbstractServer.zep", 82 TSRMLS_CC);
		ZEPHIR_MM_RESTORE();
		return;
	}
	ZEPHIR_OBS_VAR(request);
	if (!(zephir_array_isset_string_fetch(&request, rawData, SS("args"), 0 TSRMLS_CC))) {
		ZEPHIR_THROW_EXCEPTION_DEBUG_STR(zend_exception_get_default(TSRMLS_C), "args not exists", "phalconplus/RPC/Server/AbstractServer.zep", 86);
		return;
	}
	ZEPHIR_INIT_NVAR(_0);
	zephir_fast_trim(_0, service, NULL , ZEPHIR_TRIM_BOTH TSRMLS_CC);
	ZEPHIR_CPY_WRT(service, _0);
	ZEPHIR_INIT_NVAR(_0);
	zephir_fast_trim(_0, method, NULL , ZEPHIR_TRIM_BOTH TSRMLS_CC);
	ZEPHIR_CPY_WRT(method, _0);
	_3 = ZEPHIR_IS_EMPTY(service);
	if (!(_3)) {
		_3 = ZEPHIR_IS_EMPTY(method);
	}
	if (_3) {
		ZEPHIR_THROW_EXCEPTION_DEBUG_STR(zend_exception_get_default(TSRMLS_C), "service:method(args) must exists. All of them!!!", "phalconplus/RPC/Server/AbstractServer.zep", 93);
		return;
	}
	ZEPHIR_OBS_NVAR(logId);
	if (zephir_array_isset_string_fetch(&logId, rawData, SS("logId"), 0 TSRMLS_CC)) {
	}
	_4 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC);
	ZEPHIR_INIT_NVAR(_0);
	ZVAL_STRING(_0, "logger", ZEPHIR_TEMP_PARAM_COPY);
	ZEPHIR_CALL_METHOD(&_5, _4, "has", NULL, _0);
	zephir_check_temp_parameter(_0);
	zephir_check_call_status();
	if (zephir_is_true(_5)) {
		ZEPHIR_INIT_NVAR(_0);
		zephir_json_encode(_0, &(_0), request, 0  TSRMLS_CC);
		ZEPHIR_INIT_NVAR(message);
		ZEPHIR_CONCAT_SVSVSVSV(message, "RPC Request - logId: ", logId, ", invoke: ", service, "::", method, ", args: ", _0);
		_6 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC);
		ZEPHIR_INIT_VAR(_8);
		ZVAL_STRING(_8, "logger", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(&_7, _6, "get", NULL, _8);
		zephir_check_temp_parameter(_8);
		zephir_check_call_status();
		ZEPHIR_CALL_METHOD(NULL, _7, "log", NULL, message);
		zephir_check_call_status();
	}
	ZEPHIR_CALL_METHOD(&response, this_ptr, "callbyparams", NULL, service, method, request, rawData);
	zephir_check_call_status();
	_6 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC);
	ZEPHIR_INIT_NVAR(_0);
	ZVAL_STRING(_0, "logger", ZEPHIR_TEMP_PARAM_COPY);
	ZEPHIR_CALL_METHOD(&_7, _6, "has", NULL, _0);
	zephir_check_temp_parameter(_0);
	zephir_check_call_status();
	if (zephir_is_true(_7)) {
		ZEPHIR_INIT_NVAR(_0);
		zephir_json_encode(_0, &(_0), response, 0  TSRMLS_CC);
		ZEPHIR_INIT_NVAR(message);
		ZEPHIR_CONCAT_SVSVSVSV(message, "RPC Response - logId: ", logId, ", invoke: ", service, "::", method, ", response: ", _0);
		_9 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC);
		ZEPHIR_INIT_NVAR(_8);
		ZVAL_STRING(_8, "logger", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(&_10, _9, "get", NULL, _8);
		zephir_check_temp_parameter(_8);
		zephir_check_call_status();
		ZEPHIR_CALL_METHOD(NULL, _10, "log", NULL, message);
		zephir_check_call_status();
	}
	RETURN_CCTOR(response);

}
Пример #17
0
/**
 * @todo cas argument is inconsistent here
 *
 * @param \Ouchbase\Entity entity
 * @param string|null cas
 * @throws \Ouchbase\Exception\EntityLogicException
 * @throws \Ouchbase\Exception\EntityModifiedException
 * @return this
 */
PHP_METHOD(Ouchbase_Repository, update) {

	zend_class_entry *_8;
	zval *_5 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *entity = NULL, *cas = NULL, *_0 = NULL, *data = NULL, *originalData = NULL, *_1, *_2 = NULL, *_3 = NULL, *_4, *_6 = NULL, *e = NULL, *_7 = NULL, *ex;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 1, &entity, &cas);

	ZEPHIR_SEPARATE_PARAM(entity);
	if (!cas) {
		cas = ZEPHIR_GLOBAL(global_null);
	}


	if (!(zephir_instance_of_ev(entity, ouchbase_entity_ce TSRMLS_CC))) {
		ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_InvalidArgumentException, "Parameter 'entity' must be an instance of 'Ouchbase\\Entity'", "", 0);
		return;
	}
	if (zephir_instance_of_ev(entity, ouchbase_entityproxy_ce TSRMLS_CC)) {
		ZEPHIR_CALL_METHOD(&_0, entity, "isproxied",  NULL);
		zephir_check_call_status();
		if (!(zephir_is_true(_0))) {
			RETURN_THIS();
		}
		ZEPHIR_CALL_METHOD(&entity, entity, "_getobject",  NULL);
		zephir_check_call_status();
	}
	ZEPHIR_CALL_METHOD(&data, this_ptr, "toarray", NULL, entity);
	zephir_check_call_status();
	_1 = zephir_fetch_nproperty_this(this_ptr, SL("im"), PH_NOISY_CC);
	ZEPHIR_CALL_METHOD(&originalData, _1, "getoriginaldata", NULL, entity);
	zephir_check_call_status();
	if (!(zephir_is_true(originalData))) {
		ZEPHIR_INIT_VAR(_2);
		object_init_ex(_2, ouchbase_exception_entitylogicexception_ce);
		ZEPHIR_INIT_VAR(_3);
		ZVAL_STRING(_3, "was not registered in the identity map", 0);
		ZEPHIR_CALL_METHOD(NULL, _2, "__construct", NULL, entity, _3);
		zephir_check_temp_parameter(_3);
		zephir_check_call_status();
		zephir_throw_exception_debug(_2, "ouchbase/Repository.zep", 215 TSRMLS_CC);
		ZEPHIR_MM_RESTORE();
		return;
	}
	if (ZEPHIR_IS_EQUAL(data, originalData)) {
		RETURN_THIS();
	}
	_4 = zephir_fetch_nproperty_this(this_ptr, SL("im"), PH_NOISY_CC);
	ZEPHIR_CALL_METHOD(NULL, _4, "updateoriginaldata", NULL, entity, data);
	zephir_check_call_status();
	if (!(zephir_is_true(cas))) {
		ZEPHIR_INIT_VAR(_5);
		array_init_size(_5, 3);
		ZEPHIR_CALL_METHOD(&_6, entity, "getid",  NULL);
		zephir_check_call_status();
		ZEPHIR_CALL_METHOD(&_0, this_ptr, "getkey", NULL, _6);
		zephir_check_call_status();
		zephir_array_fast_append(_5, _0);
		ZEPHIR_INIT_NVAR(_3);
		zephir_json_encode(_3, &(_3), data, 0  TSRMLS_CC);
		zephir_array_fast_append(_5, _3);
		ZEPHIR_INIT_NVAR(_3);
		ZVAL_STRING(_3, "replace", 0);
		ZEPHIR_CALL_METHOD(NULL, this_ptr, "executewithouttimeouts", NULL, _3, _5);
		zephir_check_temp_parameter(_3);
		zephir_check_call_status();
		RETURN_THIS();
	}

	/* try_start_1: */

		ZEPHIR_INIT_NVAR(_5);
		array_init_size(_5, 6);
		ZEPHIR_CALL_METHOD(&_7, entity, "getid",  NULL);
		zephir_check_call_status_or_jump(try_end_1);
		ZEPHIR_CALL_METHOD(&_6, this_ptr, "getkey", NULL, _7);
		zephir_check_call_status_or_jump(try_end_1);
		zephir_array_fast_append(_5, _6);
		ZEPHIR_INIT_NVAR(_3);
		zephir_json_encode(_3, &(_3), data, 0  TSRMLS_CC);
		zephir_array_fast_append(_5, _3);
		ZEPHIR_INIT_NVAR(_3);
		ZVAL_LONG(_3, 0);
		zephir_array_fast_append(_5, _3);
		zephir_array_fast_append(_5, cas);
		ZEPHIR_INIT_NVAR(_3);
		ZVAL_STRING(_3, "replace", 0);
		ZEPHIR_CALL_METHOD(&_0, this_ptr, "executewithouttimeouts", NULL, _3, _5);
		zephir_check_temp_parameter(_3);
		zephir_check_call_status_or_jump(try_end_1);
		if (!(zephir_is_true(_0))) {
			ZEPHIR_INIT_LNVAR(_2);
			_8 = zend_fetch_class(SL("CouchbaseKeyMutatedException"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC);
			object_init_ex(_2, _8);
			ZEPHIR_CALL_METHOD(NULL, _2, "__construct", NULL);
			zephir_check_call_status_or_jump(try_end_1);
			zephir_throw_exception_debug(_2, "ouchbase/Repository.zep", 233 TSRMLS_CC);
			goto try_end_1;

		}
		RETURN_THIS();

	try_end_1:

	ZEPHIR_CPY_WRT(e, EG(exception));
	if (zephir_is_instance_of(e, SL("CouchbaseKeyMutatedException") TSRMLS_CC)) {
		zend_clear_exception(TSRMLS_C);
		ZEPHIR_INIT_VAR(ex);
		object_init_ex(ex, ouchbase_exception_entitymodifiedexception_ce);
		ZEPHIR_INIT_NVAR(_3);
		ZVAL_STRING(_3, "was modified", 0);
		ZEPHIR_CALL_METHOD(NULL, ex, "__construct", NULL, entity, _3);
		zephir_check_temp_parameter(_3);
		zephir_check_call_status();
		ZEPHIR_INIT_NVAR(_3);
		ZVAL_STRING(_3, "update", 0);
		ZEPHIR_CALL_METHOD(NULL, ex, "setaction", NULL, _3);
		zephir_check_temp_parameter(_3);
		zephir_check_call_status();
		zephir_throw_exception_debug(ex, "ouchbase/Repository.zep", 242 TSRMLS_CC);
		ZEPHIR_MM_RESTORE();
		return;
	}
	RETURN_THIS();

}
Пример #18
0
PHP_METHOD(PhalconPlus_RPC_Server_AbstractServer, callByParams) {

	zend_class_entry *_10, *_17;
	zephir_nts_static zephir_fcall_cache_entry *_5 = NULL, *_7 = NULL, *_13 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *_3 = NULL, *_18, *_19;
	zend_bool _2;
	zval *service_param = NULL, *method_param = NULL, *request = NULL, *rawData, *serviceClass = NULL, *_0 = NULL, *_1, *tmp = NULL, *param, *paramClass = NULL, *_4 = NULL, *_6 = NULL, *_8 = NULL, *_9 = NULL, *_11 = NULL, *_12 = NULL, *_14, *_15, *serviceObj, *response = NULL, *e = NULL, *_16 = NULL, *_20;
	zval *service = NULL, *method = NULL, *_21;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 4, 0, &service_param, &method_param, &request, &rawData);

	if (unlikely(Z_TYPE_P(service_param) != IS_STRING && Z_TYPE_P(service_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'service' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}

	if (likely(Z_TYPE_P(service_param) == IS_STRING)) {
		zephir_get_strval(service, service_param);
	} else {
		ZEPHIR_INIT_VAR(service);
		ZVAL_EMPTY_STRING(service);
	}
	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_INIT_VAR(serviceClass);
	ZVAL_STRING(serviceClass, "", 1);
	ZEPHIR_INIT_VAR(tmp);
	array_init(tmp);


	ZEPHIR_INIT_VAR(_1);
	zephir_ucfirst(_1, service);
	ZEPHIR_INIT_NVAR(serviceClass);
	ZEPHIR_CONCAT_VS(serviceClass, _1, "Service");
	_2 = Z_TYPE_P(request) == IS_OBJECT;
	if (_2) {
		_2 = zephir_instance_of_ev(request, phalconplus_base_protobuffer_ce TSRMLS_CC);
	}
	if (_2) {
		zephir_update_property_this(this_ptr, SL("phpOnly"), (1) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC);
	} else if (Z_TYPE_P(request) == IS_ARRAY) {
		ZEPHIR_CPY_WRT(tmp, request);
		ZEPHIR_INIT_VAR(param);
		object_init_ex(param, zephir_get_internal_ce(SS("reflectionparameter") TSRMLS_CC));
		ZEPHIR_INIT_VAR(_3);
		zephir_create_array(_3, 2, 0 TSRMLS_CC);
		zephir_array_fast_append(_3, serviceClass);
		zephir_array_fast_append(_3, method);
		ZEPHIR_INIT_VAR(_4);
		ZVAL_LONG(_4, 0);
		ZEPHIR_CALL_METHOD(NULL, param, "__construct", &_5, _3, _4);
		zephir_check_call_status();
		ZEPHIR_CALL_METHOD(&_6, param, "getclass", &_7);
		zephir_check_call_status();
		if (zephir_is_true(_6)) {
			ZEPHIR_CALL_METHOD(&_8, param, "getclass", &_7);
			zephir_check_call_status();
			ZEPHIR_CALL_METHOD(&paramClass, _8, "getname", NULL);
			zephir_check_call_status();
			ZEPHIR_INIT_NVAR(request);
			zephir_fetch_safe_class(_9, paramClass);
			_10 = zend_fetch_class(Z_STRVAL_P(_9), Z_STRLEN_P(_9), ZEND_FETCH_CLASS_AUTO TSRMLS_CC);
			object_init_ex(request, _10);
			if (zephir_has_constructor(request TSRMLS_CC)) {
				ZEPHIR_CALL_METHOD(NULL, request, "__construct", NULL);
				zephir_check_call_status();
			}
			ZEPHIR_CALL_METHOD(NULL, request, "softclone", NULL, tmp);
			zephir_check_call_status();
		} else {
			ZEPHIR_INIT_NVAR(_4);
			object_init_ex(_4, zend_exception_get_default(TSRMLS_C));
			ZEPHIR_INIT_VAR(_11);
			zephir_json_encode(_11, &(_11), request, 0  TSRMLS_CC);
			ZEPHIR_INIT_VAR(_12);
			ZEPHIR_CONCAT_SVSVSV(_12, "Service class:method definition is invalid. Detail: ", service, " : ", method, ". Request: ", _11);
			ZEPHIR_CALL_METHOD(NULL, _4, "__construct", &_13, _12);
			zephir_check_call_status();
			zephir_throw_exception_debug(_4, "phalconplus/RPC/Server/AbstractServer.zep", 36 TSRMLS_CC);
			ZEPHIR_MM_RESTORE();
			return;
		}
	} else {
		ZEPHIR_INIT_NVAR(_4);
		object_init_ex(_4, zend_exception_get_default(TSRMLS_C));
		ZEPHIR_INIT_NVAR(_11);
		zephir_json_encode(_11, &(_11), request, 0  TSRMLS_CC);
		ZEPHIR_INIT_LNVAR(_12);
		ZEPHIR_CONCAT_SV(_12, "Your input is not allowed. Request: ", _11);
		ZEPHIR_CALL_METHOD(NULL, _4, "__construct", &_13, _12);
		zephir_check_call_status();
		zephir_throw_exception_debug(_4, "phalconplus/RPC/Server/AbstractServer.zep", 39 TSRMLS_CC);
		ZEPHIR_MM_RESTORE();
		return;
	}
	_14 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC);
	ZEPHIR_INIT_NVAR(_4);
	ZVAL_STRING(_4, "requestCheck", ZEPHIR_TEMP_PARAM_COPY);
	ZEPHIR_CALL_METHOD(&_6, _14, "has", NULL, _4);
	zephir_check_temp_parameter(_4);
	zephir_check_call_status();
	if (zephir_is_true(_6)) {
		_15 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC);
		ZEPHIR_INIT_NVAR(_3);
		zephir_create_array(_3, 3, 0 TSRMLS_CC);
		zephir_array_fast_append(_3, serviceClass);
		zephir_array_fast_append(_3, method);
		zephir_array_fast_append(_3, rawData);
		ZEPHIR_INIT_NVAR(_4);
		ZVAL_STRING(_4, "requestCheck", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(NULL, _15, "get", NULL, _4, _3);
		zephir_check_temp_parameter(_4);
		zephir_check_call_status();
	} else {
		ZEPHIR_CALL_METHOD(NULL, this_ptr, "requestcheck", NULL, serviceClass, method, request);
		zephir_check_call_status();
	}
	ZEPHIR_INIT_VAR(serviceObj);
	zephir_fetch_safe_class(_16, serviceClass);
	_17 = zend_fetch_class(Z_STRVAL_P(_16), Z_STRLEN_P(_16), ZEND_FETCH_CLASS_AUTO TSRMLS_CC);
	object_init_ex(serviceObj, _17);
	if (zephir_has_constructor(serviceObj TSRMLS_CC)) {
		_15 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC);
		ZEPHIR_CALL_METHOD(NULL, serviceObj, "__construct", NULL, _15);
		zephir_check_call_status();
	}
	ZEPHIR_INIT_NVAR(_3);
	zephir_create_array(_3, 2, 0 TSRMLS_CC);
	zephir_array_fast_append(_3, serviceObj);
	zephir_array_fast_append(_3, method);
	if (zephir_is_callable(_3 TSRMLS_CC)) {

		/* try_start_1: */

			ZEPHIR_INIT_NVAR(_4);
			ZEPHIR_INIT_VAR(_18);
			zephir_create_array(_18, 2, 0 TSRMLS_CC);
			zephir_array_fast_append(_18, serviceObj);
			zephir_array_fast_append(_18, method);
			ZEPHIR_INIT_VAR(_19);
			zephir_create_array(_19, 1, 0 TSRMLS_CC);
			zephir_array_fast_append(_19, request);
			ZEPHIR_CALL_USER_FUNC_ARRAY(_4, _18, _19);
			zephir_check_call_status_or_jump(try_end_1);
			ZEPHIR_CPY_WRT(response, _4);

		try_end_1:

		if (EG(exception)) {
			ZEPHIR_CPY_WRT(e, EG(exception));
			if (zephir_instance_of_ev(e, zend_exception_get_default(TSRMLS_C) TSRMLS_CC)) {
				zend_clear_exception(TSRMLS_C);
				zephir_throw_exception_debug(e, "phalconplus/RPC/Server/AbstractServer.zep", 55 TSRMLS_CC);
				ZEPHIR_MM_RESTORE();
				return;
			}
		}
		ZEPHIR_INIT_NVAR(_4);
		_20 = zephir_fetch_nproperty_this(this_ptr, SL("phpOnly"), PH_NOISY_CC);
		if (ZEPHIR_IS_TRUE(_20)) {
			ZEPHIR_CPY_WRT(_4, response);
		} else {
			ZEPHIR_CALL_METHOD(&_4, response, "toarray", NULL);
			zephir_check_call_status();
		}
		RETURN_CCTOR(_4);
	} else {
		object_init_ex(_4, zend_exception_get_default(TSRMLS_C));
		ZEPHIR_INIT_VAR(_21);
		ZEPHIR_CONCAT_SVSV(_21, "Service:method not found. Detail: ", service, " : ", method);
		ZEPHIR_CALL_METHOD(NULL, _4, "__construct", &_13, _21);
		zephir_check_call_status();
		zephir_throw_exception_debug(_4, "phalconplus/RPC/Server/AbstractServer.zep", 59 TSRMLS_CC);
		ZEPHIR_MM_RESTORE();
		return;
	}

}
Пример #19
0
/**
 * Applies a format to a message before sending it to the log
 *
 * @param string $message
 * @param int $type
 * @param int $timestamp
 * @param array $context
 *
 * @return string
 */
PHP_METHOD(Phalcon_Logger_Formatter_Firephp, format) {

	zval *_18;
	HashTable *_7;
	HashPosition _6;
	zend_bool param, _11, _14;
	int type, timestamp, ZEPHIR_LAST_CALL_STATUS;
	zval *message_param = NULL, *type_param = NULL, *timestamp_param = NULL, *context = NULL, *meta, *body = NULL, *backtrace = NULL, *encoded, *len, *lastTrace = NULL, *_0 = NULL, *_1 = NULL, *_2, *backtraceItem = NULL, *key = NULL, _3, _4, *_5, **_8, *_9, *_10, *_12, *_13, *_15, *_16, *_17;
	zval *message = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 3, 1, &message_param, &type_param, &timestamp_param, &context);

	zephir_get_strval(message, message_param);
	type = zephir_get_intval(type_param);
	timestamp = zephir_get_intval(timestamp_param);
	if (!context) {
		context = ZEPHIR_GLOBAL(global_null);
	}


	if (Z_TYPE_P(context) == IS_ARRAY) {
		ZEPHIR_CALL_METHOD(&_0, this_ptr, "interpolate", NULL, 0, message, context);
		zephir_check_call_status();
		zephir_get_strval(message, _0);
	}
	ZEPHIR_INIT_VAR(meta);
	zephir_create_array(meta, 1, 0 TSRMLS_CC);
	ZEPHIR_INIT_VAR(_1);
	ZVAL_LONG(_1, type);
	ZEPHIR_CALL_METHOD(&_0, this_ptr, "gettypestring", NULL, 0, _1);
	zephir_check_call_status();
	zephir_array_update_string(&meta, SL("Type"), &_0, PH_COPY | PH_SEPARATE);
	_2 = zephir_fetch_nproperty_this(this_ptr, SL("_showBacktrace"), PH_NOISY_CC);
	if (zephir_is_true(_2)) {
		param = 0;
		ZEPHIR_INIT_NVAR(_1);
		ZEPHIR_GET_CONSTANT(_1, "PHP_VERSION");
		ZEPHIR_SINIT_VAR(_3);
		ZVAL_STRING(&_3, "5.3.6", 0);
		ZEPHIR_SINIT_VAR(_4);
		ZVAL_STRING(&_4, "<", 0);
		ZEPHIR_CALL_FUNCTION(&_0, "version_compare", NULL, 248, _1, &_3, &_4);
		zephir_check_call_status();
		if (!(zephir_is_true(_0))) {
			param = (2) ? 1 : 0;
		}
		ZEPHIR_CALL_FUNCTION(&backtrace, "debug_backtrace", NULL, 150, (param ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false)));
		zephir_check_call_status();
		Z_SET_ISREF_P(backtrace);
		ZEPHIR_CALL_FUNCTION(&lastTrace, "end", NULL, 170, backtrace);
		Z_UNSET_ISREF_P(backtrace);
		zephir_check_call_status();
		if (zephir_array_isset_string(lastTrace, SS("file"))) {
			zephir_array_fetch_string(&_5, lastTrace, SL("file"), PH_NOISY | PH_READONLY, "phalcon/logger/formatter/firephp.zep", 133 TSRMLS_CC);
			zephir_array_update_string(&meta, SL("File"), &_5, PH_COPY | PH_SEPARATE);
		}
		if (zephir_array_isset_string(lastTrace, SS("line"))) {
			zephir_array_fetch_string(&_5, lastTrace, SL("line"), PH_NOISY | PH_READONLY, "phalcon/logger/formatter/firephp.zep", 137 TSRMLS_CC);
			zephir_array_update_string(&meta, SL("Line"), &_5, PH_COPY | PH_SEPARATE);
		}
		zephir_is_iterable(backtrace, &_7, &_6, 1, 0, "phalcon/logger/formatter/firephp.zep", 146);
		for (
		  ; zephir_hash_get_current_data_ex(_7, (void**) &_8, &_6) == SUCCESS
		  ; zephir_hash_move_forward_ex(_7, &_6)
		) {
			ZEPHIR_GET_HMKEY(key, _7, _6);
			ZEPHIR_GET_HVALUE(backtraceItem, _8);
			zephir_array_unset_string(&backtraceItem, SS("object"), PH_SEPARATE);
			zephir_array_unset_string(&backtraceItem, SS("args"), PH_SEPARATE);
			zephir_array_update_zval(&backtrace, key, &backtraceItem, PH_COPY | PH_SEPARATE);
		}
	}
	_9 = zephir_fetch_nproperty_this(this_ptr, SL("_enableLabels"), PH_NOISY_CC);
	if (zephir_is_true(_9)) {
		zephir_array_update_string(&meta, SL("Label"), &message, PH_COPY | PH_SEPARATE);
	}
	_10 = zephir_fetch_nproperty_this(this_ptr, SL("_enableLabels"), PH_NOISY_CC);
	_11 = !zephir_is_true(_10);
	if (_11) {
		_12 = zephir_fetch_nproperty_this(this_ptr, SL("_showBacktrace"), PH_NOISY_CC);
		_11 = !zephir_is_true(_12);
	}
	_13 = zephir_fetch_nproperty_this(this_ptr, SL("_enableLabels"), PH_NOISY_CC);
	_14 = zephir_is_true(_13);
	if (_14) {
		_15 = zephir_fetch_nproperty_this(this_ptr, SL("_showBacktrace"), PH_NOISY_CC);
		_14 = !zephir_is_true(_15);
	}
	if (_11) {
		ZEPHIR_CPY_WRT(body, message);
	} else if (_14) {
		ZEPHIR_INIT_NVAR(body);
		ZVAL_STRING(body, "", 1);
	} else {
		ZEPHIR_INIT_NVAR(body);
		array_init(body);
		_16 = zephir_fetch_nproperty_this(this_ptr, SL("_showBacktrace"), PH_NOISY_CC);
		if (zephir_is_true(_16)) {
			zephir_array_update_string(&body, SL("backtrace"), &backtrace, PH_COPY | PH_SEPARATE);
		}
		_17 = zephir_fetch_nproperty_this(this_ptr, SL("_enableLabels"), PH_NOISY_CC);
		if (!(zephir_is_true(_17))) {
			zephir_array_update_string(&body, SL("message"), &message, PH_COPY | PH_SEPARATE);
		}
	}
	ZEPHIR_INIT_VAR(_18);
	zephir_create_array(_18, 2, 0 TSRMLS_CC);
	zephir_array_fast_append(_18, meta);
	zephir_array_fast_append(_18, body);
	ZEPHIR_INIT_VAR(encoded);
	zephir_json_encode(encoded, &(encoded), _18, 0  TSRMLS_CC);
	ZEPHIR_INIT_VAR(len);
	ZVAL_LONG(len, zephir_fast_strlen_ev(encoded));
	ZEPHIR_CONCAT_VSVS(return_value, len, "|", encoded, "|");
	RETURN_MM();

}
Пример #20
0
/**
 * Applies a format to a message before sending it to the log
 *
 * @param string $message
 * @param int $type
 * @param int $timestamp
 * @param array $context
 *
 * @return string
 */
PHP_METHOD(Phalcon_Logger_Formatter_Firephp, format) {

	HashTable *_7$$4;
	HashPosition _6$$4;
	zval *_18;
	zend_bool _11, _14;
	zend_long type, timestamp, ZEPHIR_LAST_CALL_STATUS;
	zval *message_param = NULL, *type_param = NULL, *timestamp_param = NULL, *context = NULL, *meta = NULL, *body = NULL, *backtrace = NULL, *encoded = NULL, *len = NULL, *lastTrace = NULL, *_1 = NULL, *_2, *_3, *_9, *_10, *_12, *_13, *_15, *_0$$3 = NULL, *param$$4 = NULL, *backtraceItem$$4 = NULL, *key$$4 = NULL, **_8$$4, *_4$$5, *_5$$6, *_16$$11, *_17$$11;
	zval *message = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 3, 1, &message_param, &type_param, &timestamp_param, &context);

	zephir_get_strval(message, message_param);
	type = zephir_get_intval(type_param);
	timestamp = zephir_get_intval(timestamp_param);
	if (!context) {
		context = ZEPHIR_GLOBAL(global_null);
	}


	if (Z_TYPE_P(context) == IS_ARRAY) {
		ZEPHIR_CALL_METHOD(&_0$$3, this_ptr, "interpolate", NULL, 0, message, context);
		zephir_check_call_status();
		zephir_get_strval(message, _0$$3);
	}
	ZEPHIR_INIT_VAR(meta);
	zephir_create_array(meta, 1, 0 TSRMLS_CC);
	ZEPHIR_INIT_VAR(_2);
	ZVAL_LONG(_2, type);
	ZEPHIR_CALL_METHOD(&_1, this_ptr, "gettypestring", NULL, 0, _2);
	zephir_check_call_status();
	zephir_array_update_string(&meta, SL("Type"), &_1, PH_COPY | PH_SEPARATE);
	_3 = zephir_fetch_nproperty_this(this_ptr, SL("_showBacktrace"), PH_NOISY_CC);
	if (zephir_is_true(_3)) {
		ZEPHIR_INIT_VAR(param$$4);
		ZVAL_LONG(param$$4, 2);
		ZEPHIR_CALL_FUNCTION(&backtrace, "debug_backtrace", NULL, 165, param$$4);
		zephir_check_call_status();
		ZEPHIR_MAKE_REF(backtrace);
		ZEPHIR_CALL_FUNCTION(&lastTrace, "end", NULL, 183, backtrace);
		ZEPHIR_UNREF(backtrace);
		zephir_check_call_status();
		if (zephir_array_isset_string(lastTrace, SS("file"))) {
			zephir_array_fetch_string(&_4$$5, lastTrace, SL("file"), PH_NOISY | PH_READONLY, "phalcon/logger/formatter/firephp.zep", 130 TSRMLS_CC);
			zephir_array_update_string(&meta, SL("File"), &_4$$5, PH_COPY | PH_SEPARATE);
		}
		if (zephir_array_isset_string(lastTrace, SS("line"))) {
			zephir_array_fetch_string(&_5$$6, lastTrace, SL("line"), PH_NOISY | PH_READONLY, "phalcon/logger/formatter/firephp.zep", 134 TSRMLS_CC);
			zephir_array_update_string(&meta, SL("Line"), &_5$$6, PH_COPY | PH_SEPARATE);
		}
		zephir_is_iterable(backtrace, &_7$$4, &_6$$4, 1, 0, "phalcon/logger/formatter/firephp.zep", 143);
		for (
		  ; zend_hash_get_current_data_ex(_7$$4, (void**) &_8$$4, &_6$$4) == SUCCESS
		  ; zend_hash_move_forward_ex(_7$$4, &_6$$4)
		) {
			ZEPHIR_GET_HMKEY(key$$4, _7$$4, _6$$4);
			ZEPHIR_GET_HVALUE(backtraceItem$$4, _8$$4);
			zephir_array_unset_string(&backtraceItem$$4, SS("object"), PH_SEPARATE);
			zephir_array_unset_string(&backtraceItem$$4, SS("args"), PH_SEPARATE);
			zephir_array_update_zval(&backtrace, key$$4, &backtraceItem$$4, PH_COPY | PH_SEPARATE);
		}
		zend_hash_destroy(_7$$4);
		FREE_HASHTABLE(_7$$4);
	}
	_9 = zephir_fetch_nproperty_this(this_ptr, SL("_enableLabels"), PH_NOISY_CC);
	if (zephir_is_true(_9)) {
		zephir_array_update_string(&meta, SL("Label"), &message, PH_COPY | PH_SEPARATE);
	}
	_10 = zephir_fetch_nproperty_this(this_ptr, SL("_enableLabels"), PH_NOISY_CC);
	_11 = !zephir_is_true(_10);
	if (_11) {
		_12 = zephir_fetch_nproperty_this(this_ptr, SL("_showBacktrace"), PH_NOISY_CC);
		_11 = !zephir_is_true(_12);
	}
	_13 = zephir_fetch_nproperty_this(this_ptr, SL("_enableLabels"), PH_NOISY_CC);
	_14 = zephir_is_true(_13);
	if (_14) {
		_15 = zephir_fetch_nproperty_this(this_ptr, SL("_showBacktrace"), PH_NOISY_CC);
		_14 = !zephir_is_true(_15);
	}
	if (_11) {
		ZEPHIR_CPY_WRT(body, message);
	} else if (_14) {
		ZEPHIR_INIT_NVAR(body);
		ZVAL_STRING(body, "", 1);
	} else {
		ZEPHIR_INIT_NVAR(body);
		array_init(body);
		_16$$11 = zephir_fetch_nproperty_this(this_ptr, SL("_showBacktrace"), PH_NOISY_CC);
		if (zephir_is_true(_16$$11)) {
			zephir_array_update_string(&body, SL("backtrace"), &backtrace, PH_COPY | PH_SEPARATE);
		}
		_17$$11 = zephir_fetch_nproperty_this(this_ptr, SL("_enableLabels"), PH_NOISY_CC);
		if (!(zephir_is_true(_17$$11))) {
			zephir_array_update_string(&body, SL("message"), &message, PH_COPY | PH_SEPARATE);
		}
	}
	ZEPHIR_INIT_VAR(_18);
	zephir_create_array(_18, 2, 0 TSRMLS_CC);
	zephir_array_fast_append(_18, meta);
	zephir_array_fast_append(_18, body);
	ZEPHIR_INIT_VAR(encoded);
	zephir_json_encode(encoded, &(encoded), _18, 0  TSRMLS_CC);
	ZEPHIR_INIT_VAR(len);
	ZVAL_LONG(len, zephir_fast_strlen_ev(encoded));
	ZEPHIR_CONCAT_VSVS(return_value, len, "|", encoded, "|");
	RETURN_MM();

}
Пример #21
0
PHP_METHOD(PhalconPlus_Db_Mysql, getConnection) {

	zephir_nts_static zephir_fcall_cache_entry *_4 = NULL, *_7 = NULL;
	zephir_fcall_cache_entry *_1 = NULL;
	int ZEPHIR_LAST_CALL_STATUS, _5;
	zval *connection = NULL, *tryTimes = NULL, *e = NULL, *_0, *_2 = NULL, *_3 = NULL, _6 = zval_used_for_init;

	ZEPHIR_MM_GROW();
	ZEPHIR_INIT_VAR(connection);
	ZVAL_NULL(connection);

	ZEPHIR_INIT_VAR(tryTimes);
	ZVAL_LONG(tryTimes, 5);
	while (1) {
		if (!(!(Z_TYPE_P(connection) == IS_OBJECT))) {
			break;
		}

		/* try_start_1: */

			ZEPHIR_INIT_NVAR(connection);
			object_init_ex(connection, zephir_get_internal_ce(SS("phalcon\\db\\adapter\\pdo\\mysql") TSRMLS_CC));
			_0 = zephir_fetch_nproperty_this(this_ptr, SL("descriptor"), PH_NOISY_CC);
			ZEPHIR_CALL_METHOD(NULL, connection, "__construct", &_1, _0);
			zephir_check_call_status_or_jump(try_end_1);

		try_end_1:

		if (EG(exception)) {
			ZEPHIR_CPY_WRT(e, EG(exception));
			if (zephir_is_instance_of(e, SL("PhalconPlus\\Db\\Exception") TSRMLS_CC)) {
				zend_clear_exception(TSRMLS_C);
				ZEPHIR_INIT_NVAR(_2);
				_0 = zephir_fetch_nproperty_this(this_ptr, SL("descriptor"), PH_NOISY_CC);
				zephir_json_encode(_2, &(_2), _0, 0  TSRMLS_CC);
				ZEPHIR_INIT_LNVAR(_3);
				ZEPHIR_CONCAT_SV(_3, "PHP Fatal error:  PhalconPlus::Db::MySQL::connect() failed to connect to MySQL. Detail: ", _2);
				ZEPHIR_CALL_FUNCTION(NULL, "error_log", &_4, _3);
				zephir_check_call_status();
				_5 = (zephir_get_numberval(tryTimes) - 1);
				ZEPHIR_INIT_NVAR(tryTimes);
				ZVAL_LONG(tryTimes, _5);
				if (ZEPHIR_GT_LONG(tryTimes, 0)) {
					ZEPHIR_SINIT_NVAR(_6);
					ZVAL_LONG(&_6, 100000);
					ZEPHIR_CALL_FUNCTION(NULL, "usleep", &_7, &_6);
					zephir_check_call_status();
					ZEPHIR_SINIT_NVAR(_6);
					ZVAL_STRING(&_6, "PHP Notice:  PhalconPlus::Db::MySQL::connnect() retry to connect to MySQL for the time ... ", 0);
					ZEPHIR_CALL_FUNCTION(NULL, "error_log", &_4, &_6);
					zephir_check_call_status();
				} else {
					ZEPHIR_SINIT_NVAR(_6);
					ZVAL_STRING(&_6, "PHP Fatal error:  PhalconPlus::Db::MySQL::connect() finally failed to connect to MySQL", 0);
					ZEPHIR_CALL_FUNCTION(NULL, "error_log", &_4, &_6);
					zephir_check_call_status();
					zephir_throw_exception_debug(e, "phalconplus/Db/Mysql.zep", 52 TSRMLS_CC);
					ZEPHIR_MM_RESTORE();
					return;
				}
			}
		}
	}
	RETURN_CCTOR(connection);

}
Пример #22
0
PHP_METHOD(PhalconPlus_Base_Exception, __construct) {

	zend_long ZEPHIR_LAST_CALL_STATUS;
	zval *info = NULL, info_sub, *logger = NULL, logger_sub, __$null, message, args, _0, _12, cnt, argsCnt, _13, _14, _1$$4, _2$$4, _3$$4, _4$$5, _5$$5, _6$$5, _7$$6, _8$$7, _9$$7, _10$$7, _11$$7, _15$$9, _16$$9;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&info_sub);
	ZVAL_UNDEF(&logger_sub);
	ZVAL_NULL(&__$null);
	ZVAL_UNDEF(&message);
	ZVAL_UNDEF(&args);
	ZVAL_UNDEF(&_0);
	ZVAL_UNDEF(&_12);
	ZVAL_UNDEF(&cnt);
	ZVAL_UNDEF(&argsCnt);
	ZVAL_UNDEF(&_13);
	ZVAL_UNDEF(&_14);
	ZVAL_UNDEF(&_1$$4);
	ZVAL_UNDEF(&_2$$4);
	ZVAL_UNDEF(&_3$$4);
	ZVAL_UNDEF(&_4$$5);
	ZVAL_UNDEF(&_5$$5);
	ZVAL_UNDEF(&_6$$5);
	ZVAL_UNDEF(&_7$$6);
	ZVAL_UNDEF(&_8$$7);
	ZVAL_UNDEF(&_9$$7);
	ZVAL_UNDEF(&_10$$7);
	ZVAL_UNDEF(&_11$$7);
	ZVAL_UNDEF(&_15$$9);
	ZVAL_UNDEF(&_16$$9);

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 0, 2, &info, &logger);

	if (!info) {
		info = &info_sub;
		ZEPHIR_INIT_VAR(info);
		ZVAL_STRING(info, "");
	}
	if (!logger) {
		logger = &logger_sub;
		logger = &__$null;
	}


	ZEPHIR_INIT_VAR(&message);
	ZVAL_STRING(&message, "");
	ZEPHIR_INIT_VAR(&args);
	array_init(&args);
	ZEPHIR_INIT_VAR(&_0);
	zephir_get_called_class(&_0 TSRMLS_CC);
	ZEPHIR_INIT_NVAR(&message);
	ZEPHIR_CONCAT_SV(&message, "An exception created: ", &_0);
	if (ZEPHIR_IS_EMPTY(info)) {
	} else {
		if (Z_TYPE_P(info) == IS_ARRAY) {
			zephir_array_fetch_long(&_1$$4, info, 0, PH_NOISY | PH_READONLY, "phalconplus/Base/Exception.zep", 22 TSRMLS_CC);
			ZEPHIR_CALL_FUNCTION(&_2$$4, "strval", NULL, 27, &_1$$4);
			zephir_check_call_status();
			ZEPHIR_INIT_VAR(&_3$$4);
			ZEPHIR_CONCAT_VSV(&_3$$4, &message, ", message: ", &_2$$4);
			ZEPHIR_CPY_WRT(&message, &_3$$4);
			ZEPHIR_OBS_NVAR(&args);
			if (zephir_array_isset_long_fetch(&args, info, 1, 0 TSRMLS_CC)) {
				zephir_array_fetch_long(&_4$$5, info, 1, PH_NOISY | PH_READONLY, "phalconplus/Base/Exception.zep", 24 TSRMLS_CC);
				if (Z_TYPE_P(&_4$$5) == IS_ARRAY) {
					ZEPHIR_OBS_NVAR(&args);
					zephir_array_fetch_long(&args, info, 1, PH_NOISY, "phalconplus/Base/Exception.zep", 24 TSRMLS_CC);
				} else {
					ZEPHIR_INIT_NVAR(&args);
					zephir_create_array(&args, 1, 0 TSRMLS_CC);
					zephir_array_fetch_long(&_5$$5, info, 1, PH_NOISY | PH_READONLY, "phalconplus/Base/Exception.zep", 24 TSRMLS_CC);
					ZEPHIR_CALL_FUNCTION(&_6$$5, "strval", NULL, 27, &_5$$5);
					zephir_check_call_status();
					zephir_array_fast_append(&args, &_6$$5);
				}
			}
		} else if (Z_TYPE_P(info) == IS_STRING) {
			ZEPHIR_INIT_VAR(&_7$$6);
			ZEPHIR_CONCAT_VSV(&_7$$6, &message, ", message: ", info);
			ZEPHIR_CPY_WRT(&message, &_7$$6);
		}
	}
	if (!(Z_TYPE_P(logger) == IS_NULL)) {
		ZEPHIR_INIT_VAR(&_8$$7);
		ZVAL_LONG(&_9$$7, 256);
		zephir_json_encode(&_8$$7, &args, zephir_get_intval(&_9$$7) );
		ZEPHIR_INIT_VAR(&_10$$7);
		ZEPHIR_CONCAT_VSV(&_10$$7, &message, ", args: ", &_8$$7);
		ZEPHIR_CALL_METHOD(&_11$$7, this_ptr, "getlevel", NULL, 0);
		zephir_check_call_status();
		ZEPHIR_CALL_METHOD(NULL, logger, "log", NULL, 0, &_10$$7, &_11$$7);
		zephir_check_call_status();
	}
	zephir_read_property(&_12, this_ptr, SL("message"), PH_NOISY_CC | PH_READONLY);
	if (ZEPHIR_IS_EMPTY(&_12)) {
		zephir_update_property_zval(this_ptr, SL("message"), &message);
	}
	zephir_read_property(&_13, this_ptr, SL("message"), PH_NOISY_CC | PH_READONLY);
	ZEPHIR_INIT_VAR(&_14);
	ZVAL_STRING(&_14, "%s");
	ZEPHIR_CALL_FUNCTION(&cnt, "substr_count", NULL, 28, &_13, &_14);
	zephir_check_call_status();
	ZEPHIR_INIT_VAR(&argsCnt);
	ZVAL_LONG(&argsCnt, zephir_fast_count_int(&args TSRMLS_CC));
	if (ZEPHIR_GE(&argsCnt, &cnt)) {
		zephir_read_property(&_15$$9, this_ptr, SL("message"), PH_NOISY_CC | PH_READONLY);
		ZEPHIR_CALL_FUNCTION(&_16$$9, "vsprintf", NULL, 29, &_15$$9, &args);
		zephir_check_call_status();
		zephir_update_property_zval(this_ptr, SL("message"), &_16$$9);
	}
	ZEPHIR_MM_RESTORE();

}