Exemplo n.º 1
0
PHP_METHOD(Test_BuiltIn_StringMethods, getParsedJson) {

	zend_bool assoc;
	zval *str_param = NULL, *assoc_param = NULL, _0, _1;
	zval str;
		zval this_zv;
	zval *this_ptr = getThis();
	if (EXPECTED(this_ptr)) {
		ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr));
		this_ptr = &this_zv;
	} else this_ptr = NULL;
	
	ZVAL_UNDEF(&str);
	ZVAL_UNDEF(&_0);
	ZVAL_UNDEF(&_1);

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 1, &str_param, &assoc_param);

	zephir_get_strval(&str, str_param);
	if (!assoc_param) {
		assoc = 1;
	} else {
		assoc = zephir_get_boolval(assoc_param);
	}


	ZEPHIR_INIT_VAR(&_0);
	ZVAL_BOOL(&_1, (assoc ? 1 : 0));
	zephir_json_decode(&_0, &str, zephir_get_intval(&str) );
	RETURN_CCTOR(_0);

}
Exemplo n.º 2
0
/**
 * Execute parsing
 *
 * @param string input
 * @return mixed
 */
PHP_METHOD(Phal_Format_Reader_AbstractJsonReader, execute) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *input_param = NULL, *data;
	zval *input = NULL;

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

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

	if (unlikely(Z_TYPE_P(input_param) == IS_STRING)) {
		input = input_param;
	} else {
		ZEPHIR_INIT_VAR(input);
		ZVAL_EMPTY_STRING(input);
	}


	ZEPHIR_INIT_VAR(data);
	zephir_json_decode(data, &(data), input, zephir_get_intval(ZEPHIR_GLOBAL(global_true))  TSRMLS_CC);
	ZEPHIR_RETURN_CALL_METHOD(this_ptr, "arraytoresource", NULL, data);
	zephir_check_call_status();
	RETURN_MM();

}
Exemplo n.º 3
0
/**
 * Phalcon\Config\Adapter\Json constructor
 */
PHP_METHOD(Phalcon_Config_Adapter_Json, __construct) {

	int ZEPHIR_LAST_CALL_STATUS;
	zephir_fcall_cache_entry *_0 = NULL;
	zval *filePath_param = NULL, *_1, *_2;
	zval *filePath = NULL;

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

	if (unlikely(Z_TYPE_P(filePath_param) != IS_STRING && Z_TYPE_P(filePath_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'filePath' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}
	if (likely(Z_TYPE_P(filePath_param) == IS_STRING)) {
		zephir_get_strval(filePath, filePath_param);
	} else {
		ZEPHIR_INIT_VAR(filePath);
		ZVAL_EMPTY_STRING(filePath);
	}


	ZEPHIR_INIT_VAR(_1);
	ZEPHIR_INIT_VAR(_2);
	zephir_file_get_contents(_2, filePath TSRMLS_CC);
	zephir_json_decode(_1, &(_1), _2, zephir_get_intval(ZEPHIR_GLOBAL(global_true))  TSRMLS_CC);
	ZEPHIR_CALL_PARENT(NULL, phalcon_config_adapter_json_ce, this_ptr, "__construct", &_0, 19, _1);
	zephir_check_call_status();
	ZEPHIR_MM_RESTORE();

}
Exemplo n.º 4
0
/**
 * Returns whether the given variable is a valid JSON string.
 *
 * @param string
 * @return boolean
 */
PHP_METHOD(Xpl_Json, validate) {

	zend_bool _0;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *str_param = NULL, *_1, *_2 = NULL;
	zval *str = NULL;

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

	zephir_get_strval(str, str_param);


	if (ZEPHIR_IS_EMPTY(str)) {
		RETURN_MM_BOOL(0);
	}
	_0 = ZEPHIR_IS_STRING_IDENTICAL(str, "{}");
	if (!(_0)) {
		_0 = ZEPHIR_IS_STRING_IDENTICAL(str, "[]");
	}
	if (_0) {
		RETURN_MM_BOOL(1);
	}
	ZEPHIR_INIT_VAR(_1);
	zephir_json_decode(_1, &(_1), str, 0  TSRMLS_CC);
	ZEPHIR_CALL_FUNCTION(&_2, "json_last_error", NULL, 112);
	zephir_check_call_status();
	RETURN_MM_BOOL(ZEPHIR_IS_LONG_IDENTICAL(_2, 0));

}
Exemplo n.º 5
0
PHP_METHOD(Test_Json, testDecodeObject) {

	zval *obj;

	ZEPHIR_MM_GROW();
	ZEPHIR_INIT_VAR(obj);
	ZVAL_STRING(obj, "{\"a\":\"hello\",\"b\":\"world\",\"c\":128}", 1);

	zephir_json_decode(return_value, &(return_value), obj, 0  TSRMLS_CC);
	RETURN_MM();

}
Exemplo n.º 6
0
PHP_METHOD(Test_Json, testDecodeArray) {

	zval *arr;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(arr);
	ZVAL_STRING(arr, "[1,2,3]", 1);
	zephir_json_decode(return_value, &(return_value), arr, 0  TSRMLS_CC);
	RETURN_MM();

}
Exemplo n.º 7
0
/**
 * Decodes a JSON-encoded string into an object or array
 *
 * @param string $json A well-formed JSON string.
 * @param boolean $assoc [Optional] Whether to decode to an associative array. Default false.
 * @param int $depth [Optional] Depth to decode to. Default 512
 * @param int $flags [Optional] Bitwise flags for use in json_decode(). Default is 0
 * @return object|array|null JSON data decoded to object(s) or array(s).
 */
PHP_METHOD(Xpl_Json, decode) {

	int depth, flags;
	zend_bool assoc;
	zval *json_param = NULL, *assoc_param = NULL, *depth_param = NULL, *flags_param = NULL, _0, _1, _2;
	zval *json = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 3, &json_param, &assoc_param, &depth_param, &flags_param);

	if (unlikely(Z_TYPE_P(json_param) != IS_STRING && Z_TYPE_P(json_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'json' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}
	if (likely(Z_TYPE_P(json_param) == IS_STRING)) {
		zephir_get_strval(json, json_param);
	} else {
		ZEPHIR_INIT_VAR(json);
		ZVAL_EMPTY_STRING(json);
	}
	if (!assoc_param) {
		assoc = 0;
	} else {
		assoc = zephir_get_boolval(assoc_param);
	}
	if (!depth_param) {
		depth = 512;
	} else {
		depth = zephir_get_intval(depth_param);
	}
	if (!flags_param) {
		flags = 0;
	} else {
		flags = zephir_get_intval(flags_param);
	}


	if (ZEPHIR_IS_EMPTY(json)) {
		RETURN_MM_NULL();
	}
	ZEPHIR_SINIT_VAR(_0);
	ZVAL_BOOL(&_0, (assoc ? 1 : 0));
	ZEPHIR_SINIT_VAR(_1);
	ZVAL_LONG(&_1, depth);
	ZEPHIR_SINIT_VAR(_2);
	ZVAL_LONG(&_2, flags);
	zephir_json_decode(return_value, &(return_value), json, zephir_get_intval(&_0)  TSRMLS_CC);
	RETURN_MM();

}
Exemplo n.º 8
0
PHP_METHOD(Yb_Task_TaskManagerAbstract, unserializeTask) {

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

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

	zephir_get_strval(task, task_param);


	zephir_json_decode(return_value, &(return_value), task, zephir_get_intval(ZEPHIR_GLOBAL(global_true))  TSRMLS_CC);
	RETURN_MM();

}
Exemplo n.º 9
0
PHP_METHOD(Test_BuiltIn_StringMethods, getParsedJson) {

	zend_bool assoc;
	zval *str_param = NULL, *assoc_param = NULL, *_0;
	zval *str = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 1, &str_param, &assoc_param);

	zephir_get_strval(str, str_param);
	if (!assoc_param) {
		assoc = 1;
	} else {
		assoc = zephir_get_boolval(assoc_param);
	}


	ZEPHIR_INIT_VAR(_0);
	zephir_json_decode(_0, &(_0), str, zephir_get_intval(str)  TSRMLS_CC);
	RETURN_CCTOR(_0);

}
Exemplo n.º 10
0
/**
 * Phalcon\Config\Adapter\Json constructor
 */
PHP_METHOD(Phalcon_Config_Adapter_Json, __construct) {

	zend_long ZEPHIR_LAST_CALL_STATUS;
	zephir_fcall_cache_entry *_0 = NULL;
	zval *filePath_param = NULL, __$true, _1, _2;
	zval filePath;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&filePath);
	ZVAL_BOOL(&__$true, 1);
	ZVAL_UNDEF(&_1);
	ZVAL_UNDEF(&_2);

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

	if (UNEXPECTED(Z_TYPE_P(filePath_param) != IS_STRING && Z_TYPE_P(filePath_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'filePath' must be of the type string") TSRMLS_CC);
		RETURN_MM_NULL();
	}
	if (EXPECTED(Z_TYPE_P(filePath_param) == IS_STRING)) {
		zephir_get_strval(&filePath, filePath_param);
	} else {
		ZEPHIR_INIT_VAR(&filePath);
		ZVAL_EMPTY_STRING(&filePath);
	}


	ZEPHIR_INIT_VAR(&_1);
	ZEPHIR_INIT_VAR(&_2);
	zephir_file_get_contents(&_2, &filePath TSRMLS_CC);
	zephir_json_decode(&_1, &_2, zephir_get_intval(&__$true) );
	ZEPHIR_CALL_PARENT(NULL, phalcon_config_adapter_json_ce, getThis(), "__construct", &_0, 0, &_1);
	zephir_check_call_status();
	ZEPHIR_MM_RESTORE();

}
Exemplo n.º 11
0
/**
 * Unserializes a value from a serialized string.
 *
 * @param string serializedData
 *
 * @return mixed
 */
PHP_METHOD(Xpl_Serializer_Json, unserialize) {

	zval *serializedData_param = NULL;
	zval *serializedData = NULL;

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

	if (unlikely(Z_TYPE_P(serializedData_param) != IS_STRING && Z_TYPE_P(serializedData_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'serializedData' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}
	if (likely(Z_TYPE_P(serializedData_param) == IS_STRING)) {
		zephir_get_strval(serializedData, serializedData_param);
	} else {
		ZEPHIR_INIT_VAR(serializedData);
		ZVAL_EMPTY_STRING(serializedData);
	}


	zephir_json_decode(return_value, &(return_value), serializedData, 0  TSRMLS_CC);
	RETURN_MM();

}
Exemplo n.º 12
0
/**
 * @return mixed
 */
PHP_METHOD(Lynx_Annotation_RegexDocParser, parseValue) {

	int ZEPHIR_LAST_CALL_STATUS;
	zephir_nts_static zephir_fcall_cache_entry *_14 = NULL;
	HashTable *_11;
	HashPosition _10;
	zend_bool _3, _15, _20;
	zval *value, *val = NULL, *vals, *v = NULL, _0, _1, *_2, _4, *_5, _6 = zval_used_for_init, _7 = zval_used_for_init, *_8 = NULL, _9 = zval_used_for_init, **_12, *_13 = NULL, *_16, _17, _18, *_19, _21, *_22, _23, _24, *_25 = NULL, *_26;

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



	ZEPHIR_INIT_VAR(val);
	zephir_fast_trim(val, value, NULL , ZEPHIR_TRIM_BOTH TSRMLS_CC);
	ZEPHIR_SINIT_VAR(_0);
	ZVAL_LONG(&_0, 0);
	ZEPHIR_SINIT_VAR(_1);
	ZVAL_LONG(&_1, 1);
	ZEPHIR_INIT_VAR(_2);
	zephir_substr(_2, val, 0 , 1 , 0);
	_3 = ZEPHIR_IS_STRING(_2, "[");
	if (_3) {
		ZEPHIR_SINIT_VAR(_4);
		ZVAL_LONG(&_4, -1);
		ZEPHIR_INIT_VAR(_5);
		zephir_substr(_5, val, -1 , 0, ZEPHIR_SUBSTR_NO_LENGTH);
		_3 = ZEPHIR_IS_STRING(_5, "]");
	}
	if (_3) {
		ZEPHIR_INIT_VAR(vals);
		ZEPHIR_SINIT_VAR(_6);
		ZVAL_LONG(&_6, 1);
		ZEPHIR_SINIT_VAR(_7);
		ZVAL_LONG(&_7, -1);
		ZEPHIR_INIT_VAR(_8);
		zephir_substr(_8, val, 1 , -1 , 0);
		ZEPHIR_SINIT_VAR(_9);
		ZVAL_LONG(&_9, ',');
		zephir_fast_explode(vals, &_9, _8, LONG_MAX TSRMLS_CC);
		ZEPHIR_INIT_NVAR(val);
		array_init(val);
		zephir_is_iterable(vals, &_11, &_10, 0, 0, "lynx/Annotation/RegexDocParser.zep", 89);
		for (
		  ; zephir_hash_get_current_data_ex(_11, (void**) &_12, &_10) == SUCCESS
		  ; zephir_hash_move_forward_ex(_11, &_10)
		) {
			ZEPHIR_GET_HVALUE(v, _12);
			ZEPHIR_CALL_SELF(&_13, "parsevalue", &_14, v);
			zephir_check_call_status();
			zephir_array_append(&val, _13, PH_SEPARATE, "lynx/Annotation/RegexDocParser.zep", 86);
		}
		RETURN_CCTOR(val);
	} else {
		ZEPHIR_SINIT_NVAR(_6);
		ZVAL_LONG(&_6, 0);
		ZEPHIR_SINIT_NVAR(_7);
		ZVAL_LONG(&_7, 1);
		ZEPHIR_INIT_NVAR(_8);
		zephir_substr(_8, val, 0 , 1 , 0);
		_15 = ZEPHIR_IS_STRING(_8, "{");
		if (_15) {
			ZEPHIR_SINIT_NVAR(_9);
			ZVAL_LONG(&_9, -1);
			ZEPHIR_INIT_VAR(_16);
			zephir_substr(_16, val, -1 , 0, ZEPHIR_SUBSTR_NO_LENGTH);
			_15 = ZEPHIR_IS_STRING(_16, "}");
		}
		if (_15) {
			zephir_json_decode(return_value, &(return_value), val, 0  TSRMLS_CC);
			RETURN_MM();
		} else {
			ZEPHIR_SINIT_VAR(_17);
			ZVAL_LONG(&_17, 0);
			ZEPHIR_SINIT_VAR(_18);
			ZVAL_LONG(&_18, 1);
			ZEPHIR_INIT_VAR(_19);
			zephir_substr(_19, val, 0 , 1 , 0);
			_20 = ZEPHIR_IS_STRING(_19, "\"");
			if (_20) {
				ZEPHIR_SINIT_VAR(_21);
				ZVAL_LONG(&_21, -1);
				ZEPHIR_INIT_VAR(_22);
				zephir_substr(_22, val, -1 , 0, ZEPHIR_SUBSTR_NO_LENGTH);
				_20 = ZEPHIR_IS_STRING(_22, "\"");
			}
			if (_20) {
				ZEPHIR_SINIT_VAR(_23);
				ZVAL_LONG(&_23, 1);
				ZEPHIR_SINIT_VAR(_24);
				ZVAL_LONG(&_24, -1);
				ZEPHIR_INIT_VAR(_25);
				zephir_substr(_25, val, 1 , -1 , 0);
				ZEPHIR_CPY_WRT(val, _25);
				ZEPHIR_RETURN_CALL_SELF("parsevalue", &_14, val);
				zephir_check_call_status();
				RETURN_MM();
			} else {
				ZEPHIR_INIT_NVAR(_25);
				zephir_fast_strtolower(_25, val);
				if (ZEPHIR_IS_STRING(_25, "true")) {
					RETURN_MM_BOOL(1);
				} else {
					ZEPHIR_INIT_VAR(_26);
					zephir_fast_strtolower(_26, val);
					if (ZEPHIR_IS_STRING(_26, "false")) {
						RETURN_MM_BOOL(0);
					} else {
						if (zephir_is_numeric(val)) {
							if (zephir_get_doubleval(val) == zephir_get_intval(val)) {
								RETURN_MM_LONG(zephir_get_intval(val));
							} else {
								RETURN_MM_DOUBLE(zephir_get_doubleval(val));
							}
						}
					}
				}
			}
		}
	}
	RETURN_CCTOR(val);

}
Exemplo n.º 13
0
/**
 * @param array ids
 * @param bool concurrent Only for entities fetched in this query
 * @return \Ouchbase\Entity[]
 */
PHP_METHOD(Ouchbase_Repository, findAll) {

	zephir_fcall_cache_entry *_7 = NULL;
	HashTable *_3;
	HashPosition _2;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *_0;
	zend_bool concurrent;
	zval *ids, *concurrent_param = NULL, *entity = NULL, *entities, *cas, *data, *dataWithCas = NULL, *id = NULL, *entityData = NULL, *_1 = NULL, **_4, *_5, *_6, *_8, *_9, *_10 = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 1, &ids, &concurrent_param);

	if (!concurrent_param) {
		concurrent = 0;
	} else {
		concurrent = zephir_get_boolval(concurrent_param);
	}


	ZEPHIR_INIT_VAR(entities);
	array_init(entities);
	ZEPHIR_INIT_VAR(_0);
	array_init_size(_0, 2);
	zephir_array_fast_append(_0, ids);
	ZEPHIR_INIT_VAR(_1);
	ZVAL_STRING(_1, "__getMultiWithCas", 0);
	ZEPHIR_CALL_METHOD(&dataWithCas, this_ptr, "executewithouttimeouts", NULL, _1, _0);
	zephir_check_temp_parameter(_1);
	zephir_check_call_status();
	ZEPHIR_OBS_VAR(data);
	zephir_array_fetch_string(&data, dataWithCas, SL("data"), PH_NOISY TSRMLS_CC);
	ZEPHIR_OBS_VAR(cas);
	zephir_array_fetch_string(&cas, dataWithCas, SL("cas"), PH_NOISY TSRMLS_CC);
	zephir_is_iterable(data, &_3, &_2, 0, 0);
	for (
	  ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS
	  ; zephir_hash_move_forward_ex(_3, &_2)
	) {
		ZEPHIR_GET_HMKEY(id, _3, _2);
		ZEPHIR_GET_HVALUE(entityData, _4);
		_5 = zephir_fetch_nproperty_this(this_ptr, SL("im"), PH_NOISY_CC);
		_6 = zephir_fetch_nproperty_this(this_ptr, SL("className"), PH_NOISY_CC);
		ZEPHIR_CALL_METHOD(&entity, _5, "getentity", NULL, _6, id);
		zephir_check_call_status();
		if (zephir_is_true(entity)) {
			zephir_array_append(&entities, entity, PH_SEPARATE);
			continue;
		}
		if (!(Z_TYPE_P(entityData) == IS_ARRAY)) {
			ZEPHIR_INIT_NVAR(_1);
			zephir_json_decode(_1, &(_1), entityData, zephir_get_intval(ZEPHIR_GLOBAL(global_true))  TSRMLS_CC);
			ZEPHIR_CPY_WRT(entityData, _1);
		}
		ZEPHIR_CALL_METHOD(&entity, this_ptr, "toobject", &_7, entityData);
		zephir_check_call_status();
		_8 = zephir_fetch_nproperty_this(this_ptr, SL("im"), PH_NOISY_CC);
		ZEPHIR_CALL_METHOD(NULL, _8, "register", NULL, entity, entityData);
		zephir_check_call_status();
		_9 = zephir_fetch_nproperty_this(this_ptr, SL("uow"), PH_NOISY_CC);
		ZEPHIR_INIT_LNVAR(_10);
		if (concurrent) {
			ZEPHIR_OBS_NVAR(_10);
			zephir_array_fetch(&_10, cas, id, PH_NOISY TSRMLS_CC);
		} else {
			ZEPHIR_INIT_NVAR(_10);
			ZVAL_NULL(_10);
		}
		ZEPHIR_CALL_METHOD(NULL, _9, "persist", NULL, entity, _10);
		zephir_check_call_status();
		zephir_array_append(&entities, entity, PH_SEPARATE);
	}
	RETURN_CCTOR(entities);

}
Exemplo n.º 14
0
/**
 * @param \Ouchbase\Entity entity
 * @param bool concurrent If entity may have concurrent updates
 * @throws \Ouchbase\Exception\EntityLogicException
 * @return this
 */
PHP_METHOD(Ouchbase_Repository, refresh) {

	zephir_fcall_cache_entry *_12 = NULL, *_14 = NULL, *_15 = NULL;
	HashTable *_9;
	HashPosition _8;
	zval *_4;
	int ZEPHIR_LAST_CALL_STATUS;
	zend_bool concurrent;
	zval *entity = NULL, *concurrent_param = NULL, *_0, *_1 = NULL, *_2, *_3 = NULL, *cas, *data = NULL, *dataWithCas = NULL, *_5 = NULL, *refreshed = NULL, *_6, *property = NULL, *propertyReflection = NULL, *_7 = NULL, **_10, *_11 = NULL, *_13 = NULL, *_16;

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

	ZEPHIR_SEPARATE_PARAM(entity);
	if (!concurrent_param) {
		concurrent = 0;
	} else {
		concurrent = zephir_get_boolval(concurrent_param);
	}


	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;
	}
	_0 = zephir_fetch_nproperty_this(this_ptr, SL("im"), PH_NOISY_CC);
	ZEPHIR_CALL_METHOD(&_1, _0, "contains", NULL, entity);
	zephir_check_call_status();
	if (!(zephir_is_true(_1))) {
		ZEPHIR_INIT_VAR(_2);
		object_init_ex(_2, ouchbase_exception_entitylogicexception_ce);
		ZEPHIR_INIT_VAR(_3);
		ZVAL_STRING(_3, "was not persisted", 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", 97 TSRMLS_CC);
		ZEPHIR_MM_RESTORE();
		return;
	}
	if (zephir_instance_of_ev(entity, ouchbase_entityproxy_ce TSRMLS_CC)) {
		ZEPHIR_CALL_METHOD(&entity, entity, "_getobject",  NULL);
		zephir_check_call_status();
	}
	ZEPHIR_INIT_VAR(_4);
	array_init_size(_4, 2);
	ZEPHIR_CALL_METHOD(&_5, entity, "getid",  NULL);
	zephir_check_call_status();
	zephir_array_fast_append(_4, _5);
	ZEPHIR_INIT_NVAR(_3);
	ZVAL_STRING(_3, "__getWithCas", 0);
	ZEPHIR_CALL_METHOD(&dataWithCas, this_ptr, "executewithouttimeouts", NULL, _3, _4);
	zephir_check_temp_parameter(_3);
	zephir_check_call_status();
	ZEPHIR_OBS_VAR(data);
	zephir_array_fetch_string(&data, dataWithCas, SL("data"), PH_NOISY TSRMLS_CC);
	ZEPHIR_OBS_VAR(cas);
	zephir_array_fetch_string(&cas, dataWithCas, SL("cas"), PH_NOISY TSRMLS_CC);
	if (!(zephir_is_true(data))) {
		RETURN_THIS();
	}
	if (!(Z_TYPE_P(data) == IS_ARRAY)) {
		ZEPHIR_INIT_NVAR(_3);
		zephir_json_decode(_3, &(_3), data, zephir_get_intval(ZEPHIR_GLOBAL(global_true))  TSRMLS_CC);
		ZEPHIR_CPY_WRT(data, _3);
	}
	ZEPHIR_CALL_METHOD(&refreshed, this_ptr, "toobject", NULL, data);
	zephir_check_call_status();
	_6 = zephir_fetch_nproperty_this(this_ptr, SL("im"), PH_NOISY_CC);
	ZEPHIR_CALL_METHOD(NULL, _6, "updateoriginaldata", NULL, entity, data);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(&_5, this_ptr, "getclassreflection",  NULL);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(&_7, _5, "getproperties",  NULL);
	zephir_check_call_status();
	zephir_is_iterable(_7, &_9, &_8, 0, 0);
	for (
	  ; zephir_hash_get_current_data_ex(_9, (void**) &_10, &_8) == SUCCESS
	  ; zephir_hash_move_forward_ex(_9, &_8)
	) {
		ZEPHIR_GET_HVALUE(property, _10);
		ZEPHIR_CALL_METHOD(&_11, property, "getname",  NULL);
		zephir_check_call_status();
		ZEPHIR_CALL_METHOD(&propertyReflection, this_ptr, "getpropertyreflection", &_12, _11);
		zephir_check_call_status();
		ZEPHIR_CALL_METHOD(&_13, propertyReflection, "getvalue", &_14, refreshed);
		zephir_check_call_status();
		ZEPHIR_CALL_METHOD(NULL, propertyReflection, "setvalue", &_15, entity, _13);
		zephir_check_call_status();
	}
	if (concurrent) {
		_16 = zephir_fetch_nproperty_this(this_ptr, SL("uow"), PH_NOISY_CC);
		ZEPHIR_CALL_METHOD(NULL, _16, "persist", NULL, entity, cas);
		zephir_check_call_status();
	}
	RETURN_THIS();

}
Exemplo n.º 15
0
/**
 * @param int|string id
 * @param bool concurrent
 * @return \Ouchbase\Entity|null
 */
PHP_METHOD(Ouchbase_Repository, find) {

	zval *_2;
	int ZEPHIR_LAST_CALL_STATUS;
	zend_bool concurrent;
	zval *id, *concurrent_param = NULL, *entity = NULL, *_0, *_1, *cas, *data = NULL, *dataWithCas = NULL, *_3, *_4, *_5, *_6 = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 1, &id, &concurrent_param);

	if (!concurrent_param) {
		concurrent = 0;
	} else {
		concurrent = zephir_get_boolval(concurrent_param);
	}


	_0 = zephir_fetch_nproperty_this(this_ptr, SL("im"), PH_NOISY_CC);
	_1 = zephir_fetch_nproperty_this(this_ptr, SL("className"), PH_NOISY_CC);
	ZEPHIR_CALL_METHOD(&entity, _0, "getentity", NULL, _1, id);
	zephir_check_call_status();
	if (zephir_is_true(entity)) {
		RETURN_CCTOR(entity);
	}
	ZEPHIR_INIT_VAR(_2);
	array_init_size(_2, 2);
	zephir_array_fast_append(_2, id);
	ZEPHIR_INIT_VAR(_3);
	ZVAL_STRING(_3, "__getWithCas", 0);
	ZEPHIR_CALL_METHOD(&dataWithCas, this_ptr, "executewithouttimeouts", NULL, _3, _2);
	zephir_check_temp_parameter(_3);
	zephir_check_call_status();
	ZEPHIR_OBS_VAR(data);
	zephir_array_fetch_string(&data, dataWithCas, SL("data"), PH_NOISY TSRMLS_CC);
	ZEPHIR_OBS_VAR(cas);
	zephir_array_fetch_string(&cas, dataWithCas, SL("cas"), PH_NOISY TSRMLS_CC);
	if (!(zephir_is_true(data))) {
		RETURN_MM_NULL();
	}
	if (!(Z_TYPE_P(data) == IS_ARRAY)) {
		ZEPHIR_INIT_BNVAR(_3);
		zephir_json_decode(_3, &(_3), data, zephir_get_intval(ZEPHIR_GLOBAL(global_true))  TSRMLS_CC);
		ZEPHIR_CPY_WRT(data, _3);
	}
	ZEPHIR_CALL_METHOD(&entity, this_ptr, "toobject", NULL, data);
	zephir_check_call_status();
	_4 = zephir_fetch_nproperty_this(this_ptr, SL("im"), PH_NOISY_CC);
	ZEPHIR_CALL_METHOD(NULL, _4, "register", NULL, entity, data);
	zephir_check_call_status();
	_5 = zephir_fetch_nproperty_this(this_ptr, SL("uow"), PH_NOISY_CC);
	ZEPHIR_INIT_VAR(_6);
	if (concurrent) {
		ZEPHIR_CPY_WRT(_6, cas);
	} else {
		ZEPHIR_INIT_BNVAR(_6);
		ZVAL_NULL(_6);
	}
	ZEPHIR_CALL_METHOD(NULL, _5, "persist", NULL, entity, _6);
	zephir_check_call_status();
	RETURN_CCTOR(entity);

}
Exemplo n.º 16
0
PHP_METHOD(Transbybd_TransApi, translate) {

	zval *args = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *query_param = NULL, *from_param = NULL, *to_param = NULL, *ret = NULL, *_0, _1, _2, *_3 = NULL, *_4, *_5;
	zval *query = NULL, *from = NULL, *to = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 3, 0, &query_param, &from_param, &to_param);

	if (unlikely(Z_TYPE_P(query_param) != IS_STRING && Z_TYPE_P(query_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'query' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}
	if (likely(Z_TYPE_P(query_param) == IS_STRING)) {
		zephir_get_strval(query, query_param);
	} else {
		ZEPHIR_INIT_VAR(query);
		ZVAL_EMPTY_STRING(query);
	}
	if (unlikely(Z_TYPE_P(from_param) != IS_STRING && Z_TYPE_P(from_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'from' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}
	if (likely(Z_TYPE_P(from_param) == IS_STRING)) {
		zephir_get_strval(from, from_param);
	} else {
		ZEPHIR_INIT_VAR(from);
		ZVAL_EMPTY_STRING(from);
	}
	if (unlikely(Z_TYPE_P(to_param) != IS_STRING && Z_TYPE_P(to_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'to' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}
	if (likely(Z_TYPE_P(to_param) == IS_STRING)) {
		zephir_get_strval(to, to_param);
	} else {
		ZEPHIR_INIT_VAR(to);
		ZVAL_EMPTY_STRING(to);
	}


	ZEPHIR_INIT_VAR(args);
	array_init(args);
	ZEPHIR_INIT_NVAR(args);
	zephir_create_array(args, 5, 0 TSRMLS_CC);
	zephir_array_update_string(&args, SL("q"), &query, PH_COPY | PH_SEPARATE);
	ZEPHIR_OBS_VAR(_0);
	zephir_read_property_this(&_0, this_ptr, SL("app_id"), PH_NOISY_CC);
	zephir_array_update_string(&args, SL("appid"), &_0, PH_COPY | PH_SEPARATE);
	ZEPHIR_SINIT_VAR(_1);
	ZVAL_LONG(&_1, 10000);
	ZEPHIR_SINIT_VAR(_2);
	ZVAL_LONG(&_2, 99999);
	ZEPHIR_CALL_FUNCTION(&_3, "rand", NULL, 1, &_1, &_2);
	zephir_check_call_status();
	zephir_array_update_string(&args, SL("salt"), &_3, PH_COPY | PH_SEPARATE);
	zephir_array_update_string(&args, SL("from"), &from, PH_COPY | PH_SEPARATE);
	zephir_array_update_string(&args, SL("to"), &to, PH_COPY | PH_SEPARATE);
	zephir_array_fetch_string(&_4, args, SL("salt"), PH_NOISY | PH_READONLY, "transbybd/transApi.zep", 33 TSRMLS_CC);
	ZEPHIR_CALL_METHOD(&_3, this_ptr, "__buildsign", NULL, 2, query, _4);
	zephir_check_call_status();
	zephir_array_update_string(&args, SL("sign"), &_3, PH_COPY | PH_SEPARATE);
	ZEPHIR_CALL_METHOD(&ret, this_ptr, "__callmutil", NULL, 3, args);
	zephir_check_call_status();
	ZEPHIR_INIT_VAR(_5);
	zephir_json_decode(_5, &(_5), ret, zephir_get_intval(ZEPHIR_GLOBAL(global_true))  TSRMLS_CC);
	ZEPHIR_CPY_WRT(ret, _5);
	RETURN_CCTOR(ret);

}