Example #1
0
PHP_METHOD(Test_NativeArray, testArrayAppend2) {

	int f = 5;
	double e = 1.10;
	zend_bool d = 0;
	zval *b;
	zval *a, *c = NULL, *g, *_0;

	ZEPHIR_MM_GROW();
	ZEPHIR_INIT_VAR(b);
	ZVAL_STRING(b, "hello", 1);
	ZEPHIR_INIT_VAR(c);
	ZVAL_NULL(c);
	ZEPHIR_INIT_VAR(g);
	array_init(g);

	ZEPHIR_INIT_VAR(a);
	array_init(a);
	zephir_array_append(&a, b, PH_SEPARATE);
	zephir_array_append(&a, c, PH_SEPARATE);
	ZEPHIR_INIT_VAR(_0);
	ZVAL_BOOL(_0, d);
	zephir_array_append(&a, _0, PH_SEPARATE);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_DOUBLE(_0, e);
	zephir_array_append(&a, _0, PH_SEPARATE);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, f);
	zephir_array_append(&a, _0, PH_SEPARATE);
	zephir_array_append(&a, g, PH_SEPARATE);
	RETURN_CCTOR(a);

}
Example #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();

}
Example #3
0
PHP_METHOD(Test_Ternary, testTernaryComplex2) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *a, *y, *_0 = NULL, *_1 = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 2, 0, &a, &y);



	ZEPHIR_INIT_VAR(_0);
	if (100) {
		ZEPHIR_INIT_BNVAR(_0);
		ZVAL_LONG(_0, (1 + 100));
	} else {
		ZEPHIR_CALL_METHOD(&_1, a, "y",  NULL);
		zephir_check_call_status();
		if (zephir_is_true(_1)) {
			ZEPHIR_CALL_METHOD(&_0, a, "x",  NULL);
			zephir_check_call_status();
		} else {
			ZEPHIR_INIT_BNVAR(_0);
			ZVAL_BOOL(_0, zephir_array_isset(a, y));
		}
	}
	RETURN_MM_LONG((5 + zephir_get_numberval(_0)));

}
Example #4
0
PHP_METHOD(Test_Flow, testFor3) {

	HashTable *_2;
	HashPosition _1;
	zval *v = NULL, *b, *c, *_0, **_3;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(c);
	array_init(c);
	ZEPHIR_INIT_VAR(b);
	array_init_size(b, 5);
	ZEPHIR_INIT_VAR(_0);
	ZVAL_LONG(_0, 1);
	zephir_array_fast_append(b, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 2);
	zephir_array_fast_append(b, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 3);
	zephir_array_fast_append(b, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 4);
	zephir_array_fast_append(b, _0);
	zephir_is_iterable(b, &_2, &_1, 0, 1);
	for (
		; zend_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS
		; zend_hash_move_backwards_ex(_2, &_1)
	) {
		ZEPHIR_GET_HVALUE(v, _3);
		zephir_array_append(&c, v, PH_SEPARATE);
	}
	RETURN_CCTOR(c);

}
Example #5
0
PHP_METHOD(Test_Flow, testFor1) {

	HashTable *_2;
	HashPosition _1;
	int c;
	zval *v = NULL, *b, *_0, **_3;

	ZEPHIR_MM_GROW();

	c = 0;
	ZEPHIR_INIT_VAR(b);
	array_init_size(b, 5);
	ZEPHIR_INIT_VAR(_0);
	ZVAL_LONG(_0, 1);
	zephir_array_fast_append(b, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 2);
	zephir_array_fast_append(b, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 3);
	zephir_array_fast_append(b, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 4);
	zephir_array_fast_append(b, _0);
	zephir_is_iterable(b, &_2, &_1, 0, 0);
	for (
		; zend_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS
		; zend_hash_move_forward_ex(_2, &_1)
	) {
		ZEPHIR_GET_HVALUE(v, _3);
		c += zephir_get_numberval(v);
	}
	RETURN_MM_LONG(c);

}
Example #6
0
PHP_METHOD(Test_NativeArray, testArray12) {

	zval *a, *b, *c, *_0;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(a);
	array_init_size(a, 5);
	ZEPHIR_INIT_VAR(_0);
	ZVAL_LONG(_0, 1);
	zephir_array_fast_append(a, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 2);
	zephir_array_fast_append(a, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 3);
	zephir_array_fast_append(a, _0);
	ZEPHIR_INIT_VAR(b);
	array_init_size(b, 2);
	zephir_array_fast_append(b, a);
	ZEPHIR_INIT_VAR(c);
	array_init_size(c, 2);
	zephir_array_fast_append(c, b);
	RETURN_CCTOR(c);

}
Example #7
0
PHP_METHOD(Test_Properties_PropertyArray, __construct) {

	zval *_1, *_3;
	zval *_0, *_2;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(_0);
	array_init_size(_0, 7);
	ZEPHIR_INIT_VAR(_1);
	ZVAL_LONG(_1, 1);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 2);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 3);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 4);
	zephir_array_fast_append(_0, _1);
	zephir_update_property_this(this_ptr, SL("someArray"), _0 TSRMLS_CC);
	ZEPHIR_INIT_BNVAR(_1);
	array_init(_1);
	zephir_update_property_this(this_ptr, SL("someEmptyArray"), _1 TSRMLS_CC);
	ZEPHIR_INIT_VAR(_2);
	array_init_size(_2, 2);
	ZEPHIR_INIT_VAR(_3);
	ZVAL_LONG(_3, 1);
	zephir_array_fast_append(_2, _3);
	zephir_update_property_this(this_ptr, SL("someArray"), _2 TSRMLS_CC);
	ZEPHIR_MM_RESTORE();

}
Example #8
0
PHP_METHOD(Test_NativeArray, testArrayUpdate3) {

	int b;
	zval *a, *_0, *_1;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(a);
	array_init_size(a, 5);
	ZEPHIR_INIT_VAR(_0);
	ZVAL_LONG(_0, 1);
	zephir_array_fast_append(a, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 2);
	zephir_array_fast_append(a, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 3);
	zephir_array_fast_append(a, _0);
	b = 0;
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 4);
	zephir_array_update_long(&a, b, &_0, PH_COPY | PH_SEPARATE, "test/nativearray.zep", 379);
	b = 1;
	ZEPHIR_INIT_VAR(_1);
	ZVAL_LONG(_1, 5);
	zephir_array_update_long(&a, b, &_1, PH_COPY | PH_SEPARATE, "test/nativearray.zep", 381);
	RETURN_CCTOR(a);

}
Example #9
0
/**
 * CacheGetOne: cached GetOne
 *
 * @param int timeout count of seconds for cache expiry
 * @param string statement String query to execute
 * @param array vars Array of variables to bind [optional]
 * @return mixed
 */
PHP_METHOD(ADOdb_Connection, cacheGetOne) {

    zval *vars = NULL;
    zval *statement = NULL;
    zval *timeout_param = NULL, *statement_param = NULL, *vars_param = NULL, *st, *_0;
    int timeout;

    ZEPHIR_MM_GROW();
    zephir_fetch_params(1, 2, 1, &timeout_param, &statement_param, &vars_param);

    timeout = zephir_get_intval(timeout_param);
    zephir_get_strval(statement, statement_param);
    if (!vars_param) {
        ZEPHIR_INIT_VAR(vars);
        array_init(vars);
    } else {
        zephir_get_arrval(vars, vars_param);
    }


    ZEPHIR_INIT_VAR(_0);
    ZVAL_LONG(_0, timeout);
    ZEPHIR_INIT_VAR(st);
    zephir_call_method_p3(st, this_ptr, "cachequery", _0, statement, vars);
    ZEPHIR_INIT_BNVAR(_0);
    ZVAL_LONG(_0, 0);
    zephir_call_method_p1(return_value, st, "fetchcolumn", _0);
    RETURN_MM();

}
Example #10
0
PHP_METHOD(Test_Fibonnaci, fibArray2) {

	int i, n;
	zval *fib, *_0, *_1, *_2, *_3 = NULL;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(fib);
	array_init_size(fib, 3);
	ZEPHIR_INIT_VAR(_0);
	ZVAL_LONG(_0, 0);
	zephir_array_fast_append(fib, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 1);
	zephir_array_fast_append(fib, _0);
	i = 2;
	n = 10;
	while (1) {
		if (!((i < n))) {
			break;
		}
		zephir_array_fetch_long(&_1, fib, (i - 1), PH_NOISY | PH_READONLY TSRMLS_CC);
		zephir_array_fetch_long(&_2, fib, (i - 2), PH_NOISY | PH_READONLY TSRMLS_CC);
		ZEPHIR_INIT_LNVAR(_3);
		zephir_add_function(_3, _1, _2 TSRMLS_CC);
		zephir_array_update_long(&fib, i, &_3, PH_COPY | PH_SEPARATE, "test/fibonnaci.zep", 67);
		i++;
	}
	RETURN_CCTOR(fib);

}
Example #11
0
/**
 * Gets the signing key
 *
 * @return string
 */
PHP_METHOD(OAuth_V1_Signature, getSigningKey) {

	zval *signingKey, *credentials = NULL, *consumerSecret, *tokenSecret, *_0, *_1;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(_0);
	zephir_call_method(_0, this_ptr, "getcredentials");
	ZEPHIR_CPY_WRT(credentials, _0);
	ZEPHIR_INIT_VAR(consumerSecret);
	zephir_call_method(consumerSecret, credentials, "getconsumersecret");
	ZEPHIR_INIT_VAR(tokenSecret);
	zephir_call_method(tokenSecret, this_ptr, "gettokensecret");
	ZEPHIR_INIT_BNVAR(_0);
	zephir_call_func_p1(_0, "rawurlencode", consumerSecret);
	ZEPHIR_INIT_VAR(signingKey);
	ZEPHIR_CONCAT_VS(signingKey, _0, "&");
	if (!(ZEPHIR_IS_EMPTY(tokenSecret))) {
		ZEPHIR_INIT_VAR(_1);
		zephir_call_func_p1(_1, "rawurlencode", tokenSecret);
		zephir_concat_self(&signingKey, _1 TSRMLS_CC);
	}
	RETURN_CCTOR(signingKey);

}
Example #12
0
PHP_METHOD(Test_Fibonnaci, fibArray) {

	int i, n, k, j;
	zval *fib, *a, *b, *c = NULL, *_0;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(fib);
	array_init_size(fib, 3);
	ZEPHIR_INIT_VAR(_0);
	ZVAL_LONG(_0, 0);
	zephir_array_fast_append(fib, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 1);
	zephir_array_fast_append(fib, _0);
	i = 2;
	n = 10;
	while (1) {
		if (!((i < n))) {
			break;
		}
		k = (i - 1);
		j = (i - 2);
		zephir_array_fetch_long(&a, fib, k, PH_NOISY | PH_READONLY TSRMLS_CC);
		zephir_array_fetch_long(&b, fib, j, PH_NOISY | PH_READONLY TSRMLS_CC);
		ZEPHIR_INIT_NVAR(c);
		zephir_add_function(c, a, b TSRMLS_CC);
		zephir_array_update_long(&fib, i, &c, PH_COPY | PH_SEPARATE, "test/fibonnaci.zep", 54);
		i++;
	}
	RETURN_CCTOR(fib);

}
Example #13
0
PHP_METHOD(Test_NativeArray, testArrayMultipleAccess4) {

	zval *_0, *_1;
	zval *a, *b, *_2, *_3, *_4;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(a);
	array_init_size(a, 2);
	ZEPHIR_INIT_VAR(_0);
	array_init_size(_0, 2);
	ZEPHIR_INIT_VAR(_1);
	array_init_size(_1, 3);
	ZEPHIR_INIT_VAR(_2);
	ZVAL_STRING(_2, "a", 1);
	zephir_array_fast_append(_1, _2);
	ZEPHIR_INIT_BNVAR(_2);
	ZVAL_STRING(_2, "b", 1);
	zephir_array_fast_append(_1, _2);
	zephir_array_fast_append(_0, _1);
	zephir_array_fast_append(a, _0);
	zephir_array_fetch_long(&_3, a, 0, PH_NOISY | PH_READONLY TSRMLS_CC);
	zephir_array_fetch_long(&_4, _3, 0, PH_NOISY | PH_READONLY TSRMLS_CC);
	zephir_array_fetch_long(&b, _4, 1, PH_NOISY | PH_READONLY TSRMLS_CC);
	RETURN_CTOR(b);

}
Example #14
0
PHP_METHOD(Test_Oo_PropertyAccess, __construct) {

	zval *test, *test1, *_0, *_1, *_2, *_3, *_4, *_5, *_6, *_7 = NULL, *_8, *_9;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(test);
	object_init(test);
	ZEPHIR_INIT_VAR(_0);
	array_init_size(_0, 6);
	ZEPHIR_INIT_VAR(_1);
	ZVAL_LONG(_1, 1);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 2);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 3);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 5);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_DOUBLE(_1, 6.00);
	zephir_array_fast_append(_0, _1);
	zephir_update_property_zval(test, SL("test"), _0 TSRMLS_CC);
	ZEPHIR_OBS_VAR(_2);
	zephir_read_property(&_2, test, SL("test"), PH_NOISY_CC);
	zephir_array_fetch_long(&_3, _2, 0, PH_NOISY | PH_READONLY TSRMLS_CC);
	zephir_update_property_zval(test, SL("test2"), _3 TSRMLS_CC);
	ZEPHIR_OBS_VAR(_4);
	zephir_read_property(&_4, test, SL("test"), PH_NOISY_CC);
	zephir_array_fetch_long(&_5, _4, 1, PH_NOISY | PH_READONLY TSRMLS_CC);
	zephir_update_property_zval(test, SL("test3"), _5 TSRMLS_CC);
	ZEPHIR_INIT_BNVAR(_1);
	array_init_size(_1, 5);
	ZEPHIR_OBS_VAR(_6);
	zephir_read_property(&_6, test, SL("test"), PH_NOISY_CC);
	ZEPHIR_OBS_VAR(_7);
	zephir_array_fetch_long(&_7, _6, 1, PH_NOISY TSRMLS_CC);
	zephir_array_fast_append(_1, _7);
	ZEPHIR_INIT_VAR(_8);
	ZVAL_LONG(_8, 1);
	zephir_array_fast_append(_1, _8);
	ZEPHIR_INIT_BNVAR(_8);
	ZVAL_LONG(_8, 2);
	zephir_array_fast_append(_1, _8);
	ZEPHIR_INIT_BNVAR(_8);
	ZVAL_LONG(_8, 3);
	zephir_array_fast_append(_1, _8);
	zephir_update_property_zval(test, SL("test3"), _1 TSRMLS_CC);
	zephir_update_property_this(this_ptr, SL("a"), test TSRMLS_CC);
	_9 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC);
	ZEPHIR_OBS_NVAR(_7);
	zephir_read_property(&_7, _9, SL("test2"), PH_NOISY_CC);
	zephir_update_property_this(this_ptr, SL("b"), _7 TSRMLS_CC);
	test1 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC);
	ZEPHIR_MM_RESTORE();

}
Example #15
0
/**
 * @link https://github.com/phalcon/zephir/issues/297
 */
PHP_METHOD(Test_Ternary, testTernaryAfterLetVariable) {

	zval *s = NULL;

	ZEPHIR_MM_GROW();
	ZEPHIR_INIT_VAR(s);
	ZVAL_LONG(s, 23);

	if (1 == 1) {
		ZEPHIR_INIT_BNVAR(s);
		ZVAL_LONG(s, 3);
	} else {
		ZEPHIR_INIT_BNVAR(s);
		ZVAL_LONG(s, 10);
	}
	RETURN_CCTOR(s);

}
Example #16
0
PHP_METHOD(Test_NativeArray, testArray3) {

	zval *a, *_0;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(a);
	array_init_size(a, 5);
	ZEPHIR_INIT_VAR(_0);
	ZVAL_DOUBLE(_0, 1.1);
	zephir_array_fast_append(a, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_DOUBLE(_0, 2.2);
	zephir_array_fast_append(a, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_DOUBLE(_0, 3.3);
	zephir_array_fast_append(a, _0);
	RETURN_CCTOR(a);

}
Example #17
0
PHP_METHOD(Test_NativeArray, testArray6) {

	zval *a, *_0;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(a);
	array_init_size(a, 5);
	ZEPHIR_INIT_VAR(_0);
	ZVAL_STRING(_0, "x", 1);
	zephir_array_fast_append(a, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_STRING(_0, "y", 1);
	zephir_array_fast_append(a, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_STRING(_0, "z", 1);
	zephir_array_fast_append(a, _0);
	RETURN_CCTOR(a);

}
Example #18
0
PHP_METHOD(Test_NativeArray, testArrayAccess1) {

	zval *a, *b, *_0;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(a);
	array_init_size(a, 5);
	ZEPHIR_INIT_VAR(_0);
	ZVAL_LONG(_0, 1);
	zephir_array_fast_append(a, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 2);
	zephir_array_fast_append(a, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 3);
	zephir_array_fast_append(a, _0);
	zephir_array_fetch_long(&b, a, 0, PH_NOISY | PH_READONLY TSRMLS_CC);
	RETURN_CTOR(b);

}
Example #19
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();

}
Example #20
0
PHP_METHOD(Test_NativeArray, testArray25) {

	zend_bool b;
	zval *a, *_0;

	ZEPHIR_MM_GROW();

	b = 0;
	ZEPHIR_INIT_VAR(a);
	array_init_size(a, 5);
	ZEPHIR_INIT_VAR(_0);
	ZVAL_BOOL(_0, b);
	zephir_array_update_long(&a, 0, &_0, PH_COPY, "test/nativearray.zep", 195);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_BOOL(_0, b);
	zephir_array_update_long(&a, 1, &_0, PH_COPY, "test/nativearray.zep", 195);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_BOOL(_0, b);
	zephir_array_update_long(&a, 2, &_0, PH_COPY, "test/nativearray.zep", 195);
	RETURN_CCTOR(a);

}
Example #21
0
PHP_METHOD(Test_NativeArray, testArray24) {

	double b;
	zval *a, *_0;

	ZEPHIR_MM_GROW();

	b = 0.0;
	ZEPHIR_INIT_VAR(a);
	array_init_size(a, 5);
	ZEPHIR_INIT_VAR(_0);
	ZVAL_DOUBLE(_0, b);
	zephir_array_update_long(&a, 0, &_0, PH_COPY, "test/nativearray.zep", 186);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_DOUBLE(_0, b);
	zephir_array_update_long(&a, 1, &_0, PH_COPY, "test/nativearray.zep", 186);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_DOUBLE(_0, b);
	zephir_array_update_long(&a, 2, &_0, PH_COPY, "test/nativearray.zep", 186);
	RETURN_CCTOR(a);

}
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);

}
Example #23
0
PHP_METHOD(Test_EmptyTest, testDynamicVarArrayNotEmpty) {

	zval *a, *_0;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(a);
	array_init_size(a, 7);
	ZEPHIR_INIT_VAR(_0);
	ZVAL_LONG(_0, 1);
	zephir_array_fast_append(a, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 2);
	zephir_array_fast_append(a, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 3);
	zephir_array_fast_append(a, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 4);
	zephir_array_fast_append(a, _0);
	RETURN_MM_BOOL(ZEPHIR_IS_EMPTY(a));

}
Example #24
0
PHP_METHOD(Test_Flow, testFor24) {

	HashTable *_3;
	HashPosition _2;
	zval *_0;
	zval *b;
	zval *a = NULL, *_1, **_4;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(b);
	ZVAL_EMPTY_STRING(b);
	ZEPHIR_INIT_VAR(_0);
	array_init_size(_0, 5);
	ZEPHIR_INIT_VAR(_1);
	ZVAL_LONG(_1, 'a');
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 'b');
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 'c');
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 'd');
	zephir_array_fast_append(_0, _1);
	zephir_is_iterable(_0, &_3, &_2, 0, 0);
	for (
		; zend_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS
		; zend_hash_move_forward_ex(_3, &_2)
	) {
		ZEPHIR_GET_HVALUE(a, _4);
		zephir_concat_self(&b, a TSRMLS_CC);
	}
	RETURN_CTOR(b);

}
Example #25
0
PHP_METHOD(Test_NativeArray, testArray9) {

	zend_bool a, b, c;
	zval *d, *_0;

	ZEPHIR_MM_GROW();

	a = 1;
	b = 0;
	c = 1;
	ZEPHIR_INIT_VAR(d);
	array_init_size(d, 5);
	ZEPHIR_INIT_VAR(_0);
	ZVAL_BOOL(_0, a);
	zephir_array_fast_append(d, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_BOOL(_0, b);
	zephir_array_fast_append(d, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_BOOL(_0, c);
	zephir_array_fast_append(d, _0);
	RETURN_CCTOR(d);

}
Example #26
0
PHP_METHOD(Test_NativeArray, testArray8) {

	double a, b, c;
	zval *d, *_0;

	ZEPHIR_MM_GROW();

	a = (double) (1);
	b = (double) (2);
	c = (double) (3);
	ZEPHIR_INIT_VAR(d);
	array_init_size(d, 5);
	ZEPHIR_INIT_VAR(_0);
	ZVAL_DOUBLE(_0, a);
	zephir_array_fast_append(d, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_DOUBLE(_0, b);
	zephir_array_fast_append(d, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_DOUBLE(_0, c);
	zephir_array_fast_append(d, _0);
	RETURN_CCTOR(d);

}
Example #27
0
PHP_METHOD(Test_NativeArray, testArray7) {

	int a, b, c;
	zval *d, *_0;

	ZEPHIR_MM_GROW();

	a = 1;
	b = 2;
	c = 3;
	ZEPHIR_INIT_VAR(d);
	array_init_size(d, 5);
	ZEPHIR_INIT_VAR(_0);
	ZVAL_LONG(_0, a);
	zephir_array_fast_append(d, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, b);
	zephir_array_fast_append(d, _0);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, c);
	zephir_array_fast_append(d, _0);
	RETURN_CCTOR(d);

}
Example #28
0
PHP_METHOD(Test_NativeArray, testArrayAppend1) {

	zval *a, *_0;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(a);
	array_init(a);
	ZEPHIR_INIT_VAR(_0);
	ZVAL_STRING(_0, "hello", 1);
	zephir_array_append(&a, _0, PH_SEPARATE);
	zephir_array_append(&a, ZEPHIR_GLOBAL(global_null), PH_SEPARATE);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_BOOL(_0, 0);
	zephir_array_append(&a, _0, PH_SEPARATE);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_DOUBLE(_0, 1.10);
	zephir_array_append(&a, _0, PH_SEPARATE);
	ZEPHIR_INIT_BNVAR(_0);
	ZVAL_LONG(_0, 5);
	zephir_array_append(&a, _0, PH_SEPARATE);
	RETURN_CCTOR(a);

}
PHP_METHOD(Auryn_AbstractCachingReflector, getCtorParams) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *className_param = NULL, *cacheKey, *reflectedCtorParams = NULL, *reflectedCtor = NULL, *_0, *_1, *_2;
	zval *className = NULL;

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

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

	if (unlikely(Z_TYPE_P(className_param) == IS_STRING)) {
		className = className_param;
	} else {
		ZEPHIR_INIT_VAR(className);
		ZVAL_EMPTY_STRING(className);
	}


	ZEPHIR_INIT_VAR(_0);
	zephir_fast_strtolower(_0, className);
	ZEPHIR_INIT_VAR(cacheKey);
	ZEPHIR_CONCAT_SV(cacheKey, "auryn.refls.ctor-params.", _0);
	_1 = zephir_fetch_nproperty_this(this_ptr, SL("cache"), PH_NOISY_CC);
	ZEPHIR_CALL_METHOD(&reflectedCtorParams, _1, "fetch", NULL, cacheKey);
	zephir_check_call_status();
	if (zephir_is_true(reflectedCtorParams)) {
		RETURN_CCTOR(reflectedCtorParams);
	} else {
		ZEPHIR_CALL_METHOD(&reflectedCtor, this_ptr, "getctor", NULL, className);
		zephir_check_call_status();
		if (zephir_is_true(reflectedCtor)) {
			ZEPHIR_CALL_METHOD(&reflectedCtorParams, reflectedCtor, "getparameters",  NULL);
			zephir_check_call_status();
		} else {
			ZEPHIR_INIT_BNVAR(reflectedCtorParams);
			ZVAL_NULL(reflectedCtorParams);
		}
	}
	_2 = zephir_fetch_nproperty_this(this_ptr, SL("cache"), PH_NOISY_CC);
	ZEPHIR_CALL_METHOD(NULL, _2, "store", NULL, cacheKey, reflectedCtorParams);
	zephir_check_call_status();
	RETURN_CCTOR(reflectedCtorParams);

}
Example #30
0
/**
 * CacheGetCol: cached GetCol
 * @param int timeout count of seconds for cache expiry
 * @param string statement String query to execute
 * @param array vars Array of variables to bind [optional]
 * @return array
 */
PHP_METHOD(ADOdb_Connection, cacheGetCol) {

    zval *vars = NULL;
    zval *statement = NULL;
    zval *timeout_param = NULL, *statement_param = NULL, *vars_param = NULL, *col, *val = NULL, *st, *_0 = NULL;
    int timeout;

    ZEPHIR_MM_GROW();
    zephir_fetch_params(1, 2, 1, &timeout_param, &statement_param, &vars_param);

    timeout = zephir_get_intval(timeout_param);
    zephir_get_strval(statement, statement_param);
    if (!vars_param) {
        ZEPHIR_INIT_VAR(vars);
        array_init(vars);
    } else {
        zephir_get_arrval(vars, vars_param);
    }


    ZEPHIR_INIT_VAR(_0);
    ZVAL_LONG(_0, timeout);
    ZEPHIR_INIT_VAR(st);
    zephir_call_method_p3(st, this_ptr, "cachequery", _0, statement, vars);
    ZEPHIR_INIT_VAR(col);
    array_init(col);
    ZEPHIR_INIT_BNVAR(_0);
    ZVAL_LONG(_0, 0);
    ZEPHIR_INIT_VAR(val);
    zephir_call_method_p1(val, st, "fetchcolumn", _0);
    while (1) {
        if (!(zephir_is_true(val))) {
            break;
        }
        zephir_array_append(&col, val, PH_SEPARATE);
        ZEPHIR_INIT_NVAR(_0);
        ZVAL_LONG(_0, 0);
        ZEPHIR_INIT_NVAR(val);
        zephir_call_method_p1(val, st, "fetchcolumn", _0);
    }
    RETURN_CCTOR(col);

}