示例#1
0
/**
 * Produces an string representation of a variable
 */
PHP_METHOD(Phalcon_Debug, _getVarDump) {

	zephir_fcall_cache_entry *_3 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zephir_nts_static zephir_fcall_cache_entry *_1 = NULL;
	zval *variable, *className, *dumpedObject = NULL, *dump, *_0 = NULL, *_2 = NULL;

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



	ZEPHIR_CALL_FUNCTION(&_0, "is_scalar", &_1, variable);
	zephir_check_call_status();
	if (zephir_is_true(_0)) {
		if (Z_TYPE_P(variable) == IS_BOOL) {
			if (zephir_is_true(variable)) {
				RETURN_MM_STRING("true", 1);
			} else {
				RETURN_MM_STRING("false", 1);
			}
		}
		if (Z_TYPE_P(variable) == IS_STRING) {
			ZEPHIR_RETURN_CALL_METHOD(this_ptr, "_escapestring", NULL, variable);
			zephir_check_call_status();
			RETURN_MM();
		}
		RETVAL_ZVAL(variable, 1, 0);
		RETURN_MM();
	}
	if (Z_TYPE_P(variable) == IS_OBJECT) {
		ZEPHIR_INIT_VAR(className);
		zephir_get_class(className, variable, 0 TSRMLS_CC);
		ZEPHIR_INIT_VAR(dump);
		if ((zephir_method_exists_ex(variable, SS("dump") TSRMLS_CC) == SUCCESS)) {
			ZEPHIR_CALL_METHOD(&dumpedObject, variable, "dump", NULL);
			zephir_check_call_status();
			ZEPHIR_CALL_METHOD(&_2, this_ptr, "_getarraydump", &_3, dumpedObject);
			zephir_check_call_status();
			ZEPHIR_CONCAT_SVSVS(dump, "Object(", className, ": ", _2, ")");
		} else {
			ZEPHIR_CONCAT_SVS(dump, "Object(", className, ")</span>");
		}
		RETURN_CCTOR(dump);
	}
	if (Z_TYPE_P(variable) == IS_ARRAY) {
		ZEPHIR_CALL_METHOD(&_2, this_ptr, "_getarraydump", &_3, variable);
		zephir_check_call_status();
		ZEPHIR_CONCAT_SVS(return_value, "Array(", _2, ")");
		RETURN_MM();
	}
	if (Z_TYPE_P(variable) == IS_NULL) {
		RETURN_MM_STRING("null", 1);
	}
	zephir_gettype(return_value, variable TSRMLS_CC);
	RETURN_MM();

}
示例#2
0
/**
 * Prepares event for execution by lazy-loading listener objects.
 *
 * @param string|\Xpl\Event\Event event The event ID or object to trigger.
 * @return boolean|array False if no listeners, otherwise indexed array of the
 * Event object (at index 0) and an array of listeners (at index 1).
 *
 * @throws \InvalidArgumentException if event is not a string or Event object.
 */
PHP_METHOD(Xpl_Event_Manager, prepare) {

	zval *_4$$7;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *event, *eventObj = NULL, *eventId = NULL, *listeners = NULL, *onceListener = NULL, *_3, *_0$$5, *_1$$5, *_2$$5;

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



	if (Z_TYPE_P(event) == IS_STRING) {
		ZEPHIR_CPY_WRT(eventId, event);
		ZEPHIR_INIT_VAR(eventObj);
		object_init_ex(eventObj, xpl_event_event_ce);
		ZEPHIR_CALL_METHOD(NULL, eventObj, "__construct", NULL, 104, event);
		zephir_check_call_status();
	} else if (zephir_instance_of_ev(event, xpl_event_event_ce TSRMLS_CC)) {
		ZEPHIR_CPY_WRT(eventObj, event);
		ZEPHIR_CALL_METHOD(&eventId, event, "getid", NULL, 0);
		zephir_check_call_status();
	} else {
		ZEPHIR_INIT_VAR(_0$$5);
		object_init_ex(_0$$5, spl_ce_InvalidArgumentException);
		ZEPHIR_INIT_VAR(_1$$5);
		zephir_gettype(_1$$5, event TSRMLS_CC);
		ZEPHIR_INIT_VAR(_2$$5);
		ZEPHIR_CONCAT_SV(_2$$5, "Event must be string or instance of Event, given: ", _1$$5);
		ZEPHIR_CALL_METHOD(NULL, _0$$5, "__construct", NULL, 5, _2$$5);
		zephir_check_call_status();
		zephir_throw_exception_debug(_0$$5, "xpl/event/manager.zep", 367 TSRMLS_CC);
		ZEPHIR_MM_RESTORE();
		return;
	}
	_3 = zephir_fetch_nproperty_this(this_ptr, SL("listeners"), PH_NOISY_CC);
	if (!(zephir_array_isset_fetch(&listeners, _3, eventId, 1 TSRMLS_CC))) {
		RETURN_MM_BOOL(0);
	}
	if (zephir_array_isset_string_fetch(&onceListener, listeners, SS("one"), 1 TSRMLS_CC)) {
		zephir_create_array(return_value, 2, 0 TSRMLS_CC);
		zephir_array_fast_append(return_value, eventObj);
		ZEPHIR_INIT_VAR(_4$$7);
		zephir_create_array(_4$$7, 1, 0 TSRMLS_CC);
		zephir_array_fast_append(_4$$7, onceListener);
		zephir_array_fast_append(return_value, _4$$7);
		RETURN_MM();
	}
	zephir_create_array(return_value, 2, 0 TSRMLS_CC);
	zephir_array_fast_append(return_value, eventObj);
	zephir_array_fast_append(return_value, listeners);
	RETURN_MM();

}
示例#3
0
文件: item.zep.c 项目: wells5609/xpl
/**
 * Sets the expiration time for this cache item.
 *
 * @param \DateTimeInterface expiration
 *   The point in time after which the item MUST be considered expired.
 *   If null is passed explicitly, a default value MAY be used. If none is set,
 *   the value should be stored permanently or for as long as the
 *   implementation allows.
 *
 * @return \Xpl\Cache\Item The called object.
 */
PHP_METHOD(Xpl_Cache_Item, expiresAt) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *expiration, *_0$$3, *_1$$3, *_2$$3, *_3$$5 = NULL, *_4$$5, *_5$$5, *_6$$6, *_7$$6 = NULL, _8$$6, *_9$$6 = NULL;

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



	if (Z_TYPE_P(expiration) == IS_NULL) {
		ZEPHIR_INIT_VAR(_0$$3);
		zephir_time(_0$$3);
		_1$$3 = zephir_fetch_nproperty_this(this_ptr, SL("defaultTtl"), PH_NOISY_CC);
		ZEPHIR_INIT_VAR(_2$$3);
		zephir_add_function(_2$$3, _0$$3, _1$$3);
		zephir_update_property_this(this_ptr, SL("expires"), _2$$3 TSRMLS_CC);
	} else {
		if (zephir_is_instance_of(expiration, SL("DateTimeInterface") TSRMLS_CC)) {
			ZEPHIR_INIT_VAR(_4$$5);
			ZVAL_STRING(_4$$5, "U", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(&_3$$5, expiration, "format", NULL, 0, _4$$5);
			zephir_check_temp_parameter(_4$$5);
			zephir_check_call_status();
			ZEPHIR_INIT_ZVAL_NREF(_5$$5);
			ZVAL_LONG(_5$$5, zephir_get_intval(_3$$5));
			zephir_update_property_this(this_ptr, SL("expires"), _5$$5 TSRMLS_CC);
		} else {
			ZEPHIR_INIT_VAR(_6$$6);
			object_init_ex(_6$$6, xpl_cache_invalidargumentexception_ce);
			ZEPHIR_INIT_VAR(_7$$6);
			if (Z_TYPE_P(expiration) == IS_OBJECT) {
				ZEPHIR_INIT_NVAR(_7$$6);
				zephir_get_class(_7$$6, expiration, 0 TSRMLS_CC);
			} else {
				ZEPHIR_INIT_NVAR(_7$$6);
				zephir_gettype(_7$$6, expiration TSRMLS_CC);
			}
			ZEPHIR_SINIT_VAR(_8$$6);
			ZVAL_STRING(&_8$$6, "Expiration date must be null or instance of DateTimeInterface, given: \"%s\".", 0);
			ZEPHIR_CALL_FUNCTION(&_9$$6, "sprintf", NULL, 41, &_8$$6, _7$$6);
			zephir_check_call_status();
			ZEPHIR_CALL_METHOD(NULL, _6$$6, "__construct", NULL, 42, _9$$6);
			zephir_check_call_status();
			zephir_throw_exception_debug(_6$$6, "xpl/cache/item.zep", 147 TSRMLS_CC);
			ZEPHIR_MM_RESTORE();
			return;
		}
	}
	RETURN_THIS();

}
示例#4
0
PHP_METHOD(Test_Resource, testTypeOffResource) {

	zval *a = NULL, *_0;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(a);
	ZEPHIR_GET_CONSTANT(a, "STDIN");
	ZEPHIR_INIT_VAR(_0);
	zephir_gettype(_0, a TSRMLS_CC);
	RETURN_CCTOR(_0);

}
示例#5
0
PHP_METHOD(Test_Invoke, __invoke) {

	zval _0;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&_0);


	zephir_read_property(&_0, this_ptr, SL("a"), PH_NOISY_CC | PH_READONLY);
	zephir_gettype(return_value, &_0 TSRMLS_CC);
	return;

}
示例#6
0
PHP_METHOD(Test_Typeoff, testNativeBoolFalse) {

    zval *_0;
    zend_bool testVar;

    ZEPHIR_MM_GROW();

    testVar = 0;
    ZEPHIR_INIT_VAR(_0);
    zephir_gettype(_0, (testVar ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false)) TSRMLS_CC);
    RETURN_MM_BOOL(ZEPHIR_IS_STRING(_0, "double"));

}
示例#7
0
PHP_METHOD(Test_Typeoff, testNativeStringTrue) {

    zval *_0;
    zval *testVar;

    ZEPHIR_MM_GROW();

    ZEPHIR_INIT_VAR(testVar);
    ZVAL_STRING(testVar, "sdfsdf", 1);
    ZEPHIR_INIT_VAR(_0);
    zephir_gettype(_0, testVar TSRMLS_CC);
    RETURN_MM_BOOL(ZEPHIR_IS_STRING(_0, "string"));

}
示例#8
0
PHP_METHOD(Test_Typeoff, testUnknownTypeOf) {

    zval *u, *_0;

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



    ZEPHIR_INIT_VAR(_0);
    zephir_gettype(_0, u TSRMLS_CC);
    RETURN_CCTOR(_0);

}
示例#9
0
PHP_METHOD(Test_Typeoff, testNativeDoubleTrue) {

    zval *_0, _1;
    double testVar;

    ZEPHIR_MM_GROW();

    testVar = (double) (12345);
    ZEPHIR_INIT_VAR(_0);
    ZEPHIR_SINIT_VAR(_1);
    ZVAL_DOUBLE(&_1, testVar);
    zephir_gettype(_0, &_1 TSRMLS_CC);
    RETURN_MM_BOOL(ZEPHIR_IS_STRING(_0, "double"));

}
示例#10
0
PHP_METHOD(Test_Typeoff, testNativeIntTrue) {

    zval *_0, _1;
    int testVar;

    ZEPHIR_MM_GROW();

    testVar = 12345;
    ZEPHIR_INIT_VAR(_0);
    ZEPHIR_SINIT_VAR(_1);
    ZVAL_LONG(&_1, testVar);
    zephir_gettype(_0, &_1 TSRMLS_CC);
    RETURN_MM_BOOL(ZEPHIR_IS_STRING(_0, "integer"));

}
示例#11
0
PHP_METHOD(Test_ResourceTest, testTypeOffResource) {

	zval a, _0;
		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(&a);
	ZVAL_UNDEF(&_0);

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(&a);
	ZEPHIR_GET_CONSTANT(&a, "STDIN");
	ZEPHIR_INIT_VAR(&_0);
	zephir_gettype(&_0, &a TSRMLS_CC);
	RETURN_CCTOR(_0);

}
示例#12
0
PHP_METHOD(Xpl_Collection_ScalarSet, cast) {

	zval *_1$$3;
	zend_bool _0;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *value, *_3, *_4, *_5, *_2$$3 = NULL;

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



	_0 = Z_TYPE_P(value) == IS_NULL;
	if (!(_0)) {
		_0 = zephir_is_scalar(value);
	}
	if (likely(_0)) {
		ZEPHIR_INIT_VAR(_1$$3);
		zephir_create_array(_1$$3, 1, 0 TSRMLS_CC);
		zephir_array_update_string(&_1$$3, SL("scalar"), &value, PH_COPY | PH_SEPARATE);
		ZEPHIR_CPY_WRT(_2$$3, _1$$3);
		zephir_convert_to_object(_2$$3);
		RETURN_CCTOR(_2$$3);
	}
	ZEPHIR_INIT_VAR(_3);
	object_init_ex(_3, spl_ce_InvalidArgumentException);
	ZEPHIR_INIT_VAR(_4);
	zephir_gettype(_4, value TSRMLS_CC);
	ZEPHIR_INIT_VAR(_5);
	ZEPHIR_CONCAT_SV(_5, "Expecting null or scalar, given: ", _4);
	ZEPHIR_CALL_METHOD(NULL, _3, "__construct", NULL, 5, _5);
	zephir_check_call_status();
	zephir_throw_exception_debug(_3, "xpl/collection/scalarset.zep", 64 TSRMLS_CC);
	ZEPHIR_MM_RESTORE();
	return;

}
示例#13
0
/**
 * Unregisters one or all listeners for an event.
 *
 * @param string|\Xpl\Event\Event event Event ID or object.
 * @param callable callback [Optional] Callback to remove. If no callback is given,
 * then all of the event's listeners are removed.
 * @return \Xpl\Event\Manager
 *
 * @throws \InvalidArgumentException if event is not a string or Event instance.
 */
PHP_METHOD(Xpl_Event_Manager, off) {

	HashTable *_6$$8;
	HashPosition _5$$8;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *event, *callback = NULL, *id = NULL, *listeners = NULL, *_4, *_0$$4, *_1$$5, *_2$$5, *_3$$5, *i$$8 = NULL, *listener$$8 = NULL, **_7$$8, *_8$$9 = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 1, &event, &callback);

	if (!callback) {
		callback = ZEPHIR_GLOBAL(global_null);
	}


	if (Z_TYPE_P(event) == IS_STRING) {
		ZEPHIR_CPY_WRT(id, event);
	} else if (zephir_instance_of_ev(event, xpl_event_event_ce TSRMLS_CC)) {
		ZEPHIR_OBS_VAR(_0$$4);
		zephir_read_property(&_0$$4, event, SL("id"), PH_NOISY_CC);
		ZEPHIR_CPY_WRT(id, _0$$4);
	} else {
		ZEPHIR_INIT_VAR(_1$$5);
		object_init_ex(_1$$5, spl_ce_InvalidArgumentException);
		ZEPHIR_INIT_VAR(_2$$5);
		zephir_gettype(_2$$5, event TSRMLS_CC);
		ZEPHIR_INIT_VAR(_3$$5);
		ZEPHIR_CONCAT_SV(_3$$5, "Event must be string or instance of Event, given: ", _2$$5);
		ZEPHIR_CALL_METHOD(NULL, _1$$5, "__construct", NULL, 5, _3$$5);
		zephir_check_call_status();
		zephir_throw_exception_debug(_1$$5, "xpl/event/manager.zep", 118 TSRMLS_CC);
		ZEPHIR_MM_RESTORE();
		return;
	}
	ZEPHIR_OBS_VAR(listeners);
	_4 = zephir_fetch_nproperty_this(this_ptr, SL("listeners"), PH_NOISY_CC);
	if (zephir_array_isset_fetch(&listeners, _4, id, 0 TSRMLS_CC)) {
		if (Z_TYPE_P(callback) == IS_NULL) {
			zephir_array_unset(&listeners, id, PH_SEPARATE);
		} else {
			zephir_is_iterable(listeners, &_6$$8, &_5$$8, 1, 0, "xpl/event/manager.zep", 137);
			for (
			  ; zephir_hash_get_current_data_ex(_6$$8, (void**) &_7$$8, &_5$$8) == SUCCESS
			  ; zephir_hash_move_forward_ex(_6$$8, &_5$$8)
			) {
				ZEPHIR_GET_HMKEY(i$$8, _6$$8, _5$$8);
				ZEPHIR_GET_HVALUE(listener$$8, _7$$8);
				ZEPHIR_OBS_NVAR(_8$$9);
				zephir_read_property(&_8$$9, listener$$8, SL("callback"), PH_NOISY_CC);
				if (ZEPHIR_IS_EQUAL(callback, _8$$9)) {
					zephir_array_unset(&listeners, i$$8, PH_SEPARATE);
				}
			}
			zend_hash_destroy(_6$$8);
			FREE_HASHTABLE(_6$$8);
		}
		zephir_update_property_array(this_ptr, SL("listeners"), id, listeners TSRMLS_CC);
	}
	RETURN_THIS();

}
示例#14
0
文件: item.zep.c 项目: wells5609/xpl
/**
 * Sets the expiration time for this cache item.
 *
 * @param int|\DateInterval time
 *   The period of time from the present after which the item MUST be considered
 *   expired. An integer parameter is understood to be the time in seconds until
 *   expiration. If null is passed explicitly, a default value MAY be used.
 *   If none is set, the value should be stored permanently or for as long as the
 *   implementation allows.
 *
 * @return \Xpl\Cache\Item
 *   The called object.
 */
PHP_METHOD(Xpl_Cache_Item, expiresAfter) {

	zend_class_entry *_6$$7;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *time, *_0$$3, *_1$$3, *_2$$3, *_3$$5, *_4$$5, *_5$$7 = NULL, *_7$$7, *_8$$7 = NULL, *_9$$7 = NULL, *_10$$7 = NULL, *_11$$8, *_12$$8 = NULL, _13$$8, *_14$$8 = NULL;

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



	if (Z_TYPE_P(time) == IS_NULL) {
		ZEPHIR_INIT_VAR(_0$$3);
		zephir_time(_0$$3);
		_1$$3 = zephir_fetch_nproperty_this(this_ptr, SL("defaultTtl"), PH_NOISY_CC);
		ZEPHIR_INIT_VAR(_2$$3);
		zephir_add_function(_2$$3, _0$$3, _1$$3);
		zephir_update_property_this(this_ptr, SL("expires"), _2$$3 TSRMLS_CC);
	} else {
		if (Z_TYPE_P(time) == IS_LONG) {
			ZEPHIR_INIT_VAR(_3$$5);
			zephir_time(_3$$5);
			ZEPHIR_INIT_VAR(_4$$5);
			zephir_add_function(_4$$5, _3$$5, time);
			zephir_update_property_this(this_ptr, SL("expires"), _4$$5 TSRMLS_CC);
		} else {
			if (zephir_instance_of_ev(time, zephir_get_internal_ce(SS("dateinterval") TSRMLS_CC) TSRMLS_CC)) {
					_6$$7 = zend_fetch_class(SL("DateTime"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC);
				ZEPHIR_INIT_VAR(_7$$7);
				zephir_time(_7$$7);
				ZEPHIR_INIT_VAR(_8$$7);
				ZVAL_STRING(_8$$7, "U", ZEPHIR_TEMP_PARAM_COPY);
				ZEPHIR_CALL_CE_STATIC(&_5$$7, _6$$7, "createfromformat", NULL, 0, _8$$7, _7$$7);
				zephir_check_temp_parameter(_8$$7);
				zephir_check_call_status();
				ZEPHIR_CALL_METHOD(&_9$$7, _5$$7, "add", NULL, 0, time);
				zephir_check_call_status();
				ZEPHIR_INIT_NVAR(_8$$7);
				ZVAL_STRING(_8$$7, "U", ZEPHIR_TEMP_PARAM_COPY);
				ZEPHIR_CALL_METHOD(&_10$$7, _9$$7, "format", NULL, 0, _8$$7);
				zephir_check_temp_parameter(_8$$7);
				zephir_check_call_status();
				zephir_update_property_this(this_ptr, SL("expires"), _10$$7 TSRMLS_CC);
			} else {
				ZEPHIR_INIT_VAR(_11$$8);
				object_init_ex(_11$$8, xpl_cache_invalidargumentexception_ce);
				ZEPHIR_INIT_VAR(_12$$8);
				if (Z_TYPE_P(time) == IS_OBJECT) {
					ZEPHIR_INIT_NVAR(_12$$8);
					zephir_get_class(_12$$8, time, 0 TSRMLS_CC);
				} else {
					ZEPHIR_INIT_NVAR(_12$$8);
					zephir_gettype(_12$$8, time TSRMLS_CC);
				}
				ZEPHIR_SINIT_VAR(_13$$8);
				ZVAL_STRING(&_13$$8, "Expiration date must be integer, DateInterval or null, given: \"%s\".", 0);
				ZEPHIR_CALL_FUNCTION(&_14$$8, "sprintf", NULL, 41, &_13$$8, _12$$8);
				zephir_check_call_status();
				ZEPHIR_CALL_METHOD(NULL, _11$$8, "__construct", NULL, 42, _14$$8);
				zephir_check_call_status();
				zephir_throw_exception_debug(_11$$8, "xpl/cache/item.zep", 181 TSRMLS_CC);
				ZEPHIR_MM_RESTORE();
				return;
			}
		}
	}
	RETURN_THIS();

}