PHP_METHOD(Test_Oo_OoDynamicA, getNew) { zend_class_entry *_1; zval className, fullClassName, _0; int ZEPHIR_LAST_CALL_STATUS; ZEPHIR_INIT_THIS(); ZVAL_UNDEF(&className); ZVAL_UNDEF(&fullClassName); ZVAL_UNDEF(&_0); ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(&className); zephir_get_called_class(&className TSRMLS_CC); ZEPHIR_INIT_VAR(&fullClassName); ZEPHIR_CONCAT_SV(&fullClassName, "\\", &className); zephir_fetch_safe_class(_0, fullClassName); _1 = zephir_fetch_class_str_ex(Z_STRVAL_P(&_0), Z_STRLEN_P(&_0), ZEND_FETCH_CLASS_AUTO); object_init_ex(return_value, _1); if (zephir_has_constructor(return_value TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 0); zephir_check_call_status(); } RETURN_MM(); }
/** * Fetches a zend class entry from a zval value */ zend_class_entry *zephir_fetch_class(const zval *class_name) { if (Z_TYPE_P(class_name) == IS_STRING) { return zend_fetch_class(Z_STR_P(class_name), ZEND_FETCH_CLASS_DEFAULT TSRMLS_CC); } php_error_docref(NULL, E_WARNING, "class name must be a string"); return zephir_fetch_class_str_ex(SL("stdclass"), ZEND_FETCH_CLASS_DEFAULT); }
/** * Dumps a PHP array to a YAML string. * * The dump method, when supplied with an array, will do its best * to convert the array into friendly YAML. * * @param array array PHP array * @param int inline The level where you switch to inline YAML * @param int indent The amount of spaces to use for indentation of nested nodes. * @param int flags A bit field of DUMP_* constants to customize the dumped YAML string * * @return string A YAML string representing the original PHP array */ PHP_METHOD(Symphir_Component_Yaml_Yaml, dump) { zephir_nts_static zend_class_entry *_0 = NULL; int inlineLevel, indent, flags, ZEPHIR_LAST_CALL_STATUS; zval *phpArray_param = NULL, *inlineLevel_param = NULL, *indent_param = NULL, *flags_param = NULL, yaml, _1, _2, _3; zval phpArray; ZEPHIR_INIT_THIS(); ZVAL_UNDEF(&phpArray); ZVAL_UNDEF(&yaml); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 3, &phpArray_param, &inlineLevel_param, &indent_param, &flags_param); zephir_get_arrval(&phpArray, phpArray_param); if (!inlineLevel_param) { inlineLevel = 2; } else { inlineLevel = zephir_get_intval(inlineLevel_param); } if (!indent_param) { indent = 4; } else { indent = zephir_get_intval(indent_param); } if (!flags_param) { flags = 0; } else { flags = zephir_get_intval(flags_param); } ZEPHIR_INIT_VAR(&yaml); if (!_0) { _0 = zephir_fetch_class_str_ex(SL("Symphir\\Component\\Yaml\\Dumper"), ZEND_FETCH_CLASS_AUTO); } object_init_ex(&yaml, _0); if (zephir_has_constructor(&yaml TSRMLS_CC)) { ZVAL_LONG(&_1, indent); ZEPHIR_CALL_METHOD(NULL, &yaml, "__construct", NULL, 0, &_1); zephir_check_call_status(); } ZVAL_LONG(&_1, inlineLevel); ZVAL_LONG(&_2, 0); ZVAL_LONG(&_3, flags); ZEPHIR_RETURN_CALL_METHOD(&yaml, "dump", NULL, 0, &phpArray, &_1, &_2, &_3); zephir_check_call_status(); RETURN_MM(); }
PHP_METHOD(Test_UseTest, testUseNamespaceAlias) { zephir_nts_static zend_class_entry *_0 = NULL; int ZEPHIR_LAST_CALL_STATUS; ZEPHIR_INIT_THIS(); ZEPHIR_MM_GROW(); if (!_0) { _0 = zephir_fetch_class_str_ex(SL("Oo\\OoConstruct"), ZEND_FETCH_CLASS_AUTO); } object_init_ex(return_value, _0); if (zephir_has_constructor(return_value TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 0); zephir_check_call_status(); } RETURN_MM(); }
/** * Check if an object is instance of a class */ int zephir_is_instance_of(zval *object, const char *class_name, unsigned int class_length) { zend_class_entry *ce, *temp_ce; if (Z_TYPE_P(object) == IS_OBJECT) { ce = Z_OBJCE_P(object); if (ZSTR_LEN(ce->name) == class_length) { if (!zend_binary_strcasecmp(ZSTR_VAL(ce->name), ZSTR_LEN(ce->name), class_name, class_length)) { return 1; } } temp_ce = zephir_fetch_class_str_ex(class_name, class_length, ZEND_FETCH_CLASS_DEFAULT); if (temp_ce) { return instanceof_function(ce, temp_ce); } } return 0; }
/** * Parses YAML into a PHP value. * * Usage: * <code> * $array = Yaml::parse(file_get_contents('config.yml')); * print_r($array); * </code> * * @param string $input A string containing YAML * @param int $flags A bit field of PARSE_* constants to customize the YAML parser behavior * * @return mixed The YAML converted to a PHP value * * @throws ParseException If the YAML is not valid */ PHP_METHOD(Symphir_Component_Yaml_Yaml, parse) { zephir_nts_static zend_class_entry *_0 = NULL; int flags, ZEPHIR_LAST_CALL_STATUS; zval *input_param = NULL, *flags_param = NULL, yaml, _1; zval input; ZEPHIR_INIT_THIS(); ZVAL_UNDEF(&input); ZVAL_UNDEF(&yaml); ZVAL_UNDEF(&_1); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &input_param, &flags_param); zephir_get_strval(&input, input_param); if (!flags_param) { flags = 0; } else { flags = zephir_get_intval(flags_param); } ZEPHIR_INIT_VAR(&yaml); if (!_0) { _0 = zephir_fetch_class_str_ex(SL("Symphir\\Component\\Yaml\\Parser"), ZEND_FETCH_CLASS_AUTO); } object_init_ex(&yaml, _0); if (zephir_has_constructor(&yaml TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, &yaml, "__construct", NULL, 0); zephir_check_call_status(); } ZVAL_LONG(&_1, flags); ZEPHIR_RETURN_CALL_METHOD(&yaml, "parse", NULL, 0, &input, &_1); zephir_check_call_status(); RETURN_MM(); }
/** * Resolves the service * * @param array parameters * @return mixed */ PHP_METHOD(Phalcon_Di_Service, resolve) { zend_class_entry *_1$$15; zend_bool found = 0; zend_long ZEPHIR_LAST_CALL_STATUS; zval *parameters = NULL, parameters_sub, *dependencyInjector = NULL, dependencyInjector_sub, __$true, __$false, __$null, shared, definition, sharedInstance, instance, builder, _0$$15, _2$$22; zval *this_ptr = getThis(); ZVAL_UNDEF(¶meters_sub); ZVAL_UNDEF(&dependencyInjector_sub); ZVAL_BOOL(&__$true, 1); ZVAL_BOOL(&__$false, 0); ZVAL_NULL(&__$null); ZVAL_UNDEF(&shared); ZVAL_UNDEF(&definition); ZVAL_UNDEF(&sharedInstance); ZVAL_UNDEF(&instance); ZVAL_UNDEF(&builder); ZVAL_UNDEF(&_0$$15); ZVAL_UNDEF(&_2$$22); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, ¶meters, &dependencyInjector); if (!parameters) { parameters = ¶meters_sub; parameters = &__$null; } if (!dependencyInjector) { dependencyInjector = &dependencyInjector_sub; dependencyInjector = &__$null; } ZEPHIR_OBS_VAR(&shared); zephir_read_property(&shared, this_ptr, SL("_shared"), PH_NOISY_CC); if (zephir_is_true(&shared)) { ZEPHIR_OBS_VAR(&sharedInstance); zephir_read_property(&sharedInstance, this_ptr, SL("_sharedInstance"), PH_NOISY_CC); if (Z_TYPE_P(&sharedInstance) != IS_NULL) { RETURN_CCTOR(&sharedInstance); } } found = 1; ZEPHIR_INIT_VAR(&instance); ZVAL_NULL(&instance); ZEPHIR_OBS_VAR(&definition); zephir_read_property(&definition, this_ptr, SL("_definition"), PH_NOISY_CC); if (Z_TYPE_P(&definition) == IS_STRING) { if (zephir_class_exists(&definition, 1 TSRMLS_CC)) { if (Z_TYPE_P(parameters) == IS_ARRAY) { if (zephir_fast_count_int(parameters TSRMLS_CC)) { ZEPHIR_INIT_NVAR(&instance); ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(&instance, &definition, parameters TSRMLS_CC); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(&instance); ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(&instance, &definition TSRMLS_CC); zephir_check_call_status(); } } else { ZEPHIR_INIT_NVAR(&instance); ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(&instance, &definition TSRMLS_CC); zephir_check_call_status(); } } else { found = 0; } } else { if (Z_TYPE_P(&definition) == IS_OBJECT) { if (zephir_instance_of_ev(&definition, zend_ce_closure TSRMLS_CC)) { if (Z_TYPE_P(dependencyInjector) == IS_OBJECT) { _1$$15 = zephir_fetch_class_str_ex(SL("Closure"), ZEND_FETCH_CLASS_AUTO); ZEPHIR_CALL_CE_STATIC(&_0$$15, _1$$15, "bind", NULL, 0, &definition, dependencyInjector); zephir_check_call_status(); ZEPHIR_CPY_WRT(&definition, &_0$$15); } if (Z_TYPE_P(parameters) == IS_ARRAY) { ZEPHIR_INIT_NVAR(&instance); ZEPHIR_CALL_USER_FUNC_ARRAY(&instance, &definition, parameters); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(&instance); ZEPHIR_CALL_USER_FUNC(&instance, &definition); zephir_check_call_status(); } } else { ZEPHIR_CPY_WRT(&instance, &definition); } } else { if (Z_TYPE_P(&definition) == IS_ARRAY) { ZEPHIR_INIT_VAR(&builder); object_init_ex(&builder, phalcon_di_service_builder_ce); if (zephir_has_constructor(&builder TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, &builder, "__construct", NULL, 0); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&instance, &builder, "build", NULL, 171, dependencyInjector, &definition, parameters); zephir_check_call_status(); } else { found = 0; } } } if (found == 0) { ZEPHIR_INIT_VAR(&_2$$22); object_init_ex(&_2$$22, phalcon_di_exception_serviceresolutionexception_ce); ZEPHIR_CALL_METHOD(NULL, &_2$$22, "__construct", NULL, 4); zephir_check_call_status(); zephir_throw_exception_debug(&_2$$22, "phalcon/di/service.zep", 186 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (zephir_is_true(&shared)) { zephir_update_property_zval(this_ptr, SL("_sharedInstance"), &instance); } if (1) { zephir_update_property_zval(this_ptr, SL("_resolved"), &__$true); } else { zephir_update_property_zval(this_ptr, SL("_resolved"), &__$false); } RETURN_CCTOR(&instance); }