summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/curl/config.m49
-rw-r--r--ext/curl/config.w323
-rw-r--r--ext/curl/curl.dsp4
-rw-r--r--ext/curl/interface.c1899
-rw-r--r--ext/curl/multi.c4
-rw-r--r--ext/curl/package.xml1
-rw-r--r--ext/curl/php_curl.h39
-rw-r--r--ext/curl/share.c136
-rw-r--r--ext/curl/tests/bug54995.phpt30
-rw-r--r--ext/curl/tests/curl_basic_022.phpt25
-rw-r--r--ext/curl/tests/curl_escape.phptbin0 -> 553 bytes
-rw-r--r--ext/curl/tests/curl_reset.phpt40
-rw-r--r--ext/curl/tests/curl_setopt_basic003.phpt2
-rw-r--r--ext/date/TODO1
-rw-r--r--ext/date/lib/parse_date.c2
-rw-r--r--ext/date/lib/parse_iso_intervals.c2
-rwxr-xr-x[-rw-r--r--]ext/date/tests/bug60236.phpt0
-rw-r--r--ext/ereg/regex.patch72
-rw-r--r--ext/fileinfo/libmagic/print.c1
-rw-r--r--ext/fileinfo/php_fileinfo.h2
-rwxr-xr-xext/interbase/tests/skipif.inc3
-rw-r--r--ext/intl/calendar/calendar_class.cpp550
-rw-r--r--ext/intl/calendar/calendar_class.h70
-rw-r--r--ext/intl/calendar/calendar_methods.cpp1325
-rw-r--r--ext/intl/calendar/calendar_methods.h112
-rw-r--r--ext/intl/calendar/gregoriancalendar_methods.cpp256
-rw-r--r--ext/intl/calendar/gregoriancalendar_methods.h32
-rwxr-xr-xext/intl/collator/collator_sort.c1
-rw-r--r--ext/intl/common/common_enum.cpp385
-rw-r--r--ext/intl/common/common_enum.h38
-rwxr-xr-xext/intl/config.m414
-rwxr-xr-xext/intl/config.w3218
-rwxr-xr-xext/intl/dateformat/dateformat.c154
-rwxr-xr-xext/intl/dateformat/dateformat_attr.c164
-rwxr-xr-xext/intl/dateformat/dateformat_attr.h4
-rw-r--r--ext/intl/dateformat/dateformat_attrcpp.cpp261
-rw-r--r--ext/intl/dateformat/dateformat_attrcpp.h35
-rwxr-xr-xext/intl/dateformat/dateformat_class.c20
-rwxr-xr-xext/intl/dateformat/dateformat_class.h12
-rw-r--r--ext/intl/dateformat/dateformat_create.cpp193
-rw-r--r--ext/intl/dateformat/dateformat_create.h25
-rwxr-xr-xext/intl/dateformat/dateformat_format.c4
-rw-r--r--ext/intl/dateformat/dateformat_helpers.cpp106
-rw-r--r--ext/intl/dateformat/dateformat_helpers.h39
-rwxr-xr-xext/intl/grapheme/grapheme.h1
-rw-r--r--ext/intl/intl_convertcpp.cpp89
-rw-r--r--ext/intl/intl_convertcpp.h32
-rw-r--r--ext/intl/intl_cppshims.h34
-rwxr-xr-xext/intl/intl_error.c25
-rwxr-xr-xext/intl/intl_error.h3
-rwxr-xr-xext/intl/locale/locale.h2
-rwxr-xr-xext/intl/locale/locale_methods.c13
-rwxr-xr-xext/intl/msgformat/msgformat_attr.c6
-rwxr-xr-xext/intl/msgformat/msgformat_data.c24
-rwxr-xr-xext/intl/msgformat/msgformat_data.h2
-rwxr-xr-xext/intl/msgformat/msgformat_format.c47
-rwxr-xr-xext/intl/msgformat/msgformat_helpers.cpp701
-rwxr-xr-xext/intl/msgformat/msgformat_helpers.h6
-rwxr-xr-xext/intl/php_intl.c309
-rwxr-xr-xext/intl/php_intl.h8
-rw-r--r--ext/intl/resourcebundle/resourcebundle_class.c2
-rwxr-xr-xext/intl/tests/badargs.phpt5
-rw-r--r--ext/intl/tests/bug50590.phpt2
-rw-r--r--ext/intl/tests/bug58756_MessageFormatter.phpt34
-rw-r--r--ext/intl/tests/bug62017.phpt2
-rw-r--r--ext/intl/tests/bug62081.phpt6
-rw-r--r--ext/intl/tests/calendar_add_basic.phpt33
-rw-r--r--ext/intl/tests/calendar_add_error.phpt41
-rw-r--r--ext/intl/tests/calendar_before_after_error.phpt57
-rw-r--r--ext/intl/tests/calendar_clear_basic.phpt40
-rw-r--r--ext/intl/tests/calendar_clear_error.phpt31
-rw-r--r--ext/intl/tests/calendar_clear_variation1.phpt33
-rw-r--r--ext/intl/tests/calendar_createInstance_basic.phpt42
-rw-r--r--ext/intl/tests/calendar_createInstance_error.phpt38
-rw-r--r--ext/intl/tests/calendar_createInstance_variation1.phpt84
-rw-r--r--ext/intl/tests/calendar_equals_before_after_basic.phpt59
-rw-r--r--ext/intl/tests/calendar_equals_error.phpt46
-rw-r--r--ext/intl/tests/calendar_fieldDifference_basic.phpt35
-rw-r--r--ext/intl/tests/calendar_fieldDifference_error.phpt42
-rw-r--r--ext/intl/tests/calendar_fromDateTime_basic.phpt52
-rw-r--r--ext/intl/tests/calendar_fromDateTime_error.phpt59
-rw-r--r--ext/intl/tests/calendar_getAvailableLocales_basic.phpt23
-rw-r--r--ext/intl/tests/calendar_getAvailableLocales_error.phpt24
-rw-r--r--ext/intl/tests/calendar_getDayOfWeekType_basic.phpt34
-rw-r--r--ext/intl/tests/calendar_getDayOfWeekType_error.phpt44
-rw-r--r--ext/intl/tests/calendar_getErrorCode_error.phpt26
-rw-r--r--ext/intl/tests/calendar_getErrorCode_getErrorMessage_basic.phpt43
-rw-r--r--ext/intl/tests/calendar_getErrorMessage_error.phpt26
-rw-r--r--ext/intl/tests/calendar_getFirstDayOfWeek_basic.phpt20
-rw-r--r--ext/intl/tests/calendar_getFirstDayOfWeek_error.phpt32
-rw-r--r--ext/intl/tests/calendar_getKeywordValuesForLocale_basic.phpt36
-rw-r--r--ext/intl/tests/calendar_getKeywordValuesForLocale_error.phpt26
-rw-r--r--ext/intl/tests/calendar_getLocale_basic.phpt22
-rw-r--r--ext/intl/tests/calendar_getLocale_error.phpt42
-rw-r--r--ext/intl/tests/calendar_getMinimalDaysInFirstWeek_basic.phpt22
-rw-r--r--ext/intl/tests/calendar_getMinimalDaysInFirstWeek_error.phpt32
-rw-r--r--ext/intl/tests/calendar_getNow_basic.phpt23
-rw-r--r--ext/intl/tests/calendar_getNow_error.phpt24
-rw-r--r--ext/intl/tests/calendar_getSkipped_RepeatedWallTimeOption_error.phpt47
-rw-r--r--ext/intl/tests/calendar_getTimeZone_basic.phpt34
-rw-r--r--ext/intl/tests/calendar_getTimeZone_error.phpt32
-rw-r--r--ext/intl/tests/calendar_getTime_basic.phpt29
-rw-r--r--ext/intl/tests/calendar_getTime_error.phpt31
-rw-r--r--ext/intl/tests/calendar_getType_basic.phpt23
-rw-r--r--ext/intl/tests/calendar_getType_error.phpt32
-rw-r--r--ext/intl/tests/calendar_getWeekendTransition_basic.phpt24
-rw-r--r--ext/intl/tests/calendar_getWeekendTransition_error.phpt44
-rw-r--r--ext/intl/tests/calendar_getXMaximum_basic.phpt34
-rw-r--r--ext/intl/tests/calendar_getXMinimum_basic.phpt34
-rw-r--r--ext/intl/tests/calendar_get_Least_Greatest_Minimum_Maximum_error.phpt100
-rw-r--r--ext/intl/tests/calendar_get_basic.phpt23
-rw-r--r--ext/intl/tests/calendar_get_getActualMaximum_Minumum_error.phpt84
-rw-r--r--ext/intl/tests/calendar_get_getActualMaximum_Minumum_error2.phpt71
-rw-r--r--ext/intl/tests/calendar_get_setRepeatedWallTimeOption_basic.phpt49
-rw-r--r--ext/intl/tests/calendar_get_setSkippedWallTimeOption_basic.phpt67
-rw-r--r--ext/intl/tests/calendar_inDaylightTime_basic.phpt24
-rw-r--r--ext/intl/tests/calendar_inDaylightTime_error.phpt32
-rw-r--r--ext/intl/tests/calendar_isEquivalentTo_basic.phpt40
-rw-r--r--ext/intl/tests/calendar_isEquivalentTo_error.phpt50
-rw-r--r--ext/intl/tests/calendar_isLenient_error.phpt32
-rw-r--r--ext/intl/tests/calendar_isSet_basic.phpt24
-rw-r--r--ext/intl/tests/calendar_isSet_error.phpt42
-rw-r--r--ext/intl/tests/calendar_isWeekend_basic.phpt26
-rw-r--r--ext/intl/tests/calendar_isWeekend_error.phpt38
-rw-r--r--ext/intl/tests/calendar_is_set_lenient_basic.phpt28
-rw-r--r--ext/intl/tests/calendar_roll_basic.phpt34
-rw-r--r--ext/intl/tests/calendar_roll_error.phpt37
-rw-r--r--ext/intl/tests/calendar_roll_variation1.phpt32
-rw-r--r--ext/intl/tests/calendar_setFirstDayOfWeek_basic.phpt28
-rw-r--r--ext/intl/tests/calendar_setFirstDayOfWeek_error.phpt40
-rw-r--r--ext/intl/tests/calendar_setLenient_error.phpt44
-rw-r--r--ext/intl/tests/calendar_setSkipped_RepeatedWallTimeOption_error.phpt82
-rw-r--r--ext/intl/tests/calendar_setTimeZone_basic.phpt39
-rw-r--r--ext/intl/tests/calendar_setTimeZone_error.phpt41
-rw-r--r--ext/intl/tests/calendar_setTimeZone_error2.phpt29
-rw-r--r--ext/intl/tests/calendar_setTimeZone_variation1.phpt30
-rw-r--r--ext/intl/tests/calendar_setTimeZone_variation2.phpt30
-rw-r--r--ext/intl/tests/calendar_setTime_basic.phpt33
-rw-r--r--ext/intl/tests/calendar_setTime_error.phpt37
-rw-r--r--ext/intl/tests/calendar_set_basic.phpt27
-rw-r--r--ext/intl/tests/calendar_set_error.phpt41
-rw-r--r--ext/intl/tests/calendar_set_variation1.phpt41
-rw-r--r--ext/intl/tests/calendar_toDateTime_basic.phpt23
-rw-r--r--ext/intl/tests/calendar_toDateTime_error.phpt41
-rw-r--r--ext/intl/tests/dateformat___construct_bad_tz_cal.phpt28
-rw-r--r--ext/intl/tests/dateformat_calendars.phpt2
-rw-r--r--ext/intl/tests/dateformat_create_cal_arg.phpt49
-rwxr-xr-xext/intl/tests/dateformat_format.phpt4
-rwxr-xr-xext/intl/tests/dateformat_format_parse.phpt2
-rw-r--r--ext/intl/tests/dateformat_getCalendarObject_error.phpt39
-rw-r--r--ext/intl/tests/dateformat_getTimeZone_error.phpt39
-rwxr-xr-xext/intl/tests/dateformat_get_set_calendar.phpt93
-rw-r--r--ext/intl/tests/dateformat_get_set_timezone.phpt58
-rwxr-xr-xext/intl/tests/dateformat_get_timezone_id.phpt15
-rw-r--r--ext/intl/tests/dateformat_setTimeZoneID_deprecation.phpt18
-rw-r--r--ext/intl/tests/dateformat_setTimeZone_error.phpt49
-rw-r--r--ext/intl/tests/dateformat_set_timezone_id2.phpt22
-rw-r--r--ext/intl/tests/dateformat_timezone_arg_variations.phpt41
-rw-r--r--ext/intl/tests/gregoriancalendar___construct_basic.phpt51
-rw-r--r--ext/intl/tests/gregoriancalendar___construct_error.phpt35
-rw-r--r--ext/intl/tests/gregoriancalendar___construct_variant1.phpt30
-rw-r--r--ext/intl/tests/gregoriancalendar_getGregorianChange_error.phpt30
-rw-r--r--ext/intl/tests/gregoriancalendar_get_setGregorianChange_basic.phpt32
-rw-r--r--ext/intl/tests/gregoriancalendar_isLeapYear_basic.phpt28
-rw-r--r--ext/intl/tests/gregoriancalendar_isLeapYear_error.phpt48
-rw-r--r--ext/intl/tests/gregoriancalendar_setGregorianChange_error.phpt42
-rw-r--r--ext/intl/tests/ini_use_exceptions_basic.phpt21
-rw-r--r--ext/intl/tests/msgfmt_format_datetime.phpt28
-rw-r--r--ext/intl/tests/msgfmt_format_error1.phpt19
-rw-r--r--ext/intl/tests/msgfmt_format_error2.phpt23
-rw-r--r--ext/intl/tests/msgfmt_format_error3.phpt23
-rw-r--r--ext/intl/tests/msgfmt_format_error4.phpt28
-rw-r--r--ext/intl/tests/msgfmt_format_error5.phpt25
-rw-r--r--ext/intl/tests/msgfmt_format_error6.phpt23
-rw-r--r--ext/intl/tests/msgfmt_format_intlcalendar.phpt30
-rw-r--r--ext/intl/tests/msgfmt_format_mixed_params.phpt25
-rw-r--r--ext/intl/tests/msgfmt_format_simple_types_numeric_strings.phpt58
-rw-r--r--ext/intl/tests/msgfmt_format_subpatterns.phpt75
-rw-r--r--ext/intl/tests/msgfmt_format_subpatterns_named.phpt75
-rwxr-xr-xext/intl/tests/msgfmt_get_error.phpt29
-rw-r--r--ext/intl/tests/msgfmt_millisecond_dates.phpt29
-rw-r--r--ext/intl/tests/msgfmt_setPattern_cache.phpt26
-rw-r--r--ext/intl/tests/timezone_clone_basic.phpt51
-rw-r--r--ext/intl/tests/timezone_clone_error.phpt32
-rw-r--r--ext/intl/tests/timezone_countEquivalentIDs_basic.phpt20
-rw-r--r--ext/intl/tests/timezone_countEquivalentIDs_error.phpt35
-rw-r--r--ext/intl/tests/timezone_createDefault_basic.phpt31
-rw-r--r--ext/intl/tests/timezone_createDefault_error.phpt19
-rw-r--r--ext/intl/tests/timezone_createEnumeration_basic.phpt26
-rw-r--r--ext/intl/tests/timezone_createEnumeration_error.phpt23
-rw-r--r--ext/intl/tests/timezone_createEnumeration_variation1.phpt24
-rw-r--r--ext/intl/tests/timezone_createEnumeration_variation2.phpt24
-rw-r--r--ext/intl/tests/timezone_createTimeZoneIDEnumeration_basic.phpt34
-rw-r--r--ext/intl/tests/timezone_createTimeZoneIDEnumeration_error.phpt42
-rw-r--r--ext/intl/tests/timezone_createTimeZoneIDEnumeration_variant1.phpt32
-rw-r--r--ext/intl/tests/timezone_createTimeZoneIDEnumeration_variant2.phpt52
-rw-r--r--ext/intl/tests/timezone_createTimeZone_basic.phpt33
-rw-r--r--ext/intl/tests/timezone_createTimeZone_error.phpt34
-rw-r--r--ext/intl/tests/timezone_equals_basic.phpt33
-rw-r--r--ext/intl/tests/timezone_equals_error.phpt43
-rw-r--r--ext/intl/tests/timezone_fromDateTimeZone_basic.phpt41
-rw-r--r--ext/intl/tests/timezone_fromDateTimeZone_error.phpt50
-rw-r--r--ext/intl/tests/timezone_getCanonicalID_basic.phpt19
-rw-r--r--ext/intl/tests/timezone_getCanonicalID_error.phpt32
-rw-r--r--ext/intl/tests/timezone_getCanonicalID_variant1.phpt24
-rw-r--r--ext/intl/tests/timezone_getDSTSavings_basic.phpt21
-rw-r--r--ext/intl/tests/timezone_getDSTSavings_error.phpt23
-rw-r--r--ext/intl/tests/timezone_getDisplayName_basic.phpt24
-rw-r--r--ext/intl/tests/timezone_getDisplayName_error.phpt45
-rw-r--r--ext/intl/tests/timezone_getDisplayName_variant1.phpt26
-rw-r--r--ext/intl/tests/timezone_getDisplayName_variant2-49+.phpt38
-rw-r--r--ext/intl/tests/timezone_getDisplayName_variant2.phpt40
-rw-r--r--ext/intl/tests/timezone_getDisplayName_variant3-49+.phpt28
-rw-r--r--ext/intl/tests/timezone_getDisplayName_variant3.phpt28
-rw-r--r--ext/intl/tests/timezone_getEquivalentID_basic.phpt19
-rw-r--r--ext/intl/tests/timezone_getEquivalentID_error.phpt34
-rw-r--r--ext/intl/tests/timezone_getErrorCodeMessage_basic.phpt31
-rw-r--r--ext/intl/tests/timezone_getErrorCode_error.phpt23
-rw-r--r--ext/intl/tests/timezone_getErrorMessage_error.phpt23
-rw-r--r--ext/intl/tests/timezone_getGMT_basic.phpt31
-rw-r--r--ext/intl/tests/timezone_getGMT_error.phpt19
-rw-r--r--ext/intl/tests/timezone_getID_error.phpt23
-rw-r--r--ext/intl/tests/timezone_getOffset_basic.phpt33
-rw-r--r--ext/intl/tests/timezone_getOffset_error.phpt33
-rw-r--r--ext/intl/tests/timezone_getRawOffset_basic.phpt21
-rw-r--r--ext/intl/tests/timezone_getRawOffset_error.phpt23
-rw-r--r--ext/intl/tests/timezone_getRegion_basic.phpt21
-rw-r--r--ext/intl/tests/timezone_getRegion_error.phpt42
-rw-r--r--ext/intl/tests/timezone_getTZDataVersion_error.phpt18
-rw-r--r--ext/intl/tests/timezone_getTZData_basic.phpt19
-rw-r--r--ext/intl/tests/timezone_getUnknown_basic.phpt35
-rw-r--r--ext/intl/tests/timezone_getUnknown_error.phpt29
-rw-r--r--ext/intl/tests/timezone_hasSameRules_basic.phpt35
-rw-r--r--ext/intl/tests/timezone_hasSameRules_error.phpt37
-rw-r--r--ext/intl/tests/timezone_toDateTimeZone_basic.phpt38
-rw-r--r--ext/intl/tests/timezone_toDateTimeZone_error.phpt38
-rw-r--r--ext/intl/tests/timezone_useDaylightTime_basic.phpt25
-rw-r--r--ext/intl/tests/timezone_useDaylightTime_error.phpt22
-rw-r--r--ext/intl/timezone/timezone_class.cpp611
-rw-r--r--ext/intl/timezone/timezone_class.h73
-rw-r--r--ext/intl/timezone/timezone_methods.cpp656
-rw-r--r--ext/intl/timezone/timezone_methods.h68
-rw-r--r--ext/mbstring/config.w322
-rw-r--r--ext/mbstring/libmbfl/filters/mbfilter_sjis_mac.c2
-rw-r--r--ext/mbstring/libmbfl/filters/mbfilter_utf8_mobile.h2
-rw-r--r--ext/mbstring/mbstring.c14
-rw-r--r--ext/mbstring/oniguruma/COPYING6
-rw-r--r--ext/mbstring/oniguruma/HISTORY318
-rw-r--r--ext/mbstring/oniguruma/README42
-rw-r--r--ext/mbstring/oniguruma/README.ja41
-rw-r--r--ext/mbstring/oniguruma/doc/API67
-rw-r--r--ext/mbstring/oniguruma/doc/API.ja72
-rw-r--r--ext/mbstring/oniguruma/doc/FAQ4
-rw-r--r--ext/mbstring/oniguruma/doc/FAQ.ja18
-rw-r--r--ext/mbstring/oniguruma/doc/RE153
-rw-r--r--ext/mbstring/oniguruma/doc/RE.ja162
-rw-r--r--ext/mbstring/oniguruma/enc/ascii.c19
-rw-r--r--ext/mbstring/oniguruma/enc/big5.c36
-rw-r--r--ext/mbstring/oniguruma/enc/cp1251.c200
-rw-r--r--ext/mbstring/oniguruma/enc/euc_jp.c199
-rw-r--r--ext/mbstring/oniguruma/enc/euc_kr.c53
-rw-r--r--ext/mbstring/oniguruma/enc/euc_tw.c39
-rw-r--r--ext/mbstring/oniguruma/enc/gb18030.c36
-rw-r--r--ext/mbstring/oniguruma/enc/iso8859_1.c269
-rw-r--r--ext/mbstring/oniguruma/enc/iso8859_10.c305
-rw-r--r--ext/mbstring/oniguruma/enc/iso8859_11.c81
-rw-r--r--ext/mbstring/oniguruma/enc/iso8859_13.c254
-rw-r--r--ext/mbstring/oniguruma/enc/iso8859_14.c297
-rw-r--r--ext/mbstring/oniguruma/enc/iso8859_15.c272
-rw-r--r--ext/mbstring/oniguruma/enc/iso8859_16.c287
-rw-r--r--ext/mbstring/oniguruma/enc/iso8859_2.c291
-rw-r--r--ext/mbstring/oniguruma/enc/iso8859_3.c282
-rw-r--r--ext/mbstring/oniguruma/enc/iso8859_4.c291
-rw-r--r--ext/mbstring/oniguruma/enc/iso8859_5.c292
-rw-r--r--ext/mbstring/oniguruma/enc/iso8859_6.c71
-rw-r--r--ext/mbstring/oniguruma/enc/iso8859_7.c264
-rw-r--r--ext/mbstring/oniguruma/enc/iso8859_8.c67
-rw-r--r--ext/mbstring/oniguruma/enc/iso8859_9.c262
-rw-r--r--ext/mbstring/oniguruma/enc/koi8.c260
-rw-r--r--ext/mbstring/oniguruma/enc/koi8_r.c240
-rw-r--r--ext/mbstring/oniguruma/enc/mktable.c127
-rw-r--r--ext/mbstring/oniguruma/enc/sjis.c188
-rw-r--r--ext/mbstring/oniguruma/enc/unicode.c9755
-rwxr-xr-xext/mbstring/oniguruma/enc/utf16_be.c125
-rwxr-xr-xext/mbstring/oniguruma/enc/utf16_le.c122
-rwxr-xr-xext/mbstring/oniguruma/enc/utf32_be.c125
-rwxr-xr-xext/mbstring/oniguruma/enc/utf32_le.c123
-rw-r--r--ext/mbstring/oniguruma/enc/utf8.c3563
-rwxr-xr-xext/mbstring/oniguruma/index.html18
-rw-r--r--ext/mbstring/oniguruma/index_ja.html190
-rw-r--r--ext/mbstring/oniguruma/onigposix.h2
-rw-r--r--ext/mbstring/oniguruma/oniguruma.h259
-rw-r--r--ext/mbstring/oniguruma/regcomp.c2070
-rw-r--r--ext/mbstring/oniguruma/regenc.c690
-rw-r--r--ext/mbstring/oniguruma/regenc.h120
-rw-r--r--ext/mbstring/oniguruma/regerror.c50
-rw-r--r--ext/mbstring/oniguruma/regexec.c998
-rwxr-xr-xext/mbstring/oniguruma/regext.c27
-rw-r--r--ext/mbstring/oniguruma/reggnu.c28
-rw-r--r--ext/mbstring/oniguruma/regint.h418
-rw-r--r--ext/mbstring/oniguruma/regparse.c1824
-rw-r--r--ext/mbstring/oniguruma/regparse.h307
-rw-r--r--ext/mbstring/oniguruma/regposerr.c14
-rw-r--r--ext/mbstring/oniguruma/regposix.c12
-rw-r--r--ext/mbstring/oniguruma/regsyntax.c87
-rw-r--r--ext/mbstring/oniguruma/regversion.c5
-rw-r--r--ext/mbstring/oniguruma/st.c21
-rw-r--r--ext/mbstring/oniguruma/testc.c863
-rw-r--r--ext/mbstring/oniguruma/testu.c911
-rw-r--r--ext/mbstring/oniguruma/win32/Makefile200
-rw-r--r--ext/mbstring/oniguruma/win32/testc.c863
-rw-r--r--ext/mbstring/php_mbregex.h2
-rw-r--r--ext/mbstring/tests/mb_str_functions_opt-parameter.phpt32
-rw-r--r--ext/mcrypt/mcrypt.c2
-rw-r--r--ext/mysql/tests/bug55473.phpt10
-rw-r--r--ext/mysqli/mysqli.c212
-rw-r--r--ext/mysqli/mysqli_api.c58
-rw-r--r--ext/mysqli/mysqli_fe.c18
-rw-r--r--ext/mysqli/mysqli_fe.h1
-rw-r--r--ext/mysqli/mysqli_nonapi.c3
-rw-r--r--ext/mysqli/mysqli_priv.h1
-rw-r--r--ext/mysqli/mysqli_prop.c4
-rw-r--r--ext/mysqli/mysqli_report.h64
-rw-r--r--ext/mysqli/package.xml1
-rw-r--r--ext/mysqli/php_mysqli_structs.h12
-rw-r--r--ext/mysqli/tests/mysqli_class_mysqli_interface.phpt6
-rw-r--r--ext/mysqli/tests/mysqli_query_local_infile_large.phpt103
-rw-r--r--ext/mysqli/tests/mysqli_set_local_infile_default.phpt132
-rw-r--r--ext/mysqli/tests/mysqli_set_local_infile_handler.phpt196
-rw-r--r--ext/mysqli/tests/mysqli_set_local_infile_handler_bad_character.phpt82
-rw-r--r--ext/mysqli/tests/mysqli_set_local_infile_handler_buffer_overflow.phpt60
-rw-r--r--ext/mysqli/tests/mysqli_set_local_infile_handler_close_link.phpt61
-rw-r--r--ext/mysqli/tests/mysqli_set_local_infile_handler_closefile.phpt70
-rwxr-xr-xext/mysqli/tests/mysqli_set_local_infile_handler_closures.phpt62
-rw-r--r--ext/mysqli/tests/mysqli_set_local_infile_handler_kill_link.phpt61
-rw-r--r--ext/mysqli/tests/mysqli_set_local_infile_handler_negative_len.phpt58
-rw-r--r--ext/mysqli/tests/mysqli_set_local_infile_handler_nested_call.phpt107
-rw-r--r--ext/mysqli/tests/mysqli_set_local_infile_handler_new_query.phpt71
-rw-r--r--ext/mysqli/tests/mysqli_set_local_infile_handler_nofileop.phpt70
-rw-r--r--ext/mysqli/tests/mysqli_set_local_infile_handler_openbasedir.phpt115
-rw-r--r--ext/mysqli/tests/mysqli_set_local_infile_handler_replace_buffer.phpt78
-rw-r--r--ext/mysqli/tests/mysqli_set_local_infile_handler_short_len.phpt101
-rw-r--r--ext/mysqli/tests/mysqli_set_local_infile_handler_unregister.phpt64
-rw-r--r--ext/mysqlnd/mysqlnd.c691
-rw-r--r--ext/mysqlnd/mysqlnd.h6
-rw-r--r--ext/mysqlnd/mysqlnd_debug.h3
-rw-r--r--ext/mysqlnd/mysqlnd_driver.c31
-rw-r--r--ext/mysqlnd/mysqlnd_enum_n_def.h2
-rw-r--r--ext/mysqlnd/mysqlnd_ext_plugin.c1
-rw-r--r--ext/mysqlnd/mysqlnd_loaddata.c8
-rw-r--r--ext/mysqlnd/mysqlnd_net.c378
-rw-r--r--ext/mysqlnd/mysqlnd_priv.h12
-rw-r--r--ext/mysqlnd/mysqlnd_reverse_api.h1
-rw-r--r--ext/mysqlnd/mysqlnd_structs.h64
-rw-r--r--ext/mysqlnd/mysqlnd_wireprotocol.c23
-rw-r--r--ext/openssl/CREDITS2
-rw-r--r--ext/openssl/openssl.c321
-rw-r--r--ext/openssl/php_openssl.h2
-rw-r--r--ext/openssl/tests/openssl_pbkdf2.phpt26
-rw-r--r--ext/openssl/xp_ssl.c4
-rwxr-xr-xext/pcntl/pcntl.c2
-rw-r--r--ext/pcntl/php_signal.c3
-rw-r--r--ext/pcre/php_pcre.c4
-rw-r--r--ext/pcre/tests/002.phpt2
-rw-r--r--ext/pcre/tests/004.phpt4
-rwxr-xr-xext/pdo/php_pdo_int.h2
-rwxr-xr-xext/pdo_mysql/mysql_driver.c2
-rw-r--r--ext/phar/phar_path_check.c2
-rw-r--r--ext/phar/tests/phar_commitwrite.phpt2
-rw-r--r--ext/phar/tests/phar_create_in_cwd.phpt2
-rw-r--r--ext/phar/tests/phar_gobyebye.phpt2
-rw-r--r--ext/phar/tests/phar_mount.phpt2
-rw-r--r--ext/snmp/snmp.c75
-rw-r--r--ext/soap/tests/bugs/bug47273.phpt3
-rw-r--r--ext/sockets/multicast.h3
-rw-r--r--ext/spl/spl_fixedarray.c33
-rwxr-xr-xext/spl/spl_iterators.c2
-rw-r--r--ext/spl/tests/SplFixedArray_serialize.phpt52
-rw-r--r--ext/sqlite3/libsqlite/sqlite3.c2
-rw-r--r--ext/sqlite3/php_sqlite3.h2
-rw-r--r--ext/sqlite3/tests/bug53463.phpt2
-rw-r--r--ext/standard/basic_functions.c130
-rw-r--r--ext/standard/credits_ext.h12
-rw-r--r--ext/standard/dl.c4
-rw-r--r--ext/standard/file.c4
-rw-r--r--ext/standard/filestat.c2
-rw-r--r--ext/standard/pack.c74
-rw-r--r--ext/standard/php_type.h1
-rw-r--r--ext/standard/tests/array/compact.phpt3
-rw-r--r--ext/standard/tests/array/locale_sort.phpt3
-rw-r--r--ext/standard/tests/dir/dir_variation1-win32.phpt170
-rw-r--r--ext/standard/tests/dir/dir_variation5-win32.phpt37
-rw-r--r--ext/standard/tests/dir/dir_variation6-win32.phpt61
-rw-r--r--ext/standard/tests/dir/dir_variation8-win32.phpt68
-rw-r--r--ext/standard/tests/dir/dir_variation9-win32.phpt125
-rw-r--r--ext/standard/tests/dir/opendir_error2-win32.phpt47
-rw-r--r--ext/standard/tests/dir/opendir_variation1-win32.phpt248
-rw-r--r--ext/standard/tests/dir/scandir_error2-win32.phpt51
-rw-r--r--ext/standard/tests/dir/scandir_variation1-win32.phpt289
-rw-r--r--ext/standard/tests/dir/scandir_variation6-win32.phpt84
-rw-r--r--ext/standard/tests/file/bug22414.phpt2
-rw-r--r--ext/standard/tests/general_functions/boolval.phpt29
-rw-r--r--ext/standard/tests/network/ip2long_variation1.phpt2
-rw-r--r--ext/standard/tests/strings/bug61038.phpt26
-rw-r--r--ext/standard/tests/strings/pack_A.phpt25
-rw-r--r--ext/standard/tests/strings/pack_Z.phpt27
-rw-r--r--ext/standard/tests/strings/parse_str_basic3.phptbin5141 -> 5140 bytes
-rw-r--r--ext/standard/tests/strings/unpack_error.phpt4
-rw-r--r--[-rwxr-xr-x]ext/standard/tests/time/bug60222.phpt0
-rw-r--r--ext/standard/type.c14
-rw-r--r--ext/standard/url_scanner_ex.c113
-rw-r--r--ext/standard/var_unserializer.c2
-rw-r--r--ext/xsl/php_xsl.c2
-rw-r--r--ext/zlib/tests/001.phpt2
-rw-r--r--ext/zlib/tests/data.inc2
-rw-r--r--ext/zlib/tests/gzfile_basic.phpt2
-rw-r--r--ext/zlib/tests/gzfile_basic2.phpt2
-rw-r--r--ext/zlib/zlib.c2
418 files changed, 33848 insertions, 16030 deletions
diff --git a/ext/curl/config.m4 b/ext/curl/config.m4
index fbb4f5b..92559be 100644
--- a/ext/curl/config.m4
+++ b/ext/curl/config.m4
@@ -131,13 +131,6 @@ int main(int argc, char *argv[])
$CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR
])
- PHP_CHECK_LIBRARY(curl,curl_version_info,
- [
- AC_DEFINE(HAVE_CURL_VERSION_INFO,1,[ ])
- ],[],[
- $CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR
- ])
-
PHP_CHECK_LIBRARY(curl,curl_easy_strerror,
[
AC_DEFINE(HAVE_CURL_EASY_STRERROR,1,[ ])
@@ -156,6 +149,6 @@ int main(int argc, char *argv[])
AC_DEFINE(PHP_CURL_URL_WRAPPERS,1,[ ])
fi
- PHP_NEW_EXTENSION(curl, interface.c multi.c streams.c, $ext_shared)
+ PHP_NEW_EXTENSION(curl, interface.c multi.c share.c streams.c, $ext_shared)
PHP_SUBST(CURL_SHARED_LIBADD)
fi
diff --git a/ext/curl/config.w32 b/ext/curl/config.w32
index 930adcf..a056845 100644
--- a/ext/curl/config.w32
+++ b/ext/curl/config.w32
@@ -13,12 +13,11 @@ if (PHP_CURL != "no") {
&& (((PHP_ZLIB=="no") && (CHECK_LIB("zlib_a.lib;zlib.lib", "curl", PHP_CURL))) ||
(PHP_ZLIB_SHARED && CHECK_LIB("zlib.lib", "curl", PHP_CURL)) || (PHP_ZLIB == "yes" && (!PHP_ZLIB_SHARED)))
) {
- EXTENSION("curl", "interface.c multi.c streams.c", true);
+ EXTENSION("curl", "interface.c multi.c share.c streams.c", true);
AC_DEFINE('HAVE_CURL', 1, 'Have cURL library');
AC_DEFINE('HAVE_CURL_SSL', 1, 'Have SSL suppurt in cURL');
AC_DEFINE('HAVE_CURL_EASY_STRERROR', 1, 'Have curl_easy_strerror in cURL');
AC_DEFINE('HAVE_CURL_MULTI_STRERROR', 1, 'Have curl_multi_strerror in cURL');
- AC_DEFINE('HAVE_CURL_VERSION_INFO', 1, 'Have curl_version_info in cURL');
ADD_FLAG("CFLAGS_CURL", "/D CURL_STATICLIB");
// TODO: check for curl_version_info
// AC_DEFINE('PHP_CURL_URL_WRAPPERS', 0, 'Use curl for URL wrappers [experimental]');
diff --git a/ext/curl/curl.dsp b/ext/curl/curl.dsp
index 81d8231..6524fce 100644
--- a/ext/curl/curl.dsp
+++ b/ext/curl/curl.dsp
@@ -166,6 +166,10 @@ SOURCE=.\multi.c
# End Source File
# Begin Source File
+SOURCE=.\share.c
+# End Source File
+
+# Begin Source File
SOURCE=.\streams.c
# End Source File
diff --git a/ext/curl/interface.c b/ext/curl/interface.c
index b03f346..14836cc 100644
--- a/ext/curl/interface.c
+++ b/ext/curl/interface.c
@@ -90,6 +90,7 @@
int le_curl;
int le_curl_multi_handle;
+int le_curl_share_handle;
#ifdef PHP_CURL_NEED_OPENSSL_TSL /* {{{ */
static MUTEX_T *php_curl_openssl_tsl = NULL;
@@ -261,7 +262,6 @@ int _php_curl_verify_handlers(php_curl *ch, int reporterror TSRMLS_DC) /* {{{ */
ch->handlers->write->stream = NULL;
ch->handlers->write->method = PHP_CURL_STDOUT;
- ch->handlers->write->type = PHP_CURL_ASCII;
curl_easy_setopt(ch->cp, CURLOPT_FILE, (void *) ch);
}
}
@@ -314,6 +314,24 @@ ZEND_BEGIN_ARG_INFO(arginfo_curl_close, 0)
ZEND_ARG_INFO(0, ch)
ZEND_END_ARG_INFO()
+#if LIBCURL_VERSION_NUM >= 0x070c01 /* 7.12.1 */
+ZEND_BEGIN_ARG_INFO(arginfo_curl_reset, 0)
+ ZEND_ARG_INFO(0, ch)
+ZEND_END_ARG_INFO()
+#endif
+
+#if LIBCURL_VERSION_NUM > 0x070f03 /* 7.15.4 */
+ZEND_BEGIN_ARG_INFO(arginfo_curl_escape, 0)
+ ZEND_ARG_INFO(0, ch)
+ ZEND_ARG_INFO(0, str)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO(arginfo_curl_unescape, 0)
+ ZEND_ARG_INFO(0, ch)
+ ZEND_ARG_INFO(0, str)
+ZEND_END_ARG_INFO()
+#endif
+
ZEND_BEGIN_ARG_INFO(arginfo_curl_multi_init, 0)
ZEND_END_ARG_INFO()
@@ -349,6 +367,19 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO(arginfo_curl_multi_close, 0)
ZEND_ARG_INFO(0, mh)
ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO(arginfo_curl_share_init, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO(arginfo_curl_share_close, 0)
+ ZEND_ARG_INFO(0, sh)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO(arginfo_curl_share_setopt, 0)
+ ZEND_ARG_INFO(0, sh)
+ ZEND_ARG_INFO(0, option)
+ ZEND_ARG_INFO(0, value)
+ZEND_END_ARG_INFO()
/* }}} */
/* {{{ curl_functions[]
@@ -364,6 +395,13 @@ const zend_function_entry curl_functions[] = {
PHP_FE(curl_error, arginfo_curl_error)
PHP_FE(curl_errno, arginfo_curl_errno)
PHP_FE(curl_close, arginfo_curl_close)
+#if LIBCURL_VERSION_NUM >= 0x070c01 /* 7.12.1 */
+ PHP_FE(curl_reset, arginfo_curl_reset)
+#endif
+#if LIBCURL_VERSION_NUM >= 0x070f04 /* 7.15.4 */
+ PHP_FE(curl_escape, arginfo_curl_escape)
+ PHP_FE(curl_unescape, arginfo_curl_unescape)
+#endif
PHP_FE(curl_multi_init, arginfo_curl_multi_init)
PHP_FE(curl_multi_add_handle, arginfo_curl_multi_add_handle)
PHP_FE(curl_multi_remove_handle, arginfo_curl_multi_remove_handle)
@@ -372,6 +410,9 @@ const zend_function_entry curl_functions[] = {
PHP_FE(curl_multi_getcontent, arginfo_curl_multi_getcontent)
PHP_FE(curl_multi_info_read, arginfo_curl_multi_info_read)
PHP_FE(curl_multi_close, arginfo_curl_multi_close)
+ PHP_FE(curl_share_init, arginfo_curl_share_init)
+ PHP_FE(curl_share_close, arginfo_curl_share_close)
+ PHP_FE(curl_share_setopt, arginfo_curl_share_setopt)
PHP_FE_END
};
/* }}} */
@@ -428,42 +469,40 @@ PHP_MINFO_FUNCTION(curl)
unsigned int i;
static const struct feat feats[] = {
-#if LIBCURL_VERSION_NUM > 0x070a06 /* 7.10.7 */
+#if LIBCURL_VERSION_NUM >= 0x070a07 /* 7.10.7 */
{"AsynchDNS", CURL_VERSION_ASYNCHDNS},
#endif
-#if LIBCURL_VERSION_NUM > 0x070a05 /* 7.10.6 */
+#if LIBCURL_VERSION_NUM >= 0x070f04 /* 7.15.4 */
+ {"CharConv", CURL_VERSION_CONV},
+#endif
+#if LIBCURL_VERSION_NUM >= 0x070a06 /* 7.10.6 */
{"Debug", CURL_VERSION_DEBUG},
{"GSS-Negotiate", CURL_VERSION_GSSNEGOTIATE},
#endif
-#if LIBCURL_VERSION_NUM > 0x070b02 /* 7.12.0 */
+#if LIBCURL_VERSION_NUM >= 0x070c00 /* 7.12.0 */
{"IDN", CURL_VERSION_IDN},
#endif
-#ifdef CURL_VERSION_IPV6
{"IPv6", CURL_VERSION_IPV6},
-#endif
-#if LIBCURL_VERSION_NUM > 0x070b00 /* 7.11.1 */
+ {"krb4", CURL_VERSION_KERBEROS4},
+#if LIBCURL_VERSION_NUM >= 0x070b01 /* 7.11.1 */
{"Largefile", CURL_VERSION_LARGEFILE},
#endif
-#if LIBCURL_VERSION_NUM > 0x070a05 /* 7.10.6 */
+ {"libz", CURL_VERSION_LIBZ},
+#if LIBCURL_VERSION_NUM >= 0x070a06 /* 7.10.6 */
{"NTLM", CURL_VERSION_NTLM},
#endif
-#if LIBCURL_VERSION_NUM > 0x070a07 /* 7.10.8 */
+#if LIBCURL_VERSION_NUM >= 0x071600 /* 7.22.0 */
+ {"NTLMWB", CURL_VERSION_NTLM_WB},
+#endif
+#if LIBCURL_VERSION_NUM >= 0x070a08 /* 7.10.8 */
{"SPNEGO", CURL_VERSION_SPNEGO},
#endif
-#ifdef CURL_VERSION_SSL
{"SSL", CURL_VERSION_SSL},
-#endif
-#if LIBCURL_VERSION_NUM > 0x070d01 /* 7.13.2 */
+#if LIBCURL_VERSION_NUM >= 0x070d02 /* 7.13.2 */
{"SSPI", CURL_VERSION_SSPI},
#endif
-#ifdef CURL_VERSION_KERBEROS4
- {"krb4", CURL_VERSION_KERBEROS4},
-#endif
-#ifdef CURL_VERSION_LIBZ
- {"libz", CURL_VERSION_LIBZ},
-#endif
-#if LIBCURL_VERSION_NUM > 0x070f03 /* 7.15.4 */
- {"CharConv", CURL_VERSION_CONV},
+#if LIBCURL_VERSION_NUM >= 0x071504 /* 7.21.4 */
+ {"TLS-SRP", CURL_VERSION_TLSAUTH_SRP},
#endif
{NULL, 0}
};
@@ -528,6 +567,7 @@ PHP_MINIT_FUNCTION(curl)
{
le_curl = zend_register_list_destructors_ex(_php_curl_close, NULL, "curl", module_number);
le_curl_multi_handle = zend_register_list_destructors_ex(_php_curl_multi_close, NULL, "curl_multi", module_number);
+ le_curl_share_handle = zend_register_list_destructors_ex(_php_curl_share_close, NULL, "curl_share", module_number);
REGISTER_INI_ENTRIES();
@@ -536,348 +576,547 @@ PHP_MINIT_FUNCTION(curl)
of options and which version they were introduced */
/* Constants for curl_setopt() */
-#if LIBCURL_VERSION_NUM > 0x070a07 /* CURLOPT_IPRESOLVE is available since curl 7.10.8 */
- REGISTER_CURL_CONSTANT(CURLOPT_IPRESOLVE);
- REGISTER_CURL_CONSTANT(CURL_IPRESOLVE_WHATEVER);
- REGISTER_CURL_CONSTANT(CURL_IPRESOLVE_V4);
- REGISTER_CURL_CONSTANT(CURL_IPRESOLVE_V6);
-#endif
- REGISTER_CURL_CONSTANT(CURLOPT_DNS_USE_GLOBAL_CACHE);
+ REGISTER_CURL_CONSTANT(CURLOPT_AUTOREFERER);
+ REGISTER_CURL_CONSTANT(CURLOPT_BINARYTRANSFER);
+ REGISTER_CURL_CONSTANT(CURLOPT_BUFFERSIZE);
+ REGISTER_CURL_CONSTANT(CURLOPT_CAINFO);
+ REGISTER_CURL_CONSTANT(CURLOPT_CAPATH);
+ REGISTER_CURL_CONSTANT(CURLOPT_CLOSEPOLICY);
+ REGISTER_CURL_CONSTANT(CURLOPT_CONNECTTIMEOUT);
+ REGISTER_CURL_CONSTANT(CURLOPT_COOKIE);
+ REGISTER_CURL_CONSTANT(CURLOPT_COOKIEFILE);
+ REGISTER_CURL_CONSTANT(CURLOPT_COOKIEJAR);
+ REGISTER_CURL_CONSTANT(CURLOPT_COOKIESESSION);
+ REGISTER_CURL_CONSTANT(CURLOPT_CRLF);
+ REGISTER_CURL_CONSTANT(CURLOPT_CUSTOMREQUEST);
REGISTER_CURL_CONSTANT(CURLOPT_DNS_CACHE_TIMEOUT);
- REGISTER_CURL_CONSTANT(CURLOPT_PORT);
+ REGISTER_CURL_CONSTANT(CURLOPT_DNS_USE_GLOBAL_CACHE);
+ REGISTER_CURL_CONSTANT(CURLOPT_EGDSOCKET);
+ REGISTER_CURL_CONSTANT(CURLOPT_ENCODING);
+ REGISTER_CURL_CONSTANT(CURLOPT_FAILONERROR);
REGISTER_CURL_CONSTANT(CURLOPT_FILE);
- REGISTER_CURL_CONSTANT(CURLOPT_READDATA);
- REGISTER_CURL_CONSTANT(CURLOPT_INFILE);
- REGISTER_CURL_CONSTANT(CURLOPT_INFILESIZE);
- REGISTER_CURL_CONSTANT(CURLOPT_URL);
- REGISTER_CURL_CONSTANT(CURLOPT_PROXY);
- REGISTER_CURL_CONSTANT(CURLOPT_VERBOSE);
+ REGISTER_CURL_CONSTANT(CURLOPT_FILETIME);
+ REGISTER_CURL_CONSTANT(CURLOPT_FOLLOWLOCATION);
+ REGISTER_CURL_CONSTANT(CURLOPT_FORBID_REUSE);
+ REGISTER_CURL_CONSTANT(CURLOPT_FRESH_CONNECT);
+ REGISTER_CURL_CONSTANT(CURLOPT_FTPAPPEND);
+ REGISTER_CURL_CONSTANT(CURLOPT_FTPLISTONLY);
+ REGISTER_CURL_CONSTANT(CURLOPT_FTPPORT);
+ REGISTER_CURL_CONSTANT(CURLOPT_FTP_USE_EPRT);
+ REGISTER_CURL_CONSTANT(CURLOPT_FTP_USE_EPSV);
REGISTER_CURL_CONSTANT(CURLOPT_HEADER);
+ REGISTER_CURL_CONSTANT(CURLOPT_HEADERFUNCTION);
+ REGISTER_CURL_CONSTANT(CURLOPT_HTTP200ALIASES);
+ REGISTER_CURL_CONSTANT(CURLOPT_HTTPGET);
REGISTER_CURL_CONSTANT(CURLOPT_HTTPHEADER);
- REGISTER_CURL_CONSTANT(CURLOPT_NOPROGRESS);
- REGISTER_CURL_CONSTANT(CURLOPT_PROGRESSFUNCTION);
+ REGISTER_CURL_CONSTANT(CURLOPT_HTTPPROXYTUNNEL);
+ REGISTER_CURL_CONSTANT(CURLOPT_HTTP_VERSION);
+ REGISTER_CURL_CONSTANT(CURLOPT_INFILE);
+ REGISTER_CURL_CONSTANT(CURLOPT_INFILESIZE);
+ REGISTER_CURL_CONSTANT(CURLOPT_INTERFACE);
+ REGISTER_CURL_CONSTANT(CURLOPT_KRB4LEVEL);
+ REGISTER_CURL_CONSTANT(CURLOPT_LOW_SPEED_LIMIT);
+ REGISTER_CURL_CONSTANT(CURLOPT_LOW_SPEED_TIME);
+ REGISTER_CURL_CONSTANT(CURLOPT_MAXCONNECTS);
+ REGISTER_CURL_CONSTANT(CURLOPT_MAXREDIRS);
+ REGISTER_CURL_CONSTANT(CURLOPT_NETRC);
REGISTER_CURL_CONSTANT(CURLOPT_NOBODY);
- REGISTER_CURL_CONSTANT(CURLOPT_FAILONERROR);
- REGISTER_CURL_CONSTANT(CURLOPT_UPLOAD);
+ REGISTER_CURL_CONSTANT(CURLOPT_NOPROGRESS);
+ REGISTER_CURL_CONSTANT(CURLOPT_NOSIGNAL);
+ REGISTER_CURL_CONSTANT(CURLOPT_PORT);
REGISTER_CURL_CONSTANT(CURLOPT_POST);
- REGISTER_CURL_CONSTANT(CURLOPT_FTPLISTONLY);
- REGISTER_CURL_CONSTANT(CURLOPT_FTPAPPEND);
- REGISTER_CURL_CONSTANT(CURLOPT_NETRC);
- REGISTER_CURL_CONSTANT(CURLOPT_FOLLOWLOCATION);
-#if CURLOPT_FTPASCII != 0
- REGISTER_CURL_CONSTANT(CURLOPT_FTPASCII);
-#endif
- REGISTER_CURL_CONSTANT(CURLOPT_PUT);
-#if CURLOPT_MUTE != 0
- REGISTER_CURL_CONSTANT(CURLOPT_MUTE);
-#endif
- REGISTER_CURL_CONSTANT(CURLOPT_USERPWD);
+ REGISTER_CURL_CONSTANT(CURLOPT_POSTFIELDS);
+ REGISTER_CURL_CONSTANT(CURLOPT_POSTQUOTE);
+ REGISTER_CURL_CONSTANT(CURLOPT_PREQUOTE);
+ REGISTER_CURL_CONSTANT(CURLOPT_PRIVATE);
+ REGISTER_CURL_CONSTANT(CURLOPT_PROGRESSFUNCTION);
+ REGISTER_CURL_CONSTANT(CURLOPT_PROXY);
+ REGISTER_CURL_CONSTANT(CURLOPT_PROXYPORT);
+ REGISTER_CURL_CONSTANT(CURLOPT_PROXYTYPE);
REGISTER_CURL_CONSTANT(CURLOPT_PROXYUSERPWD);
+ REGISTER_CURL_CONSTANT(CURLOPT_PUT);
+ REGISTER_CURL_CONSTANT(CURLOPT_QUOTE);
+ REGISTER_CURL_CONSTANT(CURLOPT_RANDOM_FILE);
REGISTER_CURL_CONSTANT(CURLOPT_RANGE);
- REGISTER_CURL_CONSTANT(CURLOPT_TIMEOUT);
-#if LIBCURL_VERSION_NUM > 0x071002
- REGISTER_CURL_CONSTANT(CURLOPT_TIMEOUT_MS);
-#endif
- REGISTER_CURL_CONSTANT(CURLOPT_POSTFIELDS);
+ REGISTER_CURL_CONSTANT(CURLOPT_READDATA);
+ REGISTER_CURL_CONSTANT(CURLOPT_READFUNCTION);
REGISTER_CURL_CONSTANT(CURLOPT_REFERER);
- REGISTER_CURL_CONSTANT(CURLOPT_USERAGENT);
- REGISTER_CURL_CONSTANT(CURLOPT_FTPPORT);
- REGISTER_CURL_CONSTANT(CURLOPT_FTP_USE_EPSV);
- REGISTER_CURL_CONSTANT(CURLOPT_LOW_SPEED_LIMIT);
- REGISTER_CURL_CONSTANT(CURLOPT_LOW_SPEED_TIME);
REGISTER_CURL_CONSTANT(CURLOPT_RESUME_FROM);
- REGISTER_CURL_CONSTANT(CURLOPT_COOKIE);
- REGISTER_CURL_CONSTANT(CURLOPT_COOKIESESSION);
- REGISTER_CURL_CONSTANT(CURLOPT_AUTOREFERER);
+ REGISTER_CURL_CONSTANT(CURLOPT_RETURNTRANSFER);
+ REGISTER_CURL_CONSTANT(CURLOPT_SHARE);
REGISTER_CURL_CONSTANT(CURLOPT_SSLCERT);
REGISTER_CURL_CONSTANT(CURLOPT_SSLCERTPASSWD);
- REGISTER_CURL_CONSTANT(CURLOPT_WRITEHEADER);
- REGISTER_CURL_CONSTANT(CURLOPT_SSL_VERIFYHOST);
- REGISTER_CURL_CONSTANT(CURLOPT_COOKIEFILE);
+ REGISTER_CURL_CONSTANT(CURLOPT_SSLCERTTYPE);
+ REGISTER_CURL_CONSTANT(CURLOPT_SSLENGINE);
+ REGISTER_CURL_CONSTANT(CURLOPT_SSLENGINE_DEFAULT);
+ REGISTER_CURL_CONSTANT(CURLOPT_SSLKEY);
+ REGISTER_CURL_CONSTANT(CURLOPT_SSLKEYPASSWD);
+ REGISTER_CURL_CONSTANT(CURLOPT_SSLKEYTYPE);
REGISTER_CURL_CONSTANT(CURLOPT_SSLVERSION);
+ REGISTER_CURL_CONSTANT(CURLOPT_SSL_CIPHER_LIST);
+ REGISTER_CURL_CONSTANT(CURLOPT_SSL_VERIFYHOST);
+ REGISTER_CURL_CONSTANT(CURLOPT_SSL_VERIFYPEER);
+ REGISTER_CURL_CONSTANT(CURLOPT_STDERR);
REGISTER_CURL_CONSTANT(CURLOPT_TIMECONDITION);
+ REGISTER_CURL_CONSTANT(CURLOPT_TIMEOUT);
REGISTER_CURL_CONSTANT(CURLOPT_TIMEVALUE);
- REGISTER_CURL_CONSTANT(CURLOPT_CUSTOMREQUEST);
- REGISTER_CURL_CONSTANT(CURLOPT_STDERR);
REGISTER_CURL_CONSTANT(CURLOPT_TRANSFERTEXT);
- REGISTER_CURL_CONSTANT(CURLOPT_RETURNTRANSFER);
- REGISTER_CURL_CONSTANT(CURLOPT_QUOTE);
- REGISTER_CURL_CONSTANT(CURLOPT_POSTQUOTE);
- REGISTER_CURL_CONSTANT(CURLOPT_INTERFACE);
- REGISTER_CURL_CONSTANT(CURLOPT_KRB4LEVEL);
- REGISTER_CURL_CONSTANT(CURLOPT_HTTPPROXYTUNNEL);
- REGISTER_CURL_CONSTANT(CURLOPT_FILETIME);
- REGISTER_CURL_CONSTANT(CURLOPT_WRITEFUNCTION);
- REGISTER_CURL_CONSTANT(CURLOPT_READFUNCTION);
-#if CURLOPT_PASSWDFUNCTION != 0
- REGISTER_CURL_CONSTANT(CURLOPT_PASSWDFUNCTION);
-#endif
- REGISTER_CURL_CONSTANT(CURLOPT_HEADERFUNCTION);
- REGISTER_CURL_CONSTANT(CURLOPT_MAXREDIRS);
- REGISTER_CURL_CONSTANT(CURLOPT_MAXCONNECTS);
- REGISTER_CURL_CONSTANT(CURLOPT_CLOSEPOLICY);
- REGISTER_CURL_CONSTANT(CURLOPT_FRESH_CONNECT);
- REGISTER_CURL_CONSTANT(CURLOPT_FORBID_REUSE);
- REGISTER_CURL_CONSTANT(CURLOPT_RANDOM_FILE);
- REGISTER_CURL_CONSTANT(CURLOPT_EGDSOCKET);
- REGISTER_CURL_CONSTANT(CURLOPT_CONNECTTIMEOUT);
-#if LIBCURL_VERSION_NUM > 0x071002
- REGISTER_CURL_CONSTANT(CURLOPT_CONNECTTIMEOUT_MS);
-#endif
- REGISTER_CURL_CONSTANT(CURLOPT_SSL_VERIFYPEER);
- REGISTER_CURL_CONSTANT(CURLOPT_CAINFO);
- REGISTER_CURL_CONSTANT(CURLOPT_CAPATH);
- REGISTER_CURL_CONSTANT(CURLOPT_COOKIEJAR);
- REGISTER_CURL_CONSTANT(CURLOPT_SSL_CIPHER_LIST);
- REGISTER_CURL_CONSTANT(CURLOPT_BINARYTRANSFER);
- REGISTER_CURL_CONSTANT(CURLOPT_NOSIGNAL);
- REGISTER_CURL_CONSTANT(CURLOPT_PROXYTYPE);
- REGISTER_CURL_CONSTANT(CURLOPT_BUFFERSIZE);
- REGISTER_CURL_CONSTANT(CURLOPT_HTTPGET);
- REGISTER_CURL_CONSTANT(CURLOPT_HTTP_VERSION);
- REGISTER_CURL_CONSTANT(CURLOPT_SSLKEY);
- REGISTER_CURL_CONSTANT(CURLOPT_SSLKEYTYPE);
- REGISTER_CURL_CONSTANT(CURLOPT_SSLKEYPASSWD);
- REGISTER_CURL_CONSTANT(CURLOPT_SSLENGINE);
- REGISTER_CURL_CONSTANT(CURLOPT_SSLENGINE_DEFAULT);
- REGISTER_CURL_CONSTANT(CURLOPT_SSLCERTTYPE);
- REGISTER_CURL_CONSTANT(CURLOPT_CRLF);
- REGISTER_CURL_CONSTANT(CURLOPT_ENCODING);
- REGISTER_CURL_CONSTANT(CURLOPT_PROXYPORT);
REGISTER_CURL_CONSTANT(CURLOPT_UNRESTRICTED_AUTH);
- REGISTER_CURL_CONSTANT(CURLOPT_FTP_USE_EPRT);
-#if LIBCURL_VERSION_NUM > 0x070b01 /* CURLOPT_TCP_NODELAY is available since curl 7.11.2 */
- REGISTER_CURL_CONSTANT(CURLOPT_TCP_NODELAY);
-#endif
- REGISTER_CURL_CONSTANT(CURLOPT_HTTP200ALIASES);
- REGISTER_CURL_CONSTANT(CURL_TIMECOND_IFMODSINCE);
- REGISTER_CURL_CONSTANT(CURL_TIMECOND_IFUNMODSINCE);
- REGISTER_CURL_CONSTANT(CURL_TIMECOND_LASTMOD);
-
-#if LIBCURL_VERSION_NUM > 0x070f04 /* CURLOPT_MAX_RECV_SPEED_LARGE & CURLOPT_MAX_SEND_SPEED_LARGE are available since curl 7.15.5 */
- REGISTER_CURL_CONSTANT(CURLOPT_MAX_RECV_SPEED_LARGE);
- REGISTER_CURL_CONSTANT(CURLOPT_MAX_SEND_SPEED_LARGE);
-#endif
-
-#if LIBCURL_VERSION_NUM > 0x070a05 /* CURLOPT_HTTPAUTH is available since curl 7.10.6 */
- REGISTER_CURL_CONSTANT(CURLOPT_HTTPAUTH);
- /* http authentication options */
- REGISTER_CURL_CONSTANT(CURLAUTH_BASIC);
- REGISTER_CURL_CONSTANT(CURLAUTH_DIGEST);
- REGISTER_CURL_CONSTANT(CURLAUTH_GSSNEGOTIATE);
- REGISTER_CURL_CONSTANT(CURLAUTH_NTLM);
- REGISTER_CURL_CONSTANT(CURLAUTH_ANY);
- REGISTER_CURL_CONSTANT(CURLAUTH_ANYSAFE);
-#endif
-
-#if LIBCURL_VERSION_NUM > 0x070a06 /* CURLOPT_PROXYAUTH & CURLOPT_FTP_CREATE_MISSING_DIRS are available since curl 7.10.7 */
- REGISTER_CURL_CONSTANT(CURLOPT_PROXYAUTH);
- REGISTER_CURL_CONSTANT(CURLOPT_FTP_CREATE_MISSING_DIRS);
-#endif
-
- REGISTER_CURL_CONSTANT(CURLOPT_PRIVATE);
+ REGISTER_CURL_CONSTANT(CURLOPT_UPLOAD);
+ REGISTER_CURL_CONSTANT(CURLOPT_URL);
+ REGISTER_CURL_CONSTANT(CURLOPT_USERAGENT);
+ REGISTER_CURL_CONSTANT(CURLOPT_USERPWD);
+ REGISTER_CURL_CONSTANT(CURLOPT_VERBOSE);
+ REGISTER_CURL_CONSTANT(CURLOPT_WRITEFUNCTION);
+ REGISTER_CURL_CONSTANT(CURLOPT_WRITEHEADER);
/* Constants effecting the way CURLOPT_CLOSEPOLICY works */
+ REGISTER_CURL_CONSTANT(CURLCLOSEPOLICY_CALLBACK);
REGISTER_CURL_CONSTANT(CURLCLOSEPOLICY_LEAST_RECENTLY_USED);
REGISTER_CURL_CONSTANT(CURLCLOSEPOLICY_LEAST_TRAFFIC);
- REGISTER_CURL_CONSTANT(CURLCLOSEPOLICY_SLOWEST);
- REGISTER_CURL_CONSTANT(CURLCLOSEPOLICY_CALLBACK);
REGISTER_CURL_CONSTANT(CURLCLOSEPOLICY_OLDEST);
+ REGISTER_CURL_CONSTANT(CURLCLOSEPOLICY_SLOWEST);
- /* Info constants */
- REGISTER_CURL_CONSTANT(CURLINFO_EFFECTIVE_URL);
- REGISTER_CURL_CONSTANT(CURLINFO_HTTP_CODE);
- REGISTER_CURL_CONSTANT(CURLINFO_HEADER_SIZE);
- REGISTER_CURL_CONSTANT(CURLINFO_REQUEST_SIZE);
- REGISTER_CURL_CONSTANT(CURLINFO_TOTAL_TIME);
- REGISTER_CURL_CONSTANT(CURLINFO_NAMELOOKUP_TIME);
- REGISTER_CURL_CONSTANT(CURLINFO_CONNECT_TIME);
- REGISTER_CURL_CONSTANT(CURLINFO_PRETRANSFER_TIME);
- REGISTER_CURL_CONSTANT(CURLINFO_SIZE_UPLOAD);
- REGISTER_CURL_CONSTANT(CURLINFO_SIZE_DOWNLOAD);
- REGISTER_CURL_CONSTANT(CURLINFO_SPEED_DOWNLOAD);
- REGISTER_CURL_CONSTANT(CURLINFO_SPEED_UPLOAD);
- REGISTER_CURL_CONSTANT(CURLINFO_FILETIME);
- REGISTER_CURL_CONSTANT(CURLINFO_SSL_VERIFYRESULT);
- REGISTER_CURL_CONSTANT(CURLINFO_CONTENT_LENGTH_DOWNLOAD);
- REGISTER_CURL_CONSTANT(CURLINFO_CONTENT_LENGTH_UPLOAD);
- REGISTER_CURL_CONSTANT(CURLINFO_STARTTRANSFER_TIME);
- REGISTER_CURL_CONSTANT(CURLINFO_CONTENT_TYPE);
- REGISTER_CURL_CONSTANT(CURLINFO_REDIRECT_TIME);
- REGISTER_CURL_CONSTANT(CURLINFO_REDIRECT_COUNT);
- REGISTER_CURL_CONSTANT(CURLINFO_HEADER_OUT);
- REGISTER_CURL_CONSTANT(CURLINFO_PRIVATE);
-#if LIBCURL_VERSION_NUM > 0x071301
- REGISTER_CURL_CONSTANT(CURLINFO_CERTINFO);
-#endif
-#if LIBCURL_VERSION_NUM >= 0x071202
- REGISTER_CURL_CONSTANT(CURLINFO_REDIRECT_URL);
-#endif
-
-
- /* cURL protocol constants (curl_version) */
- REGISTER_CURL_CONSTANT(CURL_VERSION_IPV6);
- REGISTER_CURL_CONSTANT(CURL_VERSION_KERBEROS4);
- REGISTER_CURL_CONSTANT(CURL_VERSION_SSL);
- REGISTER_CURL_CONSTANT(CURL_VERSION_LIBZ);
-
- /* version constants */
- REGISTER_CURL_CONSTANT(CURLVERSION_NOW);
-
- /* Error Constants */
- REGISTER_CURL_CONSTANT(CURLE_OK);
- REGISTER_CURL_CONSTANT(CURLE_UNSUPPORTED_PROTOCOL);
- REGISTER_CURL_CONSTANT(CURLE_FAILED_INIT);
- REGISTER_CURL_CONSTANT(CURLE_URL_MALFORMAT);
- REGISTER_CURL_CONSTANT(CURLE_URL_MALFORMAT_USER);
- REGISTER_CURL_CONSTANT(CURLE_COULDNT_RESOLVE_PROXY);
- REGISTER_CURL_CONSTANT(CURLE_COULDNT_RESOLVE_HOST);
+ /* */
+ REGISTER_CURL_CONSTANT(CURLE_ABORTED_BY_CALLBACK);
+ REGISTER_CURL_CONSTANT(CURLE_BAD_CALLING_ORDER);
+ REGISTER_CURL_CONSTANT(CURLE_BAD_CONTENT_ENCODING);
+ REGISTER_CURL_CONSTANT(CURLE_BAD_FUNCTION_ARGUMENT);
+ REGISTER_CURL_CONSTANT(CURLE_BAD_PASSWORD_ENTERED);
REGISTER_CURL_CONSTANT(CURLE_COULDNT_CONNECT);
- REGISTER_CURL_CONSTANT(CURLE_FTP_WEIRD_SERVER_REPLY);
+ REGISTER_CURL_CONSTANT(CURLE_COULDNT_RESOLVE_HOST);
+ REGISTER_CURL_CONSTANT(CURLE_COULDNT_RESOLVE_PROXY);
+ REGISTER_CURL_CONSTANT(CURLE_FAILED_INIT);
+ REGISTER_CURL_CONSTANT(CURLE_FILE_COULDNT_READ_FILE);
REGISTER_CURL_CONSTANT(CURLE_FTP_ACCESS_DENIED);
- REGISTER_CURL_CONSTANT(CURLE_FTP_USER_PASSWORD_INCORRECT);
- REGISTER_CURL_CONSTANT(CURLE_FTP_WEIRD_PASS_REPLY);
- REGISTER_CURL_CONSTANT(CURLE_FTP_WEIRD_USER_REPLY);
- REGISTER_CURL_CONSTANT(CURLE_FTP_WEIRD_PASV_REPLY);
- REGISTER_CURL_CONSTANT(CURLE_FTP_WEIRD_227_FORMAT);
+ REGISTER_CURL_CONSTANT(CURLE_FTP_BAD_DOWNLOAD_RESUME);
REGISTER_CURL_CONSTANT(CURLE_FTP_CANT_GET_HOST);
REGISTER_CURL_CONSTANT(CURLE_FTP_CANT_RECONNECT);
- REGISTER_CURL_CONSTANT(CURLE_FTP_COULDNT_SET_BINARY);
- REGISTER_CURL_CONSTANT(CURLE_PARTIAL_FILE);
+ REGISTER_CURL_CONSTANT(CURLE_FTP_COULDNT_GET_SIZE);
REGISTER_CURL_CONSTANT(CURLE_FTP_COULDNT_RETR_FILE);
- REGISTER_CURL_CONSTANT(CURLE_FTP_WRITE_ERROR);
- REGISTER_CURL_CONSTANT(CURLE_FTP_QUOTE_ERROR);
- REGISTER_CURL_CONSTANT(CURLE_HTTP_NOT_FOUND);
- REGISTER_CURL_CONSTANT(CURLE_WRITE_ERROR);
- REGISTER_CURL_CONSTANT(CURLE_MALFORMAT_USER);
- REGISTER_CURL_CONSTANT(CURLE_FTP_COULDNT_STOR_FILE);
- REGISTER_CURL_CONSTANT(CURLE_READ_ERROR);
- REGISTER_CURL_CONSTANT(CURLE_OUT_OF_MEMORY);
- REGISTER_CURL_CONSTANT(CURLE_OPERATION_TIMEOUTED);
REGISTER_CURL_CONSTANT(CURLE_FTP_COULDNT_SET_ASCII);
- REGISTER_CURL_CONSTANT(CURLE_FTP_PORT_FAILED);
+ REGISTER_CURL_CONSTANT(CURLE_FTP_COULDNT_SET_BINARY);
+ REGISTER_CURL_CONSTANT(CURLE_FTP_COULDNT_STOR_FILE);
REGISTER_CURL_CONSTANT(CURLE_FTP_COULDNT_USE_REST);
- REGISTER_CURL_CONSTANT(CURLE_FTP_COULDNT_GET_SIZE);
- REGISTER_CURL_CONSTANT(CURLE_HTTP_RANGE_ERROR);
+ REGISTER_CURL_CONSTANT(CURLE_FTP_PORT_FAILED);
+ REGISTER_CURL_CONSTANT(CURLE_FTP_QUOTE_ERROR);
+ REGISTER_CURL_CONSTANT(CURLE_FTP_USER_PASSWORD_INCORRECT);
+ REGISTER_CURL_CONSTANT(CURLE_FTP_WEIRD_227_FORMAT);
+ REGISTER_CURL_CONSTANT(CURLE_FTP_WEIRD_PASS_REPLY);
+ REGISTER_CURL_CONSTANT(CURLE_FTP_WEIRD_PASV_REPLY);
+ REGISTER_CURL_CONSTANT(CURLE_FTP_WEIRD_SERVER_REPLY);
+ REGISTER_CURL_CONSTANT(CURLE_FTP_WEIRD_USER_REPLY);
+ REGISTER_CURL_CONSTANT(CURLE_FTP_WRITE_ERROR);
+ REGISTER_CURL_CONSTANT(CURLE_FUNCTION_NOT_FOUND);
+ REGISTER_CURL_CONSTANT(CURLE_GOT_NOTHING);
+ REGISTER_CURL_CONSTANT(CURLE_HTTP_NOT_FOUND);
+ REGISTER_CURL_CONSTANT(CURLE_HTTP_PORT_FAILED);
REGISTER_CURL_CONSTANT(CURLE_HTTP_POST_ERROR);
- REGISTER_CURL_CONSTANT(CURLE_SSL_CONNECT_ERROR);
- REGISTER_CURL_CONSTANT(CURLE_FTP_BAD_DOWNLOAD_RESUME);
- REGISTER_CURL_CONSTANT(CURLE_FILE_COULDNT_READ_FILE);
+ REGISTER_CURL_CONSTANT(CURLE_HTTP_RANGE_ERROR);
REGISTER_CURL_CONSTANT(CURLE_LDAP_CANNOT_BIND);
REGISTER_CURL_CONSTANT(CURLE_LDAP_SEARCH_FAILED);
REGISTER_CURL_CONSTANT(CURLE_LIBRARY_NOT_FOUND);
- REGISTER_CURL_CONSTANT(CURLE_FUNCTION_NOT_FOUND);
- REGISTER_CURL_CONSTANT(CURLE_ABORTED_BY_CALLBACK);
- REGISTER_CURL_CONSTANT(CURLE_BAD_FUNCTION_ARGUMENT);
- REGISTER_CURL_CONSTANT(CURLE_BAD_CALLING_ORDER);
- REGISTER_CURL_CONSTANT(CURLE_HTTP_PORT_FAILED);
- REGISTER_CURL_CONSTANT(CURLE_BAD_PASSWORD_ENTERED);
- REGISTER_CURL_CONSTANT(CURLE_TOO_MANY_REDIRECTS);
- REGISTER_CURL_CONSTANT(CURLE_UNKNOWN_TELNET_OPTION);
- REGISTER_CURL_CONSTANT(CURLE_TELNET_OPTION_SYNTAX);
+ REGISTER_CURL_CONSTANT(CURLE_MALFORMAT_USER);
REGISTER_CURL_CONSTANT(CURLE_OBSOLETE);
- REGISTER_CURL_CONSTANT(CURLE_SSL_PEER_CERTIFICATE);
- REGISTER_CURL_CONSTANT(CURLE_GOT_NOTHING);
- REGISTER_CURL_CONSTANT(CURLE_SSL_ENGINE_NOTFOUND);
- REGISTER_CURL_CONSTANT(CURLE_SSL_ENGINE_SETFAILED);
- REGISTER_CURL_CONSTANT(CURLE_SEND_ERROR);
+ REGISTER_CURL_CONSTANT(CURLE_OK);
+ REGISTER_CURL_CONSTANT(CURLE_OPERATION_TIMEOUTED);
+ REGISTER_CURL_CONSTANT(CURLE_OUT_OF_MEMORY);
+ REGISTER_CURL_CONSTANT(CURLE_PARTIAL_FILE);
+ REGISTER_CURL_CONSTANT(CURLE_READ_ERROR);
REGISTER_CURL_CONSTANT(CURLE_RECV_ERROR);
+ REGISTER_CURL_CONSTANT(CURLE_SEND_ERROR);
REGISTER_CURL_CONSTANT(CURLE_SHARE_IN_USE);
+ REGISTER_CURL_CONSTANT(CURLE_SSL_CACERT);
REGISTER_CURL_CONSTANT(CURLE_SSL_CERTPROBLEM);
REGISTER_CURL_CONSTANT(CURLE_SSL_CIPHER);
- REGISTER_CURL_CONSTANT(CURLE_SSL_CACERT);
- REGISTER_CURL_CONSTANT(CURLE_BAD_CONTENT_ENCODING);
-#if LIBCURL_VERSION_NUM >= 0x070a08
- REGISTER_CURL_CONSTANT(CURLE_LDAP_INVALID_URL);
- REGISTER_CURL_CONSTANT(CURLE_FILESIZE_EXCEEDED);
-#endif
-#if LIBCURL_VERSION_NUM >= 0x070b00
- REGISTER_CURL_CONSTANT(CURLE_FTP_SSL_FAILED);
-#endif
+ REGISTER_CURL_CONSTANT(CURLE_SSL_CONNECT_ERROR);
+ REGISTER_CURL_CONSTANT(CURLE_SSL_ENGINE_NOTFOUND);
+ REGISTER_CURL_CONSTANT(CURLE_SSL_ENGINE_SETFAILED);
+ REGISTER_CURL_CONSTANT(CURLE_SSL_PEER_CERTIFICATE);
+ REGISTER_CURL_CONSTANT(CURLE_TELNET_OPTION_SYNTAX);
+ REGISTER_CURL_CONSTANT(CURLE_TOO_MANY_REDIRECTS);
+ REGISTER_CURL_CONSTANT(CURLE_UNKNOWN_TELNET_OPTION);
+ REGISTER_CURL_CONSTANT(CURLE_UNSUPPORTED_PROTOCOL);
+ REGISTER_CURL_CONSTANT(CURLE_URL_MALFORMAT);
+ REGISTER_CURL_CONSTANT(CURLE_URL_MALFORMAT_USER);
+ REGISTER_CURL_CONSTANT(CURLE_WRITE_ERROR);
+
+ /* cURL info constants */
+ REGISTER_CURL_CONSTANT(CURLINFO_CONNECT_TIME);
+ REGISTER_CURL_CONSTANT(CURLINFO_CONTENT_LENGTH_DOWNLOAD);
+ REGISTER_CURL_CONSTANT(CURLINFO_CONTENT_LENGTH_UPLOAD);
+ REGISTER_CURL_CONSTANT(CURLINFO_CONTENT_TYPE);
+ REGISTER_CURL_CONSTANT(CURLINFO_EFFECTIVE_URL);
+ REGISTER_CURL_CONSTANT(CURLINFO_FILETIME);
+ REGISTER_CURL_CONSTANT(CURLINFO_HEADER_OUT);
+ REGISTER_CURL_CONSTANT(CURLINFO_HEADER_SIZE);
+ REGISTER_CURL_CONSTANT(CURLINFO_HTTP_CODE);
+ REGISTER_CURL_CONSTANT(CURLINFO_NAMELOOKUP_TIME);
+ REGISTER_CURL_CONSTANT(CURLINFO_PRETRANSFER_TIME);
+ REGISTER_CURL_CONSTANT(CURLINFO_PRIVATE);
+ REGISTER_CURL_CONSTANT(CURLINFO_REDIRECT_COUNT);
+ REGISTER_CURL_CONSTANT(CURLINFO_REDIRECT_TIME);
+ REGISTER_CURL_CONSTANT(CURLINFO_REQUEST_SIZE);
+ REGISTER_CURL_CONSTANT(CURLINFO_SIZE_DOWNLOAD);
+ REGISTER_CURL_CONSTANT(CURLINFO_SIZE_UPLOAD);
+ REGISTER_CURL_CONSTANT(CURLINFO_SPEED_DOWNLOAD);
+ REGISTER_CURL_CONSTANT(CURLINFO_SPEED_UPLOAD);
+ REGISTER_CURL_CONSTANT(CURLINFO_SSL_VERIFYRESULT);
+ REGISTER_CURL_CONSTANT(CURLINFO_STARTTRANSFER_TIME);
+ REGISTER_CURL_CONSTANT(CURLINFO_TOTAL_TIME);
+
+ /* Other */
+ REGISTER_CURL_CONSTANT(CURLMSG_DONE);
+ REGISTER_CURL_CONSTANT(CURLVERSION_NOW);
+
+ /* Curl Multi Constants */
+ REGISTER_CURL_CONSTANT(CURLM_BAD_EASY_HANDLE);
+ REGISTER_CURL_CONSTANT(CURLM_BAD_HANDLE);
+ REGISTER_CURL_CONSTANT(CURLM_CALL_MULTI_PERFORM);
+ REGISTER_CURL_CONSTANT(CURLM_INTERNAL_ERROR);
+ REGISTER_CURL_CONSTANT(CURLM_OK);
+ REGISTER_CURL_CONSTANT(CURLM_OUT_OF_MEMORY);
+
+ /* Curl proxy constants */
REGISTER_CURL_CONSTANT(CURLPROXY_HTTP);
REGISTER_CURL_CONSTANT(CURLPROXY_SOCKS4);
REGISTER_CURL_CONSTANT(CURLPROXY_SOCKS5);
- REGISTER_CURL_CONSTANT(CURL_NETRC_OPTIONAL);
- REGISTER_CURL_CONSTANT(CURL_NETRC_IGNORED);
- REGISTER_CURL_CONSTANT(CURL_NETRC_REQUIRED);
+ /* Curl Share constants */
+ REGISTER_CURL_CONSTANT(CURLSHOPT_SHARE);
+ REGISTER_CURL_CONSTANT(CURLSHOPT_UNSHARE);
- REGISTER_CURL_CONSTANT(CURL_HTTP_VERSION_NONE);
+ /* Curl Http Version constants (CURLOPT_HTTP_VERSION) */
REGISTER_CURL_CONSTANT(CURL_HTTP_VERSION_1_0);
REGISTER_CURL_CONSTANT(CURL_HTTP_VERSION_1_1);
+ REGISTER_CURL_CONSTANT(CURL_HTTP_VERSION_NONE);
- REGISTER_CURL_CONSTANT(CURLM_CALL_MULTI_PERFORM);
- REGISTER_CURL_CONSTANT(CURLM_OK);
- REGISTER_CURL_CONSTANT(CURLM_BAD_HANDLE);
- REGISTER_CURL_CONSTANT(CURLM_BAD_EASY_HANDLE);
- REGISTER_CURL_CONSTANT(CURLM_OUT_OF_MEMORY);
- REGISTER_CURL_CONSTANT(CURLM_INTERNAL_ERROR);
+ /* Curl Lock constants */
+ REGISTER_CURL_CONSTANT(CURL_LOCK_DATA_COOKIE);
+ REGISTER_CURL_CONSTANT(CURL_LOCK_DATA_DNS);
+ REGISTER_CURL_CONSTANT(CURL_LOCK_DATA_SSL_SESSION);
- REGISTER_CURL_CONSTANT(CURLMSG_DONE);
+ /* Curl NETRC constants (CURLOPT_NETRC) */
+ REGISTER_CURL_CONSTANT(CURL_NETRC_IGNORED);
+ REGISTER_CURL_CONSTANT(CURL_NETRC_OPTIONAL);
+ REGISTER_CURL_CONSTANT(CURL_NETRC_REQUIRED);
-#if LIBCURL_VERSION_NUM >= 0x070c02
- REGISTER_CURL_CONSTANT(CURLOPT_FTPSSLAUTH);
+ /* Curl SSL Version constants (CURLOPT_SSLVERSION) */
+ REGISTER_CURL_CONSTANT(CURL_SSLVERSION_DEFAULT);
+ REGISTER_CURL_CONSTANT(CURL_SSLVERSION_SSLv2);
+ REGISTER_CURL_CONSTANT(CURL_SSLVERSION_SSLv3);
+ REGISTER_CURL_CONSTANT(CURL_SSLVERSION_TLSv1);
+
+ /* Curl TIMECOND constants (CURLOPT_TIMECONDITION) */
+ REGISTER_CURL_CONSTANT(CURL_TIMECOND_IFMODSINCE);
+ REGISTER_CURL_CONSTANT(CURL_TIMECOND_IFUNMODSINCE);
+ REGISTER_CURL_CONSTANT(CURL_TIMECOND_LASTMOD);
+
+ /* Curl version constants */
+ REGISTER_CURL_CONSTANT(CURL_VERSION_IPV6);
+ REGISTER_CURL_CONSTANT(CURL_VERSION_KERBEROS4);
+ REGISTER_CURL_CONSTANT(CURL_VERSION_LIBZ);
+ REGISTER_CURL_CONSTANT(CURL_VERSION_SSL);
+
+#if LIBCURL_VERSION_NUM >= 0x070a06 /* Available since 7.10.6 */
+ REGISTER_CURL_CONSTANT(CURLOPT_HTTPAUTH);
+ /* http authentication options */
+ REGISTER_CURL_CONSTANT(CURLAUTH_ANY);
+ REGISTER_CURL_CONSTANT(CURLAUTH_ANYSAFE);
+ REGISTER_CURL_CONSTANT(CURLAUTH_BASIC);
+ REGISTER_CURL_CONSTANT(CURLAUTH_DIGEST);
+ REGISTER_CURL_CONSTANT(CURLAUTH_GSSNEGOTIATE);
+ REGISTER_CURL_CONSTANT(CURLAUTH_NONE);
+ REGISTER_CURL_CONSTANT(CURLAUTH_NTLM);
+#endif
+
+#if LIBCURL_VERSION_NUM >= 0x070a07 /* Available since 7.10.7 */
+ REGISTER_CURL_CONSTANT(CURLINFO_HTTP_CONNECTCODE);
+ REGISTER_CURL_CONSTANT(CURLOPT_FTP_CREATE_MISSING_DIRS);
+ REGISTER_CURL_CONSTANT(CURLOPT_PROXYAUTH);
+#endif
+
+#if LIBCURL_VERSION_NUM >= 0x070a08 /* Available since 7.10.8 */
+ REGISTER_CURL_CONSTANT(CURLE_FILESIZE_EXCEEDED);
+ REGISTER_CURL_CONSTANT(CURLE_LDAP_INVALID_URL);
+ REGISTER_CURL_CONSTANT(CURLINFO_HTTPAUTH_AVAIL);
+ REGISTER_CURL_CONSTANT(CURLINFO_RESPONSE_CODE);
+ REGISTER_CURL_CONSTANT(CURLINFO_PROXYAUTH_AVAIL);
+ REGISTER_CURL_CONSTANT(CURLOPT_FTP_RESPONSE_TIMEOUT);
+ REGISTER_CURL_CONSTANT(CURLOPT_IPRESOLVE);
+ REGISTER_CURL_CONSTANT(CURLOPT_MAXFILESIZE);
+ REGISTER_CURL_CONSTANT(CURL_IPRESOLVE_V4);
+ REGISTER_CURL_CONSTANT(CURL_IPRESOLVE_V6);
+ REGISTER_CURL_CONSTANT(CURL_IPRESOLVE_WHATEVER);
+#endif
+
+#if LIBCURL_VERSION_NUM >= 0x070b00 /* Available since 7.11.0 */
+ REGISTER_CURL_CONSTANT(CURLE_FTP_SSL_FAILED);
+ REGISTER_CURL_CONSTANT(CURLFTPSSL_ALL);
+ REGISTER_CURL_CONSTANT(CURLFTPSSL_CONTROL);
+ REGISTER_CURL_CONSTANT(CURLFTPSSL_NONE);
+ REGISTER_CURL_CONSTANT(CURLFTPSSL_TRY);
+ REGISTER_CURL_CONSTANT(CURLOPT_FTP_SSL);
+ REGISTER_CURL_CONSTANT(CURLOPT_NETRC_FILE);
+#endif
+
+#if LIBCURL_VERSION_NUM >= 0x070c02 /* Available since 7.12.2 */
REGISTER_CURL_CONSTANT(CURLFTPAUTH_DEFAULT);
REGISTER_CURL_CONSTANT(CURLFTPAUTH_SSL);
REGISTER_CURL_CONSTANT(CURLFTPAUTH_TLS);
+ REGISTER_CURL_CONSTANT(CURLOPT_FTPSSLAUTH);
#endif
-#if LIBCURL_VERSION_NUM > 0x070b00
- REGISTER_CURL_CONSTANT(CURLOPT_FTP_SSL);
- REGISTER_CURL_CONSTANT(CURLFTPSSL_NONE);
- REGISTER_CURL_CONSTANT(CURLFTPSSL_TRY);
- REGISTER_CURL_CONSTANT(CURLFTPSSL_CONTROL);
- REGISTER_CURL_CONSTANT(CURLFTPSSL_ALL);
+#if LIBCURL_VERSION_NUM >= 0x070d00 /* Available since 7.13.0 */
+ REGISTER_CURL_CONSTANT(CURLOPT_FTP_ACCOUNT);
+#endif
+
+#if LIBCURL_VERSION_NUM >= 0x070b02 /* Available since 7.11.2 */
+ REGISTER_CURL_CONSTANT(CURLOPT_TCP_NODELAY);
#endif
-#if LIBCURL_VERSION_NUM > 0x071301
- REGISTER_CURL_CONSTANT(CURLOPT_CERTINFO);
- REGISTER_CURL_CONSTANT(CURLOPT_POSTREDIR);
+#if LIBCURL_VERSION_NUM >= 0x070c02 /* Available since 7.12.2 */
+ REGISTER_CURL_CONSTANT(CURLINFO_OS_ERRNO);
+#endif
+
+#if LIBCURL_VERSION_NUM >= 0x070c03 /* Available since 7.12.3 */
+ REGISTER_CURL_CONSTANT(CURLINFO_NUM_CONNECTS);
+ REGISTER_CURL_CONSTANT(CURLINFO_SSL_ENGINES);
#endif
-/* SSH support works in 7.19.0+ using libssh2 */
-#if LIBCURL_VERSION_NUM >= 0x071300
- REGISTER_CURL_CONSTANT(CURLSSH_AUTH_NONE);
- REGISTER_CURL_CONSTANT(CURLSSH_AUTH_PUBLICKEY);
- REGISTER_CURL_CONSTANT(CURLSSH_AUTH_PASSWORD);
- REGISTER_CURL_CONSTANT(CURLSSH_AUTH_HOST);
- REGISTER_CURL_CONSTANT(CURLSSH_AUTH_KEYBOARD);
- REGISTER_CURL_CONSTANT(CURLSSH_AUTH_DEFAULT);
- REGISTER_CURL_CONSTANT(CURLOPT_SSH_AUTH_TYPES);
+#if LIBCURL_VERSION_NUM >= 0x070e01 /* Available since 7.14.1 */
+ REGISTER_CURL_CONSTANT(CURLINFO_COOKIELIST);
+ REGISTER_CURL_CONSTANT(CURLOPT_COOKIELIST);
+ REGISTER_CURL_CONSTANT(CURLOPT_IGNORE_CONTENT_LENGTH);
+#endif
+
+#if LIBCURL_VERSION_NUM >= 0x070f00 /* Available since 7.15.0 */
+ REGISTER_CURL_CONSTANT(CURLOPT_FTP_SKIP_PASV_IP);
+#endif
+
+#if LIBCURL_VERSION_NUM >= 0x070f01 /* Available since 7.15.1 */
+ REGISTER_CURL_CONSTANT(CURLOPT_FTP_FILEMETHOD);
+#endif
+
+#if LIBCURL_VERSION_NUM >= 0x070f02 /* Available since 7.15.2 */
+ REGISTER_CURL_CONSTANT(CURLOPT_CONNECT_ONLY);
+ REGISTER_CURL_CONSTANT(CURLOPT_LOCALPORT);
+ REGISTER_CURL_CONSTANT(CURLOPT_LOCALPORTRANGE);
+#endif
+
+#if LIBCURL_VERSION_NUM >= 0x070f03 /* Available since 7.15.3 */
+ REGISTER_CURL_CONSTANT(CURLFTPMETHOD_MULTICWD);
+ REGISTER_CURL_CONSTANT(CURLFTPMETHOD_NOCWD);
+ REGISTER_CURL_CONSTANT(CURLFTPMETHOD_SINGLECWD);
+#endif
+
+#if LIBCURL_VERSION_NUM >- 0x070f04 /* Available since 7.15.4 */
+ REGISTER_CURL_CONSTANT(CURLINFO_FTP_ENTRY_PATH);
+#endif
+
+#if LIBCURL_VERSION_NUM >= 0x070f05 /* Available since 7.15.5 */
+ REGISTER_CURL_CONSTANT(CURLOPT_FTP_ALTERNATIVE_TO_USER);
+ REGISTER_CURL_CONSTANT(CURLOPT_MAX_RECV_SPEED_LARGE);
+ REGISTER_CURL_CONSTANT(CURLOPT_MAX_SEND_SPEED_LARGE);
+#endif
+
+#if LIBCURL_VERSION_NUM >= 0x071000 /* Available since 7.16.0 */
+ REGISTER_CURL_CONSTANT(CURLOPT_SSL_SESSIONID_CACHE);
+#endif
+
+#if LIBCURL_VERSION_NUM >= 0x071001 /* Available since 7.16.1 */
+ REGISTER_CURL_CONSTANT(CURLOPT_FTP_SSL_CCC);
+ REGISTER_CURL_CONSTANT(CURLFTPSSL_CCC_ACTIVE);
+ REGISTER_CURL_CONSTANT(CURLFTPSSL_CCC_NONE);
+ REGISTER_CURL_CONSTANT(CURLFTPSSL_CCC_PASSIVE);
+#endif
+
+#if LIBCURL_VERSION_NUM >= 0x071002 /* Available since 7.16.2 */
+ REGISTER_CURL_CONSTANT(CURLOPT_CONNECTTIMEOUT_MS);
+ REGISTER_CURL_CONSTANT(CURLOPT_HTTP_CONTENT_DECODING);
+ REGISTER_CURL_CONSTANT(CURLOPT_HTTP_TRANSFER_DECODING);
+ REGISTER_CURL_CONSTANT(CURLOPT_TIMEOUT_MS);
+#endif
+
+#if LIBCURL_VERSION_NUM >= 0x071004 /* Available since 7.16.4 */
+ REGISTER_CURL_CONSTANT(CURLOPT_KRBLEVEL);
+#endif
+
+#if LIBCURL_VERSION_NUM >= 0x071100 /* Available since 7.17.0 */
+ REGISTER_CURL_CONSTANT(CURLOPT_APPEND);
+ REGISTER_CURL_CONSTANT(CURLOPT_DIRLISTONLY);
+ REGISTER_CURL_CONSTANT(CURLOPT_NEW_DIRECTORY_PERMS);
+ REGISTER_CURL_CONSTANT(CURLOPT_NEW_FILE_PERMS);
+ REGISTER_CURL_CONSTANT(CURLOPT_USE_SSL);
+ /* Curl SSL Constants */
+ REGISTER_CURL_CONSTANT(CURLUSESSL_ALL);
+ REGISTER_CURL_CONSTANT(CURLUSESSL_CONTROL);
+ REGISTER_CURL_CONSTANT(CURLUSESSL_NONE);
+ REGISTER_CURL_CONSTANT(CURLUSESSL_TRY);
+#endif
+
+#if LIBCURL_VERSION_NUM >= 0x071200 /* Available since 7.18.0 */
+ REGISTER_CURL_CONSTANT(CURLOPT_PROXY_TRANSFER_MODE);
+#endif
+
+#if LIBCURL_VERSION_NUM >= 0x071202 /* Available since 7.18.2 */
+ REGISTER_CURL_CONSTANT(CURLINFO_REDIRECT_URL);
+#endif
+
+#if LIBCURL_VERSION_NUM >= 0x071300 /* Available since 7.19.0 */
+ REGISTER_CURL_CONSTANT(CURLE_SSH);
+ REGISTER_CURL_CONSTANT(CURLINFO_APPCONNECT_TIME);
+ REGISTER_CURL_CONSTANT(CURLINFO_PRIMARY_IP);
+
+ REGISTER_CURL_CONSTANT(CURLOPT_ADDRESS_SCOPE);
+ REGISTER_CURL_CONSTANT(CURLOPT_CRLFILE);
+ REGISTER_CURL_CONSTANT(CURLOPT_ISSUERCERT);
REGISTER_CURL_CONSTANT(CURLOPT_KEYPASSWD);
- REGISTER_CURL_CONSTANT(CURLOPT_SSH_PUBLIC_KEYFILE);
- REGISTER_CURL_CONSTANT(CURLOPT_SSH_PRIVATE_KEYFILE);
+ REGISTER_CURL_CONSTANT(CURLOPT_SSH_AUTH_TYPES);
REGISTER_CURL_CONSTANT(CURLOPT_SSH_HOST_PUBLIC_KEY_MD5);
- REGISTER_CURL_CONSTANT(CURLE_SSH);
+ REGISTER_CURL_CONSTANT(CURLOPT_SSH_PRIVATE_KEYFILE);
+ REGISTER_CURL_CONSTANT(CURLOPT_SSH_PUBLIC_KEYFILE);
+
+ REGISTER_CURL_CONSTANT(CURLSSH_AUTH_ANY);
+ REGISTER_CURL_CONSTANT(CURLSSH_AUTH_DEFAULT);
+ REGISTER_CURL_CONSTANT(CURLSSH_AUTH_HOST);
+ REGISTER_CURL_CONSTANT(CURLSSH_AUTH_KEYBOARD);
+ REGISTER_CURL_CONSTANT(CURLSSH_AUTH_NONE);
+ REGISTER_CURL_CONSTANT(CURLSSH_AUTH_PASSWORD);
+ REGISTER_CURL_CONSTANT(CURLSSH_AUTH_PUBLICKEY);
#endif
-#if LIBCURL_VERSION_NUM >= 0x071304
- REGISTER_CURL_CONSTANT(CURLOPT_REDIR_PROTOCOLS);
+#if LIBCURL_VERSION_NUM >= 0x071301 /* Available since 7.19.1 */
+ REGISTER_CURL_CONSTANT(CURLINFO_CERTINFO);
+ REGISTER_CURL_CONSTANT(CURLOPT_CERTINFO);
+ REGISTER_CURL_CONSTANT(CURLOPT_PASSWORD);
+ REGISTER_CURL_CONSTANT(CURLOPT_POSTREDIR);
+ REGISTER_CURL_CONSTANT(CURLOPT_PROXYPASSWORD);
+ REGISTER_CURL_CONSTANT(CURLOPT_PROXYUSERNAME);
+ REGISTER_CURL_CONSTANT(CURLOPT_USERNAME);
+#endif
+
+#if LIBCURL_VERSION_NUM >= 0x071303 /* Available since 7.19.3 */
+ REGISTER_CURL_CONSTANT(CURLAUTH_DIGEST_IE);
+#endif
+
+#if LIBCURL_VERSION_NUM >= 0x071304 /* Available since 7.19.4 */
+ REGISTER_CURL_CONSTANT(CURLINFO_CONDITION_UNMET);
+
+ REGISTER_CURL_CONSTANT(CURLOPT_NOPROXY);
REGISTER_CURL_CONSTANT(CURLOPT_PROTOCOLS);
- REGISTER_CURL_CONSTANT(CURLPROTO_HTTP);
- REGISTER_CURL_CONSTANT(CURLPROTO_HTTPS);
+ REGISTER_CURL_CONSTANT(CURLOPT_REDIR_PROTOCOLS);
+ REGISTER_CURL_CONSTANT(CURLOPT_SOCKS5_GSSAPI_NEC);
+ REGISTER_CURL_CONSTANT(CURLOPT_SOCKS5_GSSAPI_SERVICE);
+ REGISTER_CURL_CONSTANT(CURLOPT_TFTP_BLKSIZE);
+
+ REGISTER_CURL_CONSTANT(CURLPROTO_ALL);
+ REGISTER_CURL_CONSTANT(CURLPROTO_DICT);
+ REGISTER_CURL_CONSTANT(CURLPROTO_FILE);
REGISTER_CURL_CONSTANT(CURLPROTO_FTP);
REGISTER_CURL_CONSTANT(CURLPROTO_FTPS);
+ REGISTER_CURL_CONSTANT(CURLPROTO_HTTP);
+ REGISTER_CURL_CONSTANT(CURLPROTO_HTTPS);
+ REGISTER_CURL_CONSTANT(CURLPROTO_LDAP);
+ REGISTER_CURL_CONSTANT(CURLPROTO_LDAPS);
REGISTER_CURL_CONSTANT(CURLPROTO_SCP);
REGISTER_CURL_CONSTANT(CURLPROTO_SFTP);
REGISTER_CURL_CONSTANT(CURLPROTO_TELNET);
- REGISTER_CURL_CONSTANT(CURLPROTO_LDAP);
- REGISTER_CURL_CONSTANT(CURLPROTO_LDAPS);
- REGISTER_CURL_CONSTANT(CURLPROTO_DICT);
- REGISTER_CURL_CONSTANT(CURLPROTO_FILE);
REGISTER_CURL_CONSTANT(CURLPROTO_TFTP);
- REGISTER_CURL_CONSTANT(CURLPROTO_ALL);
#endif
-#if LIBCURL_VERSION_NUM >= 0x070f01
- REGISTER_CURL_CONSTANT(CURLOPT_FTP_FILEMETHOD);
- REGISTER_CURL_CONSTANT(CURLOPT_FTP_SKIP_PASV_IP);
+#if LIBCURL_VERSION_NUM >= 0x071306 /* Available since 7.19.6 */
+ REGISTER_CURL_CONSTANT(CURLOPT_SSH_KNOWNHOSTS);
+#endif
+
+#if LIBCURL_VERSION_NUM >= 0x071400 /* Available since 7.20.0 */
+ REGISTER_CURL_CONSTANT(CURLINFO_RTSP_CLIENT_CSEQ);
+ REGISTER_CURL_CONSTANT(CURLINFO_RTSP_CSEQ_RECV);
+ REGISTER_CURL_CONSTANT(CURLINFO_RTSP_SERVER_CSEQ);
+ REGISTER_CURL_CONSTANT(CURLINFO_RTSP_SESSION_ID);
+ REGISTER_CURL_CONSTANT(CURLOPT_FTP_USE_PRET);
+ REGISTER_CURL_CONSTANT(CURLOPT_MAIL_FROM);
+ REGISTER_CURL_CONSTANT(CURLOPT_MAIL_RCPT);
+ REGISTER_CURL_CONSTANT(CURLOPT_RTSP_CLIENT_CSEQ);
+ REGISTER_CURL_CONSTANT(CURLOPT_RTSP_REQUEST);
+ REGISTER_CURL_CONSTANT(CURLOPT_RTSP_SERVER_CSEQ);
+ REGISTER_CURL_CONSTANT(CURLOPT_RTSP_SESSION_ID);
+ REGISTER_CURL_CONSTANT(CURLOPT_RTSP_STREAM_URI);
+ REGISTER_CURL_CONSTANT(CURLOPT_RTSP_TRANSPORT);
+ REGISTER_CURL_CONSTANT(CURLPROTO_IMAP);
+ REGISTER_CURL_CONSTANT(CURLPROTO_IMAPS);
+ REGISTER_CURL_CONSTANT(CURLPROTO_POP3);
+ REGISTER_CURL_CONSTANT(CURLPROTO_POP3S);
+ REGISTER_CURL_CONSTANT(CURLPROTO_RTSP);
+ REGISTER_CURL_CONSTANT(CURLPROTO_SMTP);
+ REGISTER_CURL_CONSTANT(CURLPROTO_SMTPS);
+ REGISTER_CURL_CONSTANT(CURL_RTSPREQ_ANNOUNCE);
+ REGISTER_CURL_CONSTANT(CURL_RTSPREQ_DESCRIBE);
+ REGISTER_CURL_CONSTANT(CURL_RTSPREQ_GET_PARAMETER);
+ REGISTER_CURL_CONSTANT(CURL_RTSPREQ_OPTIONS);
+ REGISTER_CURL_CONSTANT(CURL_RTSPREQ_PAUSE);
+ REGISTER_CURL_CONSTANT(CURL_RTSPREQ_PLAY);
+ REGISTER_CURL_CONSTANT(CURL_RTSPREQ_RECEIVE);
+ REGISTER_CURL_CONSTANT(CURL_RTSPREQ_RECORD);
+ REGISTER_CURL_CONSTANT(CURL_RTSPREQ_SETUP);
+ REGISTER_CURL_CONSTANT(CURL_RTSPREQ_SET_PARAMETER);
+ REGISTER_CURL_CONSTANT(CURL_RTSPREQ_TEARDOWN);
+#endif
+
+#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
+ REGISTER_CURL_CONSTANT(CURLINFO_LOCAL_IP);
+ REGISTER_CURL_CONSTANT(CURLINFO_LOCAL_PORT);
+ REGISTER_CURL_CONSTANT(CURLINFO_PRIMARY_PORT);
+ REGISTER_CURL_CONSTANT(CURLOPT_FNMATCH_FUNCTION);
+ REGISTER_CURL_CONSTANT(CURLOPT_WILDCARDMATCH);
+ REGISTER_CURL_CONSTANT(CURLPROTO_RTMP);
+ REGISTER_CURL_CONSTANT(CURLPROTO_RTMPE);
+ REGISTER_CURL_CONSTANT(CURLPROTO_RTMPS);
+ REGISTER_CURL_CONSTANT(CURLPROTO_RTMPT);
+ REGISTER_CURL_CONSTANT(CURLPROTO_RTMPTE);
+ REGISTER_CURL_CONSTANT(CURLPROTO_RTMPTS);
+ REGISTER_CURL_CONSTANT(CURL_FNMATCHFUNC_FAIL);
+ REGISTER_CURL_CONSTANT(CURL_FNMATCHFUNC_MATCH);
+ REGISTER_CURL_CONSTANT(CURL_FNMATCHFUNC_NOMATCH);
+#endif
+
+#if LIBCURL_VERSION_NUM >= 0x071502 /* Available since 7.21.2 */
+ REGISTER_CURL_CONSTANT(CURLPROTO_GOPHER);
#endif
-#if LIBCURL_VERSION_NUM >= 0x071001
- REGISTER_CURL_CONSTANT(CURLFTPMETHOD_MULTICWD);
- REGISTER_CURL_CONSTANT(CURLFTPMETHOD_NOCWD);
- REGISTER_CURL_CONSTANT(CURLFTPMETHOD_SINGLECWD);
+#if LIBCURL_VERSION_NUM >= 0x071503 /* Available since 7.21.3 */
+ REGISTER_CURL_CONSTANT(CURLAUTH_ONLY);
+ REGISTER_CURL_CONSTANT(CURLOPT_RESOLVE);
+#endif
+
+#if LIBCURL_VERSION_NUM >= 0x071504 /* Available since 7.21.4 */
+ REGISTER_CURL_CONSTANT(CURLOPT_TLSAUTH_PASSWORD);
+ REGISTER_CURL_CONSTANT(CURLOPT_TLSAUTH_TYPE);
+ REGISTER_CURL_CONSTANT(CURLOPT_TLSAUTH_USERNAME);
+ REGISTER_CURL_CONSTANT(CURL_TLSAUTH_SRP);
+#endif
+
+#if LIBCURL_VERSION_NUM >= 0x071506 /* Available since 7.21.6 */
+ REGISTER_CURL_CONSTANT(CURLOPT_ACCEPT_ENCODING);
+ REGISTER_CURL_CONSTANT(CURLOPT_TRANSFER_ENCODING);
+#endif
+
+#if LIBCURL_VERSION_NUM >= 0x071800 /* Available since 7.24.0 */
+ REGISTER_CURL_CONSTANT(CURLOPT_DNS_SERVERS);
+#endif
+
+#if LIBCURL_VERSION_NUM >= 0x071900 /* Available since 7.25.0 */
+ REGISTER_CURL_CONSTANT(CURLOPT_MAIL_AUTH);
+#endif
+
+#if CURLOPT_FTPASCII != 0
+ REGISTER_CURL_CONSTANT(CURLOPT_FTPASCII);
+#endif
+#if CURLOPT_MUTE != 0
+ REGISTER_CURL_CONSTANT(CURLOPT_MUTE);
+#endif
+#if CURLOPT_PASSWDFUNCTION != 0
+ REGISTER_CURL_CONSTANT(CURLOPT_PASSWDFUNCTION);
#endif
#ifdef PHP_CURL_NEED_OPENSSL_TSL
@@ -906,7 +1145,6 @@ PHP_MINIT_FUNCTION(curl)
}
#ifdef PHP_CURL_URL_WRAPPERS
-# if HAVE_CURL_VERSION_INFO
{
curl_version_info_data *info = curl_version_info(CURLVERSION_NOW);
char **p = (char **)info->protocols;
@@ -920,18 +1158,6 @@ PHP_MINIT_FUNCTION(curl)
(void) *p++;
}
}
-# else
- php_unregister_url_stream_wrapper("http");
- php_register_url_stream_wrapper("http", &php_curl_wrapper TSRMLS_CC);
- php_unregister_url_stream_wrapper("https");
- php_register_url_stream_wrapper("https", &php_curl_wrapper TSRMLS_CC);
- php_unregister_url_stream_wrapper("ftp");
- php_register_url_stream_wrapper("ftp", &php_curl_wrapper TSRMLS_CC);
- php_unregister_url_stream_wrapper("ftps");
- php_register_url_stream_wrapper("ftps", &php_curl_wrapper TSRMLS_CC);
- php_unregister_url_stream_wrapper("ldap");
- php_register_url_stream_wrapper("ldap", &php_curl_wrapper TSRMLS_CC);
-# endif
#endif
return SUCCESS;
@@ -943,10 +1169,18 @@ PHP_MINIT_FUNCTION(curl)
PHP_MSHUTDOWN_FUNCTION(curl)
{
#ifdef PHP_CURL_URL_WRAPPERS
- php_unregister_url_stream_wrapper("http" TSRMLS_CC);
- php_unregister_url_stream_wrapper("https" TSRMLS_CC);
- php_unregister_url_stream_wrapper("ftp" TSRMLS_CC);
- php_unregister_url_stream_wrapper("ldap" TSRMLS_CC);
+ {
+ curl_version_info_data *info = curl_version_info(CURLVERSION_NOW);
+ char **p = (char **)info->protocols;
+
+ while (*p != NULL) {
+ /* Do not enable cURL "file" protocol and make sure cURL is always used when --with-curlwrappers is enabled */
+ if (strncasecmp(*p, "file", sizeof("file")-1) != 0) {
+ php_unregister_url_stream_wrapper(*p TSRMLS_CC);
+ }
+ (void) *p++;
+ }
+ }
#endif
curl_global_cleanup();
#ifdef PHP_CURL_NEED_OPENSSL_TSL
@@ -1045,13 +1279,77 @@ static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx)
}
/* }}} */
+#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
+/* {{{ curl_fnmatch
+ */
+static int curl_fnmatch(void *ctx, const char *pattern, const char *string)
+{
+ php_curl *ch = (php_curl *) ctx;
+ php_curl_fnmatch *t = ch->handlers->fnmatch;
+ int rval = CURL_FNMATCHFUNC_FAIL;
+ switch (t->method) {
+ case PHP_CURL_USER: {
+ zval **argv[3];
+ zval *zhandle = NULL;
+ zval *zpattern = NULL;
+ zval *zstring = NULL;
+ zval *retval_ptr;
+ int error;
+ zend_fcall_info fci;
+ TSRMLS_FETCH_FROM_CTX(ch->thread_ctx);
+
+ MAKE_STD_ZVAL(zhandle);
+ MAKE_STD_ZVAL(zpattern);
+ MAKE_STD_ZVAL(zstring);
+
+ ZVAL_RESOURCE(zhandle, ch->id);
+ zend_list_addref(ch->id);
+ ZVAL_STRING(zpattern, pattern, 1);
+ ZVAL_STRING(zstring, string, 1);
+
+ argv[0] = &zhandle;
+ argv[1] = &zpattern;
+ argv[2] = &zstring;
+
+ fci.size = sizeof(fci);
+ fci.function_table = EG(function_table);
+ fci.function_name = t->func_name;
+ fci.object_ptr = NULL;
+ fci.retval_ptr_ptr = &retval_ptr;
+ fci.param_count = 3;
+ fci.params = argv;
+ fci.no_separation = 0;
+ fci.symbol_table = NULL;
+
+ ch->in_callback = 1;
+ error = zend_call_function(&fci, &t->fci_cache TSRMLS_CC);
+ ch->in_callback = 0;
+ if (error == FAILURE) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot call the CURLOPT_FNMATCH_FUNCTION");
+ } else if (retval_ptr) {
+ if (Z_TYPE_P(retval_ptr) != IS_LONG) {
+ convert_to_long_ex(&retval_ptr);
+ }
+ rval = Z_LVAL_P(retval_ptr);
+ zval_ptr_dtor(&retval_ptr);
+ }
+ zval_ptr_dtor(argv[0]);
+ zval_ptr_dtor(argv[1]);
+ zval_ptr_dtor(argv[2]);
+ break;
+ }
+ }
+ return rval;
+}
+/* }}} */
+#endif
+
/* {{{ curl_progress
*/
static size_t curl_progress(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
{
php_curl *ch = (php_curl *) clientp;
php_curl_progress *t = ch->handlers->progress;
- int length = -1;
size_t rval = 0;
#if PHP_CURL_DEBUG
@@ -1061,7 +1359,8 @@ static size_t curl_progress(void *clientp, double dltotal, double dlnow, double
switch (t->method) {
case PHP_CURL_USER: {
- zval **argv[4];
+ zval **argv[5];
+ zval *handle = NULL;
zval *zdltotal = NULL;
zval *zdlnow = NULL;
zval *zultotal = NULL;
@@ -1071,27 +1370,31 @@ static size_t curl_progress(void *clientp, double dltotal, double dlnow, double
zend_fcall_info fci;
TSRMLS_FETCH_FROM_CTX(ch->thread_ctx);
+ MAKE_STD_ZVAL(handle);
MAKE_STD_ZVAL(zdltotal);
MAKE_STD_ZVAL(zdlnow);
MAKE_STD_ZVAL(zultotal);
MAKE_STD_ZVAL(zulnow);
+ ZVAL_RESOURCE(handle, ch->id);
+ zend_list_addref(ch->id);
ZVAL_LONG(zdltotal, (long) dltotal);
ZVAL_LONG(zdlnow, (long) dlnow);
ZVAL_LONG(zultotal, (long) ultotal);
ZVAL_LONG(zulnow, (long) ulnow);
- argv[0] = &zdltotal;
- argv[1] = &zdlnow;
- argv[2] = &zultotal;
- argv[3] = &zulnow;
+ argv[0] = &handle;
+ argv[1] = &zdltotal;
+ argv[2] = &zdlnow;
+ argv[3] = &zultotal;
+ argv[4] = &zulnow;
fci.size = sizeof(fci);
fci.function_table = EG(function_table);
fci.function_name = t->func_name;
fci.object_ptr = NULL;
fci.retval_ptr_ptr = &retval_ptr;
- fci.param_count = 4;
+ fci.param_count = 5;
fci.params = argv;
fci.no_separation = 0;
fci.symbol_table = NULL;
@@ -1101,7 +1404,6 @@ static size_t curl_progress(void *clientp, double dltotal, double dlnow, double
ch->in_callback = 0;
if (error == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot call the CURLOPT_PROGRESSFUNCTION");
- length = -1;
} else if (retval_ptr) {
if (Z_TYPE_P(retval_ptr) != IS_LONG) {
convert_to_long_ex(&retval_ptr);
@@ -1115,6 +1417,7 @@ static size_t curl_progress(void *clientp, double dltotal, double dlnow, double
zval_ptr_dtor(argv[1]);
zval_ptr_dtor(argv[2]);
zval_ptr_dtor(argv[3]);
+ zval_ptr_dtor(argv[4]);
break;
}
}
@@ -1415,7 +1718,10 @@ static void alloc_curl_handle(php_curl **ch)
(*ch)->handlers->write = ecalloc(1, sizeof(php_curl_write));
(*ch)->handlers->write_header = ecalloc(1, sizeof(php_curl_write));
(*ch)->handlers->read = ecalloc(1, sizeof(php_curl_read));
- (*ch)->handlers->progress = ecalloc(1, sizeof(php_curl_progress));
+ (*ch)->handlers->progress = NULL;
+#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
+ (*ch)->handlers->fnmatch = NULL;
+#endif
(*ch)->in_callback = 0;
(*ch)->header.str_len = 0;
@@ -1441,14 +1747,14 @@ static void split_certinfo(char *string, zval *hash)
char *split;
if(org) {
- do {
+ do {
char *key;
char *val;
char *tmp;
- split = strstr(s, "; ");
- if(split)
- *split = '\0';
+ split = strstr(s, "; ");
+ if(split)
+ *split = '\0';
key = s;
tmp = memchr(key, '=', 64);
@@ -1509,6 +1815,36 @@ static void create_certinfo(struct curl_certinfo *ci, zval *listcode TSRMLS_DC)
/* }}} */
#endif
+/* {{{ _php_curl_set_default_options()
+ Set default options for a handle */
+static void _php_curl_set_default_options(php_curl *ch)
+{
+ char *cainfo;
+
+ curl_easy_setopt(ch->cp, CURLOPT_NOPROGRESS, 1);
+ curl_easy_setopt(ch->cp, CURLOPT_VERBOSE, 0);
+ curl_easy_setopt(ch->cp, CURLOPT_ERRORBUFFER, ch->err.str);
+ curl_easy_setopt(ch->cp, CURLOPT_WRITEFUNCTION, curl_write);
+ curl_easy_setopt(ch->cp, CURLOPT_FILE, (void *) ch);
+ curl_easy_setopt(ch->cp, CURLOPT_READFUNCTION, curl_read);
+ curl_easy_setopt(ch->cp, CURLOPT_INFILE, (void *) ch);
+ curl_easy_setopt(ch->cp, CURLOPT_HEADERFUNCTION, curl_write_header);
+ curl_easy_setopt(ch->cp, CURLOPT_WRITEHEADER, (void *) ch);
+ curl_easy_setopt(ch->cp, CURLOPT_DNS_USE_GLOBAL_CACHE, 1);
+ curl_easy_setopt(ch->cp, CURLOPT_DNS_CACHE_TIMEOUT, 120);
+ curl_easy_setopt(ch->cp, CURLOPT_MAXREDIRS, 20); /* prevent infinite redirects */
+
+ cainfo = INI_STR("curl.cainfo");
+ if (cainfo && strlen(cainfo) > 0) {
+ curl_easy_setopt(ch->cp, CURLOPT_CAINFO, cainfo);
+ }
+
+#if defined(ZTS)
+ curl_easy_setopt(ch->cp, CURLOPT_NOSIGNAL, 1);
+#endif
+}
+/* }}} */
+
/* {{{ proto resource curl_init([string url])
Initialize a cURL session */
PHP_FUNCTION(curl_init)
@@ -1518,7 +1854,6 @@ PHP_FUNCTION(curl_init)
zval *clone;
char *url = NULL;
int url_len = 0;
- char *cainfo;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &url, &url_len) == FAILURE) {
return;
@@ -1536,7 +1871,6 @@ PHP_FUNCTION(curl_init)
ch->cp = cp;
ch->handlers->write->method = PHP_CURL_STDOUT;
- ch->handlers->write->type = PHP_CURL_ASCII;
ch->handlers->read->method = PHP_CURL_DIRECT;
ch->handlers->write_header->method = PHP_CURL_IGNORE;
@@ -1545,27 +1879,7 @@ PHP_FUNCTION(curl_init)
MAKE_STD_ZVAL(clone);
ch->clone = clone;
- curl_easy_setopt(ch->cp, CURLOPT_NOPROGRESS, 1);
- curl_easy_setopt(ch->cp, CURLOPT_VERBOSE, 0);
- curl_easy_setopt(ch->cp, CURLOPT_ERRORBUFFER, ch->err.str);
- curl_easy_setopt(ch->cp, CURLOPT_WRITEFUNCTION, curl_write);
- curl_easy_setopt(ch->cp, CURLOPT_FILE, (void *) ch);
- curl_easy_setopt(ch->cp, CURLOPT_READFUNCTION, curl_read);
- curl_easy_setopt(ch->cp, CURLOPT_INFILE, (void *) ch);
- curl_easy_setopt(ch->cp, CURLOPT_HEADERFUNCTION, curl_write_header);
- curl_easy_setopt(ch->cp, CURLOPT_WRITEHEADER, (void *) ch);
- curl_easy_setopt(ch->cp, CURLOPT_DNS_USE_GLOBAL_CACHE, 1);
- curl_easy_setopt(ch->cp, CURLOPT_DNS_CACHE_TIMEOUT, 120);
- curl_easy_setopt(ch->cp, CURLOPT_MAXREDIRS, 20); /* prevent infinite redirects */
-
- cainfo = INI_STR("curl.cainfo");
- if (cainfo && strlen(cainfo) > 0) {
- curl_easy_setopt(ch->cp, CURLOPT_CAINFO, cainfo);
- }
-
-#if defined(ZTS)
- curl_easy_setopt(ch->cp, CURLOPT_NOSIGNAL, 1);
-#endif
+ _php_curl_set_default_options(ch);
if (url) {
if (!php_curl_option_url(ch, url, url_len TSRMLS_CC)) {
@@ -1610,7 +1924,6 @@ PHP_FUNCTION(curl_copy_handle)
dupch->handlers->write->stream = ch->handlers->write->stream;
}
dupch->handlers->write->method = ch->handlers->write->method;
- dupch->handlers->write->type = ch->handlers->write->type;
if (ch->handlers->read->stream) {
Z_ADDREF_P(ch->handlers->read->stream);
}
@@ -1645,18 +1958,34 @@ PHP_FUNCTION(curl_copy_handle)
zval_add_ref(&ch->handlers->write_header->func_name);
dupch->handlers->write_header->func_name = ch->handlers->write_header->func_name;
}
-
- if (ch->handlers->progress->func_name) {
- zval_add_ref(&ch->handlers->progress->func_name);
- dupch->handlers->progress->func_name = ch->handlers->progress->func_name;
- }
- dupch->handlers->progress->method = ch->handlers->progress->method;
curl_easy_setopt(dupch->cp, CURLOPT_ERRORBUFFER, dupch->err.str);
curl_easy_setopt(dupch->cp, CURLOPT_FILE, (void *) dupch);
curl_easy_setopt(dupch->cp, CURLOPT_INFILE, (void *) dupch);
curl_easy_setopt(dupch->cp, CURLOPT_WRITEHEADER, (void *) dupch);
- curl_easy_setopt(dupch->cp, CURLOPT_PROGRESSDATA, (void *) dupch);
+
+ if (ch->handlers->progress) {
+ dupch->handlers->progress = ecalloc(1, sizeof(php_curl_progress));
+ if (ch->handlers->progress->func_name) {
+ zval_add_ref(&ch->handlers->progress->func_name);
+ dupch->handlers->progress->func_name = ch->handlers->progress->func_name;
+ }
+ dupch->handlers->progress->method = ch->handlers->progress->method;
+ curl_easy_setopt(dupch->cp, CURLOPT_PROGRESSDATA, (void *) dupch);
+ }
+
+/* Available since 7.21.0 */
+#if LIBCURL_VERSION_NUM >= 0x071500
+ if (ch->handlers->fnmatch) {
+ dupch->handlers->fnmatch = ecalloc(1, sizeof(php_curl_fnmatch));
+ if (ch->handlers->fnmatch->func_name) {
+ zval_add_ref(&ch->handlers->fnmatch->func_name);
+ dupch->handlers->fnmatch->func_name = ch->handlers->fnmatch->func_name;
+ }
+ dupch->handlers->fnmatch->method = ch->handlers->fnmatch->method;
+ curl_easy_setopt(dupch->cp, CURLOPT_FNMATCH_DATA, (void *) dupch);
+ }
+#endif
efree(dupch->to_free);
dupch->to_free = ch->to_free;
@@ -1675,90 +2004,139 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu
CURLcode error=CURLE_OK;
switch (option) {
- case CURLOPT_INFILESIZE:
- case CURLOPT_VERBOSE:
- case CURLOPT_HEADER:
- case CURLOPT_NOPROGRESS:
- case CURLOPT_NOBODY:
+ /* Long options */
+ case CURLOPT_AUTOREFERER:
+ case CURLOPT_BUFFERSIZE:
+ case CURLOPT_CLOSEPOLICY:
+ case CURLOPT_CONNECTTIMEOUT:
+ case CURLOPT_COOKIESESSION:
+ case CURLOPT_CRLF:
+ case CURLOPT_DNS_CACHE_TIMEOUT:
+ case CURLOPT_DNS_USE_GLOBAL_CACHE:
case CURLOPT_FAILONERROR:
- case CURLOPT_UPLOAD:
- case CURLOPT_POST:
- case CURLOPT_FTPLISTONLY:
- case CURLOPT_FTPAPPEND:
- case CURLOPT_NETRC:
- case CURLOPT_PUT:
-#if CURLOPT_MUTE != 0
- case CURLOPT_MUTE:
-#endif
- case CURLOPT_TIMEOUT:
-#if LIBCURL_VERSION_NUM > 0x071002
- case CURLOPT_TIMEOUT_MS:
-#endif
+ case CURLOPT_FILETIME:
+ case CURLOPT_FORBID_REUSE:
+ case CURLOPT_FRESH_CONNECT:
+ case CURLOPT_FTP_USE_EPRT:
case CURLOPT_FTP_USE_EPSV:
+ case CURLOPT_HEADER:
+ case CURLOPT_HTTPGET:
+ case CURLOPT_HTTPPROXYTUNNEL:
+ case CURLOPT_HTTP_VERSION:
+ case CURLOPT_INFILESIZE:
case CURLOPT_LOW_SPEED_LIMIT:
- case CURLOPT_SSLVERSION:
case CURLOPT_LOW_SPEED_TIME:
- case CURLOPT_RESUME_FROM:
- case CURLOPT_TIMEVALUE:
- case CURLOPT_TIMECONDITION:
- case CURLOPT_TRANSFERTEXT:
- case CURLOPT_HTTPPROXYTUNNEL:
- case CURLOPT_FILETIME:
- case CURLOPT_MAXREDIRS:
case CURLOPT_MAXCONNECTS:
- case CURLOPT_CLOSEPOLICY:
- case CURLOPT_FRESH_CONNECT:
- case CURLOPT_FORBID_REUSE:
- case CURLOPT_CONNECTTIMEOUT:
-#if LIBCURL_VERSION_NUM > 0x071002
- case CURLOPT_CONNECTTIMEOUT_MS:
-#endif
- case CURLOPT_SSL_VERIFYHOST:
- case CURLOPT_SSL_VERIFYPEER:
- case CURLOPT_DNS_USE_GLOBAL_CACHE:
+ case CURLOPT_MAXREDIRS:
+ case CURLOPT_NETRC:
+ case CURLOPT_NOBODY:
+ case CURLOPT_NOPROGRESS:
case CURLOPT_NOSIGNAL:
- case CURLOPT_PROXYTYPE:
- case CURLOPT_BUFFERSIZE:
- case CURLOPT_HTTPGET:
- case CURLOPT_HTTP_VERSION:
- case CURLOPT_CRLF:
- case CURLOPT_DNS_CACHE_TIMEOUT:
+ case CURLOPT_PORT:
+ case CURLOPT_POST:
case CURLOPT_PROXYPORT:
- case CURLOPT_FTP_USE_EPRT:
-#if LIBCURL_VERSION_NUM > 0x070a05 /* CURLOPT_HTTPAUTH is available since curl 7.10.6 */
+ case CURLOPT_PROXYTYPE:
+ case CURLOPT_PUT:
+ case CURLOPT_RESUME_FROM:
+ case CURLOPT_SSLVERSION:
+ case CURLOPT_SSL_VERIFYHOST:
+ case CURLOPT_SSL_VERIFYPEER:
+ case CURLOPT_TIMECONDITION:
+ case CURLOPT_TIMEOUT:
+ case CURLOPT_TIMEVALUE:
+ case CURLOPT_TRANSFERTEXT:
+ case CURLOPT_UNRESTRICTED_AUTH:
+ case CURLOPT_UPLOAD:
+ case CURLOPT_VERBOSE:
+#if LIBCURL_VERSION_NUM >= 0x070a06 /* Available since 7.10.6 */
case CURLOPT_HTTPAUTH:
#endif
-#if LIBCURL_VERSION_NUM > 0x070a06 /* CURLOPT_PROXYAUTH & CURLOPT_FTP_CREATE_MISSING_DIRS are available since curl 7.10.7 */
- case CURLOPT_PROXYAUTH:
+#if LIBCURL_VERSION_NUM >= 0x070a07 /* Available since 7.10.7 */
case CURLOPT_FTP_CREATE_MISSING_DIRS:
+ case CURLOPT_PROXYAUTH:
#endif
-
-#if LIBCURL_VERSION_NUM >= 0x070c02
+#if LIBCURL_VERSION_NUM >= 0x070a08 /* Available since 7.10.8 */
+ case CURLOPT_FTP_RESPONSE_TIMEOUT:
+ case CURLOPT_IPRESOLVE:
+ case CURLOPT_MAXFILESIZE:
+#endif
+#if LIBCURL_VERSION_NUM >= 0x070b02 /* Available since 7.11.2 */
+ case CURLOPT_TCP_NODELAY:
+#endif
+#if LIBCURL_VERSION_NUM >= 0x070c02 /* Available since 7.12.2 */
case CURLOPT_FTPSSLAUTH:
#endif
-#if LIBCURL_VERSION_NUM > 0x070b00
+#if LIBCURL_VERSION_NUM >= 0x070e01 /* Available since 7.14.1 */
+ case CURLOPT_IGNORE_CONTENT_LENGTH:
+#endif
+#if LIBCURL_VERSION_NUM >= 0x070f00 /* Available since 7.15.0 */
+ case CURLOPT_FTP_SKIP_PASV_IP:
+#endif
+#if LIBCURL_VERSION_NUM >= 0x070f01 /* Available since 7.15.1 */
+ case CURLOPT_FTP_FILEMETHOD:
+#endif
+#if LIBCURL_VERSION_NUM >= 0x070f02 /* Available since 7.15.2 */
+ case CURLOPT_CONNECT_ONLY:
+ case CURLOPT_LOCALPORT:
+ case CURLOPT_LOCALPORTRANGE:
+#endif
+#if LIBCURL_VERSION_NUM >= 0x071000 /* Available since 7.16.0 */
+ case CURLOPT_SSL_SESSIONID_CACHE:
+#endif
+#if LIBCURL_VERSION_NUM >= 0x071001 /* Available since 7.16.1 */
+ case CURLOPT_FTP_SSL_CCC:
+#endif
+#if LIBCURL_VERSION_NUM >= 0x071002 /* Available since 7.16.2 */
+ case CURLOPT_CONNECTTIMEOUT_MS:
+ case CURLOPT_HTTP_CONTENT_DECODING:
+ case CURLOPT_HTTP_TRANSFER_DECODING:
+ case CURLOPT_TIMEOUT_MS:
+#endif
+#if LIBCURL_VERSION_NUM >= 0x071100 /* Available since 7.17.0 */
+ case CURLOPT_USE_SSL:
+#elif LIBCURL_VERSION_NUM >= 0x070b00 /* Available since 7.11.0 */
case CURLOPT_FTP_SSL:
+#endif
+#if LIBCURL_VERSION_NUM >= 0x071100 /* Available since 7.17.0 */
+ case CURLOPT_APPEND:
+ case CURLOPT_DIRLISTONLY:
+ case CURLOPT_NEW_DIRECTORY_PERMS:
+ case CURLOPT_NEW_FILE_PERMS:
+#else
+ case CURLOPT_FTPAPPEND:
+ case CURLOPT_FTPLISTONLY:
#endif
- case CURLOPT_UNRESTRICTED_AUTH:
- case CURLOPT_PORT:
- case CURLOPT_AUTOREFERER:
- case CURLOPT_COOKIESESSION:
-#if LIBCURL_VERSION_NUM > 0x070b01 /* CURLOPT_TCP_NODELAY is available since curl 7.11.2 */
- case CURLOPT_TCP_NODELAY:
+#if LIBCURL_VERSION_NUM >= 0x071200 /* Available since 7.18.0 */
+ case CURLOPT_PROXY_TRANSFER_MODE:
#endif
-#if LIBCURL_VERSION_NUM >= 0x71304
- case CURLOPT_REDIR_PROTOCOLS:
+#if LIBCURL_VERSION_NUM >= 0x071300 /* Available since 7.19.0 */
+ case CURLOPT_ADDRESS_SCOPE:
+ case CURLOPT_SSH_AUTH_TYPES:
+#endif
+#if LIBCURL_VERSION_NUM > 0x071301 /* Available since 7.19.1 */
+ case CURLOPT_CERTINFO:
+#endif
+#if LIBCURL_VERSION_NUM >= 0x071304 /* Available since 7.19.4 */
+ case CURLOPT_NOPROXY:
case CURLOPT_PROTOCOLS:
+ case CURLOPT_REDIR_PROTOCOLS:
+ case CURLOPT_SOCKS5_GSSAPI_NEC:
+ case CURLOPT_TFTP_BLKSIZE:
#endif
-#if LIBCURL_VERSION_NUM > 0x070a07 /* CURLOPT_IPRESOLVE is available since curl 7.10.8 */
- case CURLOPT_IPRESOLVE:
+#if LIBCURL_VERSION_NUM >= 0x071400 /* Available since 7.20.0 */
+ case CURLOPT_FTP_USE_PRET:
+ case CURLOPT_RTSP_CLIENT_CSEQ:
+ case CURLOPT_RTSP_REQUEST:
+ case CURLOPT_RTSP_SERVER_CSEQ:
#endif
-#if LIBCURL_VERSION_NUM >= 0x070f01
- case CURLOPT_FTP_FILEMETHOD:
- case CURLOPT_FTP_SKIP_PASV_IP:
+#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
+ case CURLOPT_WILDCARDMATCH:
#endif
-#if LIBCURL_VERSION_NUM > 0x071301
- case CURLOPT_CERTINFO:
+#if LIBCURL_VERSION_NUM >= 0x071504 /* Available since 7.21.4 */
+ case CURLOPT_TLSAUTH_TYPE:
+#endif
+#if CURLOPT_MUTE != 0
+ case CURLOPT_MUTE:
#endif
convert_to_long_ex(zvalue);
#if LIBCURL_VERSION_NUM >= 0x71304
@@ -1771,57 +2149,77 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu
#endif
error = curl_easy_setopt(ch->cp, option, Z_LVAL_PP(zvalue));
break;
-#if LIBCURL_VERSION_NUM > 0x070f04
- case CURLOPT_MAX_RECV_SPEED_LARGE:
- case CURLOPT_MAX_SEND_SPEED_LARGE:
- convert_to_long_ex(zvalue);
- error = curl_easy_setopt(ch->cp, option, (curl_off_t)Z_LVAL_PP(zvalue));
- break;
-#endif
- case CURLOPT_FOLLOWLOCATION:
- convert_to_long_ex(zvalue);
- if (PG(open_basedir) && *PG(open_basedir)) {
- if (Z_LVAL_PP(zvalue) != 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "CURLOPT_FOLLOWLOCATION cannot be activated when an open_basedir is set");
- RETVAL_FALSE;
- return 1;
- }
- }
- error = curl_easy_setopt(ch->cp, option, Z_LVAL_PP(zvalue));
- break;
-#if LIBCURL_VERSION_NUM > 0x071301
- case CURLOPT_POSTREDIR:
- convert_to_long_ex(zvalue);
- error = curl_easy_setopt(ch->cp, CURLOPT_POSTREDIR, Z_LVAL_PP(zvalue) & CURL_REDIR_POST_ALL);
- break;
-#endif
+
+ /* String options */
+ case CURLOPT_CAINFO:
+ case CURLOPT_CAPATH:
+ case CURLOPT_COOKIE:
+ case CURLOPT_CUSTOMREQUEST:
+ case CURLOPT_EGDSOCKET:
+ case CURLOPT_FTPPORT:
+ case CURLOPT_INTERFACE:
case CURLOPT_PRIVATE:
- case CURLOPT_URL:
case CURLOPT_PROXY:
- case CURLOPT_USERPWD:
case CURLOPT_PROXYUSERPWD:
case CURLOPT_RANGE:
- case CURLOPT_CUSTOMREQUEST:
- case CURLOPT_USERAGENT:
- case CURLOPT_FTPPORT:
- case CURLOPT_COOKIE:
case CURLOPT_REFERER:
- case CURLOPT_INTERFACE:
- case CURLOPT_KRB4LEVEL:
- case CURLOPT_EGDSOCKET:
- case CURLOPT_CAINFO:
- case CURLOPT_CAPATH:
- case CURLOPT_SSL_CIPHER_LIST:
- case CURLOPT_SSLKEY:
- case CURLOPT_SSLKEYTYPE:
- case CURLOPT_SSLKEYPASSWD:
+ case CURLOPT_SSLCERTTYPE:
case CURLOPT_SSLENGINE:
case CURLOPT_SSLENGINE_DEFAULT:
- case CURLOPT_SSLCERTTYPE:
+ case CURLOPT_SSLKEY:
+ case CURLOPT_SSLKEYPASSWD:
+ case CURLOPT_SSLKEYTYPE:
+ case CURLOPT_SSL_CIPHER_LIST:
+ case CURLOPT_URL:
+ case CURLOPT_USERAGENT:
+ case CURLOPT_USERPWD:
+#if LIBCURL_VERSION_NUM >= 0x070d00 /* Available since 7.13.0 */
+ case CURLOPT_FTP_ACCOUNT:
+#endif
+#if LIBCURL_VERSION_NUM >= 0x070e01 /* Available since 7.14.1 */
+ case CURLOPT_COOKIELIST:
+#endif
+#if LIBCURL_VERSION_NUM >= 0x070f05 /* Available since 7.15.5 */
+ case CURLOPT_FTP_ALTERNATIVE_TO_USER:
+#endif
+#if LIBCURL_VERSION_NUM >= 0x071004 /* Available since 7.16.4 */
+ case CURLOPT_KRBLEVEL:
+#else
+ case CURLOPT_KRB4LEVEL:
+#endif
+#if LIBCURL_VERSION_NUM >= 0x071300 /* Available since 7.19.0 */
+ case CURLOPT_SSH_HOST_PUBLIC_KEY_MD5:
+#endif
+#if LIBCURL_VERSION_NUM >= 0x071301 /* Available since 7.19.1 */
+ case CURLOPT_PASSWORD:
+ case CURLOPT_PROXYPASSWORD:
+ case CURLOPT_PROXYUSERNAME:
+ case CURLOPT_USERNAME:
+#endif
+#if LIBCURL_VERSION_NUM >= 0x071304 /* Available since 7.19.4 */
+ case CURLOPT_SOCKS5_GSSAPI_SERVICE:
+#endif
+#if LIBCURL_VERSION_NUM >= 0x071400 /* Available since 7.20.0 */
+ case CURLOPT_MAIL_FROM:
+ case CURLOPT_RTSP_SESSION_ID:
+ case CURLOPT_RTSP_STREAM_URI:
+ case CURLOPT_RTSP_TRANSPORT:
+#endif
+#if LIBCURL_VERSION_NUM >= 0x071504 /* Available since 7.21.4 */
+ case CURLOPT_TLSAUTH_PASSWORD:
+ case CURLOPT_TLSAUTH_USERNAME:
+#endif
+#if LIBCURL_VERSION_NUM >= 0x071506 /* Available since 7.21.6 */
+ case CURLOPT_ACCEPT_ENCODING:
+ case CURLOPT_TRANSFER_ENCODING:
+#else
case CURLOPT_ENCODING:
-#if LIBCURL_VERSION_NUM >= 0x071300
- case CURLOPT_SSH_PUBLIC_KEYFILE:
- case CURLOPT_SSH_PRIVATE_KEYFILE:
+#endif
+#if LIBCURL_VERSION_NUM >= 0x071800 /* Available since 7.24.0 */
+ case CURLOPT_DNS_SERVERS:
+#endif
+#if LIBCURL_VERSION_NUM >= 0x071900 /* Available since 7.25.0 */
+ case CURLOPT_MAIL_AUTH:
#endif
{
#if LIBCURL_VERSION_NUM < 0x071100
@@ -1829,17 +2227,6 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu
#endif
convert_to_string_ex(zvalue);
-#if LIBCURL_VERSION_NUM >= 0x071300
- if (
- option == CURLOPT_SSH_PUBLIC_KEYFILE || option == CURLOPT_SSH_PRIVATE_KEYFILE
-
- ) {
- if (php_check_open_basedir(Z_STRVAL_PP(zvalue) TSRMLS_CC)) {
- RETVAL_FALSE;
- return 1;
- }
- }
-#endif
if (option == CURLOPT_URL) {
if (!php_curl_option_url(ch, Z_STRVAL_PP(zvalue), Z_STRLEN_PP(zvalue) TSRMLS_CC)) {
RETVAL_FALSE;
@@ -1865,10 +2252,12 @@ string_copy:
}
break;
}
+
+ /* Curl file handle options */
case CURLOPT_FILE:
case CURLOPT_INFILE:
- case CURLOPT_WRITEHEADER:
- case CURLOPT_STDERR: {
+ case CURLOPT_STDERR:
+ case CURLOPT_WRITEHEADER: {
FILE *fp = NULL;
int type;
void * what;
@@ -1947,56 +2336,98 @@ string_copy:
error = curl_easy_setopt(ch->cp, option, fp);
break;
}
-
break;
}
- case CURLOPT_RETURNTRANSFER:
- convert_to_long_ex(zvalue);
- if (Z_LVAL_PP(zvalue)) {
- ch->handlers->write->method = PHP_CURL_RETURN;
- } else {
- ch->handlers->write->method = PHP_CURL_STDOUT;
- }
- break;
- case CURLOPT_BINARYTRANSFER:
- convert_to_long_ex(zvalue);
+ /* Curl linked list options */
+ case CURLOPT_HTTP200ALIASES:
+ case CURLOPT_HTTPHEADER:
+ case CURLOPT_POSTQUOTE:
+ case CURLOPT_PREQUOTE:
+ case CURLOPT_QUOTE:
+#if LIBCURL_VERSION_NUM >= 0x071400 /* Available since 7.20.0 */
+ case CURLOPT_MAIL_RCPT:
+#endif
+#if LIBCURL_VERSION_NUM >= 0x071503 /* Available since 7.21.3 */
+ case CURLOPT_RESOLVE:
+#endif
+ {
+ zval **current;
+ HashTable *ph;
+ struct curl_slist *slist = NULL;
- if (Z_LVAL_PP(zvalue)) {
- ch->handlers->write->type = PHP_CURL_BINARY;
- } else {
- ch->handlers->write->type = PHP_CURL_ASCII;
+ ph = HASH_OF(*zvalue);
+ if (!ph) {
+ char *name;
+ switch (option) {
+ case CURLOPT_HTTPHEADER:
+ name = "CURLOPT_HTTPHEADER";
+ break;
+ case CURLOPT_QUOTE:
+ name = "CURLOPT_QUOTE";
+ break;
+ case CURLOPT_HTTP200ALIASES:
+ name = "CURLOPT_HTTP200ALIASES";
+ break;
+ case CURLOPT_POSTQUOTE:
+ name = "CURLOPT_POSTQUOTE";
+ break;
+ case CURLOPT_PREQUOTE:
+ name = "CURLOPT_PREQUOTE";
+ break;
+#if LIBCURL_VERSION_NUM >= 0x071400 /* Available since 7.20.0 */
+ case CURLOPT_MAIL_RCPT:
+ name = "CURLOPT_MAIL_RCPT";
+ break;
+#endif
+#if LIBCURL_VERSION_NUM >= 0x071503 /* Available since 7.21.3 */
+ case CURLOPT_RESOLVE:
+ name = "CURLOPT_RESOLVE";
+ break;
+#endif
+ }
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "You must pass either an object or an array with the %s argument", name);
+ RETVAL_FALSE;
+ return 1;
}
- break;
- case CURLOPT_WRITEFUNCTION:
- if (ch->handlers->write->func_name) {
- zval_ptr_dtor(&ch->handlers->write->func_name);
- ch->handlers->write->fci_cache = empty_fcall_info_cache;
+
+ for (zend_hash_internal_pointer_reset(ph);
+ zend_hash_get_current_data(ph, (void **) &current) == SUCCESS;
+ zend_hash_move_forward(ph)
+ ) {
+ SEPARATE_ZVAL(current);
+ convert_to_string_ex(current);
+
+ slist = curl_slist_append(slist, Z_STRVAL_PP(current));
+ if (!slist) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not build curl_slist");
+ RETVAL_FALSE;
+ return 1;
+ }
}
- zval_add_ref(zvalue);
- ch->handlers->write->func_name = *zvalue;
- ch->handlers->write->method = PHP_CURL_USER;
+ zend_llist_add_element(&ch->to_free->slist, &slist);
+
+ error = curl_easy_setopt(ch->cp, option, slist);
+
break;
- case CURLOPT_READFUNCTION:
- if (ch->handlers->read->func_name) {
- zval_ptr_dtor(&ch->handlers->read->func_name);
- ch->handlers->read->fci_cache = empty_fcall_info_cache;
- }
- zval_add_ref(zvalue);
- ch->handlers->read->func_name = *zvalue;
- ch->handlers->read->method = PHP_CURL_USER;
+ }
+
+ case CURLOPT_BINARYTRANSFER:
+ /* Do nothing, just backward compatibility */
break;
- case CURLOPT_PROGRESSFUNCTION:
- curl_easy_setopt(ch->cp, CURLOPT_PROGRESSFUNCTION, curl_progress);
- curl_easy_setopt(ch->cp, CURLOPT_PROGRESSDATA, ch);
- if (ch->handlers->progress->func_name) {
- zval_ptr_dtor(&ch->handlers->progress->func_name);
- ch->handlers->progress->fci_cache = empty_fcall_info_cache;
+
+ case CURLOPT_FOLLOWLOCATION:
+ convert_to_long_ex(zvalue);
+ if (PG(open_basedir) && *PG(open_basedir)) {
+ if (Z_LVAL_PP(zvalue) != 0) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "CURLOPT_FOLLOWLOCATION cannot be activated when an open_basedir is set");
+ RETVAL_FALSE;
+ return 1;
+ }
}
- zval_add_ref(zvalue);
- ch->handlers->progress->func_name = *zvalue;
- ch->handlers->progress->method = PHP_CURL_USER;
+ error = curl_easy_setopt(ch->cp, option, Z_LVAL_PP(zvalue));
break;
+
case CURLOPT_HEADERFUNCTION:
if (ch->handlers->write_header->func_name) {
zval_ptr_dtor(&ch->handlers->write_header->func_name);
@@ -2006,17 +2437,7 @@ string_copy:
ch->handlers->write_header->func_name = *zvalue;
ch->handlers->write_header->method = PHP_CURL_USER;
break;
-#if CURLOPT_PASSWDFUNCTION != 0
- case CURLOPT_PASSWDFUNCTION:
- if (ch->handlers->passwd) {
- zval_ptr_dtor(&ch->handlers->passwd);
- }
- zval_add_ref(zvalue);
- ch->handlers->passwd = *zvalue;
- error = curl_easy_setopt(ch->cp, CURLOPT_PASSWDFUNCTION, curl_passwd);
- error = curl_easy_setopt(ch->cp, CURLOPT_PASSWDDATA, (void *) ch);
- break;
-#endif
+
case CURLOPT_POSTFIELDS:
if (Z_TYPE_PP(zvalue) == IS_ARRAY || Z_TYPE_PP(zvalue) == IS_OBJECT) {
zval **current;
@@ -2035,11 +2456,11 @@ string_copy:
zend_hash_get_current_data(postfields, (void **) &current) == SUCCESS;
zend_hash_move_forward(postfields)
) {
- char *postval;
- char *string_key = NULL;
- uint string_key_len;
- ulong num_key;
- int numeric_key;
+ char *postval;
+ char *string_key = NULL;
+ uint string_key_len;
+ ulong num_key;
+ int numeric_key;
SEPARATE_ZVAL(current);
convert_to_string_ex(current);
@@ -2129,48 +2550,97 @@ string_copy:
#endif
}
break;
- case CURLOPT_HTTPHEADER:
- case CURLOPT_QUOTE:
- case CURLOPT_HTTP200ALIASES:
- case CURLOPT_POSTQUOTE: {
- zval **current;
- HashTable *ph;
- struct curl_slist *slist = NULL;
- ph = HASH_OF(*zvalue);
- if (!ph) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "You must pass either an object or an array with the CURLOPT_HTTPHEADER, CURLOPT_QUOTE, CURLOPT_HTTP200ALIASES and CURLOPT_POSTQUOTE arguments");
- RETVAL_FALSE;
- return 1;
+ case CURLOPT_PROGRESSFUNCTION:
+ curl_easy_setopt(ch->cp, CURLOPT_PROGRESSFUNCTION, curl_progress);
+ curl_easy_setopt(ch->cp, CURLOPT_PROGRESSDATA, ch);
+ if (ch->handlers->progress == NULL) {
+ ch->handlers->progress = ecalloc(1, sizeof(php_curl_progress));
+ } else if (ch->handlers->progress->func_name) {
+ zval_ptr_dtor(&ch->handlers->progress->func_name);
+ ch->handlers->progress->fci_cache = empty_fcall_info_cache;
}
+ zval_add_ref(zvalue);
+ ch->handlers->progress->func_name = *zvalue;
+ ch->handlers->progress->method = PHP_CURL_USER;
+ break;
- for (zend_hash_internal_pointer_reset(ph);
- zend_hash_get_current_data(ph, (void **) &current) == SUCCESS;
- zend_hash_move_forward(ph)
- ) {
- SEPARATE_ZVAL(current);
- convert_to_string_ex(current);
+ case CURLOPT_READFUNCTION:
+ if (ch->handlers->read->func_name) {
+ zval_ptr_dtor(&ch->handlers->read->func_name);
+ ch->handlers->read->fci_cache = empty_fcall_info_cache;
+ }
+ zval_add_ref(zvalue);
+ ch->handlers->read->func_name = *zvalue;
+ ch->handlers->read->method = PHP_CURL_USER;
+ break;
- slist = curl_slist_append(slist, Z_STRVAL_PP(current));
- if (!slist) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not build curl_slist");
- RETVAL_FALSE;
- return 1;
- }
+ case CURLOPT_RETURNTRANSFER:
+ convert_to_long_ex(zvalue);
+ if (Z_LVAL_PP(zvalue)) {
+ ch->handlers->write->method = PHP_CURL_RETURN;
+ } else {
+ ch->handlers->write->method = PHP_CURL_STDOUT;
}
- zend_llist_add_element(&ch->to_free->slist, &slist);
+ break;
- error = curl_easy_setopt(ch->cp, option, slist);
+ case CURLOPT_WRITEFUNCTION:
+ if (ch->handlers->write->func_name) {
+ zval_ptr_dtor(&ch->handlers->write->func_name);
+ ch->handlers->write->fci_cache = empty_fcall_info_cache;
+ }
+ zval_add_ref(zvalue);
+ ch->handlers->write->func_name = *zvalue;
+ ch->handlers->write->method = PHP_CURL_USER;
+ break;
+#if LIBCURL_VERSION_NUM >= 0x070f05 /* Available since 7.15.5 */
+ case CURLOPT_MAX_RECV_SPEED_LARGE:
+ case CURLOPT_MAX_SEND_SPEED_LARGE:
+ convert_to_long_ex(zvalue);
+ error = curl_easy_setopt(ch->cp, option, (curl_off_t)Z_LVAL_PP(zvalue));
break;
- }
+#endif
+
+#if LIBCURL_VERSION_NUM >= 0x071301 /* Available since 7.19.1 */
+ case CURLOPT_POSTREDIR:
+ convert_to_long_ex(zvalue);
+ error = curl_easy_setopt(ch->cp, CURLOPT_POSTREDIR, Z_LVAL_PP(zvalue) & CURL_REDIR_POST_ALL);
+ break;
+#endif
+
+#if CURLOPT_PASSWDFUNCTION != 0
+ case CURLOPT_PASSWDFUNCTION:
+ if (ch->handlers->passwd) {
+ zval_ptr_dtor(&ch->handlers->passwd);
+ }
+ zval_add_ref(zvalue);
+ ch->handlers->passwd = *zvalue;
+ error = curl_easy_setopt(ch->cp, CURLOPT_PASSWDFUNCTION, curl_passwd);
+ error = curl_easy_setopt(ch->cp, CURLOPT_PASSWDDATA, (void *) ch);
+ break;
+#endif
+
/* the following options deal with files, therefore the open_basedir check
* is required.
*/
+ case CURLOPT_COOKIEFILE:
case CURLOPT_COOKIEJAR:
- case CURLOPT_SSLCERT:
case CURLOPT_RANDOM_FILE:
- case CURLOPT_COOKIEFILE: {
+ case CURLOPT_SSLCERT:
+#if LIBCURL_VERSION_NUM >= 0x070b00 /* Available since 7.11.0 */
+ case CURLOPT_NETRC_FILE:
+#endif
+#if LIBCURL_VERSION_NUM >= 0x071300 /* Available since 7.19.0 */
+ case CURLOPT_CRLFILE:
+ case CURLOPT_ISSUERCERT:
+ case CURLOPT_SSH_PRIVATE_KEYFILE:
+ case CURLOPT_SSH_PUBLIC_KEYFILE:
+#endif
+#if LIBCURL_VERSION_NUM >= 0x071306 /* Available since 7.19.6 */
+ case CURLOPT_SSH_KNOWNHOSTS:
+#endif
+ {
#if LIBCURL_VERSION_NUM < 0x071100
char *copystr = NULL;
#endif
@@ -2192,6 +2662,7 @@ string_copy:
#endif
break;
}
+
case CURLINFO_HEADER_OUT:
convert_to_long_ex(zvalue);
if (Z_LVAL_PP(zvalue) == 1) {
@@ -2204,6 +2675,32 @@ string_copy:
curl_easy_setopt(ch->cp, CURLOPT_VERBOSE, 0);
}
break;
+
+ case CURLOPT_SHARE:
+ {
+ php_curlsh *sh = NULL;
+ ZEND_FETCH_RESOURCE(sh, php_curlsh *, zvalue, -1, le_curl_share_handle_name, le_curl_share_handle);
+ if (sh) {
+ curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
+ }
+ }
+
+#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
+ case CURLOPT_FNMATCH_FUNCTION:
+ curl_easy_setopt(ch->cp, CURLOPT_FNMATCH_FUNCTION, curl_fnmatch);
+ curl_easy_setopt(ch->cp, CURLOPT_FNMATCH_DATA, ch);
+ if (ch->handlers->fnmatch == NULL) {
+ ch->handlers->fnmatch = ecalloc(1, sizeof(php_curl_fnmatch));
+ } else if (ch->handlers->fnmatch->func_name) {
+ zval_ptr_dtor(&ch->handlers->fnmatch->func_name);
+ ch->handlers->fnmatch->fci_cache = empty_fcall_info_cache;
+ }
+ zval_add_ref(zvalue);
+ ch->handlers->fnmatch->func_name = *zvalue;
+ ch->handlers->fnmatch->method = PHP_CURL_USER;
+ break;
+#endif
+
}
SAVE_CURL_ERROR(ch, error);
@@ -2440,18 +2937,25 @@ PHP_FUNCTION(curl_getinfo)
if (curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_TIME, &d_code) == CURLE_OK) {
CAAD("redirect_time", d_code);
}
-#if LIBCURL_VERSION_NUM > 0x071301
+#if LIBCURL_VERSION_NUM >= 0x071202 /* Available since 7.18.2 */
+ if (curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_URL, &s_code) == CURLE_OK) {
+ CAAS("redirect_url", s_code);
+ }
+#endif
+#if LIBCURL_VERSION_NUM >= 0x071300 /* Available since 7.19.0 */
+ if (curl_easy_getinfo(ch->cp, CURLINFO_PRIMARY_IP, &s_code) == CURLE_OK) {
+ CAAS("primary_ip", s_code);
+ }
+#endif
+#if LIBCURL_VERSION_NUM >= 0x071301 /* Available since 7.19.1 */
if (curl_easy_getinfo(ch->cp, CURLINFO_CERTINFO, &ci) == CURLE_OK) {
MAKE_STD_ZVAL(listcode);
array_init(listcode);
create_certinfo(ci, listcode TSRMLS_CC);
CAAZ("certinfo", listcode);
}
- if (curl_easy_getinfo(ch->cp, CURLINFO_PRIMARY_IP, &s_code) == CURLE_OK) {
- CAAS("primary_ip", s_code);
- }
#endif
-#if LIBCURL_VERSION_NUM > 0x071500
+#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
if (curl_easy_getinfo(ch->cp, CURLINFO_PRIMARY_PORT, &l_code) == CURLE_OK) {
CAAL("primary_port", l_code);
}
@@ -2462,88 +2966,18 @@ PHP_FUNCTION(curl_getinfo)
CAAL("local_port", l_code);
}
#endif
-#if LIBCURL_VERSION_NUM >= 0x071202
- if (curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_URL, &s_code) == CURLE_OK) {
- CAAS("redirect_url", s_code);
- }
-#endif
if (ch->header.str_len > 0) {
CAAS("request_header", ch->header.str);
}
} else {
switch (option) {
- /* string variable types */
-#if LIBCURL_VERSION_NUM >= 0x071500
- case CURLINFO_PRIMARY_IP:
-#endif
-#if LIBCURL_VERSION_NUM >= 0x071500
- case CURLINFO_LOCAL_IP:
-#endif
- case CURLINFO_PRIVATE:
- case CURLINFO_EFFECTIVE_URL:
- case CURLINFO_CONTENT_TYPE:
-#if LIBCURL_VERSION_NUM >= 0x071202
- case CURLINFO_REDIRECT_URL:
-#endif
- {
- char *s_code = NULL;
-
- if (curl_easy_getinfo(ch->cp, option, &s_code) == CURLE_OK && s_code) {
- RETURN_STRING(s_code, 1);
- } else {
- RETURN_FALSE;
- }
- break;
- }
- /* Long variable types */
-#if LIBCURL_VERSION_NUM >= 0x071500
- case CURLINFO_PRIMARY_PORT:
- case CURLINFO_LOCAL_PORT:
-#endif
- case CURLINFO_HTTP_CODE:
- case CURLINFO_HEADER_SIZE:
- case CURLINFO_REQUEST_SIZE:
- case CURLINFO_FILETIME:
- case CURLINFO_SSL_VERIFYRESULT:
- case CURLINFO_REDIRECT_COUNT: {
- long code = 0;
-
- if (curl_easy_getinfo(ch->cp, option, &code) == CURLE_OK) {
- RETURN_LONG(code);
- } else {
- RETURN_FALSE;
- }
- break;
- }
- /* Double variable types */
- case CURLINFO_TOTAL_TIME:
- case CURLINFO_NAMELOOKUP_TIME:
- case CURLINFO_CONNECT_TIME:
- case CURLINFO_PRETRANSFER_TIME:
- case CURLINFO_SIZE_UPLOAD:
- case CURLINFO_SIZE_DOWNLOAD:
- case CURLINFO_SPEED_DOWNLOAD:
- case CURLINFO_SPEED_UPLOAD:
- case CURLINFO_CONTENT_LENGTH_DOWNLOAD:
- case CURLINFO_CONTENT_LENGTH_UPLOAD:
- case CURLINFO_STARTTRANSFER_TIME:
- case CURLINFO_REDIRECT_TIME: {
- double code = 0.0;
-
- if (curl_easy_getinfo(ch->cp, option, &code) == CURLE_OK) {
- RETURN_DOUBLE(code);
- } else {
- RETURN_FALSE;
- }
- break;
- }
case CURLINFO_HEADER_OUT:
if (ch->header.str_len > 0) {
RETURN_STRINGL(ch->header.str, ch->header.str_len, 1);
} else {
RETURN_FALSE;
}
-#if LIBCURL_VERSION_NUM > 0x071301
+#if LIBCURL_VERSION_NUM >= 0x071301 /* Available since 7.19.1 */
case CURLINFO_CERTINFO: {
struct curl_certinfo *ci = NULL;
@@ -2557,6 +2991,61 @@ PHP_FUNCTION(curl_getinfo)
break;
}
#endif
+ default: {
+ int type = CURLINFO_TYPEMASK & option;
+ switch (type) {
+ case CURLINFO_STRING:
+ {
+ char *s_code = NULL;
+
+ if (curl_easy_getinfo(ch->cp, option, &s_code) == CURLE_OK && s_code) {
+ RETURN_STRING(s_code, 1);
+ } else {
+ RETURN_FALSE;
+ }
+ break;
+ }
+ case CURLINFO_LONG:
+ {
+ long code = 0;
+
+ if (curl_easy_getinfo(ch->cp, option, &code) == CURLE_OK) {
+ RETURN_LONG(code);
+ } else {
+ RETURN_FALSE;
+ }
+ break;
+ }
+ case CURLINFO_DOUBLE:
+ {
+ double code = 0.0;
+
+ if (curl_easy_getinfo(ch->cp, option, &code) == CURLE_OK) {
+ RETURN_DOUBLE(code);
+ } else {
+ RETURN_FALSE;
+ }
+ break;
+ }
+ case CURLINFO_SLIST:
+ {
+ struct curl_slist *slist;
+ array_init(return_value);
+ if (curl_easy_getinfo(ch->cp, option, &slist) == CURLE_OK) {
+ while (slist) {
+ add_next_index_string(return_value, slist->data, 1);
+ slist = slist->next;
+ }
+ curl_slist_free_all(slist);
+ } else {
+ RETURN_FALSE;
+ }
+ break;
+ }
+ default:
+ RETURN_FALSE;
+ }
+ }
}
}
}
@@ -2657,9 +3146,6 @@ static void _php_curl_close_ex(php_curl *ch TSRMLS_DC)
if (ch->handlers->write_header->func_name) {
zval_ptr_dtor(&ch->handlers->write_header->func_name);
}
- if (ch->handlers->progress->func_name) {
- zval_ptr_dtor(&ch->handlers->progress->func_name);
- }
if (ch->handlers->passwd) {
zval_ptr_dtor(&ch->handlers->passwd);
}
@@ -2683,7 +3169,23 @@ static void _php_curl_close_ex(php_curl *ch TSRMLS_DC)
efree(ch->handlers->write);
efree(ch->handlers->write_header);
efree(ch->handlers->read);
- efree(ch->handlers->progress);
+
+ if (ch->handlers->progress) {
+ if (ch->handlers->progress->func_name) {
+ zval_ptr_dtor(&ch->handlers->progress->func_name);
+ }
+ efree(ch->handlers->progress);
+ }
+
+#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
+ if (ch->handlers->fnmatch) {
+ if (ch->handlers->fnmatch->func_name) {
+ zval_ptr_dtor(&ch->handlers->fnmatch->func_name);
+ }
+ efree(ch->handlers->fnmatch);
+ }
+#endif
+
efree(ch->handlers);
efree(ch);
}
@@ -2698,6 +3200,133 @@ static void _php_curl_close(zend_rsrc_list_entry *rsrc TSRMLS_DC)
}
/* }}} */
+#if LIBCURL_VERSION_NUM >= 0x070c01 /* 7.12.1 */
+/* {{{ _php_curl_reset_handlers()
+ Reset all handlers of a given php_curl */
+static _php_curl_reset_handlers(php_curl *ch)
+{
+ if (ch->handlers->write->stream) {
+ Z_DELREF_P(ch->handlers->write->stream);
+ ch->handlers->write->stream = NULL;
+ }
+ ch->handlers->write->fp = NULL;
+ ch->handlers->write->method = PHP_CURL_STDOUT;
+
+ if (ch->handlers->write_header->stream) {
+ Z_DELREF_P(ch->handlers->write_header->stream);
+ ch->handlers->write_header->stream = NULL;
+ }
+ ch->handlers->write_header->fp = NULL;
+ ch->handlers->write_header->method = PHP_CURL_IGNORE;
+
+ if (ch->handlers->read->stream) {
+ Z_DELREF_P(ch->handlers->read->stream);
+ ch->handlers->read->stream = NULL;
+ }
+ ch->handlers->read->fp = NULL;
+ ch->handlers->read->fd = NULL;
+ ch->handlers->read->method = PHP_CURL_DIRECT;
+
+ if (ch->handlers->std_err) {
+ zval_ptr_dtor(&ch->handlers->std_err);
+ ch->handlers->std_err = NULL;
+ }
+
+ if (ch->handlers->progress) {
+ if (ch->handlers->progress->func_name) {
+ zval_ptr_dtor(&ch->handlers->progress->func_name);
+ }
+ efree(ch->handlers->progress);
+ ch->handlers->progress = NULL;
+ }
+
+#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
+ if (ch->handlers->fnmatch) {
+ if (ch->handlers->fnmatch->func_name) {
+ zval_ptr_dtor(&ch->handlers->fnmatch->func_name);
+ }
+ efree(ch->handlers->fnmatch);
+ ch->handlers->fnmatch = NULL;
+ }
+#endif
+
+}
+/* }}} */
+
+/* {{{ proto void curl_reset(resource ch)
+ Reset all options of a libcurl session handle */
+PHP_FUNCTION(curl_reset)
+{
+ zval *zid;
+ php_curl *ch;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zid) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(ch, php_curl *, &zid, -1, le_curl_name, le_curl);
+
+ if (ch->in_callback) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to reset cURL handle from a callback");
+ return;
+ }
+
+ curl_easy_reset(ch->cp);
+ _php_curl_reset_handlers(ch);
+ _php_curl_set_default_options(ch);
+}
+/* }}} */
+#endif
+
+#if LIBCURL_VERSION_NUM > 0x070f03 /* 7.15.4 */
+/* {{{ proto void curl_escape(resource ch, string str)
+ URL encodes the given string */
+PHP_FUNCTION(curl_escape)
+{
+ char *str = NULL, *res = NULL;
+ int str_len = 0;
+ zval *zid;
+ php_curl *ch;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &zid, &str, &str_len) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(ch, php_curl *, &zid, -1, le_curl_name, le_curl);
+
+ if (res = curl_easy_escape(ch->cp, str, str_len)) {
+ RETVAL_STRING(res, 1);
+ free(res);
+ } else {
+ RETURN_FALSE;
+ }
+}
+/* }}} */
+
+/* {{{ proto void curl_unescape(resource ch, string str)
+ URL decodes the given string */
+PHP_FUNCTION(curl_unescape)
+{
+ char *str = NULL, *out = NULL;
+ int str_len = 0, out_len;
+ zval *zid;
+ php_curl *ch;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &zid, &str, &str_len) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(ch, php_curl *, &zid, -1, le_curl_name, le_curl);
+
+ if (out = curl_easy_unescape(ch->cp, str, str_len, &out_len)) {
+ RETVAL_STRINGL(out, out_len, 1);
+ free(out);
+ } else {
+ RETURN_FALSE;
+ }
+}
+#endif
+/* }}} */
#endif /* HAVE_CURL */
/*
diff --git a/ext/curl/multi.c b/ext/curl/multi.c
index 034aa65..bdf7166 100644
--- a/ext/curl/multi.c
+++ b/ext/curl/multi.c
@@ -125,8 +125,8 @@ void _php_curl_multi_cleanup_list(void *data) /* {{{ */
static int curl_compare_resources( zval *z1, zval **z2 ) /* {{{ */
{
return (Z_TYPE_P( z1 ) == Z_TYPE_PP( z2 ) &&
- Z_TYPE_P( z1 ) == IS_RESOURCE &&
- Z_LVAL_P( z1 ) == Z_LVAL_PP( z2 ) );
+ Z_TYPE_P( z1 ) == IS_RESOURCE &&
+ Z_LVAL_P( z1 ) == Z_LVAL_PP( z2 ) );
}
/* }}} */
diff --git a/ext/curl/package.xml b/ext/curl/package.xml
index 85cb634..c143217 100644
--- a/ext/curl/package.xml
+++ b/ext/curl/package.xml
@@ -39,6 +39,7 @@ package.xml added to support installation using pear installer
<file role="src" name="curl.dsp"/>
<file role="src" name="interface.c"/>
<file role="src" name="multi.c"/>
+ <file role="src" name="share.c"/>
<file role="src" name="streams.c"/>
<file role="src" name="php_curl.h"/>
</filelist>
diff --git a/ext/curl/php_curl.h b/ext/curl/php_curl.h
index 0527545..a9e0f86 100644
--- a/ext/curl/php_curl.h
+++ b/ext/curl/php_curl.h
@@ -41,20 +41,20 @@ extern zend_module_entry curl_module_entry;
#define curl_module_ptr &curl_module_entry
#define CURLOPT_RETURNTRANSFER 19913
-#define CURLOPT_BINARYTRANSFER 19914
+#define CURLOPT_BINARYTRANSFER 19914 /* For Backward compatibility */
#define PHP_CURL_STDOUT 0
#define PHP_CURL_FILE 1
#define PHP_CURL_USER 2
#define PHP_CURL_DIRECT 3
#define PHP_CURL_RETURN 4
-#define PHP_CURL_ASCII 5
-#define PHP_CURL_BINARY 6
#define PHP_CURL_IGNORE 7
extern int le_curl;
#define le_curl_name "cURL handle"
extern int le_curl_multi_handle;
#define le_curl_multi_handle_name "cURL Multi Handle"
+extern int le_curl_share_handle;
+#define le_curl_share_handle_name "cURL Share Handle"
PHP_MINIT_FUNCTION(curl);
PHP_MSHUTDOWN_FUNCTION(curl);
@@ -69,6 +69,15 @@ PHP_FUNCTION(curl_getinfo);
PHP_FUNCTION(curl_error);
PHP_FUNCTION(curl_errno);
PHP_FUNCTION(curl_close);
+
+#if LIBCURL_VERSION_NUM >= 0x070c01 /* 7.12.1 */
+PHP_FUNCTION(curl_reset);
+#endif
+#if LIBCURL_VERSION_NUM > 0x070f03 /* 7.15.4 */
+PHP_FUNCTION(curl_escape);
+PHP_FUNCTION(curl_unescape);
+#endif
+
PHP_FUNCTION(curl_multi_init);
PHP_FUNCTION(curl_multi_add_handle);
PHP_FUNCTION(curl_multi_remove_handle);
@@ -77,7 +86,21 @@ PHP_FUNCTION(curl_multi_exec);
PHP_FUNCTION(curl_multi_getcontent);
PHP_FUNCTION(curl_multi_info_read);
PHP_FUNCTION(curl_multi_close);
+PHP_FUNCTION(curl_share_init);
+PHP_FUNCTION(curl_share_close);
+PHP_FUNCTION(curl_share_setopt);
+
+#if LIBCURL_VERSION_NUM >= 0x070c01 /* 7.12.1 */
+PHP_FUNCTION(curl_reset);
+#endif
+
+#if LIBCURL_VERSION_NUM >= 0x070f04 /* 7.15.4 */
+PHP_FUNCTION(curl_escape);
+PHP_FUNCTION(curl_unescape);
+#endif
+
void _php_curl_multi_close(zend_rsrc_list_entry * TSRMLS_DC);
+void _php_curl_share_close(zend_rsrc_list_entry * TSRMLS_DC);
typedef struct {
zval *func_name;
@@ -85,7 +108,6 @@ typedef struct {
FILE *fp;
smart_str buf;
int method;
- int type;
zval *stream;
} php_curl_write;
@@ -102,7 +124,7 @@ typedef struct {
zval *func_name;
zend_fcall_info_cache fci_cache;
int method;
-} php_curl_progress;
+} php_curl_progress, php_curl_fnmatch;
typedef struct {
php_curl_write *write;
@@ -111,6 +133,9 @@ typedef struct {
zval *passwd;
zval *std_err;
php_curl_progress *progress;
+#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
+ php_curl_fnmatch *fnmatch;
+#endif
} php_curl_handlers;
struct _php_curl_error {
@@ -148,6 +173,10 @@ typedef struct {
zend_llist easyh;
} php_curlm;
+typedef struct {
+ CURLSH *share;
+} php_curlsh;
+
void _php_curl_cleanup_handle(php_curl *);
void _php_curl_multi_cleanup_list(void *data);
int _php_curl_verify_handlers(php_curl *ch, int reporterror TSRMLS_DC);
diff --git a/ext/curl/share.c b/ext/curl/share.c
new file mode 100644
index 0000000..d7cec23
--- /dev/null
+++ b/ext/curl/share.c
@@ -0,0 +1,136 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2012 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Author: Pierrick Charron <pierrick@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
+#define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+
+#if HAVE_CURL
+
+#include "php_curl.h"
+
+#include <curl/curl.h>
+
+/* {{{ proto void curl_share_init()
+ Initialize a share curl handle */
+PHP_FUNCTION(curl_share_init)
+{
+ php_curlsh *sh;
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
+ sh = ecalloc(1, sizeof(php_curlsh));
+
+ sh->share = curl_share_init();
+
+ ZEND_REGISTER_RESOURCE(return_value, sh, le_curl_share_handle);
+}
+/* }}} */
+
+/* {{{ proto void curl_share_close(resource sh)
+ Close a set of cURL handles */
+PHP_FUNCTION(curl_share_close)
+{
+ zval *z_sh;
+ php_curlsh *sh;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &z_sh) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(sh, php_curlsh *, &z_sh, -1, le_curl_share_handle_name, le_curl_share_handle);
+ zend_list_delete(Z_LVAL_P(z_sh));
+}
+/* }}} */
+
+static int _php_curl_share_setopt(php_curlsh *sh, long option, zval **zvalue, zval *return_value TSRMLS_DC) /* {{{ */
+{
+ CURLSHcode error = CURLSHE_OK;
+
+ switch (option) {
+ case CURLSHOPT_SHARE:
+ case CURLSHOPT_UNSHARE:
+ convert_to_long_ex(zvalue);
+ error = curl_share_setopt(sh->share, option, Z_LVAL_PP(zvalue));
+ break;
+ }
+
+ if (error != CURLE_OK) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+/* }}} */
+
+/* {{{ proto bool curl_share_setopt(resource sh, int option, mixed value)
+ Set an option for a cURL transfer */
+PHP_FUNCTION(curl_share_setopt)
+{
+ zval *zid, **zvalue;
+ long options;
+ php_curlsh *sh;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlZ", &zid, &options, &zvalue) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(sh, php_curlsh *, &zid, -1, le_curl_share_handle_name, le_curl_share_handle);
+
+ if (options <= 0) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid curl share configuration option");
+ RETURN_FALSE;
+ }
+
+ if (!_php_curl_share_setopt(sh, options, zvalue, return_value TSRMLS_CC)) {
+ RETURN_TRUE;
+ } else {
+ RETURN_FALSE;
+ }
+}
+/* }}} */
+
+void _php_curl_share_close(zend_rsrc_list_entry *rsrc TSRMLS_DC) /* {{{ */
+{
+ php_curlsh *sh = (php_curlsh *) rsrc->ptr;
+ if (sh) {
+ curl_share_cleanup(sh->share);
+ efree(sh);
+ rsrc->ptr = NULL;
+ }
+}
+/* }}} */
+
+#endif
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/ext/curl/tests/bug54995.phpt b/ext/curl/tests/bug54995.phpt
new file mode 100644
index 0000000..0f3f50f
--- /dev/null
+++ b/ext/curl/tests/bug54995.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Bug #54995 (Missing CURLINFO_RESPONSE_CODE support)
+--SKIPIF--
+<?php
+if (!extension_loaded("curl")) {
+ exit("skip curl extension not loaded");
+}
+if ($curl_version['version_number'] > 0x070a08) {
+ exit("skip: tests works a versions of curl >= 7.10.8");
+}
+if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) {
+ exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
+}
+?>
+--FILE--
+<?php
+
+$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
+$ch = curl_init();
+curl_setopt($ch, CURLOPT_URL, "{$host}/get.php");
+curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+
+var_dump(curl_getinfo($ch, CURLINFO_HTTP_CODE) == curl_getinfo($ch, CURLINFO_RESPONSE_CODE));
+
+curl_exec($ch);
+curl_close($ch);
+
+?>
+--EXPECTF--
+bool(true)
diff --git a/ext/curl/tests/curl_basic_022.phpt b/ext/curl/tests/curl_basic_022.phpt
new file mode 100644
index 0000000..6a611af
--- /dev/null
+++ b/ext/curl/tests/curl_basic_022.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Test curl_getinfo() function with CURLINFO_COOKIELIST parameter
+--SKIPIF--
+<?php if (!extension_loaded("curl")) print "skip";
+$curl_version = curl_version();
+if ($curl_version['version_number'] < 0x070e01) {
+ exit("skip: test works only with curl >= 7.14.1");
+}
+?>
+--FILE--
+<?php
+
+$ch = curl_init();
+curl_setopt($ch, CURLOPT_COOKIELIST, 'Set-Cookie: C1=v1; expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.php.net');
+curl_setopt($ch, CURLOPT_COOKIELIST, 'Set-Cookie: C2=v2; expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.php.net');
+var_dump(curl_getinfo($ch, CURLINFO_COOKIELIST));
+
+?>
+--EXPECT--
+array(2) {
+ [0]=>
+ string(38) ".php.net TRUE / FALSE 2147368447 C1 v1"
+ [1]=>
+ string(38) ".php.net TRUE / FALSE 2147368447 C2 v2"
+}
diff --git a/ext/curl/tests/curl_escape.phpt b/ext/curl/tests/curl_escape.phpt
new file mode 100644
index 0000000..7c90fb9
--- /dev/null
+++ b/ext/curl/tests/curl_escape.phpt
Binary files differ
diff --git a/ext/curl/tests/curl_reset.phpt b/ext/curl/tests/curl_reset.phpt
new file mode 100644
index 0000000..c78a8e0
--- /dev/null
+++ b/ext/curl/tests/curl_reset.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Test curl_reset
+--SKIPIF--
+<?php if (!extension_loaded("curl")) print "skip";
+if (!function_exists("curl_reset")) exit("skip curl_reset doesn't exists (require libcurl >= 7.12.1)");
+?>
+--FILE--
+<?php
+
+$test_file = tempnam(sys_get_temp_dir(), 'php-curl-test');
+$log_file = tempnam(sys_get_temp_dir(), 'php-curl-test');
+
+$fp = fopen($log_file, 'w+');
+fwrite($fp, "test");
+fclose($fp);
+
+$testfile_fp = fopen($test_file, 'w+');
+
+$ch = curl_init();
+curl_setopt($ch, CURLOPT_FILE, $testfile_fp);
+curl_setopt($ch, CURLOPT_URL, 'file://' . $log_file);
+curl_exec($ch);
+
+curl_reset($ch);
+curl_setopt($ch, CURLOPT_URL, 'file://' . $log_file);
+curl_exec($ch);
+
+curl_close($ch);
+
+fclose($testfile_fp);
+
+echo file_get_contents($test_file);
+
+// cleanup
+unlink($test_file);
+unlink($log_file);
+
+?>
+--EXPECT--
+testtest
diff --git a/ext/curl/tests/curl_setopt_basic003.phpt b/ext/curl/tests/curl_setopt_basic003.phpt
index 7849140..aa225c6 100644
--- a/ext/curl/tests/curl_setopt_basic003.phpt
+++ b/ext/curl/tests/curl_setopt_basic003.phpt
@@ -38,6 +38,6 @@ var_dump( $curl_content );
--EXPECTF--
*** curl_setopt() call with CURLOPT_HTTPHEADER
-Warning: curl_setopt(): You must pass either an object or an array with the CURLOPT_HTTPHEADER, CURLOPT_QUOTE, CURLOPT_HTTP200ALIASES and CURLOPT_POSTQUOTE arguments in %s on line %d
+Warning: curl_setopt(): You must pass either an object or an array with the CURLOPT_HTTPHEADER argument in %s on line %d
bool(false)
bool(true)
diff --git a/ext/date/TODO b/ext/date/TODO
index 4b1237c..a585b05 100644
--- a/ext/date/TODO
+++ b/ext/date/TODO
@@ -1,6 +1,5 @@
- Port over my 200 test cases to .phpt format.
- Write an error handler for unexpected characters while parsing dates.
- Cache lookups for timezone information.
-- Optimize parsing @ with a negative timestamp.
- Make sure that date_default_timezone_set() validates the passed timezone
identifier.
diff --git a/ext/date/lib/parse_date.c b/ext/date/lib/parse_date.c
index fbe3307..4020e7b 100644
--- a/ext/date/lib/parse_date.c
+++ b/ext/date/lib/parse_date.c
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.5 on Mon Dec 5 22:02:27 2011 */
+/* Generated by re2c 0.13.5 on Mon Dec 5 22:02:39 2011 */
#line 1 "ext/date/lib/parse_date.re"
/*
+----------------------------------------------------------------------+
diff --git a/ext/date/lib/parse_iso_intervals.c b/ext/date/lib/parse_iso_intervals.c
index 34de3b4..a9a4838 100644
--- a/ext/date/lib/parse_iso_intervals.c
+++ b/ext/date/lib/parse_iso_intervals.c
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.5 on Mon Dec 5 22:02:27 2011 */
+/* Generated by re2c 0.13.5 on Mon Dec 5 22:02:35 2011 */
#line 1 "ext/date/lib/parse_iso_intervals.re"
/*
+----------------------------------------------------------------------+
diff --git a/ext/date/tests/bug60236.phpt b/ext/date/tests/bug60236.phpt
index faa0e16..faa0e16 100644..100755
--- a/ext/date/tests/bug60236.phpt
+++ b/ext/date/tests/bug60236.phpt
diff --git a/ext/ereg/regex.patch b/ext/ereg/regex.patch
new file mode 100644
index 0000000..864e6bb
--- /dev/null
+++ b/ext/ereg/regex.patch
@@ -0,0 +1,72 @@
+diff -u regex.orig/regerror.c regex/regerror.c
+--- regex.orig/regerror.c 2011-08-09 19:49:30.000000000 +0800
++++ regex/regerror.c 2011-08-12 10:45:57.000000000 +0800
+@@ -8,6 +8,7 @@
+ #include "regex.h"
+ #include "utils.h"
+ #include "regerror.ih"
++#include "php.h"
+
+ /*
+ = #define REG_OKAY 0
+@@ -74,17 +75,19 @@
+ char convbuf[50];
+
+ if (errcode == REG_ATOI)
+- s = regatoi(preg, convbuf);
++ s = regatoi(preg, convbuf, sizeof(convbuf));
+ else {
+ for (r = rerrs; r->code >= 0; r++)
+ if (r->code == target)
+ break;
+
+ if (errcode&REG_ITOA) {
+- if (r->code >= 0)
+- (void) strcpy(convbuf, r->name);
+- else
+- sprintf(convbuf, "REG_0x%x", target);
++ if (r->code >= 0) {
++ (void) strncpy(convbuf, r->name, sizeof(convbuf) - 1);
++ convbuf[sizeof(convbuf) - 1] = '\0';
++ } else {
++ snprintf(convbuf, sizeof(convbuf), "REG_0x%x", target);
++ }
+ assert(strlen(convbuf) < sizeof(convbuf));
+ s = convbuf;
+ } else
+@@ -106,12 +109,13 @@
+
+ /*
+ - regatoi - internal routine to implement REG_ATOI
+- == static char *regatoi(const regex_t *preg, char *localbuf);
++ == static char *regatoi(const regex_t *preg, char *localbuf, int bufsize);
+ */
+ static char *
+-regatoi(preg, localbuf)
++regatoi(preg, localbuf, bufsize)
+ const regex_t *preg;
+ char *localbuf;
++int bufsize;
+ {
+ register const struct rerr *r;
+
+@@ -121,6 +125,6 @@
+ if (r->code < 0)
+ return("0");
+
+- sprintf(localbuf, "%d", r->code);
++ snprintf(localbuf, bufsize, "%d", r->code);
+ return(localbuf);
+ }
+diff -u regex.orig/regerror.ih regex/regerror.ih
+--- regex.orig/regerror.ih 2011-08-09 19:49:00.000000000 +0800
++++ regex/regerror.ih 2011-08-09 19:41:07.000000000 +0800
+@@ -4,7 +4,7 @@
+ #endif
+
+ /* === regerror.c === */
+-static char *regatoi(const regex_t *preg, char *localbuf);
++static char *regatoi(const regex_t *preg, char *localbuf, int bufsize);
+
+ #ifdef __cplusplus
+ }
diff --git a/ext/fileinfo/libmagic/print.c b/ext/fileinfo/libmagic/print.c
index 8370f50..89c51b0 100644
--- a/ext/fileinfo/libmagic/print.c
+++ b/ext/fileinfo/libmagic/print.c
@@ -28,7 +28,6 @@
/*
* print.c - debugging printout routines
*/
-
#define _GNU_SOURCE
#include "php.h"
diff --git a/ext/fileinfo/php_fileinfo.h b/ext/fileinfo/php_fileinfo.h
index 330bad8..3f0326b 100644
--- a/ext/fileinfo/php_fileinfo.h
+++ b/ext/fileinfo/php_fileinfo.h
@@ -24,7 +24,7 @@
extern zend_module_entry fileinfo_module_entry;
#define phpext_fileinfo_ptr &fileinfo_module_entry
-#define PHP_FILEINFO_VERSION "1.0.5"
+#define PHP_FILEINFO_VERSION "1.0.5-dev"
#ifdef PHP_WIN32
#define PHP_FILEINFO_API __declspec(dllexport)
diff --git a/ext/interbase/tests/skipif.inc b/ext/interbase/tests/skipif.inc
index 79813f6..8f903a5 100755
--- a/ext/interbase/tests/skipif.inc
+++ b/ext/interbase/tests/skipif.inc
@@ -1,9 +1,8 @@
<?php /* $Id$ */
-if (!extension_loaded("interbase")) print "skip interbase extension not available";
+if (!extension_loaded("interbase")) print "skip interbase extension not available";
require("interbase.inc");
if(!@ibase_connect($test_base)){
die("skip cannot connnect");
}
-
?>
diff --git a/ext/intl/calendar/calendar_class.cpp b/ext/intl/calendar/calendar_class.cpp
new file mode 100644
index 0000000..beb65f7
--- /dev/null
+++ b/ext/intl/calendar/calendar_class.cpp
@@ -0,0 +1,550 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Gustavo Lopes <cataphract@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "../intl_cppshims.h"
+
+#include <unicode/calendar.h>
+#include <unicode/gregocal.h>
+
+extern "C" {
+#define USE_TIMEZONE_POINTER 1
+#include "../timezone/timezone_class.h"
+#define USE_CALENDAR_POINTER 1
+#include "calendar_class.h"
+#include "calendar_methods.h"
+#include "gregoriancalendar_methods.h"
+#include <zend_exceptions.h>
+#include <assert.h>
+}
+
+/* {{{ Global variables */
+zend_class_entry *Calendar_ce_ptr;
+zend_class_entry *GregorianCalendar_ce_ptr;
+zend_object_handlers Calendar_handlers;
+/* }}} */
+
+U_CFUNC void calendar_object_create(zval *object,
+ Calendar *calendar TSRMLS_DC)
+{
+ UClassID classId = calendar->getDynamicClassID();
+ zend_class_entry *ce;
+
+ //if (dynamic_cast<GregorianCalendar*>(calendar) != NULL) {
+ if (classId == GregorianCalendar::getStaticClassID()) {
+ ce = GregorianCalendar_ce_ptr;
+ } else {
+ ce = Calendar_ce_ptr;
+ }
+
+ object_init_ex(object, ce);
+ calendar_object_construct(object, calendar TSRMLS_CC);
+}
+
+U_CFUNC Calendar *calendar_fetch_native_calendar(zval *object TSRMLS_DC)
+{
+ Calendar_object *co = (Calendar_object*)
+ zend_object_store_get_object(object TSRMLS_CC);
+
+ return co->ucal;
+}
+
+U_CFUNC void calendar_object_construct(zval *object,
+ Calendar *calendar TSRMLS_DC)
+{
+ Calendar_object *co;
+
+ CALENDAR_METHOD_FETCH_OBJECT_NO_CHECK; //populate to from object
+ assert(co->ucal == NULL);
+ co->ucal = (Calendar*)calendar;
+}
+
+/* {{{ clone handler for Calendar */
+static zend_object_value Calendar_clone_obj(zval *object TSRMLS_DC)
+{
+ Calendar_object *co_orig,
+ *co_new;
+ zend_object_value ret_val;
+ intl_error_reset(NULL TSRMLS_CC);
+
+ co_orig = (Calendar_object*)zend_object_store_get_object(object TSRMLS_CC);
+ intl_error_reset(INTL_DATA_ERROR_P(co_orig) TSRMLS_CC);
+
+ ret_val = Calendar_ce_ptr->create_object(Z_OBJCE_P(object) TSRMLS_CC);
+ co_new = (Calendar_object*)zend_object_store_get_object_by_handle(ret_val.handle TSRMLS_CC);
+
+ zend_objects_clone_members(&co_new->zo, ret_val,
+ &co_orig->zo, Z_OBJ_HANDLE_P(object) TSRMLS_CC);
+
+ if (co_orig->ucal != NULL) {
+ Calendar *newCalendar;
+
+ newCalendar = co_orig->ucal->clone();
+ if (!newCalendar) {
+ char *err_msg;
+ intl_errors_set_code(CALENDAR_ERROR_P(co_orig),
+ U_MEMORY_ALLOCATION_ERROR TSRMLS_CC);
+ intl_errors_set_custom_msg(CALENDAR_ERROR_P(co_orig),
+ "Could not clone IntlCalendar", 0 TSRMLS_CC);
+ err_msg = intl_error_get_message(CALENDAR_ERROR_P(co_orig) TSRMLS_CC);
+ zend_throw_exception(NULL, err_msg, 0 TSRMLS_CC);
+ efree(err_msg);
+ } else {
+ co_new->ucal = newCalendar;
+ }
+ } else {
+ zend_throw_exception(NULL, "Cannot clone unconstructed IntlCalendar", 0 TSRMLS_CC);
+ }
+
+ return ret_val;
+}
+/* }}} */
+
+static const struct {
+ UCalendarDateFields field;
+ const char *name;
+} debug_info_fields[] = {
+ {UCAL_ERA, "era"},
+ {UCAL_YEAR, "year"},
+ {UCAL_MONTH, "month"},
+ {UCAL_WEEK_OF_YEAR, "week of year"},
+ {UCAL_WEEK_OF_MONTH, "week of month"},
+ {UCAL_DAY_OF_YEAR, "day of year"},
+ {UCAL_DAY_OF_MONTH, "day of month"},
+ {UCAL_DAY_OF_WEEK, "day of week"},
+ {UCAL_DAY_OF_WEEK_IN_MONTH, "day of week in month"},
+ {UCAL_AM_PM, "AM/PM"},
+ {UCAL_HOUR, "hour"},
+ {UCAL_HOUR_OF_DAY, "hour of day"},
+ {UCAL_MINUTE, "minute"},
+ {UCAL_SECOND, "second"},
+ {UCAL_MILLISECOND, "millisecond"},
+ {UCAL_ZONE_OFFSET, "zone offset"},
+ {UCAL_DST_OFFSET, "DST offset"},
+ {UCAL_YEAR_WOY, "year for week of year"},
+ {UCAL_DOW_LOCAL, "localized day of week"},
+ {UCAL_EXTENDED_YEAR, "extended year"},
+ {UCAL_JULIAN_DAY, "julian day"},
+ {UCAL_MILLISECONDS_IN_DAY, "milliseconds in day"},
+ {UCAL_IS_LEAP_MONTH, "is leap month"},
+};
+
+/* {{{ get_debug_info handler for Calendar */
+static HashTable *Calendar_get_debug_info(zval *object, int *is_temp TSRMLS_DC)
+{
+ zval zv = zval_used_for_init,
+ *zfields;
+ Calendar_object *co;
+ const Calendar *cal;
+
+ *is_temp = 1;
+
+ array_init_size(&zv, 8);
+
+ co = (Calendar_object*)zend_object_store_get_object(object TSRMLS_CC);
+ cal = co->ucal;
+
+ if (cal == NULL) {
+ add_assoc_bool_ex(&zv, "valid", sizeof("valid"), 0);
+ return Z_ARRVAL(zv);
+ }
+
+ add_assoc_bool_ex(&zv, "valid", sizeof("valid"), 1);
+
+ add_assoc_string_ex(&zv, "type", sizeof("type"),
+ const_cast<char*>(cal->getType()), 1);
+
+ {
+ zval ztz = zval_used_for_init,
+ *ztz_debug;
+ int is_tmp;
+ HashTable *debug_info;
+
+ timezone_object_construct(&cal->getTimeZone(), &ztz , 0 TSRMLS_CC);
+ debug_info = Z_OBJ_HANDLER(ztz, get_debug_info)(&ztz, &is_tmp TSRMLS_CC);
+ assert(is_tmp == 1);
+
+ ALLOC_INIT_ZVAL(ztz_debug);
+ Z_TYPE_P(ztz_debug) = IS_ARRAY;
+ Z_ARRVAL_P(ztz_debug) = debug_info;
+ add_assoc_zval_ex(&zv, "timeZone", sizeof("timeZone"), ztz_debug);
+ }
+
+ {
+ UErrorCode uec = U_ZERO_ERROR;
+ Locale locale = cal->getLocale(ULOC_VALID_LOCALE, uec);
+ if (U_SUCCESS(uec)) {
+ add_assoc_string_ex(&zv, "locale", sizeof("locale"),
+ const_cast<char*>(locale.getName()), 1);
+ } else {
+ add_assoc_string_ex(&zv, "locale", sizeof("locale"),
+ const_cast<char*>(u_errorName(uec)), 1);
+ }
+ }
+
+ ALLOC_INIT_ZVAL(zfields);
+ array_init_size(zfields, UCAL_FIELD_COUNT);
+
+ for (int i = 0;
+ i < sizeof(debug_info_fields) / sizeof(*debug_info_fields);
+ i++) {
+ UErrorCode uec = U_ZERO_ERROR;
+ const char *name = debug_info_fields[i].name;
+ int32_t res = cal->get(debug_info_fields[i].field, uec);
+ if (U_SUCCESS(uec)) {
+ add_assoc_long(zfields, name, (long)res);
+ } else {
+ add_assoc_string(zfields, name, const_cast<char*>(u_errorName(uec)), 1);
+ }
+ }
+
+ add_assoc_zval_ex(&zv, "fields", sizeof("fields"), zfields);
+
+ return Z_ARRVAL(zv);
+}
+/* }}} */
+
+/* {{{ void calendar_object_init(Calendar_object* to)
+ * Initialize internals of Calendar_object not specific to zend standard objects.
+ */
+static void calendar_object_init(Calendar_object *co TSRMLS_DC)
+{
+ intl_error_init(CALENDAR_ERROR_P(co) TSRMLS_CC);
+ co->ucal = NULL;
+}
+/* }}} */
+
+/* {{{ Calendar_objects_dtor */
+static void Calendar_objects_dtor(void *object,
+ zend_object_handle handle TSRMLS_DC)
+{
+ zend_objects_destroy_object((zend_object*)object, handle TSRMLS_CC);
+}
+/* }}} */
+
+/* {{{ Calendar_objects_free */
+static void Calendar_objects_free(zend_object *object TSRMLS_DC)
+{
+ Calendar_object* co = (Calendar_object*) object;
+
+ if (co->ucal) {
+ delete co->ucal;
+ co->ucal = NULL;
+ }
+ intl_error_reset(CALENDAR_ERROR_P(co) TSRMLS_CC);
+
+ zend_object_std_dtor(&co->zo TSRMLS_CC);
+
+ efree(co);
+}
+/* }}} */
+
+/* {{{ Calendar_object_create */
+static zend_object_value Calendar_object_create(zend_class_entry *ce TSRMLS_DC)
+{
+ zend_object_value retval;
+ Calendar_object* intern;
+
+ intern = (Calendar_object*)ecalloc(1, sizeof(Calendar_object));
+
+ zend_object_std_init(&intern->zo, ce TSRMLS_CC);
+#if PHP_VERSION_ID < 50399
+ zend_hash_copy(intern->zo.properties, &(ce->default_properties),
+ (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
+#else
+ object_properties_init((zend_object*) intern, ce);
+#endif
+ calendar_object_init(intern TSRMLS_CC);
+
+ retval.handle = zend_objects_store_put(
+ intern,
+ Calendar_objects_dtor,
+ (zend_objects_free_object_storage_t) Calendar_objects_free,
+ NULL TSRMLS_CC);
+
+ retval.handlers = &Calendar_handlers;
+
+ return retval;
+}
+/* }}} */
+
+/* {{{ Calendar methods arguments info */
+
+ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_void, 0, 0, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_field, 0, 0, 1)
+ ZEND_ARG_INFO(0, field)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_dow, 0, 0, 1)
+ ZEND_ARG_INFO(0, dayOfWeek)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_other_cal, 0, 0, 1)
+ ZEND_ARG_OBJ_INFO(0, calendar, IntlCalendar, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_date, 0, 0, 1)
+ ZEND_ARG_INFO(0, date)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_date_optional, 0, 0, 0)
+ ZEND_ARG_INFO(0, date)
+ZEND_END_ARG_INFO()
+
+
+ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_createInstance, 0, 0, 0)
+ ZEND_ARG_INFO(0, timeZone)
+ ZEND_ARG_INFO(0, locale)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_get_keyword_values_for_locale, 0, 0, 3)
+ ZEND_ARG_INFO(0, key)
+ ZEND_ARG_INFO(0, locale)
+ ZEND_ARG_INFO(0, commonlyUsed)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_add, 0, 0, 2)
+ ZEND_ARG_INFO(0, field)
+ ZEND_ARG_INFO(0, amount)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_setTimeZone, 0, 0, 1)
+ ZEND_ARG_INFO(0, timeZone)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_set, 0, 0, 2)
+ ZEND_ARG_INFO(0, fieldOrYear)
+ ZEND_ARG_INFO(0, valueOrMonth)
+ ZEND_ARG_INFO(0, dayOfMonth)
+ ZEND_ARG_INFO(0, hour)
+ ZEND_ARG_INFO(0, minute)
+ ZEND_ARG_INFO(0, second)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_roll, 0, 0, 2)
+ ZEND_ARG_INFO(0, field)
+ ZEND_ARG_INFO(0, amountOrUpOrDown)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_clear, 0, 0, 0)
+ ZEND_ARG_INFO(0, field)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_field_difference, 0, 0, 2)
+ ZEND_ARG_INFO(0, when)
+ ZEND_ARG_INFO(0, field)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_get_locale, 0, 0, 1)
+ ZEND_ARG_INFO(0, localeType)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_setLenient, 0, 0, 1)
+ ZEND_ARG_INFO(0, isLenient)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_from_date_time, 0, 0, 1)
+ ZEND_ARG_INFO(0, dateTime)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_wall_time_option, 0, 0, 1)
+ ZEND_ARG_INFO(0, wallTimeOption)
+ZEND_END_ARG_INFO()
+
+/* Gregorian Calendar */
+ZEND_BEGIN_ARG_INFO_EX(ainfo_gregcal___construct, 0, 0, 0)
+ ZEND_ARG_INFO(0, timeZoneOrYear)
+ ZEND_ARG_INFO(0, localeOrMonth)
+ ZEND_ARG_INFO(0, dayOfMonth)
+ ZEND_ARG_INFO(0, hour)
+ ZEND_ARG_INFO(0, minute)
+ ZEND_ARG_INFO(0, second)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(ainfo_gregcal_isLeapYear, 0, 0, 1)
+ ZEND_ARG_INFO(0, year)
+ZEND_END_ARG_INFO()
+
+/* }}} */
+
+/* {{{ Calendar_class_functions
+ * Every 'IntlCalendar' class method has an entry in this table
+ */
+static const zend_function_entry Calendar_class_functions[] = {
+ PHP_ME(IntlCalendar, __construct, ainfo_cal_void, ZEND_ACC_PRIVATE)
+ PHP_ME_MAPPING(createInstance, intlcal_create_instance, ainfo_cal_createInstance, ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
+#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 42
+ PHP_ME_MAPPING(getKeywordValuesForLocale, intlcal_get_keyword_values_for_locale, ainfo_cal_get_keyword_values_for_locale, ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
+#endif
+ PHP_ME_MAPPING(getNow, intlcal_get_now, ainfo_cal_void, ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
+ PHP_ME_MAPPING(getAvailableLocales, intlcal_get_available_locales, ainfo_cal_void, ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
+ PHP_ME_MAPPING(get, intlcal_get, ainfo_cal_field, ZEND_ACC_PUBLIC)
+ PHP_ME_MAPPING(getTime, intlcal_get_time, ainfo_cal_void, ZEND_ACC_PUBLIC)
+ PHP_ME_MAPPING(setTime, intlcal_set_time, ainfo_cal_date, ZEND_ACC_PUBLIC)
+ PHP_ME_MAPPING(add, intlcal_add, ainfo_cal_add, ZEND_ACC_PUBLIC)
+ PHP_ME_MAPPING(setTimeZone, intlcal_set_time_zone, ainfo_cal_setTimeZone, ZEND_ACC_PUBLIC)
+ PHP_ME_MAPPING(after, intlcal_after, ainfo_cal_other_cal, ZEND_ACC_PUBLIC)
+ PHP_ME_MAPPING(before, intlcal_before, ainfo_cal_other_cal, ZEND_ACC_PUBLIC)
+ PHP_ME_MAPPING(set, intlcal_set, ainfo_cal_set, ZEND_ACC_PUBLIC)
+ PHP_ME_MAPPING(roll, intlcal_roll, ainfo_cal_roll, ZEND_ACC_PUBLIC)
+ PHP_ME_MAPPING(clear, intlcal_clear, ainfo_cal_clear, ZEND_ACC_PUBLIC)
+ PHP_ME_MAPPING(fieldDifference, intlcal_field_difference, ainfo_cal_field_difference, ZEND_ACC_PUBLIC)
+ PHP_ME_MAPPING(getActualMaximum, intlcal_get_actual_maximum, ainfo_cal_field, ZEND_ACC_PUBLIC)
+ PHP_ME_MAPPING(getActualMinimum, intlcal_get_actual_minimum, ainfo_cal_field, ZEND_ACC_PUBLIC)
+#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44
+ PHP_ME_MAPPING(getDayOfWeekType, intlcal_get_day_of_week_type, ainfo_cal_dow, ZEND_ACC_PUBLIC)
+#endif
+ PHP_ME_MAPPING(getFirstDayOfWeek, intlcal_get_first_day_of_week, ainfo_cal_void, ZEND_ACC_PUBLIC)
+ PHP_ME_MAPPING(getGreatestMinimum, intlcal_get_greatest_minimum, ainfo_cal_field, ZEND_ACC_PUBLIC)
+ PHP_ME_MAPPING(getLeastMaximum, intlcal_get_least_maximum, ainfo_cal_field, ZEND_ACC_PUBLIC)
+ PHP_ME_MAPPING(getLocale, intlcal_get_locale, ainfo_cal_get_locale, ZEND_ACC_PUBLIC)
+ PHP_ME_MAPPING(getMaximum, intlcal_get_maximum, ainfo_cal_field, ZEND_ACC_PUBLIC)
+ PHP_ME_MAPPING(getMinimalDaysInFirstWeek, intlcal_get_minimal_days_in_first_week, ainfo_cal_void, ZEND_ACC_PUBLIC)
+ PHP_ME_MAPPING(getMinimum, intlcal_get_minimum, ainfo_cal_field, ZEND_ACC_PUBLIC)
+ PHP_ME_MAPPING(getTimeZone, intlcal_get_time_zone, ainfo_cal_void, ZEND_ACC_PUBLIC)
+ PHP_ME_MAPPING(getType, intlcal_get_type, ainfo_cal_void, ZEND_ACC_PUBLIC)
+#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44
+ PHP_ME_MAPPING(getWeekendTransition,intlcal_get_weekend_transition, ainfo_cal_dow, ZEND_ACC_PUBLIC)
+#endif
+ PHP_ME_MAPPING(inDaylightTime, intlcal_in_daylight_time, ainfo_cal_void, ZEND_ACC_PUBLIC)
+ PHP_ME_MAPPING(isEquivalentTo, intlcal_is_equivalent_to, ainfo_cal_other_cal, ZEND_ACC_PUBLIC)
+ PHP_ME_MAPPING(isLenient, intlcal_is_lenient, ainfo_cal_void, ZEND_ACC_PUBLIC)
+ PHP_ME_MAPPING(isSet, intlcal_is_set, ainfo_cal_field, ZEND_ACC_PUBLIC)
+#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44
+ PHP_ME_MAPPING(isWeekend, intlcal_is_weekend, ainfo_cal_date_optional, ZEND_ACC_PUBLIC)
+#endif
+ PHP_ME_MAPPING(setFirstDayOfWeek, intlcal_set_first_day_of_week, ainfo_cal_dow, ZEND_ACC_PUBLIC)
+ PHP_ME_MAPPING(setLenient, intlcal_set_lenient, ainfo_cal_setLenient, ZEND_ACC_PUBLIC)
+ PHP_ME_MAPPING(equals, intlcal_equals, ainfo_cal_other_cal, ZEND_ACC_PUBLIC)
+#if U_ICU_VERSION_MAJOR_NUM >= 49
+ PHP_ME_MAPPING(getRepeatedWallTimeOption,intlcal_get_repeated_wall_time_option,ainfo_cal_void, ZEND_ACC_PUBLIC)
+ PHP_ME_MAPPING(getSkippedWallTimeOption,intlcal_get_skipped_wall_time_option,ainfo_cal_void, ZEND_ACC_PUBLIC)
+ PHP_ME_MAPPING(setRepeatedWallTimeOption,intlcal_set_repeated_wall_time_option,ainfo_cal_wall_time_option,ZEND_ACC_PUBLIC)
+ PHP_ME_MAPPING(setSkippedWallTimeOption,intlcal_set_skipped_wall_time_option,ainfo_cal_wall_time_option,ZEND_ACC_PUBLIC)
+#endif
+ PHP_ME_MAPPING(fromDateTime, intlcal_from_date_time, ainfo_cal_from_date_time, ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
+ PHP_ME_MAPPING(toDateTime, intlcal_to_date_time, ainfo_cal_void, ZEND_ACC_PUBLIC)
+ PHP_ME_MAPPING(getErrorCode, intlcal_get_error_code, ainfo_cal_void, ZEND_ACC_PUBLIC)
+ PHP_ME_MAPPING(getErrorMessage, intlcal_get_error_message, ainfo_cal_void, ZEND_ACC_PUBLIC)
+ PHP_FE_END
+};
+/* }}} */
+
+/* {{{ GregorianCalendar_class_functions
+ */
+static const zend_function_entry GregorianCalendar_class_functions[] = {
+ PHP_ME(IntlGregorianCalendar, __construct, ainfo_gregcal___construct, ZEND_ACC_PUBLIC)
+ PHP_ME_MAPPING(setGregorianChange, intlgregcal_set_gregorian_change, ainfo_cal_date, ZEND_ACC_PUBLIC)
+ PHP_ME_MAPPING(getGregorianChange, intlgregcal_get_gregorian_change, ainfo_cal_void, ZEND_ACC_PUBLIC)
+ PHP_ME_MAPPING(isLeapYear, intlgregcal_is_leap_year, ainfo_gregcal_isLeapYear, ZEND_ACC_PUBLIC)
+ PHP_FE_END
+};
+/* }}} */
+
+
+/* {{{ calendar_register_IntlCalendar_class
+ * Initialize 'IntlCalendar' class
+ */
+void calendar_register_IntlCalendar_class(TSRMLS_D)
+{
+ zend_class_entry ce;
+
+ /* Create and register 'IntlCalendar' class. */
+ INIT_CLASS_ENTRY(ce, "IntlCalendar", Calendar_class_functions);
+ ce.create_object = Calendar_object_create;
+ Calendar_ce_ptr = zend_register_internal_class(&ce TSRMLS_CC);
+ if (!Calendar_ce_ptr) {
+ //can't happen now without bigger problems before
+ php_error_docref0(NULL TSRMLS_CC, E_ERROR,
+ "IntlCalendar: class registration has failed.");
+ return;
+ }
+ memcpy( &Calendar_handlers, zend_get_std_object_handlers(),
+ sizeof Calendar_handlers);
+ Calendar_handlers.clone_obj = Calendar_clone_obj;
+ Calendar_handlers.get_debug_info = Calendar_get_debug_info;
+
+ /* Create and register 'IntlGregorianCalendar' class. */
+ INIT_CLASS_ENTRY(ce, "IntlGregorianCalendar", GregorianCalendar_class_functions);
+ GregorianCalendar_ce_ptr = zend_register_internal_class_ex(&ce,
+ Calendar_ce_ptr, NULL TSRMLS_CC);
+ if (!GregorianCalendar_ce_ptr) {
+ //can't happen know without bigger problems before
+ php_error_docref0(NULL TSRMLS_CC, E_ERROR,
+ "IntlGregorianCalendar: class registration has failed.");
+ return;
+ }
+
+ /* Declare 'IntlCalendar' class constants */
+#define CALENDAR_DECL_LONG_CONST(name, val) \
+ zend_declare_class_constant_long(Calendar_ce_ptr, name, sizeof(name) - 1, \
+ val TSRMLS_CC)
+
+ CALENDAR_DECL_LONG_CONST("FIELD_ERA", UCAL_ERA);
+ CALENDAR_DECL_LONG_CONST("FIELD_YEAR", UCAL_YEAR);
+ CALENDAR_DECL_LONG_CONST("FIELD_MONTH", UCAL_MONTH);
+ CALENDAR_DECL_LONG_CONST("FIELD_WEEK_OF_YEAR", UCAL_WEEK_OF_YEAR);
+ CALENDAR_DECL_LONG_CONST("FIELD_WEEK_OF_MONTH", UCAL_WEEK_OF_MONTH);
+ CALENDAR_DECL_LONG_CONST("FIELD_DATE", UCAL_DATE);
+ CALENDAR_DECL_LONG_CONST("FIELD_DAY_OF_YEAR", UCAL_DAY_OF_YEAR);
+ CALENDAR_DECL_LONG_CONST("FIELD_DAY_OF_WEEK", UCAL_DAY_OF_WEEK);
+ CALENDAR_DECL_LONG_CONST("FIELD_DAY_OF_WEEK_IN_MONTH", UCAL_DAY_OF_WEEK_IN_MONTH);
+ CALENDAR_DECL_LONG_CONST("FIELD_AM_PM", UCAL_AM_PM);
+ CALENDAR_DECL_LONG_CONST("FIELD_HOUR", UCAL_HOUR);
+ CALENDAR_DECL_LONG_CONST("FIELD_HOUR_OF_DAY", UCAL_HOUR_OF_DAY);
+ CALENDAR_DECL_LONG_CONST("FIELD_HOUR", UCAL_HOUR);
+ CALENDAR_DECL_LONG_CONST("FIELD_HOUR_OF_DAY", UCAL_HOUR_OF_DAY);
+ CALENDAR_DECL_LONG_CONST("FIELD_MINUTE", UCAL_MINUTE);
+ CALENDAR_DECL_LONG_CONST("FIELD_SECOND", UCAL_SECOND);
+ CALENDAR_DECL_LONG_CONST("FIELD_MILLISECOND", UCAL_MILLISECOND);
+ CALENDAR_DECL_LONG_CONST("FIELD_ZONE_OFFSET", UCAL_ZONE_OFFSET);
+ CALENDAR_DECL_LONG_CONST("FIELD_DST_OFFSET", UCAL_DST_OFFSET);
+ CALENDAR_DECL_LONG_CONST("FIELD_YEAR_WOY", UCAL_YEAR_WOY);
+ CALENDAR_DECL_LONG_CONST("FIELD_DOW_LOCAL", UCAL_DOW_LOCAL);
+ CALENDAR_DECL_LONG_CONST("FIELD_EXTENDED_YEAR", UCAL_EXTENDED_YEAR);
+ CALENDAR_DECL_LONG_CONST("FIELD_JULIAN_DAY", UCAL_JULIAN_DAY);
+ CALENDAR_DECL_LONG_CONST("FIELD_MILLISECONDS_IN_DAY", UCAL_MILLISECONDS_IN_DAY);
+ CALENDAR_DECL_LONG_CONST("FIELD_IS_LEAP_MONTH", UCAL_IS_LEAP_MONTH);
+ CALENDAR_DECL_LONG_CONST("FIELD_FIELD_COUNT ", UCAL_FIELD_COUNT);
+ CALENDAR_DECL_LONG_CONST("FIELD_DAY_OF_MONTH", UCAL_DAY_OF_MONTH);
+
+ CALENDAR_DECL_LONG_CONST("DOW_SUNDAY", UCAL_SUNDAY);
+ CALENDAR_DECL_LONG_CONST("DOW_MONDAY", UCAL_MONDAY);
+ CALENDAR_DECL_LONG_CONST("DOW_TUESDAY", UCAL_TUESDAY);
+ CALENDAR_DECL_LONG_CONST("DOW_WEDNESDAY", UCAL_WEDNESDAY);
+ CALENDAR_DECL_LONG_CONST("DOW_THURSDAY", UCAL_THURSDAY);
+ CALENDAR_DECL_LONG_CONST("DOW_FRIDAY", UCAL_FRIDAY);
+ CALENDAR_DECL_LONG_CONST("DOW_SATURDAY", UCAL_SATURDAY);
+
+#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44
+ CALENDAR_DECL_LONG_CONST("DOW_TYPE_WEEKDAY", UCAL_WEEKDAY);
+ CALENDAR_DECL_LONG_CONST("DOW_TYPE_WEEKEND", UCAL_WEEKEND);
+ CALENDAR_DECL_LONG_CONST("DOW_TYPE_WEEKEND_OFFSET", UCAL_WEEKEND_ONSET);
+ CALENDAR_DECL_LONG_CONST("DOW_TYPE_WEEKEND_CEASE", UCAL_WEEKEND_CEASE);
+#endif
+
+#if U_ICU_VERSION_MAJOR_NUM >= 49
+ CALENDAR_DECL_LONG_CONST("WALLTIME_FIRST", UCAL_WALLTIME_FIRST);
+ CALENDAR_DECL_LONG_CONST("WALLTIME_LAST", UCAL_WALLTIME_LAST);
+ CALENDAR_DECL_LONG_CONST("WALLTIME_NEXT_VALID", UCAL_WALLTIME_NEXT_VALID);
+#endif
+}
+/* }}} */
diff --git a/ext/intl/calendar/calendar_class.h b/ext/intl/calendar/calendar_class.h
new file mode 100644
index 0000000..140389b
--- /dev/null
+++ b/ext/intl/calendar/calendar_class.h
@@ -0,0 +1,70 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Gustavo Lopes <cataphract@php.net> |
+ +----------------------------------------------------------------------+
+ */
+
+#ifndef CALENDAR_CLASS_H
+#define CALENDAR_CLASS_H
+
+//redefinition of inline in PHP headers causes problems, so include this before
+#include <math.h>
+
+#include <php.h>
+#include "intl_error.h"
+#include "intl_data.h"
+
+#ifndef USE_CALENDAR_POINTER
+typedef void Calendar;
+#endif
+
+typedef struct {
+ zend_object zo;
+
+ // error handling
+ intl_error err;
+
+ // ICU calendar
+ Calendar* ucal;
+} Calendar_object;
+
+#define CALENDAR_ERROR(co) (co)->err
+#define CALENDAR_ERROR_P(co) &(CALENDAR_ERROR(co))
+
+#define CALENDAR_ERROR_CODE(co) INTL_ERROR_CODE(CALENDAR_ERROR(co))
+#define CALENDAR_ERROR_CODE_P(co) &(INTL_ERROR_CODE(CALENDAR_ERROR(co)))
+
+#define CALENDAR_METHOD_INIT_VARS INTL_METHOD_INIT_VARS(Calendar, co)
+#define CALENDAR_METHOD_FETCH_OBJECT_NO_CHECK INTL_METHOD_FETCH_OBJECT(Calendar, co)
+#define CALENDAR_METHOD_FETCH_OBJECT \
+ CALENDAR_METHOD_FETCH_OBJECT_NO_CHECK; \
+ if (co->ucal == NULL) \
+ { \
+ intl_errors_set(&co->err, U_ILLEGAL_ARGUMENT_ERROR, "Found unconstructed IntlCalendar", 0 TSRMLS_CC); \
+ RETURN_FALSE; \
+ }
+
+void calendar_object_create(zval *object, Calendar *calendar TSRMLS_DC);
+
+Calendar *calendar_fetch_native_calendar(zval *object TSRMLS_DC);
+
+void calendar_object_construct(zval *object, Calendar *calendar TSRMLS_DC);
+
+void calendar_register_IntlCalendar_class(TSRMLS_D);
+
+extern zend_class_entry *Calendar_ce_ptr,
+ *GregorianCalendar_ce_ptr;
+
+extern zend_object_handlers Calendar_handlers;
+
+#endif /* #ifndef CALENDAR_CLASS_H */
diff --git a/ext/intl/calendar/calendar_methods.cpp b/ext/intl/calendar/calendar_methods.cpp
new file mode 100644
index 0000000..8562a2d
--- /dev/null
+++ b/ext/intl/calendar/calendar_methods.cpp
@@ -0,0 +1,1325 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Gustavo Lopes <cataphract@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "../intl_cppshims.h"
+
+#include <unicode/locid.h>
+#include <unicode/calendar.h>
+#include <unicode/ustring.h>
+#include "../intl_convertcpp.h"
+extern "C" {
+#define USE_TIMEZONE_POINTER 1
+#include "../timezone/timezone_class.h"
+#define USE_CALENDAR_POINTER 1
+#include "calendar_class.h"
+#include "../intl_convert.h"
+#include "../locale/locale.h"
+#include <zend_exceptions.h>
+#include <zend_interfaces.h>
+#include <ext/date/php_date.h>
+}
+#include "../common/common_enum.h"
+
+U_CFUNC PHP_METHOD(IntlCalendar, __construct)
+{
+ zend_throw_exception( NULL,
+ "An object of this type cannot be created with the new operator",
+ 0 TSRMLS_CC );
+}
+
+U_CFUNC PHP_FUNCTION(intlcal_create_instance)
+{
+ zval **zv_timezone = NULL;
+ const char *locale_str = NULL;
+ int dummy;
+ TimeZone *timeZone;
+ UErrorCode status = U_ZERO_ERROR;
+ intl_error_reset(NULL TSRMLS_CC);
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|Zs!",
+ &zv_timezone, &locale_str, &dummy) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_create_calendar: bad arguments", 0 TSRMLS_CC);
+ RETURN_NULL();
+ }
+
+ timeZone = timezone_process_timezone_argument(zv_timezone, NULL,
+ "intlcal_create_instance" TSRMLS_CC);
+ if (timeZone == NULL) {
+ RETURN_NULL();
+ }
+
+ if (!locale_str) {
+ locale_str = intl_locale_get_default(TSRMLS_C);
+ }
+
+ Calendar *cal = Calendar::createInstance(timeZone,
+ Locale::createFromName(locale_str), status);
+ if (cal == NULL) {
+ delete timeZone;
+ intl_error_set(NULL, status, "Error creating ICU Calendar object", 0 TSRMLS_CC);
+ RETURN_NULL();
+ }
+
+ calendar_object_create(return_value, cal TSRMLS_CC);
+}
+
+#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 42
+class BugStringCharEnumeration : public StringEnumeration
+{
+public:
+ BugStringCharEnumeration(UEnumeration* _uenum) : uenum(_uenum) {}
+
+ ~BugStringCharEnumeration()
+ {
+ uenum_close(uenum);
+ }
+
+ int32_t count(UErrorCode& status) const {
+ return uenum_count(uenum, &status);
+ }
+
+ virtual const UnicodeString* snext(UErrorCode& status)
+ {
+ int32_t length;
+ const UChar* str = uenum_unext(uenum, &length, &status);
+ if (str == 0 || U_FAILURE(status)) {
+ return 0;
+ }
+ return &unistr.setTo(str, length);
+ }
+
+ virtual const char* next(int32_t *resultLength, UErrorCode &status)
+ {
+ int32_t length = -1;
+ const char* str = uenum_next(uenum, &length, &status);
+ if (str == 0 || U_FAILURE(status)) {
+ return 0;
+ }
+ if (resultLength) {
+ //the bug is that uenum_next doesn't set the length
+ *resultLength = (length == -1) ? strlen(str) : length;
+ }
+
+ return str;
+ }
+
+ void reset(UErrorCode& status)
+ {
+ uenum_reset(uenum, &status);
+ }
+
+ virtual UClassID getDynamicClassID() const;
+
+ static UClassID U_EXPORT2 getStaticClassID();
+
+private:
+ UEnumeration *uenum;
+};
+UOBJECT_DEFINE_RTTI_IMPLEMENTATION(BugStringCharEnumeration)
+
+U_CFUNC PHP_FUNCTION(intlcal_get_keyword_values_for_locale)
+{
+ UErrorCode status = U_ZERO_ERROR;
+ char *key,
+ *locale;
+ int key_len,
+ locale_len;
+ zend_bool commonly_used;
+ intl_error_reset(NULL TSRMLS_CC);
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssb",
+ &key, &key_len, &locale, &locale_len, &commonly_used) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_get_keyword_values_for_locale: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ //does not work; see ICU bug 9194
+#if 0
+ StringEnumeration *se = Calendar::getKeywordValuesForLocale(key,
+ Locale::createFromName(locale), (UBool)commonly_used,
+ status);
+ if (se == NULL) {
+ intl_error_set(NULL, status, "intlcal_get_keyword_values_for_locale: "
+ "error calling underlying method", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+#else
+ UEnumeration *uenum = ucal_getKeywordValuesForLocale(
+ key, locale, !!commonly_used, &status);
+ if (U_FAILURE(status)) {
+ uenum_close(uenum);
+ intl_error_set(NULL, status, "intlcal_get_keyword_values_for_locale: "
+ "error calling underlying method", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ StringEnumeration *se = new BugStringCharEnumeration(uenum);
+#endif
+
+ IntlIterator_from_StringEnumeration(se, return_value TSRMLS_CC);
+}
+#endif //ICU 4.2 only
+
+U_CFUNC PHP_FUNCTION(intlcal_get_now)
+{
+ UErrorCode status = U_ZERO_ERROR;
+ intl_error_reset(NULL TSRMLS_CC);
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_get_now: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ RETURN_DOUBLE((double)Calendar::getNow());
+}
+
+U_CFUNC PHP_FUNCTION(intlcal_get_available_locales)
+{
+ intl_error_reset(NULL TSRMLS_CC);
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_get_available_locales: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ int32_t count;
+ const Locale *availLocales = Calendar::getAvailableLocales(count);
+ array_init(return_value);
+ for (int i = 0; i < count; i++) {
+ Locale locale = availLocales[i];
+ add_next_index_string(return_value, locale.getName(), 1);
+ }
+}
+
+static void _php_intlcal_field_uec_ret_in32t_method(
+ int32_t (Calendar::*func)(UCalendarDateFields, UErrorCode&) const,
+ const char *method_name,
+ INTERNAL_FUNCTION_PARAMETERS)
+{
+ long field;
+ char *message;
+ CALENDAR_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
+ "Ol", &object, Calendar_ce_ptr, &field) == FAILURE) {
+ spprintf(&message, 0, "%s: bad arguments", method_name);
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, message, 1 TSRMLS_CC);
+ efree(message);
+ RETURN_FALSE;
+ }
+
+ if (field < 0 || field >= UCAL_FIELD_COUNT) {
+ spprintf(&message, 0, "%s: invalid field", method_name);
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, message, 1 TSRMLS_CC);
+ efree(message);
+ RETURN_FALSE;
+ }
+
+ CALENDAR_METHOD_FETCH_OBJECT;
+
+ int32_t result = (co->ucal->*func)(
+ (UCalendarDateFields)field, CALENDAR_ERROR_CODE(co));
+ INTL_METHOD_CHECK_STATUS(co, "Call to ICU method has failed");
+
+ RETURN_LONG((long)result);
+}
+
+U_CFUNC PHP_FUNCTION(intlcal_get)
+{
+ _php_intlcal_field_uec_ret_in32t_method(&Calendar::get,
+ "intlcal_get", INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
+U_CFUNC PHP_FUNCTION(intlcal_get_time)
+{
+ CALENDAR_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
+ &object, Calendar_ce_ptr) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_get_time: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ CALENDAR_METHOD_FETCH_OBJECT;
+
+ UDate result = co->ucal->getTime(CALENDAR_ERROR_CODE(co));
+ INTL_METHOD_CHECK_STATUS(co,
+ "intlcal_get_time: error calling ICU Calendar::getTime");
+
+ RETURN_DOUBLE((double)result);
+}
+
+U_CFUNC PHP_FUNCTION(intlcal_set_time)
+{
+ double time_arg;
+ CALENDAR_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Od",
+ &object, Calendar_ce_ptr, &time_arg) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_set_time: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ CALENDAR_METHOD_FETCH_OBJECT;
+
+ co->ucal->setTime((UDate)time_arg, CALENDAR_ERROR_CODE(co));
+ INTL_METHOD_CHECK_STATUS(co, "Call to underlying method failed");
+
+ RETURN_TRUE;
+}
+
+U_CFUNC PHP_FUNCTION(intlcal_add)
+{
+ long field,
+ amount;
+ CALENDAR_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
+ "Oll", &object, Calendar_ce_ptr, &field, &amount) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_add: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ if (field < 0 || field >= UCAL_FIELD_COUNT) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_add: invalid field", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+ if (amount < INT32_MIN || amount > INT32_MAX) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_add: amount out of bounds", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ CALENDAR_METHOD_FETCH_OBJECT;
+
+ co->ucal->add((UCalendarDateFields)field, (int32_t)amount, CALENDAR_ERROR_CODE(co));
+ INTL_METHOD_CHECK_STATUS(co, "intlcal_add: Call to underlying method failed");
+
+ RETURN_TRUE;
+}
+
+U_CFUNC PHP_FUNCTION(intlcal_set_time_zone)
+{
+ zval *zv_timezone;
+ TimeZone *timeZone;
+ CALENDAR_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
+ "Oz!", &object, Calendar_ce_ptr, &zv_timezone) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_set_time_zone: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ CALENDAR_METHOD_FETCH_OBJECT;
+
+ if (zv_timezone == NULL) {
+ RETURN_TRUE; /* the method does nothing if passed null */
+ }
+
+ timeZone = timezone_process_timezone_argument(&zv_timezone,
+ CALENDAR_ERROR_P(co), "intlcal_set_time_zone" TSRMLS_CC);
+ if (timeZone == NULL) {
+ RETURN_FALSE;
+ }
+
+ co->ucal->adoptTimeZone(timeZone);
+
+ RETURN_TRUE;
+}
+
+
+static void _php_intlcal_before_after(
+ UBool (Calendar::*func)(const Calendar&, UErrorCode&) const,
+ INTERNAL_FUNCTION_PARAMETERS)
+{
+ zval *when_object;
+ Calendar_object *when_co;
+ CALENDAR_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
+ "OO", &object, Calendar_ce_ptr, &when_object, Calendar_ce_ptr)
+ == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_before/after: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ CALENDAR_METHOD_FETCH_OBJECT;
+
+ when_co = static_cast<Calendar_object*>(
+ zend_object_store_get_object(when_object TSRMLS_CC));
+ if (when_co->ucal == NULL) {
+ intl_errors_set(&co->err, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_before/after: Other IntlCalendar was unconstructed", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ UBool res = (co->ucal->*func)(*when_co->ucal, CALENDAR_ERROR_CODE(co));
+ INTL_METHOD_CHECK_STATUS(co, "intlcal_before/after: Error calling ICU method");
+
+ RETURN_BOOL((int)res);
+}
+
+U_CFUNC PHP_FUNCTION(intlcal_after)
+{
+ _php_intlcal_before_after(&Calendar::after, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
+U_CFUNC PHP_FUNCTION(intlcal_before)
+{
+ _php_intlcal_before_after(&Calendar::before, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
+U_CFUNC PHP_FUNCTION(intlcal_set)
+{
+ long arg1, arg2, arg3, arg4, arg5, arg6;
+ zval **args_a[7] = {0},
+ ***args = &args_a[0];
+ int i;
+ int variant; /* number of args of the set() overload */
+ CALENDAR_METHOD_INIT_VARS;
+
+ /* must come before zpp because zpp would convert the args in the stack to 0 */
+ if (ZEND_NUM_ARGS() > (getThis() ? 6 : 7) ||
+ zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_set: too many arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+ if (!getThis()) {
+ args++;
+ }
+ variant = ZEND_NUM_ARGS() - (getThis() ? 0 : 1);
+ while (variant > 2 && Z_TYPE_PP(args[variant - 1]) == IS_NULL) {
+ variant--;
+ }
+
+ if (variant == 4 ||
+ zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
+ "Oll|llll", &object, Calendar_ce_ptr, &arg1, &arg2, &arg3, &arg4,
+ &arg5, &arg6) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_set: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ for (i = 0; i < variant; i++) {
+ if (Z_LVAL_PP(args[i]) < INT32_MIN || Z_LVAL_PP(args[i]) > INT32_MAX) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_set: at least one of the arguments has an absolute "
+ "value that is too large", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+ }
+
+ if (variant == 2 && (arg1 < 0 || arg1 >= UCAL_FIELD_COUNT)) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_set: invalid field", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ CALENDAR_METHOD_FETCH_OBJECT;
+
+ if (variant == 2) {
+ co->ucal->set((UCalendarDateFields)arg1, (int32_t)arg2);
+ } else if (variant == 3) {
+ co->ucal->set((int32_t)arg1, (int32_t)arg2, (int32_t)arg3);
+ } else if (variant == 5) {
+ co->ucal->set((int32_t)arg1, (int32_t)arg2, (int32_t)arg3, (int32_t)arg4, (int32_t)arg5);
+ } else if (variant == 6) {
+ co->ucal->set((int32_t)arg1, (int32_t)arg2, (int32_t)arg3, (int32_t)arg4, (int32_t)arg5, (int32_t)arg6);
+ }
+
+ RETURN_TRUE;
+}
+
+U_CFUNC PHP_FUNCTION(intlcal_roll)
+{
+ long field,
+ value;
+ zval **args_a[3] = {0},
+ ***args = &args_a[0];
+ zend_bool bool_variant_val = (zend_bool)-1;
+ CALENDAR_METHOD_INIT_VARS;
+
+ if (ZEND_NUM_ARGS() > (getThis() ? 2 :3) ||
+ zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_set: too many arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+ if (!getThis()) {
+ args++;
+ }
+ if (args[1] != NULL && Z_TYPE_PP(args[1]) == IS_BOOL) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
+ "Olb", &object, Calendar_ce_ptr, &field, &bool_variant_val)
+ == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_roll: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+ bool_variant_val = Z_BVAL_PP(args[1]);
+ } else if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
+ "Oll", &object, Calendar_ce_ptr, &field, &value) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_roll: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ if (field < 0 || field >= UCAL_FIELD_COUNT) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_roll: invalid field", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+ if (bool_variant_val == (zend_bool)-1 &&
+ (value < INT32_MIN || value > INT32_MAX)) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_roll: value out of bounds", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ CALENDAR_METHOD_FETCH_OBJECT;
+
+ if (bool_variant_val != (zend_bool)-1) {
+ co->ucal->roll((UCalendarDateFields)field, (UBool)bool_variant_val,
+ CALENDAR_ERROR_CODE(co));
+ } else {
+ co->ucal->roll((UCalendarDateFields)field, (int32_t)value,
+ CALENDAR_ERROR_CODE(co));
+ }
+ INTL_METHOD_CHECK_STATUS(co, "intlcal_roll: Error calling ICU Calendar::roll");
+
+ RETURN_TRUE;
+}
+
+U_CFUNC PHP_FUNCTION(intlcal_clear)
+{
+ zval **args_a[2] = {0},
+ ***args = &args_a[0];
+ long field;
+ int variant;
+ CALENDAR_METHOD_INIT_VARS;
+
+ if (ZEND_NUM_ARGS() > (getThis() ? 1 : 2) ||
+ zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_clear: too many arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+ if (!getThis()) {
+ args++;
+ }
+ if (args[0] == NULL || Z_TYPE_PP(args[0]) == IS_NULL) {
+ zval *dummy; /* we know it's null */
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
+ getThis(), "O|z", &object, Calendar_ce_ptr, &dummy) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_clear: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+ variant = 0;
+ } else if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
+ getThis(), "Ol", &object, Calendar_ce_ptr, &field) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_clear: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ } else if (field < 0 || field >= UCAL_FIELD_COUNT) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_clear: invalid field", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ } else {
+ variant = 1;
+ }
+
+ CALENDAR_METHOD_FETCH_OBJECT;
+
+ if (variant == 0) {
+ co->ucal->clear();
+ } else {
+ co->ucal->clear((UCalendarDateFields)field);
+ }
+
+ RETURN_TRUE;
+}
+
+U_CFUNC PHP_FUNCTION(intlcal_field_difference)
+{
+ long field;
+ double when;
+ CALENDAR_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
+ "Odl", &object, Calendar_ce_ptr, &when, &field) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_field_difference: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ if (field < 0 || field >= UCAL_FIELD_COUNT) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_field_difference: invalid field", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ CALENDAR_METHOD_FETCH_OBJECT;
+
+ int32_t result = co->ucal->fieldDifference((UDate)when,
+ (UCalendarDateFields)field, CALENDAR_ERROR_CODE(co));
+ INTL_METHOD_CHECK_STATUS(co,
+ "intlcal_field_difference: Call to ICU method has failed");
+
+ RETURN_LONG((long)result);
+}
+
+U_CFUNC PHP_FUNCTION(intlcal_get_actual_maximum)
+{
+ _php_intlcal_field_uec_ret_in32t_method(&Calendar::getActualMaximum,
+ "intlcal_get_actual_maximum", INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
+U_CFUNC PHP_FUNCTION(intlcal_get_actual_minimum)
+{
+ _php_intlcal_field_uec_ret_in32t_method(&Calendar::getActualMinimum,
+ "intlcal_get_actual_minimum", INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
+#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44
+U_CFUNC PHP_FUNCTION(intlcal_get_day_of_week_type)
+{
+ long dow;
+ CALENDAR_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
+ "Ol", &object, Calendar_ce_ptr, &dow) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_get_day_of_week_type: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ if (dow < UCAL_SUNDAY || dow > UCAL_SATURDAY) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_get_day_of_week_type: invalid day of week", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ CALENDAR_METHOD_FETCH_OBJECT;
+
+ int32_t result = co->ucal->getDayOfWeekType(
+ (UCalendarDaysOfWeek)dow, CALENDAR_ERROR_CODE(co));
+ INTL_METHOD_CHECK_STATUS(co,
+ "intlcal_get_day_of_week_type: Call to ICU method has failed");
+
+ RETURN_LONG((long)result);
+}
+#endif
+
+U_CFUNC PHP_FUNCTION(intlcal_get_first_day_of_week)
+{
+ CALENDAR_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
+ "O", &object, Calendar_ce_ptr) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_get_first_day_of_week: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ CALENDAR_METHOD_FETCH_OBJECT;
+
+ int32_t result = co->ucal->getFirstDayOfWeek(CALENDAR_ERROR_CODE(co));
+ INTL_METHOD_CHECK_STATUS(co,
+ "intlcal_get_first_day_of_week: Call to ICU method has failed");
+
+ RETURN_LONG((long)result);
+}
+
+static void _php_intlcal_field_ret_in32t_method(
+ int32_t (Calendar::*func)(UCalendarDateFields) const,
+ const char *method_name,
+ INTERNAL_FUNCTION_PARAMETERS)
+{
+ long field;
+ char *message;
+ CALENDAR_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
+ "Ol", &object, Calendar_ce_ptr, &field) == FAILURE) {
+ spprintf(&message, 0, "%s: bad arguments", method_name);
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, message, 1 TSRMLS_CC);
+ efree(message);
+ RETURN_FALSE;
+ }
+
+ if (field < 0 || field >= UCAL_FIELD_COUNT) {
+ spprintf(&message, 0, "%s: invalid field", method_name);
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, message, 1 TSRMLS_CC);
+ efree(message);
+ RETURN_FALSE;
+ }
+
+ CALENDAR_METHOD_FETCH_OBJECT;
+
+ int32_t result = (co->ucal->*func)((UCalendarDateFields)field);
+ INTL_METHOD_CHECK_STATUS(co, "Call to ICU method has failed");
+
+ RETURN_LONG((long)result);
+}
+
+U_CFUNC PHP_FUNCTION(intlcal_get_greatest_minimum)
+{
+ _php_intlcal_field_ret_in32t_method(&Calendar::getGreatestMinimum,
+ "intlcal_get_greatest_minimum", INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
+U_CFUNC PHP_FUNCTION(intlcal_get_least_maximum)
+{
+ _php_intlcal_field_ret_in32t_method(&Calendar::getLeastMaximum,
+ "intlcal_get_least_maximum", INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
+U_CFUNC PHP_FUNCTION(intlcal_get_locale)
+{
+ long locale_type;
+ CALENDAR_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
+ "Ol", &object, Calendar_ce_ptr, &locale_type) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_get_locale: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ if (locale_type != ULOC_ACTUAL_LOCALE && locale_type != ULOC_VALID_LOCALE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_get_locale: invalid locale type", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ CALENDAR_METHOD_FETCH_OBJECT;
+
+ Locale locale = co->ucal->getLocale((ULocDataLocaleType)locale_type,
+ CALENDAR_ERROR_CODE(co));
+ INTL_METHOD_CHECK_STATUS(co,
+ "intlcal_get_locale: Call to ICU method has failed");
+
+ RETURN_STRING(locale.getName(), 1);
+}
+
+U_CFUNC PHP_FUNCTION(intlcal_get_maximum)
+{
+ _php_intlcal_field_ret_in32t_method(&Calendar::getMaximum,
+ "intlcal_get_maximum", INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
+U_CFUNC PHP_FUNCTION(intlcal_get_minimal_days_in_first_week)
+{
+ CALENDAR_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
+ "O", &object, Calendar_ce_ptr) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_get_minimal_days_in_first_week: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ CALENDAR_METHOD_FETCH_OBJECT;
+
+ uint8_t result = co->ucal->getMinimalDaysInFirstWeek();
+ INTL_METHOD_CHECK_STATUS(co,
+ "intlcal_get_first_day_of_week: Call to ICU method has failed");
+
+ RETURN_LONG((long)result);
+}
+
+U_CFUNC PHP_FUNCTION(intlcal_get_minimum)
+{
+ _php_intlcal_field_ret_in32t_method(&Calendar::getMinimum,
+ "intlcal_get_minimum", INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
+U_CFUNC PHP_FUNCTION(intlcal_get_time_zone)
+{
+ CALENDAR_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
+ "O", &object, Calendar_ce_ptr) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_get_time_zone: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ CALENDAR_METHOD_FETCH_OBJECT;
+
+ TimeZone *tz = co->ucal->getTimeZone().clone();
+ if (tz == NULL) {
+ intl_error_set(NULL, U_MEMORY_ALLOCATION_ERROR,
+ "intlcal_get_time_zone: could not clone TimeZone", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ timezone_object_construct(tz, return_value, 1 TSRMLS_CC);
+}
+
+U_CFUNC PHP_FUNCTION(intlcal_get_type)
+{
+ CALENDAR_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
+ "O", &object, Calendar_ce_ptr) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_get_type: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ CALENDAR_METHOD_FETCH_OBJECT;
+
+ RETURN_STRING(co->ucal->getType(), 1);
+}
+
+#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44
+U_CFUNC PHP_FUNCTION(intlcal_get_weekend_transition)
+{
+ long dow;
+ CALENDAR_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
+ "Ol", &object, Calendar_ce_ptr, &dow) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_get_weekend_transition: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ if (dow < UCAL_SUNDAY || dow > UCAL_SATURDAY) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_get_weekend_transition: invalid day of week", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ CALENDAR_METHOD_FETCH_OBJECT;
+
+ int32_t res = co->ucal->getWeekendTransition((UCalendarDaysOfWeek)dow,
+ CALENDAR_ERROR_CODE(co));
+ INTL_METHOD_CHECK_STATUS(co, "intlcal_get_weekend_transition: "
+ "Error calling ICU method");
+
+ RETURN_LONG((long)res);
+}
+#endif
+
+U_CFUNC PHP_FUNCTION(intlcal_in_daylight_time)
+{
+ CALENDAR_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
+ "O", &object, Calendar_ce_ptr) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_in_daylight_time: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ CALENDAR_METHOD_FETCH_OBJECT;
+
+ UBool ret = co->ucal->inDaylightTime(CALENDAR_ERROR_CODE(co));
+ INTL_METHOD_CHECK_STATUS(co, "intlcal_in_daylight_time: "
+ "Error calling ICU method");
+
+ RETURN_BOOL((int)ret);
+}
+
+U_CFUNC PHP_FUNCTION(intlcal_is_equivalent_to)
+{
+ zval *other_object;
+ Calendar_object *other_co;
+ CALENDAR_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
+ "OO", &object, Calendar_ce_ptr, &other_object, Calendar_ce_ptr)
+ == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_is_equivalent_to: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ other_co = (Calendar_object*)zend_object_store_get_object(other_object TSRMLS_CC);
+ if (other_co->ucal == NULL) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "intlcal_is_equivalent_to:"
+ " Other IntlCalendar is unconstructed", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ CALENDAR_METHOD_FETCH_OBJECT;
+
+ RETURN_BOOL((int)co->ucal->isEquivalentTo(*other_co->ucal));
+}
+
+U_CFUNC PHP_FUNCTION(intlcal_is_lenient)
+{
+ CALENDAR_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
+ "O", &object, Calendar_ce_ptr) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_is_lenient: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ CALENDAR_METHOD_FETCH_OBJECT;
+
+ RETURN_BOOL((int)co->ucal->isLenient());
+}
+
+U_CFUNC PHP_FUNCTION(intlcal_is_set)
+{
+ long field;
+ CALENDAR_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
+ "Ol", &object, Calendar_ce_ptr, &field) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_is_set: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ if (field < 0 || field >= UCAL_FIELD_COUNT) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_is_set: invalid field", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ CALENDAR_METHOD_FETCH_OBJECT;
+
+ RETURN_BOOL((int)co->ucal->isSet((UCalendarDateFields)field));
+}
+
+#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44
+U_CFUNC PHP_FUNCTION(intlcal_is_weekend)
+{
+ double date;
+ zval *rawDate = NULL;
+ CALENDAR_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters_ex(ZEND_PARSE_PARAMS_QUIET,
+ ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
+ "O|z!", &object, Calendar_ce_ptr, &rawDate) == FAILURE
+ || (rawDate != NULL &&
+ zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
+ "O|d", &object, Calendar_ce_ptr, &date) == FAILURE)) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_is_weekend: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ CALENDAR_METHOD_FETCH_OBJECT;
+
+ if (rawDate == NULL) {
+ RETURN_BOOL((int)co->ucal->isWeekend());
+ } else {
+ UBool ret = co->ucal->isWeekend((UDate)date, CALENDAR_ERROR_CODE(co));
+ INTL_METHOD_CHECK_STATUS(co, "intlcal_is_weekend: "
+ "Error calling ICU method");
+ RETURN_BOOL((int)ret);
+ }
+}
+#endif
+
+
+U_CFUNC PHP_FUNCTION(intlcal_set_first_day_of_week)
+{
+ long dow;
+ CALENDAR_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
+ "Ol", &object, Calendar_ce_ptr, &dow) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_set_first_day_of_week: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ if (dow < UCAL_SUNDAY || dow > UCAL_SATURDAY) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_set_first_day_of_week: invalid day of week", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ CALENDAR_METHOD_FETCH_OBJECT;
+
+ co->ucal->setFirstDayOfWeek((UCalendarDaysOfWeek)dow);
+
+ RETURN_TRUE;
+}
+
+U_CFUNC PHP_FUNCTION(intlcal_set_lenient)
+{
+ zend_bool is_lenient;
+ CALENDAR_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
+ "Ob", &object, Calendar_ce_ptr, &is_lenient) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_set_lenient: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ CALENDAR_METHOD_FETCH_OBJECT;
+
+ co->ucal->setLenient((UBool) is_lenient);
+
+ RETURN_TRUE;
+}
+
+U_CFUNC PHP_FUNCTION(intlcal_equals)
+{
+ zval *other_object;
+ Calendar_object *other_co;
+ CALENDAR_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
+ "OO", &object, Calendar_ce_ptr, &other_object, Calendar_ce_ptr)
+ == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_equals: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ CALENDAR_METHOD_FETCH_OBJECT;
+ other_co = (Calendar_object *) zend_object_store_get_object(other_object TSRMLS_CC);
+ if (other_co->ucal == NULL) {
+ intl_errors_set(&co->err, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_equals: The second IntlCalendar is unconstructed", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ UBool result = co->ucal->equals(*other_co->ucal, CALENDAR_ERROR_CODE(co));
+ INTL_METHOD_CHECK_STATUS(co, "intlcal_equals: error calling ICU Calendar::equals");
+
+ RETURN_BOOL((int)result);
+}
+
+#if U_ICU_VERSION_MAJOR_NUM >= 49
+
+U_CFUNC PHP_FUNCTION(intlcal_get_repeated_wall_time_option)
+{
+ CALENDAR_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
+ "O", &object, Calendar_ce_ptr) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_get_repeated_wall_time_option: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ CALENDAR_METHOD_FETCH_OBJECT;
+
+ RETURN_LONG(co->ucal->getRepeatedWallTimeOption());
+}
+
+U_CFUNC PHP_FUNCTION(intlcal_get_skipped_wall_time_option)
+{
+ CALENDAR_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
+ "O", &object, Calendar_ce_ptr) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_get_skipped_wall_time_option: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ CALENDAR_METHOD_FETCH_OBJECT;
+
+ RETURN_LONG(co->ucal->getSkippedWallTimeOption());
+}
+
+U_CFUNC PHP_FUNCTION(intlcal_set_repeated_wall_time_option)
+{
+ long option;
+ CALENDAR_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
+ "Ol", &object, Calendar_ce_ptr, &option) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_set_repeated_wall_time_option: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ if (option != UCAL_WALLTIME_FIRST && option != UCAL_WALLTIME_LAST) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_set_repeated_wall_time_option: invalid option", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ CALENDAR_METHOD_FETCH_OBJECT;
+
+ co->ucal->setRepeatedWallTimeOption((UCalendarWallTimeOption)option);
+
+ RETURN_TRUE;
+}
+
+U_CFUNC PHP_FUNCTION(intlcal_set_skipped_wall_time_option)
+{
+ long option;
+ CALENDAR_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
+ "Ol", &object, Calendar_ce_ptr, &option) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_set_skipped_wall_time_option: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ if (option != UCAL_WALLTIME_FIRST && option != UCAL_WALLTIME_LAST
+ && option != UCAL_WALLTIME_NEXT_VALID) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_set_skipped_wall_time_option: invalid option", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ CALENDAR_METHOD_FETCH_OBJECT;
+
+ co->ucal->setSkippedWallTimeOption((UCalendarWallTimeOption)option);
+
+ RETURN_TRUE;
+}
+
+#endif
+
+U_CFUNC PHP_FUNCTION(intlcal_from_date_time)
+{
+ zval **zv_arg,
+ *zv_datetime = NULL,
+ *zv_timestamp = NULL;
+ php_date_obj *datetime;
+ char *locale_str = NULL;
+ int locale_str_len;
+ TimeZone *timeZone;
+ UErrorCode status = U_ZERO_ERROR;
+ Calendar *cal;
+ intl_error_reset(NULL TSRMLS_CC);
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z|s!",
+ &zv_arg, &locale_str, &locale_str_len) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_from_date_time: bad arguments", 0 TSRMLS_CC);
+ RETURN_NULL();
+ }
+
+ if (!(Z_TYPE_PP(zv_arg) == IS_OBJECT && instanceof_function(
+ Z_OBJCE_PP(zv_arg), php_date_get_date_ce() TSRMLS_CC))) {
+ ALLOC_INIT_ZVAL(zv_datetime);
+ object_init_ex(zv_datetime, php_date_get_date_ce());
+ zend_call_method_with_1_params(&zv_datetime, NULL, NULL, "__construct",
+ NULL, *zv_arg);
+ if (EG(exception)) {
+ zend_object_store_ctor_failed(zv_datetime TSRMLS_CC);
+ goto error;
+ }
+ } else {
+ zv_datetime = *zv_arg;
+ }
+
+ datetime = (php_date_obj*)zend_object_store_get_object(zv_datetime TSRMLS_CC);
+ if (!datetime->time) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_from_date_time: DateTime object is unconstructed",
+ 0 TSRMLS_CC);
+ goto error;
+ }
+
+ zend_call_method_with_0_params(&zv_datetime, php_date_get_date_ce(),
+ NULL, "gettimestamp", &zv_timestamp);
+ if (!zv_timestamp || Z_TYPE_P(zv_timestamp) != IS_LONG) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_from_date_time: bad DateTime; call to "
+ "DateTime::getTimestamp() failed", 0 TSRMLS_CC);
+ goto error;
+ }
+
+ if (!datetime->time->is_localtime) {
+ timeZone = TimeZone::getGMT()->clone();
+ } else {
+ timeZone = timezone_convert_datetimezone(datetime->time->zone_type,
+ datetime, 1, NULL, "intlcal_from_date_time" TSRMLS_CC);
+ if (timeZone == NULL) {
+ goto error;
+ }
+ }
+
+ if (!locale_str) {
+ locale_str = const_cast<char*>(intl_locale_get_default(TSRMLS_C));
+ }
+
+ cal = Calendar::createInstance(timeZone,
+ Locale::createFromName(locale_str), status);
+ if (cal == NULL) {
+ delete timeZone;
+ intl_error_set(NULL, status, "intlcal_from_date_time: "
+ "error creating ICU Calendar object", 0 TSRMLS_CC);
+ goto error;
+ }
+ cal->setTime(((UDate)Z_LVAL_P(zv_timestamp)) * 1000., status);
+ if (U_FAILURE(status)) {
+ /* time zone was adopted by cal; should not be deleted here */
+ delete cal;
+ intl_error_set(NULL, status, "intlcal_from_date_time: "
+ "error creating ICU Calendar::setTime()", 0 TSRMLS_CC);
+ goto error;
+ }
+
+ calendar_object_create(return_value, cal TSRMLS_CC);
+
+error:
+ if (zv_datetime != *zv_arg) {
+ zval_ptr_dtor(&zv_datetime);
+ }
+ if (zv_timestamp) {
+ zval_ptr_dtor(&zv_timestamp);
+ }
+}
+
+U_CFUNC PHP_FUNCTION(intlcal_to_date_time)
+{
+ zval *retval = NULL;
+ CALENDAR_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
+ &object, Calendar_ce_ptr) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_to_date_time: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ CALENDAR_METHOD_FETCH_OBJECT;
+
+ /* There are no exported functions in ext/date to this
+ * in a more native fashion */
+ double date = co->ucal->getTime(CALENDAR_ERROR_CODE(co)) / 1000.;
+ int64_t ts;
+ char ts_str[sizeof("@-9223372036854775808")];
+ int ts_str_len;
+ zval ts_zval = zval_used_for_init;
+
+ INTL_METHOD_CHECK_STATUS(co, "Call to ICU method has failed");
+
+ if (date > (double)U_INT64_MAX || date < (double)U_INT64_MIN) {
+ intl_errors_set(CALENDAR_ERROR_P(co), U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_to_date_time: The calendar date is out of the "
+ "range for a 64-bit integer", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ ts = (int64_t)date;
+
+ ts_str_len = slprintf(ts_str, sizeof(ts_str), "@%I64d", ts);
+ ZVAL_STRINGL(&ts_zval, ts_str, ts_str_len, 0);
+
+ /* Now get the time zone */
+ const TimeZone& tz = co->ucal->getTimeZone();
+ zval *timezone_zval = timezone_convert_to_datetimezone(
+ &tz, CALENDAR_ERROR_P(co), "intlcal_to_date_time" TSRMLS_CC);
+ if (timezone_zval == NULL) {
+ RETURN_FALSE;
+ }
+
+ /* resources allocated from now on */
+
+ /* Finally, instantiate object and call constructor */
+ object_init_ex(return_value, php_date_get_date_ce());
+ zend_call_method_with_2_params(&return_value, NULL, NULL, "__construct",
+ NULL, &ts_zval, timezone_zval);
+ if (EG(exception)) {
+ intl_errors_set(CALENDAR_ERROR_P(co), U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_to_date_time: DateTime constructor has thrown exception",
+ 1 TSRMLS_CC);
+ zend_object_store_ctor_failed(return_value TSRMLS_CC);
+ zval_ptr_dtor(&return_value);
+
+ RETVAL_FALSE;
+ goto error;
+ }
+
+ /* due to bug #40743, we have to set the time zone again */
+ zend_call_method_with_1_params(&return_value, NULL, NULL, "settimezone",
+ &retval, timezone_zval);
+ if (retval == NULL || Z_TYPE_P(retval) == IS_BOOL) {
+ intl_errors_set(CALENDAR_ERROR_P(co), U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_to_date_time: call to DateTime::setTimeZone has failed",
+ 1 TSRMLS_CC);
+ zval_ptr_dtor(&return_value);
+ RETVAL_FALSE;
+ goto error;
+ }
+
+error:
+ zval_ptr_dtor(&timezone_zval);
+ if (retval != NULL) {
+ zval_ptr_dtor(&retval);
+ }
+}
+
+U_CFUNC PHP_FUNCTION(intlcal_get_error_code)
+{
+ CALENDAR_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
+ &object, Calendar_ce_ptr) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_get_error_code: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ /* Fetch the object (without resetting its last error code ). */
+ co = (Calendar_object*)zend_object_store_get_object(object TSRMLS_CC);
+ if (co == NULL)
+ RETURN_FALSE;
+
+ RETURN_LONG((long)CALENDAR_ERROR_CODE(co));
+}
+
+U_CFUNC PHP_FUNCTION(intlcal_get_error_message)
+{
+ const char* message = NULL;
+ CALENDAR_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
+ &object, Calendar_ce_ptr) == FAILURE) {
+ intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlcal_get_error_message: bad arguments", 0 TSRMLS_CC );
+ RETURN_FALSE;
+ }
+
+
+ /* Fetch the object (without resetting its last error code ). */
+ co = (Calendar_object*)zend_object_store_get_object(object TSRMLS_CC);
+ if (co == NULL)
+ RETURN_FALSE;
+
+ /* Return last error message. */
+ message = intl_error_get_message(CALENDAR_ERROR_P(co) TSRMLS_CC);
+ RETURN_STRING(message, 0);
+}
diff --git a/ext/intl/calendar/calendar_methods.h b/ext/intl/calendar/calendar_methods.h
new file mode 100644
index 0000000..2be13e4
--- /dev/null
+++ b/ext/intl/calendar/calendar_methods.h
@@ -0,0 +1,112 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Gustavo Lopes <cataphract@netcabo.pt> |
+ +----------------------------------------------------------------------+
+ */
+
+#ifndef CALENDAR_METHODS_H
+#define CALENDAR_METHODS_H
+
+#include <php.h>
+
+PHP_METHOD(IntlCalendar, __construct);
+
+PHP_FUNCTION(intlcal_create_instance);
+
+PHP_FUNCTION(intlcal_get_keyword_values_for_locale);
+
+PHP_FUNCTION(intlcal_get_now);
+
+PHP_FUNCTION(intlcal_get_available_locales);
+
+PHP_FUNCTION(intlcal_get);
+
+PHP_FUNCTION(intlcal_get_time);
+
+PHP_FUNCTION(intlcal_set_time);
+
+PHP_FUNCTION(intlcal_add);
+
+PHP_FUNCTION(intlcal_set_time_zone);
+
+PHP_FUNCTION(intlcal_after);
+
+PHP_FUNCTION(intlcal_before);
+
+PHP_FUNCTION(intlcal_set);
+
+PHP_FUNCTION(intlcal_roll);
+
+PHP_FUNCTION(intlcal_clear);
+
+PHP_FUNCTION(intlcal_field_difference);
+
+PHP_FUNCTION(intlcal_get_actual_maximum);
+
+PHP_FUNCTION(intlcal_get_actual_minimum);
+
+PHP_FUNCTION(intlcal_get_day_of_week_type);
+
+PHP_FUNCTION(intlcal_get_first_day_of_week);
+
+PHP_FUNCTION(intlcal_get_greatest_minimum);
+
+PHP_FUNCTION(intlcal_get_least_maximum);
+
+PHP_FUNCTION(intlcal_get_locale);
+
+PHP_FUNCTION(intlcal_get_maximum);
+
+PHP_FUNCTION(intlcal_get_minimal_days_in_first_week);
+
+PHP_FUNCTION(intlcal_get_minimum);
+
+PHP_FUNCTION(intlcal_get_time_zone);
+
+PHP_FUNCTION(intlcal_get_type);
+
+PHP_FUNCTION(intlcal_get_weekend_transition);
+
+PHP_FUNCTION(intlcal_in_daylight_time);
+
+PHP_FUNCTION(intlcal_is_equivalent_to);
+
+PHP_FUNCTION(intlcal_is_lenient);
+
+PHP_FUNCTION(intlcal_is_set);
+
+PHP_FUNCTION(intlcal_is_weekend);
+
+PHP_FUNCTION(intlcal_set_first_day_of_week);
+
+PHP_FUNCTION(intlcal_set_lenient);
+
+PHP_FUNCTION(intlcal_equals);
+
+PHP_FUNCTION(intlcal_get_repeated_wall_time_option);
+
+PHP_FUNCTION(intlcal_get_skipped_wall_time_option);
+
+PHP_FUNCTION(intlcal_set_repeated_wall_time_option);
+
+PHP_FUNCTION(intlcal_set_skipped_wall_time_option);
+
+PHP_FUNCTION(intlcal_from_date_time);
+
+PHP_FUNCTION(intlcal_to_date_time);
+
+PHP_FUNCTION(intlcal_get_error_code);
+
+PHP_FUNCTION(intlcal_get_error_message);
+
+#endif /* #ifndef CALENDAR_METHODS_H */
diff --git a/ext/intl/calendar/gregoriancalendar_methods.cpp b/ext/intl/calendar/gregoriancalendar_methods.cpp
new file mode 100644
index 0000000..47e8463
--- /dev/null
+++ b/ext/intl/calendar/gregoriancalendar_methods.cpp
@@ -0,0 +1,256 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Gustavo Lopes <cataphract@php.net> |
+ +----------------------------------------------------------------------+
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "../intl_cppshims.h"
+
+#include <unicode/locid.h>
+#include <unicode/calendar.h>
+#include <unicode/gregocal.h>
+extern "C" {
+#define USE_TIMEZONE_POINTER 1
+#include "../timezone/timezone_class.h"
+#define USE_CALENDAR_POINTER 1
+#include "calendar_class.h"
+#include "../locale/locale.h"
+#include <ext/date/php_date.h>
+}
+
+static inline GregorianCalendar *fetch_greg(Calendar_object *co) {
+ return (GregorianCalendar*)co->ucal;
+}
+
+static void _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAMETERS)
+{
+ zval *object = getThis();
+ zval **tz_object = NULL;
+ zval **args_a[6] = {0},
+ ***args = &args_a[0];
+ char *locale = NULL;
+ int locale_len;
+ long largs[6];
+ UErrorCode status = U_ZERO_ERROR;
+ int variant;
+ intl_error_reset(NULL TSRMLS_CC);
+
+ // parameter number validation / variant determination
+ if (ZEND_NUM_ARGS() > 6 ||
+ zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlgregcal_create_instance: too many arguments", 0 TSRMLS_CC);
+ RETURN_NULL();
+ }
+ for (variant = ZEND_NUM_ARGS();
+ variant > 0 && Z_TYPE_PP(args[variant - 1]) == IS_NULL;
+ variant--) {}
+ if (variant == 4) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlgregcal_create_instance: no variant with 4 arguments "
+ "(excluding trailing NULLs)", 0 TSRMLS_CC);
+ RETURN_NULL();
+ }
+
+ // argument parsing
+ if (variant <= 2) {
+ if (zend_parse_parameters(MIN(ZEND_NUM_ARGS(), 2) TSRMLS_CC,
+ "|Z!s!", &tz_object, &locale, &locale_len) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlgregcal_create_instance: bad arguments", 0 TSRMLS_CC);
+ RETURN_NULL();
+ }
+ }
+ if (variant > 2 && zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
+ "lll|lll", &largs[0], &largs[1], &largs[2], &largs[3], &largs[4],
+ &largs[5]) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlgregcal_create_instance: bad arguments", 0 TSRMLS_CC);
+ RETURN_NULL();
+ }
+
+ // instantion of ICU object
+ GregorianCalendar *gcal;
+
+ if (variant <= 2) {
+ // From timezone and locale (0 to 2 arguments)
+ TimeZone *tz = timezone_process_timezone_argument(tz_object, NULL,
+ "intlgregcal_create_instance" TSRMLS_CC);
+ if (tz == NULL) {
+ RETURN_NULL();
+ }
+ if (!locale) {
+ locale = const_cast<char*>(intl_locale_get_default(TSRMLS_C));
+ }
+
+ gcal = new GregorianCalendar(tz, Locale::createFromName(locale),
+ status);
+ if (U_FAILURE(status)) {
+ intl_error_set(NULL, status, "intlgregcal_create_instance: error "
+ "creating ICU GregorianCalendar from time zone and locale", 0 TSRMLS_CC);
+ if (gcal) {
+ delete gcal;
+ }
+ delete tz;
+ RETURN_NULL();
+ }
+ } else {
+ // From date/time (3, 5 or 6 arguments)
+ for (int i = 0; i < variant; i++) {
+ if (largs[i] < INT32_MIN || largs[i] > INT32_MAX) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlgregcal_create_instance: at least one of the arguments"
+ " has an absolute value that is too large", 0 TSRMLS_CC);
+ RETURN_NULL();
+ }
+ }
+
+ if (variant == 3) {
+ gcal = new GregorianCalendar((int32_t)largs[0], (int32_t)largs[1],
+ (int32_t)largs[2], status);
+ } else if (variant == 5) {
+ gcal = new GregorianCalendar((int32_t)largs[0], (int32_t)largs[1],
+ (int32_t)largs[2], (int32_t)largs[3], (int32_t)largs[4], status);
+ } else if (variant == 6) {
+ gcal = new GregorianCalendar((int32_t)largs[0], (int32_t)largs[1],
+ (int32_t)largs[2], (int32_t)largs[3], (int32_t)largs[4], (int32_t)largs[5],
+ status);
+ }
+ if (U_FAILURE(status)) {
+ intl_error_set(NULL, status, "intlgregcal_create_instance: error "
+ "creating ICU GregorianCalendar from date", 0 TSRMLS_CC);
+ if (gcal) {
+ delete gcal;
+ }
+ RETURN_NULL();
+ }
+
+ timelib_tzinfo *tzinfo = get_timezone_info(TSRMLS_C);
+#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 42
+ UnicodeString tzstr = UnicodeString::fromUTF8(StringPiece(tzinfo->name));
+#else
+ UnicodeString tzstr = UnicodeString(tzinfo->name,
+ strlen(tzinfo->name), US_INV);
+#endif
+ if (tzstr.isBogus()) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlgregcal_create_instance: could not create UTF-8 string "
+ "from PHP's default timezone name (see date_default_timezone_get())",
+ 0 TSRMLS_CC);
+ delete gcal;
+ RETURN_NULL();
+ }
+
+ TimeZone *tz = TimeZone::createTimeZone(tzstr);
+ gcal->adoptTimeZone(tz);
+ }
+
+ Calendar_object *co = (Calendar_object*)zend_object_store_get_object(
+ return_value TSRMLS_CC);
+ co->ucal = gcal;
+}
+
+U_CFUNC PHP_FUNCTION(intlgregcal_create_instance)
+{
+ zval orig;
+ intl_error_reset(NULL TSRMLS_CC);
+
+ object_init_ex(return_value, GregorianCalendar_ce_ptr);
+ orig = *return_value;
+
+ _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+
+ if (Z_TYPE_P(return_value) == IS_NULL) {
+ zend_object_store_ctor_failed(&orig TSRMLS_CC);
+ zval_dtor(&orig);
+ }
+}
+
+U_CFUNC PHP_METHOD(IntlGregorianCalendar, __construct)
+{
+ zval orig_this = *getThis();
+ intl_error_reset(NULL TSRMLS_CC);
+
+ return_value = getThis();
+ //changes this to IS_NULL (without first destroying) if there's an error
+ _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+
+ if (Z_TYPE_P(return_value) == IS_NULL) {
+ zend_object_store_ctor_failed(&orig_this TSRMLS_CC);
+ zval_dtor(&orig_this);
+ }
+}
+
+U_CFUNC PHP_FUNCTION(intlgregcal_set_gregorian_change)
+{
+ double date;
+ CALENDAR_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
+ "Od", &object, GregorianCalendar_ce_ptr, &date) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlgregcal_set_gregorian_change: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ CALENDAR_METHOD_FETCH_OBJECT;
+
+ fetch_greg(co)->setGregorianChange(date, CALENDAR_ERROR_CODE(co));
+ INTL_METHOD_CHECK_STATUS(co, "intlgregcal_set_gregorian_change: error "
+ "calling ICU method");
+
+ RETURN_TRUE;
+}
+
+U_CFUNC PHP_FUNCTION(intlgregcal_get_gregorian_change)
+{
+ CALENDAR_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
+ "O", &object, GregorianCalendar_ce_ptr) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlgregcal_get_gregorian_change: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ CALENDAR_METHOD_FETCH_OBJECT;
+
+ RETURN_DOUBLE((double)fetch_greg(co)->getGregorianChange());
+}
+
+U_CFUNC PHP_FUNCTION(intlgregcal_is_leap_year)
+{
+ long year;
+ CALENDAR_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
+ "Ol", &object, GregorianCalendar_ce_ptr, &year) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlgregcal_is_leap_year: bad arguments", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ if (year < INT32_MIN || year > INT32_MAX) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "intlgregcal_is_leap_year: year out of bounds", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ CALENDAR_METHOD_FETCH_OBJECT;
+
+ RETURN_BOOL((int)fetch_greg(co)->isLeapYear((int32_t)year));
+}
diff --git a/ext/intl/calendar/gregoriancalendar_methods.h b/ext/intl/calendar/gregoriancalendar_methods.h
new file mode 100644
index 0000000..f911752
--- /dev/null
+++ b/ext/intl/calendar/gregoriancalendar_methods.h
@@ -0,0 +1,32 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Gustavo Lopes <cataphract@php.net> |
+ +----------------------------------------------------------------------+
+ */
+
+#ifndef GREORIANCALENDAR_METHODS_H
+#define GREORIANCALENDAR_METHODS_H
+
+#include <php.h>
+
+PHP_FUNCTION(intlgregcal_create_instance);
+
+PHP_METHOD(IntlGregorianCalendar, __construct);
+
+PHP_FUNCTION(intlgregcal_set_gregorian_change);
+
+PHP_FUNCTION(intlgregcal_get_gregorian_change);
+
+PHP_FUNCTION(intlgregcal_is_leap_year);
+
+#endif
diff --git a/ext/intl/collator/collator_sort.c b/ext/intl/collator/collator_sort.c
index 0785111..04a24f0 100755
--- a/ext/intl/collator/collator_sort.c
+++ b/ext/intl/collator/collator_sort.c
@@ -78,6 +78,7 @@ static int collator_regular_compare_function(zval *result, zval *op1, zval *op2
intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ),
"Object not initialized", 0 TSRMLS_CC );
php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Object not initialized");
+
}
/* Compare the strings using ICU. */
diff --git a/ext/intl/common/common_enum.cpp b/ext/intl/common/common_enum.cpp
new file mode 100644
index 0000000..a0e3460
--- /dev/null
+++ b/ext/intl/common/common_enum.cpp
@@ -0,0 +1,385 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Gustavo Lopes <cataphract@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "../intl_cppshims.h"
+
+// Fix build on Windows/old versions of ICU
+#include <stdio.h>
+
+#include "common_enum.h"
+
+extern "C" {
+#include "intl_error.h"
+#include "intl_data.h"
+#include <zend_interfaces.h>
+#include <zend_exceptions.h>
+}
+
+static zend_class_entry *IntlIterator_ce_ptr;
+static zend_object_handlers IntlIterator_handlers;
+
+typedef struct {
+ zend_object zo;
+ intl_error err;
+ zend_object_iterator *iterator;
+} IntlIterator_object;
+
+#define INTLITERATOR_ERROR(ii) (ii)->err
+#define INTLITERATOR_ERROR_P(ii) &(INTLITERATOR_ERROR(ii))
+
+#define INTLITERATOR_ERROR_CODE(ii) INTL_ERROR_CODE(INTLITERATOR_ERROR(ii))
+#define INTLITERATOR_ERROR_CODE_P(ii) &(INTL_ERROR_CODE(INTLITERATOR_ERROR(ii)))
+
+#define INTLITERATOR_METHOD_INIT_VARS INTL_METHOD_INIT_VARS(IntlIterator, ii)
+#define INTLITERATOR_METHOD_FETCH_OBJECT_NO_CHECK INTL_METHOD_FETCH_OBJECT(IntlIterator, ii)
+#define INTLITERATOR_METHOD_FETCH_OBJECT\
+ object = getThis(); \
+ INTLITERATOR_METHOD_FETCH_OBJECT_NO_CHECK; \
+ if (ii->iterator == NULL) { \
+ intl_errors_set(&ii->err, U_ILLEGAL_ARGUMENT_ERROR, "Found unconstructed IntlIterator", 0 TSRMLS_CC); \
+ RETURN_FALSE; \
+ }
+
+typedef struct {
+ zend_object_iterator zoi;
+ zval *current;
+ zval *wrapping_obj;
+ void (*destroy_free_it)(zend_object_iterator *iterator TSRMLS_DC);
+} zoi_with_current;
+
+static void zoi_with_current_dtor(zend_object_iterator *iter TSRMLS_DC)
+{
+ zoi_with_current *zoiwc = (zoi_with_current*)iter;
+
+ if (zoiwc->wrapping_obj) {
+ /* we have to copy the pointer because zoiwc->wrapping_obj may be
+ * changed midway the execution of zval_ptr_dtor() */
+ zval *zwo = zoiwc->wrapping_obj;
+
+ /* object is still here, we can rely on it to call this again and
+ * destroy this object */
+ zval_ptr_dtor(&zwo);
+ } else {
+ /* Object not here anymore (we've been called by the object free handler)
+ * Note that the iterator wrapper objects (that also depend on this
+ * structure) call this function earlier, in the destruction phase, which
+ * precedes the object free phase. Therefore there's no risk on this
+ * function being called by the iterator wrapper destructor function and
+ * not finding the memory of this iterator allocated anymore. */
+ iter->funcs->invalidate_current(iter TSRMLS_CC);
+ zoiwc->destroy_free_it(iter TSRMLS_CC);
+ efree(iter);
+ }
+}
+
+static int zoi_with_current_valid(zend_object_iterator *iter TSRMLS_DC)
+{
+ return ((zoi_with_current*)iter)->current != NULL ? SUCCESS : FAILURE;
+}
+
+static void zoi_with_current_get_current_data(zend_object_iterator *iter, zval ***data TSRMLS_DC)
+{
+ *data = &((zoi_with_current*)iter)->current;
+}
+
+static void zoi_with_current_invalidate_current(zend_object_iterator *iter TSRMLS_DC)
+{
+ zoi_with_current *zoi_iter = (zoi_with_current*)iter;
+ if (zoi_iter->current) {
+ zval_ptr_dtor(&zoi_iter->current);
+ zoi_iter->current = NULL; //valid would return FAILURE now
+ }
+}
+
+static void string_enum_current_move_forward(zend_object_iterator *iter TSRMLS_DC)
+{
+ zoi_with_current *zoi_iter = (zoi_with_current*)iter;
+ INTLITERATOR_METHOD_INIT_VARS;
+
+ iter->funcs->invalidate_current(iter TSRMLS_CC);
+
+ object = zoi_iter->wrapping_obj;
+ INTLITERATOR_METHOD_FETCH_OBJECT_NO_CHECK;
+
+ int32_t result_length;
+ const char *result = ((StringEnumeration*)iter->data)->next(
+ &result_length, INTLITERATOR_ERROR_CODE(ii));
+
+ intl_error_set_code(NULL, INTLITERATOR_ERROR_CODE(ii) TSRMLS_CC);
+ if (U_FAILURE(INTLITERATOR_ERROR_CODE(ii))) {
+ intl_errors_set_custom_msg(INTL_DATA_ERROR_P(ii),
+ "Error fetching next iteration element", 0 TSRMLS_CC);
+ } else if (result) {
+ MAKE_STD_ZVAL(zoi_iter->current);
+ ZVAL_STRINGL(zoi_iter->current, result, result_length, 1);
+ } //else we've reached the end of the enum, nothing more is required
+}
+
+static void string_enum_rewind(zend_object_iterator *iter TSRMLS_DC)
+{
+ zoi_with_current *zoi_iter = (zoi_with_current*)iter;
+ INTLITERATOR_METHOD_INIT_VARS;
+
+ if (zoi_iter->current) {
+ iter->funcs->invalidate_current(iter TSRMLS_CC);
+ }
+
+ object = zoi_iter->wrapping_obj;
+ INTLITERATOR_METHOD_FETCH_OBJECT_NO_CHECK;
+
+ ((StringEnumeration*)iter->data)->reset(INTLITERATOR_ERROR_CODE(ii));
+
+ intl_error_set_code(NULL, INTLITERATOR_ERROR_CODE(ii) TSRMLS_CC);
+ if (U_FAILURE(INTLITERATOR_ERROR_CODE(ii))) {
+ intl_errors_set_custom_msg(INTL_DATA_ERROR_P(ii),
+ "Error resetting enumeration", 0 TSRMLS_CC);
+ } else {
+ iter->funcs->move_forward(iter TSRMLS_CC);
+ }
+}
+
+static void string_enum_destroy_free_it(zend_object_iterator *iter TSRMLS_DC)
+{
+ delete (StringEnumeration*)iter->data;
+}
+
+static zend_object_iterator_funcs string_enum_object_iterator_funcs = {
+ zoi_with_current_dtor,
+ zoi_with_current_valid,
+ zoi_with_current_get_current_data,
+ NULL,
+ string_enum_current_move_forward,
+ string_enum_rewind,
+ zoi_with_current_invalidate_current
+};
+
+U_CFUNC void IntlIterator_from_StringEnumeration(StringEnumeration *se, zval *object TSRMLS_DC)
+{
+ IntlIterator_object *ii;
+ object_init_ex(object, IntlIterator_ce_ptr);
+ ii = (IntlIterator_object*)zend_object_store_get_object(object TSRMLS_CC);
+ ii->iterator = (zend_object_iterator*)emalloc(sizeof(zoi_with_current));
+ ii->iterator->data = (void*)se;
+ ii->iterator->funcs = &string_enum_object_iterator_funcs;
+ ii->iterator->index = 0;
+ ((zoi_with_current*)ii->iterator)->destroy_free_it = string_enum_destroy_free_it;
+ ((zoi_with_current*)ii->iterator)->wrapping_obj = object;
+ ((zoi_with_current*)ii->iterator)->current = NULL;
+}
+
+static void IntlIterator_objects_free(zend_object *object TSRMLS_DC)
+{
+ IntlIterator_object *ii = (IntlIterator_object*) object;
+
+ if (ii->iterator) {
+ zval **wrapping_objp = &((zoi_with_current*)ii->iterator)->wrapping_obj;
+ *wrapping_objp = NULL;
+ ii->iterator->funcs->dtor(ii->iterator TSRMLS_CC);
+ }
+ intl_error_reset(INTLITERATOR_ERROR_P(ii) TSRMLS_CC);
+
+ zend_object_std_dtor(&ii->zo TSRMLS_CC);
+
+ efree(ii);
+}
+
+static zend_object_iterator *IntlIterator_get_iterator(
+ zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC)
+{
+ if (by_ref) {
+ zend_throw_exception(NULL,
+ "Iteration by reference is not supported", 0 TSRMLS_CC);
+ return NULL;
+ }
+
+ IntlIterator_object *ii = (IntlIterator_object*)
+ zend_object_store_get_object(object TSRMLS_CC);
+
+ if (ii->iterator == NULL) {
+ zend_throw_exception(NULL,
+ "The IntlIterator is not properly constructed", 0 TSRMLS_CC);
+ return NULL;
+ }
+
+ zval_add_ref(&object);
+
+ return ii->iterator;
+}
+
+static zend_object_value IntlIterator_object_create(zend_class_entry *ce TSRMLS_DC)
+{
+ zend_object_value retval;
+ IntlIterator_object *intern;
+
+ intern = (IntlIterator_object*)ecalloc(1, sizeof(IntlIterator_object));
+
+ zend_object_std_init(&intern->zo, ce TSRMLS_CC);
+#if PHP_VERSION_ID < 50399
+ zend_hash_copy(intern->zo.properties, &(ce->default_properties),
+ (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
+#else
+ object_properties_init((zend_object*) intern, ce);
+#endif
+ intl_error_init(INTLITERATOR_ERROR_P(intern) TSRMLS_CC);
+ intern->iterator = NULL;
+
+ retval.handle = zend_objects_store_put(
+ intern,
+ (zend_objects_store_dtor_t)zend_objects_destroy_object,
+ (zend_objects_free_object_storage_t)IntlIterator_objects_free,
+ NULL TSRMLS_CC);
+
+ retval.handlers = &IntlIterator_handlers;
+
+ return retval;
+}
+
+static PHP_METHOD(IntlIterator, current)
+{
+ zval **data;
+ INTLITERATOR_METHOD_INIT_VARS;
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "IntlIterator::current: bad arguments", 0 TSRMLS_CC);
+ return;
+ }
+
+ INTLITERATOR_METHOD_FETCH_OBJECT;
+ ii->iterator->funcs->get_current_data(ii->iterator, &data TSRMLS_CC);
+ if (data && *data) {
+ RETURN_ZVAL(*data, 1, 0);
+ }
+}
+
+static PHP_METHOD(IntlIterator, key)
+{
+ INTLITERATOR_METHOD_INIT_VARS;
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "IntlIterator::key: bad arguments", 0 TSRMLS_CC);
+ return;
+ }
+
+ INTLITERATOR_METHOD_FETCH_OBJECT;
+
+ if (ii->iterator->funcs->get_current_key) {
+ char *str_key;
+ uint str_key_len;
+ ulong int_key;
+
+ switch (ii->iterator->funcs->get_current_key(
+ ii->iterator, &str_key, &str_key_len, &int_key TSRMLS_CC)) {
+ case HASH_KEY_IS_LONG:
+ RETURN_LONG(int_key);
+ break;
+ case HASH_KEY_IS_STRING:
+ RETURN_STRINGL(str_key, str_key_len-1, 0);
+ break;
+ }
+ } else {
+ RETURN_LONG(ii->iterator->index);
+ }
+}
+
+static PHP_METHOD(IntlIterator, next)
+{
+ INTLITERATOR_METHOD_INIT_VARS;
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "IntlIterator::next: bad arguments", 0 TSRMLS_CC);
+ return;
+ }
+
+ INTLITERATOR_METHOD_FETCH_OBJECT;
+ ii->iterator->funcs->move_forward(ii->iterator TSRMLS_CC);
+ /* foreach also advances the index after the last iteration,
+ * so I see no problem in incrementing the index here unconditionally */
+ ii->iterator->index++;
+}
+
+static PHP_METHOD(IntlIterator, rewind)
+{
+ INTLITERATOR_METHOD_INIT_VARS;
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "IntlIterator::rewind: bad arguments", 0 TSRMLS_CC);
+ return;
+ }
+
+ INTLITERATOR_METHOD_FETCH_OBJECT;
+ if (ii->iterator->funcs->rewind) {
+ ii->iterator->funcs->rewind(ii->iterator TSRMLS_CC);
+ } else {
+ intl_error_set(NULL, U_UNSUPPORTED_ERROR,
+ "IntlIterator::rewind: rewind not supported", 0 TSRMLS_CC);
+ }
+}
+
+static PHP_METHOD(IntlIterator, valid)
+{
+ INTLITERATOR_METHOD_INIT_VARS;
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "IntlIterator::valid: bad arguments", 0 TSRMLS_CC);
+ return;
+ }
+
+ INTLITERATOR_METHOD_FETCH_OBJECT;
+ RETURN_BOOL(ii->iterator->funcs->valid(ii->iterator TSRMLS_CC) == SUCCESS);
+}
+
+ZEND_BEGIN_ARG_INFO_EX(ainfo_se_void, 0, 0, 0)
+ZEND_END_ARG_INFO()
+
+static zend_function_entry IntlIterator_class_functions[] = {
+ PHP_ME(IntlIterator, current, ainfo_se_void, ZEND_ACC_PUBLIC)
+ PHP_ME(IntlIterator, key, ainfo_se_void, ZEND_ACC_PUBLIC)
+ PHP_ME(IntlIterator, next, ainfo_se_void, ZEND_ACC_PUBLIC)
+ PHP_ME(IntlIterator, rewind, ainfo_se_void, ZEND_ACC_PUBLIC)
+ PHP_ME(IntlIterator, valid, ainfo_se_void, ZEND_ACC_PUBLIC)
+ PHP_FE_END
+};
+
+
+/* {{{ intl_register_IntlIterator_class
+ * Initialize 'IntlIterator' class
+ */
+U_CFUNC void intl_register_IntlIterator_class(TSRMLS_D)
+{
+ zend_class_entry ce;
+
+ /* Create and register 'IntlIterator' class. */
+ INIT_CLASS_ENTRY(ce, "IntlIterator", IntlIterator_class_functions);
+ ce.create_object = IntlIterator_object_create;
+ IntlIterator_ce_ptr = zend_register_internal_class(&ce TSRMLS_CC);
+ IntlIterator_ce_ptr->get_iterator = IntlIterator_get_iterator;
+ zend_class_implements(IntlIterator_ce_ptr TSRMLS_CC, 1,
+ zend_ce_iterator);
+
+ memcpy(&IntlIterator_handlers, zend_get_std_object_handlers(),
+ sizeof IntlIterator_handlers);
+ IntlIterator_handlers.clone_obj = NULL;
+
+}
diff --git a/ext/intl/common/common_enum.h b/ext/intl/common/common_enum.h
new file mode 100644
index 0000000..f3c8bfc
--- /dev/null
+++ b/ext/intl/common/common_enum.h
@@ -0,0 +1,38 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Vadim Savchuk <vsavchuk@productengine.com> |
+ | Dmitry Lakhtyuk <dlakhtyuk@productengine.com> |
+ +----------------------------------------------------------------------+
+ */
+
+#ifndef INTL_COMMON_ENUM_H
+#define INTL_COMMON_ENUM_H
+
+#include <unicode/umachine.h>
+#ifdef __cplusplus
+#include <unicode/strenum.h>
+extern "C" {
+#include <math.h>
+#endif
+#include <php.h>
+#ifdef __cplusplus
+}
+#endif
+
+#ifdef __cplusplus
+U_CFUNC void IntlIterator_from_StringEnumeration(StringEnumeration *se, zval *object TSRMLS_DC);
+#endif
+
+U_CFUNC void intl_register_IntlIterator_class(TSRMLS_D);
+
+#endif // INTL_COMMON_ENUM_H
diff --git a/ext/intl/config.m4 b/ext/intl/config.m4
index 0477c7f..431deeb 100755
--- a/ext/intl/config.m4
+++ b/ext/intl/config.m4
@@ -20,6 +20,7 @@ if test "$PHP_INTL" != "no"; then
PHP_NEW_EXTENSION(intl, php_intl.c \
intl_error.c \
intl_convert.c \
+ intl_convertcpp.cpp \
collator/collator.c \
collator/collator_class.c \
collator/collator_sort.c \
@@ -31,6 +32,7 @@ if test "$PHP_INTL" != "no"; then
collator/collator_is_numeric.c \
collator/collator_error.c \
common/common_error.c \
+ common/common_enum.cpp \
formatter/formatter.c \
formatter/formatter_main.c \
formatter/formatter_class.c \
@@ -50,6 +52,9 @@ if test "$PHP_INTL" != "no"; then
dateformat/dateformat_data.c \
dateformat/dateformat_format.c \
dateformat/dateformat_parse.c \
+ dateformat/dateformat_create.cpp \
+ dateformat/dateformat_attrcpp.cpp \
+ dateformat/dateformat_helpers.cpp \
msgformat/msgformat.c \
msgformat/msgformat_attr.c \
msgformat/msgformat_class.c \
@@ -65,8 +70,13 @@ if test "$PHP_INTL" != "no"; then
transliterator/transliterator.c \
transliterator/transliterator_class.c \
transliterator/transliterator_methods.c \
+ timezone/timezone_class.cpp \
+ timezone/timezone_methods.cpp \
+ calendar/calendar_class.cpp \
+ calendar/calendar_methods.cpp \
+ calendar/gregoriancalendar_methods.cpp \
idn/idn.c \
- $icu_spoof_src, $ext_shared,,$ICU_INCS)
+ $icu_spoof_src, $ext_shared,,$ICU_INCS -Wno-write-strings)
PHP_ADD_BUILD_DIR($ext_builddir/collator)
PHP_ADD_BUILD_DIR($ext_builddir/common)
PHP_ADD_BUILD_DIR($ext_builddir/formatter)
@@ -77,6 +87,8 @@ if test "$PHP_INTL" != "no"; then
PHP_ADD_BUILD_DIR($ext_builddir/grapheme)
PHP_ADD_BUILD_DIR($ext_builddir/resourcebundle)
PHP_ADD_BUILD_DIR($ext_builddir/transliterator)
+ PHP_ADD_BUILD_DIR($ext_builddir/timezone)
+ PHP_ADD_BUILD_DIR($ext_builddir/calendar)
PHP_ADD_BUILD_DIR($ext_builddir/idn)
PHP_ADD_BUILD_DIR($ext_builddir/spoofchecker)
fi
diff --git a/ext/intl/config.w32 b/ext/intl/config.w32
index 437fedb..735749a 100755
--- a/ext/intl/config.w32
+++ b/ext/intl/config.w32
@@ -7,7 +7,7 @@ if (PHP_INTL != "no") {
if (CHECK_LIB("icuuc.lib", "intl", PHP_INTL) &&
CHECK_HEADER_ADD_INCLUDE("unicode/utf.h", "CFLAGS_INTL")) {
// always build as shared - zend_strtod.c/ICU type conflict
- EXTENSION("intl", "php_intl.c intl_convert.c intl_error.c ", true,
+ EXTENSION("intl", "php_intl.c intl_convert.c intl_convertcpp.cpp intl_error.c ", true,
"/I \"" + configure_module_dirname + "\"");
ADD_SOURCES(configure_module_dirname + "/collator", "\
collator.c \
@@ -23,6 +23,7 @@ if (PHP_INTL != "no") {
", "intl");
ADD_SOURCES(configure_module_dirname + "/common", "\
common_error.c \
+ common_enum.cpp \
", "intl");
ADD_SOURCES(configure_module_dirname + "/formatter", "\
formatter.c \
@@ -62,6 +63,9 @@ if (PHP_INTL != "no") {
dateformat_format.c \
dateformat_parse.c \
dateformat_data.c \
+ dateformat_attrcpp.cpp \
+ dateformat_helpers.cpp \
+ dateformat_create.cpp \
", "intl");
ADD_SOURCES(configure_module_dirname + "/idn", "\
idn.c",
@@ -87,6 +91,18 @@ if (PHP_INTL != "no") {
transliterator_class.c \
transliterator_methods.c",
"intl");
+
+ ADD_SOURCES(configure_module_dirname + "/timezone", "\
+ timezone_class.cpp \
+ timezone_methods.cpp",
+ "intl");
+
+ ADD_SOURCES(configure_module_dirname + "/calendar", "\
+ calendar_methods.cpp \
+ gregoriancalendar_methods.cpp \
+ calendar_class.cpp",
+ "intl");
+
ADD_FLAG("LIBS_INTL", "icudt.lib icuin.lib icuio.lib icule.lib iculx.lib");
AC_DEFINE("HAVE_INTL", 1, "Internationalization support enabled");
} else {
diff --git a/ext/intl/dateformat/dateformat.c b/ext/intl/dateformat/dateformat.c
index b399a39..fb83eee 100755
--- a/ext/intl/dateformat/dateformat.c
+++ b/ext/intl/dateformat/dateformat.c
@@ -17,12 +17,9 @@
#include "config.h"
#endif
-#include <unicode/ustring.h>
#include <unicode/udat.h>
-#include <unicode/ucal.h>
#include "php_intl.h"
-#include "intl_convert.h"
#include "dateformat_class.h"
#include "dateformat.h"
@@ -67,157 +64,6 @@ void dateformat_register_constants( INIT_FUNC_ARGS )
}
/* }}} */
-/* {{{ */
-static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
-{
- char* locale;
- int locale_len = 0;
- zval* object;
- long date_type = 0;
- long time_type = 0;
- long calendar = UCAL_GREGORIAN;
- char* timezone_str = NULL;
- int timezone_str_len = 0;
- char* pattern_str = NULL;
- int pattern_str_len = 0;
- UChar* svalue = NULL; /* UTF-16 pattern_str */
- int slength = 0;
- UChar* timezone_utf16 = NULL; /* UTF-16 timezone_str */
- int timezone_utf16_len = 0;
- UCalendar ucal_obj = NULL;
- IntlDateFormatter_object* dfo;
-
- intl_error_reset( NULL TSRMLS_CC );
- object = return_value;
- /* Parse parameters. */
- if( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "sll|sls",
- &locale, &locale_len, &date_type, &time_type, &timezone_str, &timezone_str_len, &calendar,&pattern_str, &pattern_str_len ) == FAILURE )
- {
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: unable to parse input parameters", 0 TSRMLS_CC );
- zval_dtor(return_value);
- RETURN_NULL();
- }
-
- INTL_CHECK_LOCALE_LEN_OBJ(locale_len, return_value);
-
- if (calendar != UCAL_TRADITIONAL && calendar != UCAL_GREGORIAN) {
- intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: "
- "invalid value for calendar type; it must be one of "
- "IntlDateFormatter::TRADITIONAL (locale's default calendar) "
- "or IntlDateFormatter::GREGORIAN", 0 TSRMLS_CC);
- goto error;
- }
-
- DATE_FORMAT_METHOD_FETCH_OBJECT;
-
- if (DATE_FORMAT_OBJECT(dfo) != NULL) {
- intl_errors_set(INTL_DATA_ERROR_P(dfo), U_ILLEGAL_ARGUMENT_ERROR,
- "datefmt_create: cannot call constructor twice", 0 TSRMLS_CC);
- return;
- }
-
- /* Convert pattern (if specified) to UTF-16. */
- if( pattern_str && pattern_str_len>0 ){
- intl_convert_utf8_to_utf16(&svalue, &slength,
- pattern_str, pattern_str_len, &INTL_DATA_ERROR_CODE(dfo));
- if (U_FAILURE(INTL_DATA_ERROR_CODE(dfo))) {
- /* object construction -> only set global error */
- intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo), "datefmt_create: "
- "error converting pattern to UTF-16", 0 TSRMLS_CC);
- goto error;
- }
- }
-
- /* resources allocated from now on */
-
- /* Convert pattern (if specified) to UTF-16. */
- if( timezone_str && timezone_str_len >0 ){
- intl_convert_utf8_to_utf16(&timezone_utf16, &timezone_utf16_len,
- timezone_str, timezone_str_len, &INTL_DATA_ERROR_CODE(dfo));
- if (U_FAILURE(INTL_DATA_ERROR_CODE(dfo))) {
- intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo), "datefmt_create: "
- "error converting timezone_str to UTF-16", 0 TSRMLS_CC);
- goto error;
- }
- }
-
- if(locale_len == 0) {
- locale = INTL_G(default_locale);
- }
-
- if( pattern_str && pattern_str_len>0 ){
- DATE_FORMAT_OBJECT(dfo) = udat_open(UDAT_IGNORE, UDAT_IGNORE, locale, timezone_utf16, timezone_utf16_len, svalue, slength, &INTL_DATA_ERROR_CODE(dfo));
- } else {
- DATE_FORMAT_OBJECT(dfo) = udat_open(time_type, date_type, locale, timezone_utf16, timezone_utf16_len, svalue, slength, &INTL_DATA_ERROR_CODE(dfo));
- }
-
- if (!U_FAILURE(INTL_DATA_ERROR_CODE(dfo))) {
- if (calendar != UCAL_TRADITIONAL) {
- ucal_obj = ucal_open(timezone_utf16, timezone_utf16_len, locale,
- calendar, &INTL_DATA_ERROR_CODE(dfo));
- if (!U_FAILURE(INTL_DATA_ERROR_CODE(dfo))) {
- udat_setCalendar(DATE_FORMAT_OBJECT(dfo), ucal_obj);
- ucal_close(ucal_obj);
- } else {
- intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo), "datefmt_create"
- ": error opening calendar", 0 TSRMLS_CC);
- goto error;
- }
- }
- } else {
- intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo), "datefmt_create: date "
- "formatter creation failed", 0 TSRMLS_CC);
- goto error;
- }
-
- /* Set the class variables */
- dfo->date_type = date_type;
- dfo->time_type = time_type;
- dfo->calendar = calendar;
- if( timezone_str && timezone_str_len > 0){
- dfo->timezone_id = estrndup( timezone_str, timezone_str_len);
- }
-
-error:
- if (svalue) {
- efree(svalue);
- }
- if (timezone_utf16) {
- efree(timezone_utf16);
- }
- if (U_FAILURE(intl_error_get_code(NULL TSRMLS_CC))) {
- /* free_object handles partially constructed instances fine */
- zval_dtor(return_value);
- RETVAL_NULL();
- }
-}
-/* }}} */
-
-/* {{{ proto IntlDateFormatter IntlDateFormatter::create(string $locale, long date_type, long time_type[, string $timezone_str, long $calendar, string $pattern] )
- * Create formatter. }}} */
-/* {{{ proto IntlDateFormatter datefmt_create(string $locale, long date_type, long time_type[, string $timezone_str, long $calendar, string $pattern] )
-
- * Create formatter.
- */
-PHP_FUNCTION( datefmt_create )
-{
- object_init_ex( return_value, IntlDateFormatter_ce_ptr );
- datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
-}
-/* }}} */
-
-/* {{{ proto void IntlDateFormatter::__construct(string $locale, long date_type, long time_type[, string $timezone_str, long $calendar, string $pattern])
- * IntlDateFormatter object constructor.
- */
-PHP_METHOD( IntlDateFormatter, __construct )
-{
- /* return_value param is being changed, therefore we will always return
- * NULL here */
- return_value = getThis();
- datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
-}
-/* }}} */
-
/* {{{ proto int IntlDateFormatter::getErrorCode()
* Get formatter's last error code. }}} */
/* {{{ proto int datefmt_get_error_code( IntlDateFormatter $nf )
diff --git a/ext/intl/dateformat/dateformat_attr.c b/ext/intl/dateformat/dateformat_attr.c
index 6131ced..a32a486 100755
--- a/ext/intl/dateformat/dateformat_attr.c
+++ b/ext/intl/dateformat/dateformat_attr.c
@@ -24,39 +24,6 @@
#include <unicode/ustring.h>
#include <unicode/udat.h>
-#include <unicode/ucal.h>
-
-static void internal_set_calendar(IntlDateFormatter_object *dfo, char* timezone_id, int timezone_id_len, int calendar, zval* return_value TSRMLS_DC){
- int timezone_utf16_len = 0;
- UChar* timezone_utf16 = NULL; /* timezone_id in UTF-16 */
- char* locale = NULL;
-
- UCalendar* ucal_obj = NULL;
-
- /* check for the validity of value of calendar passed */
- intl_error_reset( NULL TSRMLS_CC );
- if( calendar > 1){
- intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "datefmt_set_calendar: calendar value specified is out of valid range", 0 TSRMLS_CC);
- RETURN_FALSE;
- }
-
- /* Convert timezone to UTF-16. */
- intl_convert_utf8_to_utf16(&timezone_utf16, &timezone_utf16_len, timezone_id, timezone_id_len, &INTL_DATA_ERROR_CODE(dfo));
- INTL_METHOD_CHECK_STATUS(dfo, "Error converting timezone to UTF-16" );
-
- /* Get the locale for the dateformatter */
- locale = (char *)udat_getLocaleByType(DATE_FORMAT_OBJECT(dfo), ULOC_ACTUAL_LOCALE, &INTL_DATA_ERROR_CODE(dfo));
-
- /* Set the calendar if passed */
- ucal_obj = ucal_open(timezone_utf16, timezone_utf16_len, locale, calendar, &INTL_DATA_ERROR_CODE(dfo) );
- udat_setCalendar( DATE_FORMAT_OBJECT(dfo), ucal_obj );
- INTL_METHOD_CHECK_STATUS(dfo, "Error setting the calendar.");
-
- if( timezone_utf16){
- efree(timezone_utf16);
- }
-}
/* {{{ proto unicode IntlDateFormatter::getDateType( )
* Get formatter datetype. }}} */
@@ -110,97 +77,6 @@ PHP_FUNCTION( datefmt_get_timetype )
}
/* }}} */
-
-/* {{{ proto unicode IntlDateFormatter::getCalendar( )
- * Get formatter calendar. }}} */
-/* {{{ proto string datefmt_get_calendar( IntlDateFormatter $mf )
- * Get formatter calendar.
- */
-PHP_FUNCTION( datefmt_get_calendar )
-{
- DATE_FORMAT_METHOD_INIT_VARS;
-
- /* Parse parameters. */
- if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &object, IntlDateFormatter_ce_ptr ) == FAILURE )
- {
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "datefmt_get_calendar: unable to parse input params", 0 TSRMLS_CC );
- RETURN_FALSE;
- }
-
- /* Fetch the object. */
- DATE_FORMAT_METHOD_FETCH_OBJECT;
-
- INTL_METHOD_CHECK_STATUS(dfo, "Error getting formatter calendar." );
-
- RETURN_LONG(dfo->calendar);
-}
-/* }}} */
-
-/* {{{ proto unicode IntlDateFormatter::getTimeZoneId( )
- * Get formatter timezone_id. }}} */
-/* {{{ proto string datefmt_get_timezone_id( IntlDateFormatter $mf )
- * Get formatter timezone_id.
- */
-PHP_FUNCTION( datefmt_get_timezone_id )
-{
- DATE_FORMAT_METHOD_INIT_VARS;
-
- /* Parse parameters. */
- if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &object, IntlDateFormatter_ce_ptr ) == FAILURE )
- {
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "datefmt_get_timezone_id: unable to parse input params", 0 TSRMLS_CC );
- RETURN_FALSE;
- }
-
- /* Fetch the object. */
- DATE_FORMAT_METHOD_FETCH_OBJECT;
-
- INTL_METHOD_CHECK_STATUS(dfo, "Error getting formatter timezone_id." );
-
- if( dfo->timezone_id ){
- RETURN_STRING((char*)dfo->timezone_id, TRUE );
- }else{
- RETURN_NULL();
- }
-}
-
-/* {{{ proto boolean IntlDateFormatter::setTimeZoneId( $timezone_id)
- * Set formatter timezone_id. }}} */
-/* {{{ proto boolean datefmt_set_timezone_id( IntlDateFormatter $mf,$timezone_id)
- * Set formatter timezone_id.
- */
-PHP_FUNCTION( datefmt_set_timezone_id )
-{
- char* timezone_id = NULL;
- int timezone_id_len = 0;
-
- DATE_FORMAT_METHOD_INIT_VARS;
-
- /* Parse parameters. */
- if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &object, IntlDateFormatter_ce_ptr,&timezone_id, &timezone_id_len) == FAILURE )
- {
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "datefmt_set_timezone_id: unable to parse input params", 0 TSRMLS_CC );
- RETURN_FALSE;
- }
-
- /* Fetch the object. */
- DATE_FORMAT_METHOD_FETCH_OBJECT;
-
- /* set the timezone for the calendar */
- internal_set_calendar( dfo, timezone_id, timezone_id_len, dfo->calendar, return_value TSRMLS_CC );
-
- /* Set the IntlDateFormatter variable */
- if( dfo->timezone_id ){
- efree(dfo->timezone_id);
- }
- dfo->timezone_id = estrndup(timezone_id, timezone_id_len);
-
- RETURN_TRUE;
-}
-
/* {{{ proto string IntlDateFormatter::getPattern( )
* Get formatter pattern. }}} */
/* {{{ proto string datefmt_get_pattern( IntlDateFormatter $mf )
@@ -369,43 +245,3 @@ PHP_FUNCTION( datefmt_set_lenient )
udat_setLenient(DATE_FORMAT_OBJECT(dfo), (UBool)isLenient );
}
/* }}} */
-
-/* {{{ proto bool IntlDateFormatter::setPattern( int $calendar )
- * Set formatter calendar. }}} */
-/* {{{ proto bool datefmt_set_calendar( IntlDateFormatter $mf, int $calendar )
- * Set formatter calendar.
- */
-PHP_FUNCTION( datefmt_set_calendar )
-{
- long calendar = 0;
-
- DATE_FORMAT_METHOD_INIT_VARS;
-
- /* Parse parameters. */
- if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol",
- &object, IntlDateFormatter_ce_ptr, &calendar ) == FAILURE ) {
- intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "datefmt_set_calendar: unable to parse input params", 0 TSRMLS_CC);
- RETURN_FALSE;
- }
-
- /* check for the validity of value of calendar passed */
- intl_error_reset( NULL TSRMLS_CC );
- if (calendar > 1) {
- intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "datefmt_set_calendar: calendar value specified is out of valid range", 0 TSRMLS_CC);
- RETURN_FALSE;
- }
-
- DATE_FORMAT_METHOD_FETCH_OBJECT;
-
- internal_set_calendar( dfo, dfo->timezone_id, strlen(dfo->timezone_id), calendar, return_value TSRMLS_CC );
-
- /* Set the calendar value in the IntlDateFormatter object */
- dfo->calendar = calendar;
-
- RETURN_TRUE;
-}
-/* }}} */
-
-
diff --git a/ext/intl/dateformat/dateformat_attr.h b/ext/intl/dateformat/dateformat_attr.h
index bf28824..6fe82a6 100755
--- a/ext/intl/dateformat/dateformat_attr.h
+++ b/ext/intl/dateformat/dateformat_attr.h
@@ -21,11 +21,7 @@
//PHP_FUNCTION( datefmt_get_timezone );
PHP_FUNCTION( datefmt_get_datetype );
PHP_FUNCTION( datefmt_get_timetype );
-PHP_FUNCTION( datefmt_get_calendar );
-PHP_FUNCTION( datefmt_set_calendar );
PHP_FUNCTION( datefmt_get_locale );
-PHP_FUNCTION( datefmt_get_timezone_id );
-PHP_FUNCTION( datefmt_set_timezone_id );
PHP_FUNCTION( datefmt_get_pattern );
PHP_FUNCTION( datefmt_set_pattern );
PHP_FUNCTION( datefmt_is_lenient );
diff --git a/ext/intl/dateformat/dateformat_attrcpp.cpp b/ext/intl/dateformat/dateformat_attrcpp.cpp
new file mode 100644
index 0000000..b68abec
--- /dev/null
+++ b/ext/intl/dateformat/dateformat_attrcpp.cpp
@@ -0,0 +1,261 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Gustavo Lopes <cataphract@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+#include "../intl_cppshims.h"
+
+#include <unicode/timezone.h>
+#include <unicode/calendar.h>
+#include <unicode/datefmt.h>
+
+extern "C" {
+#include "../php_intl.h"
+#include "dateformat_class.h"
+#include "dateformat_attrcpp.h"
+#define USE_TIMEZONE_POINTER 1
+#include "../timezone/timezone_class.h"
+#define USE_CALENDAR_POINTER 1
+#include "../calendar/calendar_class.h"
+}
+
+#include "../intl_convertcpp.h"
+#include "dateformat_helpers.h"
+
+static inline DateFormat *fetch_datefmt(IntlDateFormatter_object *dfo) {
+ return (DateFormat *)dfo->datef_data.udatf;
+}
+
+/* {{{ proto string IntlDateFormatter::getTimeZoneId()
+ * Get formatter timezone_id. }}} */
+/* {{{ proto string datefmt_get_timezone_id(IntlDateFormatter $mf)
+ * Get formatter timezone_id.
+ */
+U_CFUNC PHP_FUNCTION(datefmt_get_timezone_id)
+{
+ DATE_FORMAT_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
+ &object, IntlDateFormatter_ce_ptr ) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_get_timezone_"
+ "id: unable to parse input params", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ DATE_FORMAT_METHOD_FETCH_OBJECT;
+
+ UnicodeString res = UnicodeString();
+ fetch_datefmt(dfo)->getTimeZone().getID(res);
+ intl_charFromString(res, &Z_STRVAL_P(return_value),
+ &Z_STRLEN_P(return_value), &INTL_DATA_ERROR_CODE(dfo));
+ INTL_METHOD_CHECK_STATUS(dfo, "Could not convert time zone id to UTF-8");
+
+ Z_TYPE_P(return_value) = IS_STRING;
+}
+
+/* {{{ proto IntlTimeZone IntlDateFormatter::getTimeZone()
+ * Get formatter timezone. }}} */
+/* {{{ proto IntlTimeZone datefmt_get_timezone(IntlDateFormatter $mf)
+ * Get formatter timezone.
+ */
+U_CFUNC PHP_FUNCTION(datefmt_get_timezone)
+{
+ DATE_FORMAT_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
+ &object, IntlDateFormatter_ce_ptr ) == FAILURE) {
+ intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "datefmt_get_timezone: unable to parse input params", 0 TSRMLS_CC );
+ RETURN_FALSE;
+ }
+
+ DATE_FORMAT_METHOD_FETCH_OBJECT;
+
+ const TimeZone& tz = fetch_datefmt(dfo)->getTimeZone();
+ TimeZone *tz_clone = tz.clone();
+ if (tz_clone == NULL) {
+ intl_errors_set(INTL_DATA_ERROR_P(dfo), U_MEMORY_ALLOCATION_ERROR,
+ "datefmt_get_timezone: Out of memory when cloning time zone",
+ 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ object_init_ex(return_value, TimeZone_ce_ptr);
+ timezone_object_construct(tz_clone, return_value, 1 TSRMLS_CC);
+}
+
+U_CFUNC PHP_FUNCTION(datefmt_set_timezone_id)
+{
+ php_error_docref0(NULL TSRMLS_CC, E_DEPRECATED,
+ "Use datefmt_set_timezone() instead, which also accepts a plain "
+ "time zone identifier and for which this function is now an "
+ "alias");
+ PHP_FN(datefmt_set_timezone)(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
+/* {{{ proto boolean IntlDateFormatter::setTimeZone(mixed $timezone)
+ * Set formatter's timezone. }}} */
+/* {{{ proto boolean datefmt_set_timezone_id(IntlDateFormatter $mf, $timezone_id)
+ * Set formatter timezone_id.
+ */
+U_CFUNC PHP_FUNCTION(datefmt_set_timezone)
+{
+ zval **timezone_zv;
+ TimeZone *timezone;
+
+ DATE_FORMAT_METHOD_INIT_VARS;
+
+ if ( zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
+ "OZ", &object, IntlDateFormatter_ce_ptr, &timezone_zv) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_set_timezone: "
+ "unable to parse input params", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ DATE_FORMAT_METHOD_FETCH_OBJECT;
+
+ timezone = timezone_process_timezone_argument(timezone_zv,
+ INTL_DATA_ERROR_P(dfo), "datefmt_set_timezone" TSRMLS_CC);
+ if (timezone == NULL) {
+ RETURN_FALSE;
+ }
+
+ fetch_datefmt(dfo)->adoptTimeZone(timezone);
+}
+
+/* {{{ proto int IntlDateFormatter::getCalendar( )
+ * Get formatter calendar type. }}} */
+/* {{{ proto int datefmt_get_calendar(IntlDateFormatter $mf)
+ * Get formatter calendar type.
+ */
+U_CFUNC PHP_FUNCTION(datefmt_get_calendar)
+{
+ DATE_FORMAT_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
+ &object, IntlDateFormatter_ce_ptr ) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "datefmt_get_calendar: unable to parse input params", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ DATE_FORMAT_METHOD_FETCH_OBJECT;
+
+ if (dfo->calendar == -1) {
+ /* an IntlCalendar was provided to the constructor */
+ RETURN_FALSE;
+ }
+
+ RETURN_LONG(dfo->calendar);
+}
+/* }}} */
+
+/* {{{ proto IntlCalendar IntlDateFormatter::getCalendarObject()
+ * Get formatter calendar. }}} */
+/* {{{ proto IntlCalendar datefmt_get_calendar_object(IntlDateFormatter $mf)
+ * Get formatter calendar.
+ */
+U_CFUNC PHP_FUNCTION(datefmt_get_calendar_object)
+{
+ DATE_FORMAT_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
+ &object, IntlDateFormatter_ce_ptr ) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "datefmt_get_calendar_object: unable to parse input params",
+ 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ DATE_FORMAT_METHOD_FETCH_OBJECT;
+
+ const Calendar *cal = fetch_datefmt(dfo)->getCalendar();
+ if (cal == NULL) {
+ RETURN_NULL();
+ }
+
+ Calendar *cal_clone = cal->clone();
+ if (cal_clone == NULL) {
+ intl_errors_set(INTL_DATA_ERROR_P(dfo), U_MEMORY_ALLOCATION_ERROR,
+ "datefmt_get_calendar_object: Out of memory when cloning "
+ "calendar", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ calendar_object_create(return_value, cal_clone TSRMLS_CC);
+}
+/* }}} */
+
+/* {{{ proto bool IntlDateFormatter::setCalendar(mixed $calendar)
+ * Set formatter's calendar. }}} */
+/* {{{ proto bool datefmt_set_calendar(IntlDateFormatter $mf, mixed $calendar)
+ * Set formatter's calendar.
+ */
+U_CFUNC PHP_FUNCTION(datefmt_set_calendar)
+{
+ zval *calendar_zv;
+ DATE_FORMAT_METHOD_INIT_VARS;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oz",
+ &object, IntlDateFormatter_ce_ptr, &calendar_zv) == FAILURE) {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "datefmt_set_calendar: unable to parse input params", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ DATE_FORMAT_METHOD_FETCH_OBJECT;
+
+ Calendar *cal;
+ long cal_type;
+ bool cal_owned;
+ Locale locale = Locale::createFromName(dfo->requested_locale);
+ // getting the actual locale from the DateFormat is not enough
+ // because we would have lost modifiers such as @calendar. We
+ // must store the requested locale on object creation
+
+ if (datefmt_process_calendar_arg(calendar_zv, locale,
+ "datefmt_set_calendar", INTL_DATA_ERROR_P(dfo), cal, cal_type,
+ cal_owned TSRMLS_CC) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ if (cal_owned) {
+ /* a non IntlCalendar was specified, we want to keep the timezone */
+ TimeZone *old_timezone = fetch_datefmt(dfo)->getTimeZone().clone();
+ if (old_timezone == NULL) {
+ intl_errors_set(INTL_DATA_ERROR_P(dfo), U_MEMORY_ALLOCATION_ERROR,
+ "datefmt_set_calendar: Out of memory when cloning calendar",
+ 0 TSRMLS_CC);
+ delete cal;
+ RETURN_FALSE;
+ }
+ cal->adoptTimeZone(old_timezone);
+ } else {
+ cal = cal->clone();
+ if (cal == NULL) {
+ intl_errors_set(INTL_DATA_ERROR_P(dfo), U_MEMORY_ALLOCATION_ERROR,
+ "datefmt_set_calendar: Out of memory when cloning calendar",
+ 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
+ }
+
+ fetch_datefmt(dfo)->adoptCalendar(cal);
+
+ dfo->calendar = cal_type;
+
+ RETURN_TRUE;
+}
+/* }}} */
+
diff --git a/ext/intl/dateformat/dateformat_attrcpp.h b/ext/intl/dateformat/dateformat_attrcpp.h
new file mode 100644
index 0000000..408232f
--- /dev/null
+++ b/ext/intl/dateformat/dateformat_attrcpp.h
@@ -0,0 +1,35 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Gustavo Lopes <cataphract@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+#ifndef DATEFORMAT_ATTRCPP_H
+#define DATEFORMAT_ATTRCPP_H
+
+PHP_FUNCTION(datefmt_get_timezone_id);
+
+PHP_FUNCTION(datefmt_set_timezone_id);
+
+PHP_FUNCTION(datefmt_get_timezone);
+
+PHP_FUNCTION(datefmt_set_timezone);
+
+PHP_FUNCTION(datefmt_get_calendar);
+
+PHP_FUNCTION(datefmt_set_calendar);
+
+PHP_FUNCTION(datefmt_get_calendar_object);
+
+#endif /* DATEFORMAT_ATTRCPP_H */
+
diff --git a/ext/intl/dateformat/dateformat_class.c b/ext/intl/dateformat/dateformat_class.c
index c66610f..fda67f1 100755
--- a/ext/intl/dateformat/dateformat_class.c
+++ b/ext/intl/dateformat/dateformat_class.c
@@ -22,6 +22,7 @@
#include "dateformat_parse.h"
#include "dateformat.h"
#include "dateformat_attr.h"
+#include "dateformat_attrcpp.h"
zend_class_entry *IntlDateFormatter_ce_ptr = NULL;
static zend_object_handlers IntlDateFormatter_handlers;
@@ -44,12 +45,12 @@ void IntlDateFormatter_object_free( zend_object *object TSRMLS_DC )
zend_object_std_dtor( &dfo->zo TSRMLS_CC );
- dateformat_data_free( &dfo->datef_data TSRMLS_CC );
-
- if( dfo->timezone_id ){
- efree(dfo->timezone_id);
+ if (dfo->requested_locale) {
+ efree( dfo->requested_locale );
}
+ dateformat_data_free( &dfo->datef_data TSRMLS_CC );
+
efree( dfo );
}
/* }}} */
@@ -63,10 +64,10 @@ zend_object_value IntlDateFormatter_object_create(zend_class_entry *ce TSRMLS_DC
intern = ecalloc( 1, sizeof(IntlDateFormatter_object) );
dateformat_data_init( &intern->datef_data TSRMLS_CC );
zend_object_std_init( &intern->zo, ce TSRMLS_CC );
- intern->date_type = 0;
- intern->time_type = 0;
- intern->calendar = 1; /* Gregorian calendar */
- intern->timezone_id = NULL;
+ intern->date_type = 0;
+ intern->time_type = 0;
+ intern->calendar = -1;
+ intern->requested_locale = NULL;
retval.handle = zend_objects_store_put(
intern,
@@ -157,9 +158,12 @@ static zend_function_entry IntlDateFormatter_class_functions[] = {
PHP_NAMED_FE( getDateType, ZEND_FN( datefmt_get_datetype ), arginfo_intldateformatter_getdatetype )
PHP_NAMED_FE( getTimeType, ZEND_FN( datefmt_get_timetype ), arginfo_intldateformatter_getdatetype )
PHP_NAMED_FE( getCalendar, ZEND_FN( datefmt_get_calendar ), arginfo_intldateformatter_getdatetype )
+ PHP_NAMED_FE( getCalendarObject, ZEND_FN( datefmt_get_calendar_object ), arginfo_intldateformatter_getdatetype )
PHP_NAMED_FE( setCalendar, ZEND_FN( datefmt_set_calendar ), arginfo_intldateformatter_setcalendar )
PHP_NAMED_FE( getTimeZoneId, ZEND_FN( datefmt_get_timezone_id ), arginfo_intldateformatter_getdatetype )
PHP_NAMED_FE( setTimeZoneId, ZEND_FN( datefmt_set_timezone_id ), arginfo_intldateformatter_settimezoneid )
+ PHP_NAMED_FE( getTimeZone, ZEND_FN( datefmt_get_timezone ), arginfo_intldateformatter_getdatetype )
+ PHP_NAMED_FE( setTimeZone, ZEND_FN( datefmt_set_timezone ), arginfo_intldateformatter_settimezoneid )
PHP_NAMED_FE( setPattern, ZEND_FN( datefmt_set_pattern ), arginfo_intldateformatter_setpattern )
PHP_NAMED_FE( getPattern, ZEND_FN( datefmt_get_pattern ), arginfo_intldateformatter_getdatetype )
PHP_NAMED_FE( getLocale, ZEND_FN( datefmt_get_locale ), arginfo_intldateformatter_getdatetype )
diff --git a/ext/intl/dateformat/dateformat_class.h b/ext/intl/dateformat/dateformat_class.h
index 9ad83ee..de5cf4a 100755
--- a/ext/intl/dateformat/dateformat_class.h
+++ b/ext/intl/dateformat/dateformat_class.h
@@ -24,12 +24,12 @@
#include "dateformat_data.h"
typedef struct {
- zend_object zo;
- dateformat_data datef_data;
- int date_type ;
- int time_type ;
- int calendar ;
- char* timezone_id;
+ zend_object zo;
+ dateformat_data datef_data;
+ int date_type;
+ int time_type;
+ int calendar;
+ char *requested_locale;
} IntlDateFormatter_object;
void dateformat_register_IntlDateFormatter_class( TSRMLS_D );
diff --git a/ext/intl/dateformat/dateformat_create.cpp b/ext/intl/dateformat/dateformat_create.cpp
new file mode 100644
index 0000000..fef93e9
--- /dev/null
+++ b/ext/intl/dateformat/dateformat_create.cpp
@@ -0,0 +1,193 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Kirti Velankar <kirtig@yahoo-inc.com> |
+ | Gustavo Lopes <cataphract@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+#include "../intl_cppshims.h"
+
+#include <unicode/timezone.h>
+#include <unicode/calendar.h>
+#include <unicode/datefmt.h>
+
+extern "C" {
+#include <unicode/ustring.h>
+#include <unicode/udat.h>
+
+#include "php_intl.h"
+#include "dateformat_create.h"
+#include "dateformat_class.h"
+#define USE_TIMEZONE_POINTER 1
+#include "../timezone/timezone_class.h"
+#include "../intl_convert.h"
+}
+
+#include "dateformat_helpers.h"
+
+/* {{{ */
+static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
+{
+ zval *object;
+
+ char *locale_str;
+ int locale_len = 0;
+ Locale locale;
+ long date_type = 0;
+ long time_type = 0;
+ zval *calendar_zv = NULL;
+ Calendar *calendar = NULL;
+ long calendar_type;
+ bool calendar_owned;
+ zval **timezone_zv = NULL;
+ TimeZone *timezone = NULL;
+ bool explicit_tz;
+ char* pattern_str = NULL;
+ int pattern_str_len = 0;
+ UChar* svalue = NULL; /* UTF-16 pattern_str */
+ int slength = 0;
+ IntlDateFormatter_object* dfo;
+
+ intl_error_reset(NULL TSRMLS_CC);
+ object = return_value;
+ /* Parse parameters. */
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sll|Zzs",
+ &locale_str, &locale_len, &date_type, &time_type, &timezone_zv,
+ &calendar_zv, &pattern_str, &pattern_str_len) == FAILURE) {
+ intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: "
+ "unable to parse input parameters", 0 TSRMLS_CC);
+ zval_dtor(return_value);
+ RETURN_NULL();
+ }
+
+ INTL_CHECK_LOCALE_LEN_OBJ(locale_len, return_value);
+ if (locale_len == 0) {
+ locale_str = INTL_G(default_locale);
+ }
+ locale = Locale::createFromName(locale_str);
+
+ DATE_FORMAT_METHOD_FETCH_OBJECT;
+
+ if (DATE_FORMAT_OBJECT(dfo) != NULL) {
+ intl_errors_set(INTL_DATA_ERROR_P(dfo), U_ILLEGAL_ARGUMENT_ERROR,
+ "datefmt_create: cannot call constructor twice", 0 TSRMLS_CC);
+ return;
+ }
+
+ /* process calendar */
+ if (datefmt_process_calendar_arg(calendar_zv, locale, "datefmt_create",
+ INTL_DATA_ERROR_P(dfo), calendar, calendar_type,
+ calendar_owned TSRMLS_CC)
+ == FAILURE) {
+ goto error;
+ }
+
+ /* process timezone */
+ explicit_tz = timezone_zv != NULL && Z_TYPE_PP(timezone_zv) != IS_NULL;
+
+ if (explicit_tz || calendar_owned ) {
+ //we have an explicit time zone or a non-object calendar
+ timezone = timezone_process_timezone_argument(timezone_zv,
+ INTL_DATA_ERROR_P(dfo), "datefmt_create" TSRMLS_CC);
+ if (timezone == NULL) {
+ goto error;
+ }
+ }
+
+ /* Convert pattern (if specified) to UTF-16. */
+ if (pattern_str && pattern_str_len > 0) {
+ intl_convert_utf8_to_utf16(&svalue, &slength,
+ pattern_str, pattern_str_len, &INTL_DATA_ERROR_CODE(dfo));
+ if (U_FAILURE(INTL_DATA_ERROR_CODE(dfo))) {
+ /* object construction -> only set global error */
+ intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo), "datefmt_create: "
+ "error converting pattern to UTF-16", 0 TSRMLS_CC);
+ goto error;
+ }
+ }
+
+ if (pattern_str && pattern_str_len > 0) {
+ DATE_FORMAT_OBJECT(dfo) = udat_open(UDAT_IGNORE, UDAT_IGNORE,
+ locale_str, NULL, 0, svalue, slength,
+ &INTL_DATA_ERROR_CODE(dfo));
+ } else {
+ DATE_FORMAT_OBJECT(dfo) = udat_open((UDateFormatStyle)time_type,
+ (UDateFormatStyle)date_type, locale_str, NULL, 0, svalue,
+ slength, &INTL_DATA_ERROR_CODE(dfo));
+ }
+
+ if (!U_FAILURE(INTL_DATA_ERROR_CODE(dfo))) {
+ DateFormat *df = (DateFormat*)DATE_FORMAT_OBJECT(dfo);
+ if (calendar_owned) {
+ df->adoptCalendar(calendar);
+ calendar_owned = false;
+ } else {
+ df->setCalendar(*calendar);
+ }
+
+ if (timezone != NULL) {
+ df->adoptTimeZone(timezone);
+ }
+ } else {
+ intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo), "datefmt_create: date "
+ "formatter creation failed", 0 TSRMLS_CC);
+ goto error;
+ }
+
+ /* Set the class variables */
+ dfo->date_type = date_type;
+ dfo->time_type = time_type;
+ dfo->calendar = calendar_type;
+ dfo->requested_locale = estrdup(locale_str);
+
+error:
+ if (svalue) {
+ efree(svalue);
+ }
+ if (timezone != NULL && DATE_FORMAT_OBJECT(dfo) == NULL) {
+ delete timezone;
+ }
+ if (calendar != NULL && calendar_owned) {
+ delete calendar;
+ }
+ if (U_FAILURE(intl_error_get_code(NULL TSRMLS_CC))) {
+ /* free_object handles partially constructed instances fine */
+ zval_dtor(return_value);
+ RETVAL_NULL();
+ }
+}
+/* }}} */
+
+/* {{{ proto IntlDateFormatter IntlDateFormatter::create(string $locale, long date_type, long time_type[, string $timezone_str, long $calendar, string $pattern] )
+ * Create formatter. }}} */
+/* {{{ proto IntlDateFormatter datefmt_create(string $locale, long date_type, long time_type[, string $timezone_str, long $calendar, string $pattern)
+ * Create formatter.
+ */
+U_CFUNC PHP_FUNCTION( datefmt_create )
+{
+ object_init_ex( return_value, IntlDateFormatter_ce_ptr );
+ datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+/* }}} */
+
+/* {{{ proto void IntlDateFormatter::__construct(string $locale, long date_type, long time_type[, string $timezone_str, long $calendar, string $pattern])
+ * IntlDateFormatter object constructor.
+ */
+U_CFUNC PHP_METHOD( IntlDateFormatter, __construct )
+{
+ /* return_value param is being changed, therefore we will always return
+ * NULL here */
+ return_value = getThis();
+ datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+/* }}} */
diff --git a/ext/intl/dateformat/dateformat_create.h b/ext/intl/dateformat/dateformat_create.h
new file mode 100644
index 0000000..47e67c2
--- /dev/null
+++ b/ext/intl/dateformat/dateformat_create.h
@@ -0,0 +1,25 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Gustavo Lopes <cataphract@php.net> |
+ +----------------------------------------------------------------------+
+*/
+#ifndef DATE_FORMATTER_H
+#define DATE_FORMATTER_H
+
+#include <php.h>
+
+PHP_FUNCTION( datefmt_create );
+PHP_METHOD( IntlDateFormatter, __construct );
+void dateformat_register_constants( INIT_FUNC_ARGS );
+
+#endif // DATE_FORMATTER_H
diff --git a/ext/intl/dateformat/dateformat_format.c b/ext/intl/dateformat/dateformat_format.c
index 4d03d92..82f825f 100755
--- a/ext/intl/dateformat/dateformat_format.c
+++ b/ext/intl/dateformat/dateformat_format.c
@@ -27,6 +27,8 @@
#include "dateformat_class.h"
#include "dateformat_format.h"
#include "dateformat_data.h"
+/* avoid redefinition of int8_t, already defined in unicode/pwin32.h */
+#define _MSC_STDINT_H_ 1
#include "ext/date/php_date.h"
/* {{{
@@ -91,7 +93,7 @@ static UDate internal_get_timestamp(IntlDateFormatter_object *dfo, HashTable* ha
long yday =0;
long mday =0;
UBool isInDST = FALSE;
- UCalendar *pcal;
+ const UCalendar *pcal;
/* Fetch values from the incoming array */
year = internal_get_arr_ele( dfo, hash_arr, CALENDAR_YEAR TSRMLS_CC) + 1900; /* tm_year is years since 1900 */
diff --git a/ext/intl/dateformat/dateformat_helpers.cpp b/ext/intl/dateformat/dateformat_helpers.cpp
new file mode 100644
index 0000000..74758bb
--- /dev/null
+++ b/ext/intl/dateformat/dateformat_helpers.cpp
@@ -0,0 +1,106 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Gustavo Lopes <cataphract@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+#include "../intl_cppshims.h"
+
+#include <unicode/calendar.h>
+#include <unicode/gregocal.h>
+
+#include "dateformat_helpers.h"
+
+extern "C" {
+#include "../php_intl.h"
+#include <Zend/zend_operators.h>
+#define USE_CALENDAR_POINTER 1
+#include "../calendar/calendar_class.h"
+}
+
+int datefmt_process_calendar_arg(zval* calendar_zv,
+ Locale const& locale,
+ const char *func_name,
+ intl_error *err,
+ Calendar*& cal,
+ long& cal_int_type,
+ bool& calendar_owned TSRMLS_DC)
+{
+ char *msg;
+ UErrorCode status = UErrorCode();
+
+ if (calendar_zv == NULL || Z_TYPE_P(calendar_zv) == IS_NULL) {
+
+ // default requested
+ cal = new GregorianCalendar(locale, status);
+ calendar_owned = true;
+
+ cal_int_type = UCAL_GREGORIAN;
+
+ } else if (Z_TYPE_P(calendar_zv) == IS_LONG) {
+
+ long v = Z_LVAL_P(calendar_zv);
+ if (v != (long)UCAL_TRADITIONAL && v != (long)UCAL_GREGORIAN) {
+ spprintf(&msg, 0, "%s: invalid value for calendar type; it must be "
+ "one of IntlDateFormatter::TRADITIONAL (locale's default "
+ "calendar) or IntlDateFormatter::GREGORIAN. "
+ "Alternatively, it can be an IntlCalendar object",
+ func_name);
+ intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, msg, 1 TSRMLS_CC);
+ efree(msg);
+ return FAILURE;
+ } else if (v == (long)UCAL_TRADITIONAL) {
+ cal = Calendar::createInstance(locale, status);
+ } else { //UCAL_GREGORIAN
+ cal = new GregorianCalendar(locale, status);
+ }
+ calendar_owned = true;
+
+ cal_int_type = Z_LVAL_P(calendar_zv);
+
+ } else if (Z_TYPE_P(calendar_zv) == IS_OBJECT &&
+ instanceof_function_ex(Z_OBJCE_P(calendar_zv),
+ Calendar_ce_ptr, 0 TSRMLS_CC)) {
+
+ cal = calendar_fetch_native_calendar(calendar_zv TSRMLS_CC);
+ if (cal == NULL) {
+ spprintf(&msg, 0, "%s: Found unconstructed IntlCalendar object",
+ func_name);
+ intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, msg, 1 TSRMLS_CC);
+ efree(msg);
+ return FAILURE;
+ }
+ calendar_owned = false;
+
+ cal_int_type = -1;
+
+ } else {
+ spprintf(&msg, 0, "%s: Invalid calendar argument; should be an integer "
+ "or an IntlCalendar instance", func_name);
+ intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, msg, 1 TSRMLS_CC);
+ efree(msg);
+ return FAILURE;
+ }
+
+ if (cal == NULL && !U_FAILURE(status)) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ }
+ if (U_FAILURE(status)) {
+ spprintf(&msg, 0, "%s: Failure instantiating calendar", func_name);
+ intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, msg, 1 TSRMLS_CC);
+ efree(msg);
+ return FAILURE;
+ }
+
+ return SUCCESS;
+}
diff --git a/ext/intl/dateformat/dateformat_helpers.h b/ext/intl/dateformat/dateformat_helpers.h
new file mode 100644
index 0000000..bded0b7
--- /dev/null
+++ b/ext/intl/dateformat/dateformat_helpers.h
@@ -0,0 +1,39 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Gustavo Lopes <cataphract@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+#ifndef DATEFORMAT_HELPERS_H
+#define DATEFORMAT_HELPERS_H
+
+#ifndef __cplusplus
+#error For C++ only
+#endif
+
+#include <unicode/calendar.h>
+
+extern "C" {
+#include "../php_intl.h"
+}
+
+int datefmt_process_calendar_arg(zval* calendar_zv,
+ Locale const& locale,
+ const char *func_name,
+ intl_error *err,
+ Calendar*& cal,
+ long& cal_int_type,
+ bool& calendar_owned TSRMLS_DC);
+
+#endif /* DATEFORMAT_HELPERS_H */
+
diff --git a/ext/intl/grapheme/grapheme.h b/ext/intl/grapheme/grapheme.h
index c0e697a..756ce91 100755
--- a/ext/intl/grapheme/grapheme.h
+++ b/ext/intl/grapheme/grapheme.h
@@ -19,7 +19,6 @@
#include <php.h>
#include <unicode/utypes.h>
-#include <unicode/ubrk.h>
PHP_FUNCTION(grapheme_strlen);
PHP_FUNCTION(grapheme_strpos);
diff --git a/ext/intl/intl_convertcpp.cpp b/ext/intl/intl_convertcpp.cpp
new file mode 100644
index 0000000..f699a3c
--- /dev/null
+++ b/ext/intl/intl_convertcpp.cpp
@@ -0,0 +1,89 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Gustavo Lopes <cataphract@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
+#include "intl_cppshims.h"
+
+#include "intl_convertcpp.h"
+#include <unicode/ustring.h>
+extern "C" {
+#include <php.h>
+}
+
+/* {{{ intl_stringFromChar */
+int intl_stringFromChar(UnicodeString &ret, char *str, int32_t str_len, UErrorCode *status)
+{
+ //the number of UTF-16 code units is not larger than that of UTF-8 code
+ //units, + 1 for the terminator
+ int32_t capacity = str_len + 1;
+
+ //no check necessary -- if NULL will fail ahead
+ UChar *utf16 = ret.getBuffer(capacity);
+ int32_t utf16_len = 0;
+ *status = U_ZERO_ERROR;
+ u_strFromUTF8WithSub(utf16, ret.getCapacity(), &utf16_len,
+ str, str_len, U_SENTINEL /* no substitution */, NULL,
+ status);
+ ret.releaseBuffer(utf16_len);
+ if (U_FAILURE(*status)) {
+ ret.setToBogus();
+ return FAILURE;
+ }
+ return SUCCESS;
+}
+/* }}} */
+
+/* {{{ intl_charFromString
+ * faster than doing intl_convert_utf16_to_utf8(&res, &res_len,
+ * from.getBuffer(), from.length(), &status),
+ * but consumes more memory */
+int intl_charFromString(const UnicodeString &from, char **res, int *res_len, UErrorCode *status)
+{
+ if (from.isBogus()) {
+ return FAILURE;
+ }
+
+ //the number of UTF-8 code units is not larger than that of UTF-16 code
+ //units * 3 + 1 for the terminator
+ int32_t capacity = from.length() * 3 + 1;
+
+ if (from.isEmpty()) {
+ *res = (char*)emalloc(1);
+ **res = '\0';
+ *res_len = 0;
+ return SUCCESS;
+ }
+
+ *res = (char*)emalloc(capacity);
+ *res_len = 0; //tbd
+
+ const UChar *utf16buf = from.getBuffer();
+ int32_t actual_len;
+ u_strToUTF8WithSub(*res, capacity - 1, &actual_len, utf16buf, from.length(),
+ U_SENTINEL, NULL, status);
+
+ if (U_FAILURE(*status)) {
+ efree(*res);
+ *res = NULL;
+ return FAILURE;
+ }
+ (*res)[actual_len] = '\0';
+ *res_len = (int)actual_len;
+
+ return SUCCESS;
+}
+/* }}} */
diff --git a/ext/intl/intl_convertcpp.h b/ext/intl/intl_convertcpp.h
new file mode 100644
index 0000000..89d4209
--- /dev/null
+++ b/ext/intl/intl_convertcpp.h
@@ -0,0 +1,32 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Gustavo Lopes <cataphract@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
+#ifndef INTL_CONVERTCPP_H
+#define INTL_CONVERTCPP_H
+
+#ifndef __cplusplus
+#error Should be included only in C++ Files
+#endif
+
+#include <unicode/unistr.h>
+
+int intl_stringFromChar(UnicodeString &ret, char *str, int32_t str_len, UErrorCode *status);
+
+int intl_charFromString(const UnicodeString &from, char **res, int *res_len, UErrorCode *status);
+
+#endif /* INTL_CONVERTCPP_H */
diff --git a/ext/intl/intl_cppshims.h b/ext/intl/intl_cppshims.h
new file mode 100644
index 0000000..2fb70ed
--- /dev/null
+++ b/ext/intl/intl_cppshims.h
@@ -0,0 +1,34 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Gustavo Lopes <cataphract@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+#ifndef INTL_CPPSHIMS_H
+#define INTL_CPPSHIMS_H
+
+#ifndef __cplusplus
+#error For inclusion form C++ files only
+#endif
+
+#ifdef _MSC_VER
+//This is only required for old versions of ICU only
+#include <stdio.h>
+
+#include <math.h>
+
+/* avoid redefinition of int8_t, also defined in unicode/pwin32.h */
+#define _MSC_STDINT_H_ 1
+#endif
+
+#endif \ No newline at end of file
diff --git a/ext/intl/intl_error.c b/ext/intl/intl_error.c
index 9c2e13d..2c7066b 100755
--- a/ext/intl/intl_error.c
+++ b/ext/intl/intl_error.c
@@ -21,12 +21,15 @@
#endif
#include <php.h>
+#include <zend_exceptions.h>
#include "php_intl.h"
#include "intl_error.h"
ZEND_EXTERN_MODULE_GLOBALS( intl )
+static zend_class_entry *IntlException_ce_ptr;
+
/* {{{ intl_error* intl_g_error_get()
* Return global error structure.
*/
@@ -102,8 +105,11 @@ void intl_error_set_custom_msg( intl_error* err, char* msg, int copyMsg TSRMLS_D
if( !msg )
return;
- if(!err && INTL_G(error_level)) {
- php_error_docref(NULL TSRMLS_CC, INTL_G(error_level), "%s", msg);
+ if( !err ) {
+ if( INTL_G( error_level ) )
+ php_error_docref( NULL TSRMLS_CC, INTL_G( error_level ), "%s", msg );
+ if( INTL_G( use_exceptions ) )
+ zend_throw_exception_ex( IntlException_ce_ptr, 0 TSRMLS_CC, "%s", msg );
}
if( !err && !( err = intl_g_error_get( TSRMLS_C ) ) )
return;
@@ -223,6 +229,21 @@ void intl_errors_set_code( intl_error* err, UErrorCode err_code TSRMLS_DC )
}
/* }}} */
+void intl_register_IntlException_class( TSRMLS_D )
+{
+ zend_class_entry ce,
+ *default_exception_ce;
+
+ default_exception_ce = zend_exception_get_default( TSRMLS_C );
+
+ /* Create and register 'IntlException' class. */
+ INIT_CLASS_ENTRY_EX( ce, "IntlException", sizeof( "IntlException" ) - 1, NULL );
+ IntlException_ce_ptr = zend_register_internal_class_ex( &ce,
+ default_exception_ce, NULL TSRMLS_CC );
+ IntlException_ce_ptr->create_object = default_exception_ce->create_object;
+}
+/* }}} */
+
/*
* Local variables:
* tab-width: 4
diff --git a/ext/intl/intl_error.h b/ext/intl/intl_error.h
index 3adae85..b5000a1 100755
--- a/ext/intl/intl_error.h
+++ b/ext/intl/intl_error.h
@@ -44,4 +44,7 @@ void intl_errors_set_custom_msg( intl_error* err, char* msg, int copyMsg
void intl_errors_set_code( intl_error* err, UErrorCode err_code TSRMLS_DC );
void intl_errors_set( intl_error* err, UErrorCode code, char* msg, int copyMsg TSRMLS_DC );
+// exported to be called on extension MINIT
+void intl_register_IntlException_class( TSRMLS_D );
+
#endif // INTL_ERROR_H
diff --git a/ext/intl/locale/locale.h b/ext/intl/locale/locale.h
index f3859c7..0aaab4b 100755
--- a/ext/intl/locale/locale.h
+++ b/ext/intl/locale/locale.h
@@ -22,6 +22,8 @@
#include <php.h>
void locale_register_constants( INIT_FUNC_ARGS );
+
+const char *intl_locale_get_default( TSRMLS_D );
#define OPTION_DEFAULT NULL
#define LOC_LANG_TAG "language"
diff --git a/ext/intl/locale/locale_methods.c b/ext/intl/locale/locale_methods.c
index 1707c69..466dba1 100755
--- a/ext/intl/locale/locale_methods.c
+++ b/ext/intl/locale/locale_methods.c
@@ -201,6 +201,14 @@ static int getSingletonPos(char* str)
}
/* }}} */
+const char *intl_locale_get_default( TSRMLS_D )
+{
+ if( INTL_G(default_locale) == NULL ) {
+ return uloc_getDefault();
+ }
+ return INTL_G(default_locale);
+}
+
/* {{{ proto static string Locale::getDefault( )
Get default locale */
/* }}} */
@@ -208,10 +216,7 @@ static int getSingletonPos(char* str)
Get default locale */
PHP_NAMED_FUNCTION(zif_locale_get_default)
{
- if( INTL_G(default_locale) == NULL ) {
- INTL_G(default_locale) = pestrdup( uloc_getDefault(), 1);
- }
- RETURN_STRING( INTL_G(default_locale), TRUE );
+ RETURN_STRING( intl_locale_get_default( TSRMLS_C ), TRUE );
}
/* }}} */
diff --git a/ext/intl/msgformat/msgformat_attr.c b/ext/intl/msgformat/msgformat_attr.c
index ed2dae2..c333a24 100755
--- a/ext/intl/msgformat/msgformat_attr.c
+++ b/ext/intl/msgformat/msgformat_attr.c
@@ -102,6 +102,12 @@ PHP_FUNCTION( msgfmt_set_pattern )
}
mfo->mf_data.orig_format = estrndup(value, value_len);
mfo->mf_data.orig_format_len = value_len;
+ /* invalidate cached format types */
+ if (mfo->mf_data.arg_types) {
+ zend_hash_destroy(mfo->mf_data.arg_types);
+ efree(mfo->mf_data.arg_types);
+ mfo->mf_data.arg_types = NULL;
+ }
RETURN_TRUE;
}
diff --git a/ext/intl/msgformat/msgformat_data.c b/ext/intl/msgformat/msgformat_data.c
index 527c1d4..5d49054 100755
--- a/ext/intl/msgformat/msgformat_data.c
+++ b/ext/intl/msgformat/msgformat_data.c
@@ -31,8 +31,10 @@ void msgformat_data_init( msgformat_data* mf_data TSRMLS_DC )
if( !mf_data )
return;
- mf_data->umsgf = NULL;
- mf_data->orig_format = NULL;
+ mf_data->umsgf = NULL;
+ mf_data->orig_format = NULL;
+ mf_data->arg_types = NULL;
+ mf_data->tz_set = 0;
intl_error_reset( &mf_data->error TSRMLS_CC );
}
/* }}} */
@@ -40,21 +42,27 @@ void msgformat_data_init( msgformat_data* mf_data TSRMLS_DC )
/* {{{ void msgformat_data_free( msgformat_data* mf_data )
* Clean up memory allocated for msgformat_data
*/
-void msgformat_data_free( msgformat_data* mf_data TSRMLS_DC )
+void msgformat_data_free(msgformat_data* mf_data TSRMLS_DC)
{
- if( !mf_data )
+ if (!mf_data)
return;
- if( mf_data->umsgf )
- umsg_close( mf_data->umsgf );
+ if (mf_data->umsgf)
+ umsg_close(mf_data->umsgf);
- if(mf_data->orig_format) {
+ if (mf_data->orig_format) {
efree(mf_data->orig_format);
mf_data->orig_format = NULL;
}
+ if (mf_data->arg_types) {
+ zend_hash_destroy(mf_data->arg_types);
+ efree(mf_data->arg_types);
+ mf_data->arg_types = NULL;
+ }
+
mf_data->umsgf = NULL;
- intl_error_reset( &mf_data->error TSRMLS_CC );
+ intl_error_reset(&mf_data->error TSRMLS_CC);
}
/* }}} */
diff --git a/ext/intl/msgformat/msgformat_data.h b/ext/intl/msgformat/msgformat_data.h
index 6479888..51d7687 100755
--- a/ext/intl/msgformat/msgformat_data.h
+++ b/ext/intl/msgformat/msgformat_data.h
@@ -31,6 +31,8 @@ typedef struct {
UMessageFormat* umsgf;
char* orig_format;
ulong orig_format_len;
+ HashTable* arg_types;
+ int tz_set; /* if we've already the time zone in sub-formats */
} msgformat_data;
msgformat_data* msgformat_data_create( TSRMLS_D );
diff --git a/ext/intl/msgformat/msgformat_format.c b/ext/intl/msgformat/msgformat_format.c
index 9a18ac0..3965232 100755
--- a/ext/intl/msgformat/msgformat_format.c
+++ b/ext/intl/msgformat/msgformat_format.c
@@ -32,51 +32,34 @@
#endif
/* {{{ */
-static void msgfmt_do_format(MessageFormatter_object *mfo, zval *args, zval *return_value TSRMLS_DC)
+static void msgfmt_do_format(MessageFormatter_object *mfo, zval *args, zval *return_value TSRMLS_DC)
{
- zval **fargs;
int count;
UChar* formatted = NULL;
int formatted_len = 0;
- HashPosition pos;
- int i;
+ HashTable *args_copy;
count = zend_hash_num_elements(Z_ARRVAL_P(args));
- if(count < umsg_format_arg_count(MSG_FORMAT_OBJECT(mfo))) {
- /* Not enough aguments for format! */
- intl_error_set( INTL_DATA_ERROR_P(mfo), U_ILLEGAL_ARGUMENT_ERROR,
- "msgfmt_format: not enough parameters", 0 TSRMLS_CC );
- RETVAL_FALSE;
- return;
- }
-
- fargs = safe_emalloc(count, sizeof(zval *), 0);
+ ALLOC_HASHTABLE(args_copy);
+ zend_hash_init(args_copy, count, NULL, ZVAL_PTR_DTOR, 0);
+ zend_hash_copy(args_copy, Z_ARRVAL_P(args), (copy_ctor_func_t)zval_add_ref,
+ NULL, sizeof(zval*));
- zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(args), &pos);
- for(i=0;i<count;i++) {
- zval **val;
- zend_hash_get_current_data_ex(Z_ARRVAL_P(args), (void **)&val, &pos);
- fargs[i] = *val;
- Z_ADDREF_P(fargs[i]);
- /* TODO: needs refcount increase here? */
- zend_hash_move_forward_ex(Z_ARRVAL_P(args), &pos);
- }
+ umsg_format_helper(mfo, args_copy, &formatted, &formatted_len TSRMLS_CC);
- umsg_format_helper(MSG_FORMAT_OBJECT(mfo), count, fargs, &formatted, &formatted_len, &INTL_DATA_ERROR_CODE(mfo) TSRMLS_CC);
-
- for(i=0;i<count;i++) {
- zval_ptr_dtor(&fargs[i]);
- }
+ zend_hash_destroy(args_copy);
+ efree(args_copy);
- efree(fargs);
-
- if (formatted && U_FAILURE( INTL_DATA_ERROR_CODE(mfo) ) ) {
+ if (formatted && U_FAILURE(INTL_DATA_ERROR_CODE(mfo))) {
efree(formatted);
}
- INTL_METHOD_CHECK_STATUS( mfo, "Number formatting failed" );
- INTL_METHOD_RETVAL_UTF8( mfo, formatted, formatted_len, 1 );
+ if (U_FAILURE(INTL_DATA_ERROR_CODE(mfo))) {
+ RETURN_FALSE;
+ } else {
+ INTL_METHOD_RETVAL_UTF8(mfo, formatted, formatted_len, 1);
+ }
}
/* }}} */
diff --git a/ext/intl/msgformat/msgformat_helpers.cpp b/ext/intl/msgformat/msgformat_helpers.cpp
index 1895de2..fd8df1a 100755
--- a/ext/intl/msgformat/msgformat_helpers.cpp
+++ b/ext/intl/msgformat/msgformat_helpers.cpp
@@ -18,9 +18,19 @@
#include "config.h"
#endif
-#include <math.h>
+#include "../intl_cppshims.h"
+
+#include <limits.h>
#include <unicode/msgfmt.h>
#include <unicode/chariter.h>
+#include <unicode/ustdio.h>
+#include <unicode/timezone.h>
+#include <unicode/datefmt.h>
+#include <unicode/calendar.h>
+
+#include <vector>
+
+#include "../intl_convertcpp.h"
extern "C" {
#include "php_intl.h"
@@ -28,8 +38,27 @@ extern "C" {
#include "msgformat_format.h"
#include "msgformat_helpers.h"
#include "intl_convert.h"
+#define USE_CALENDAR_POINTER 1
+#include "../calendar/calendar_class.h"
+/* avoid redefinition of int8_t, already defined in unicode/pwin32.h */
+#define _MSC_STDINT_H_ 1
+#include "ext/date/php_date.h"
+#define USE_TIMEZONE_POINTER
+#include "../timezone/timezone_class.h"
}
+#ifndef INFINITY
+#define INFINITY (DBL_MAX+DBL_MAX)
+#endif
+
+#ifndef NAN
+#define NAN (INFINITY-INFINITY)
+#endif
+
+#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 48
+#define HAS_MESSAGE_PATTERN 1
+#endif
+
U_NAMESPACE_BEGIN
/**
* This class isolates our access to private internal methods of
@@ -40,96 +69,638 @@ class MessageFormatAdapter {
public:
static const Formattable::Type* getArgTypeList(const MessageFormat& m,
int32_t& count);
+#ifdef HAS_MESSAGE_PATTERN
+ static const MessagePattern getMessagePattern(MessageFormat* m);
+#endif
};
+
const Formattable::Type*
MessageFormatAdapter::getArgTypeList(const MessageFormat& m,
int32_t& count) {
return m.getArgTypeList(count);
}
+
+#ifdef HAS_MESSAGE_PATTERN
+const MessagePattern
+MessageFormatAdapter::getMessagePattern(MessageFormat* m) {
+ return m->msgPattern;
+}
+#endif
U_NAMESPACE_END
-U_CFUNC int32_t umsg_format_arg_count(UMessageFormat *fmt)
+U_CFUNC int32_t umsg_format_arg_count(UMessageFormat *fmt)
{
int32_t fmt_count = 0;
MessageFormatAdapter::getArgTypeList(*(const MessageFormat*)fmt, fmt_count);
return fmt_count;
}
-U_CFUNC void umsg_format_helper(UMessageFormat *fmt, int arg_count, zval **args, UChar **formatted, int *formatted_len, UErrorCode *status TSRMLS_DC)
+static double umsg_helper_zval_to_millis(zval *z, UErrorCode *status TSRMLS_DC) {
+ double rv = NAN;
+ long lv;
+ int type;
+
+ if (U_FAILURE(*status)) {
+ return NAN;
+ }
+
+ switch (Z_TYPE_P(z)) {
+ case IS_STRING:
+ type = is_numeric_string(Z_STRVAL_P(z), Z_STRLEN_P(z), &lv, &rv, 0);
+ if (type == IS_DOUBLE) {
+ rv *= U_MILLIS_PER_SECOND;
+ } else if (type == IS_LONG) {
+ rv = U_MILLIS_PER_SECOND * (double)lv;
+ } else {
+ *status = U_ILLEGAL_ARGUMENT_ERROR;
+ }
+ break;
+ case IS_LONG:
+ rv = U_MILLIS_PER_SECOND * (double)Z_LVAL_P(z);
+ break;
+ case IS_DOUBLE:
+ rv = U_MILLIS_PER_SECOND * Z_DVAL_P(z);
+ break;
+ case IS_OBJECT:
+ if (instanceof_function(Z_OBJCE_P(z), php_date_get_date_ce() TSRMLS_CC)) {
+ zval retval;
+ zval *zfuncname;
+ INIT_ZVAL(retval);
+ MAKE_STD_ZVAL(zfuncname);
+ ZVAL_STRING(zfuncname, "getTimestamp", 1);
+ if (call_user_function(NULL, &(z), zfuncname, &retval, 0, NULL TSRMLS_CC)
+ != SUCCESS || Z_TYPE(retval) != IS_LONG) {
+ *status = U_INTERNAL_PROGRAM_ERROR;
+ } else {
+ rv = U_MILLIS_PER_SECOND * (double)Z_LVAL(retval);
+ }
+ zval_ptr_dtor(&zfuncname);
+ } else if (instanceof_function(Z_OBJCE_P(z), Calendar_ce_ptr TSRMLS_CC)) {
+ Calendar_object *co = (Calendar_object *)
+ zend_object_store_get_object(z TSRMLS_CC );
+ if (co->ucal == NULL) {
+ *status = U_ILLEGAL_ARGUMENT_ERROR;
+ } else {
+ rv = (double)co->ucal->getTime(*status);
+ }
+ } else {
+ /* TODO: try with cast(), get() to obtain a number */
+ *status = U_ILLEGAL_ARGUMENT_ERROR;
+ }
+ break;
+ default:
+ *status = U_ILLEGAL_ARGUMENT_ERROR;
+ }
+
+ return rv;
+}
+
+static HashTable *umsg_get_numeric_types(MessageFormatter_object *mfo,
+ intl_error& err TSRMLS_DC)
{
- int fmt_count = 0;
- const Formattable::Type* argTypes =
- MessageFormatAdapter::getArgTypeList(*(const MessageFormat*)fmt, fmt_count);
- Formattable* fargs = new Formattable[fmt_count ? fmt_count : 1];
+ HashTable *ret;
+ int32_t parts_count;
- for(int32_t i = 0; i < fmt_count; ++i) {
- UChar *stringVal = NULL;
- int stringLen = 0;
- int64_t tInt64 = 0;
+ if (U_FAILURE(err.code)) {
+ return NULL;
+ }
- switch(argTypes[i]) {
- case Formattable::kDate:
- convert_to_long_ex(&args[i]);
- fargs[i].setDate(U_MILLIS_PER_SECOND * (double)Z_LVAL_P(args[i]));
- break;
+ if (mfo->mf_data.arg_types) {
+ /* already cached */
+ return mfo->mf_data.arg_types;
+ }
- case Formattable::kDouble:
- convert_to_double_ex(&args[i]);
- fargs[i].setDouble(Z_DVAL_P(args[i]));
- break;
-
- case Formattable::kLong:
- convert_to_long_ex(&args[i]);
- fargs[i].setLong(Z_LVAL_P(args[i]));
- break;
+ const Formattable::Type *types = MessageFormatAdapter::getArgTypeList(
+ *(MessageFormat*)mfo->mf_data.umsgf, parts_count);
+
+ /* Hash table will store Formattable::Type objects directly,
+ * so no need for destructor */
+ ALLOC_HASHTABLE(ret);
+ zend_hash_init(ret, parts_count, NULL, NULL, 0);
+
+ for (int i = 0; i < parts_count; i++) {
+ const Formattable::Type t = types[i];
+ if (zend_hash_index_update(ret, (ulong)i, (void*)&t, sizeof(t), NULL)
+ == FAILURE) {
+ intl_errors_set(&err, U_MEMORY_ALLOCATION_ERROR,
+ "Write to argument types hash table failed", 0 TSRMLS_CC);
+ break;
+ }
+ }
- case Formattable::kInt64:
- if(Z_TYPE_P(args[i]) == IS_DOUBLE) {
- tInt64 = (int64_t)Z_DVAL_P(args[i]);
- } else if(Z_TYPE_P(args[i]) == IS_LONG) {
- tInt64 = (int64_t)Z_LVAL_P(args[i]);
+ if (U_FAILURE(err.code)) {
+ zend_hash_destroy(ret);
+ efree(ret);
+
+ return NULL;
+ }
+
+ mfo->mf_data.arg_types = ret;
+
+ return ret;
+}
+
+#ifdef HAS_MESSAGE_PATTERN
+static HashTable *umsg_parse_format(MessageFormatter_object *mfo,
+ const MessagePattern& mp,
+ intl_error& err TSRMLS_DC)
+{
+ HashTable *ret;
+ int32_t parts_count;
+
+ if (U_FAILURE(err.code)) {
+ return NULL;
+ }
+
+ if (!((MessageFormat *)mfo->mf_data.umsgf)->usesNamedArguments()) {
+ return umsg_get_numeric_types(mfo, err TSRMLS_CC);
+ }
+
+ if (mfo->mf_data.arg_types) {
+ /* already cached */
+ return mfo->mf_data.arg_types;
+ }
+
+ /* Hash table will store Formattable::Type objects directly,
+ * so no need for destructor */
+ ALLOC_HASHTABLE(ret);
+ zend_hash_init(ret, 32, NULL, NULL, 0);
+
+ parts_count = mp.countParts();
+
+ // See MessageFormat::cacheExplicitFormats()
+ /*
+ * Looking through the pattern, go to each arg_start part type.
+ * The arg-typeof that tells us the argument type (simple, complicated)
+ * then the next part is either the arg_name or arg number
+ * and then if it's simple after that there could be a part-type=arg-type
+ * while substring will tell us number, spellout, etc.
+ * If the next thing isn't an arg-type then assume string.
+ */
+ /* The last two "parts" can at most be ARG_LIMIT and MSG_LIMIT
+ * which we need not examine. */
+ for (int32_t i = 0; i < parts_count - 2 && U_SUCCESS(err.code); i++) {
+ MessagePattern::Part p = mp.getPart(i);
+
+ if (p.getType() != UMSGPAT_PART_TYPE_ARG_START) {
+ continue;
+ }
+
+ MessagePattern::Part name_part = mp.getPart(++i); /* Getting name, advancing i */
+ Formattable::Type type,
+ *storedType;
+
+ if (name_part.getType() == UMSGPAT_PART_TYPE_ARG_NAME) {
+ UnicodeString argName = mp.getSubstring(name_part);
+ if (zend_hash_find(ret, (char*)argName.getBuffer(), argName.length(),
+ (void**)&storedType) == FAILURE) {
+ /* not found already; create new entry in HT */
+ Formattable::Type bogusType = Formattable::kObject;
+ if (zend_hash_update(ret, (char*)argName.getBuffer(), argName.length(),
+ (void*)&bogusType, sizeof(bogusType), (void**)&storedType) == FAILURE) {
+ intl_errors_set(&err, U_MEMORY_ALLOCATION_ERROR,
+ "Write to argument types hash table failed", 0 TSRMLS_CC);
+ continue;
+ }
+ }
+ } else if (name_part.getType() == UMSGPAT_PART_TYPE_ARG_NUMBER) {
+ int32_t argNumber = name_part.getValue();
+ if (argNumber < 0) {
+ intl_errors_set(&err, U_INVALID_FORMAT_ERROR,
+ "Found part with negative number", 0 TSRMLS_CC);
+ continue;
+ }
+ if (zend_hash_index_find(ret, (ulong)argNumber, (void**)&storedType)
+ == FAILURE) {
+ /* not found already; create new entry in HT */
+ Formattable::Type bogusType = Formattable::kObject;
+ if (zend_hash_index_update(ret, (ulong)argNumber, (void*)&bogusType,
+ sizeof(bogusType), (void**)&storedType) == FAILURE) {
+ intl_errors_set(&err, U_MEMORY_ALLOCATION_ERROR,
+ "Write to argument types hash table failed", 0 TSRMLS_CC);
+ continue;
+ }
+ }
+ }
+
+ UMessagePatternArgType argType = p.getArgType();
+ /* No type specified, treat it as a string */
+ if (argType == UMSGPAT_ARG_TYPE_NONE) {
+ type = Formattable::kString;
+ } else { /* Some type was specified, might be simple or complicated */
+ if (argType == UMSGPAT_ARG_TYPE_SIMPLE) {
+ /* For a SIMPLE arg, after the name part, there should be
+ * an ARG_TYPE part whose string value tells us what to do */
+ MessagePattern::Part type_part = mp.getPart(++i); /* Getting type, advancing i */
+ if (type_part.getType() == UMSGPAT_PART_TYPE_ARG_TYPE) {
+ UnicodeString typeString = mp.getSubstring(type_part);
+ /* This is all based on the rules in the docs for MessageFormat
+ * @see http://icu-project.org/apiref/icu4c/classMessageFormat.html */
+ if (typeString == "number") {
+ MessagePattern::Part style_part = mp.getPart(i + 1); /* Not advancing i */
+ if (style_part.getType() == UMSGPAT_PART_TYPE_ARG_STYLE) {
+ UnicodeString styleString = mp.getSubstring(style_part);
+ if (styleString == "integer") {
+ type = Formattable::kInt64;
+ } else if (styleString == "currency") {
+ type = Formattable::kDouble;
+ } else if (styleString == "percent") {
+ type = Formattable::kDouble;
+ } else { /* some style invalid/unknown to us */
+ type = Formattable::kDouble;
+ }
+ } else { // if missing style, part, make it a double
+ type = Formattable::kDouble;
+ }
+ } else if ((typeString == "date") || (typeString == "time")) {
+ type = Formattable::kDate;
+ } else if ((typeString == "spellout") || (typeString == "ordinal")
+ || (typeString == "duration")) {
+ type = Formattable::kDouble;
+ }
} else {
- SEPARATE_ZVAL_IF_NOT_REF(&args[i]);
- convert_scalar_to_number( args[i] TSRMLS_CC );
- tInt64 = (Z_TYPE_P(args[i]) == IS_DOUBLE)?(int64_t)Z_DVAL_P(args[i]):Z_LVAL_P(args[i]);
+ /* If there's no UMSGPAT_PART_TYPE_ARG_TYPE right after a
+ * UMSGPAT_ARG_TYPE_SIMPLE argument, then the pattern
+ * is broken. */
+ intl_errors_set(&err, U_PARSE_ERROR,
+ "Expected UMSGPAT_PART_TYPE_ARG_TYPE part following "
+ "UMSGPAT_ARG_TYPE_SIMPLE part", 0 TSRMLS_CC);
+ continue;
}
- fargs[i].setInt64(tInt64);
+ } else if (argType == UMSGPAT_ARG_TYPE_PLURAL) {
+ type = Formattable::kDouble;
+ } else if (argType == UMSGPAT_ARG_TYPE_CHOICE) {
+ type = Formattable::kDouble;
+ } else if (argType == UMSGPAT_ARG_TYPE_SELECT) {
+ type = Formattable::kString;
+ } else {
+ type = Formattable::kString;
+ }
+ } /* was type specified? */
+
+ /* We found a different type for the same arg! */
+ if (*storedType != Formattable::kObject && *storedType != type) {
+ intl_errors_set(&err, U_ARGUMENT_TYPE_MISMATCH,
+ "Inconsistent types declared for an argument", 0 TSRMLS_CC);
+ continue;
+ }
+
+ *storedType = type;
+ } /* visiting each part */
+
+ if (U_FAILURE(err.code)) {
+ zend_hash_destroy(ret);
+ efree(ret);
+
+ return NULL;
+ }
+
+ mfo->mf_data.arg_types = ret;
+
+ return ret;
+}
+#endif
+
+static HashTable *umsg_get_types(MessageFormatter_object *mfo,
+ intl_error& err TSRMLS_DC)
+{
+ MessageFormat *mf = (MessageFormat *)mfo->mf_data.umsgf;
+
+#ifdef HAS_MESSAGE_PATTERN
+ const MessagePattern mp = MessageFormatAdapter::getMessagePattern(mf);
+
+ return umsg_parse_format(mfo, mp, err TSRMLS_CC);
+#else
+ if (mf->usesNamedArguments()) {
+ intl_errors_set(&err, U_UNSUPPORTED_ERROR,
+ "This extension supports named arguments only on ICU 4.8+",
+ 0 TSRMLS_CC);
+ return NULL;
+ }
+ return umsg_get_numeric_types(mfo, err TSRMLS_CC);
+#endif
+}
+
+static void umsg_set_timezone(MessageFormatter_object *mfo,
+ intl_error& err TSRMLS_DC)
+{
+ MessageFormat *mf = (MessageFormat *)mfo->mf_data.umsgf;
+ TimeZone *used_tz = NULL;
+ const Format **formats;
+ int32_t count;
+
+ /* Unfortanely, this cannot change the time zone for arguments that
+ * appear inside complex formats because ::getFormats() returns NULL
+ * for all uncached formats, which is the case for complex formats
+ * unless they were set via one of the ::setFormat() methods */
+
+ if (mfo->mf_data.tz_set) {
+ return; /* already done */
+ }
+
+ formats = mf->getFormats(count);
+
+ if (formats == NULL) {
+ intl_errors_set(&err, U_MEMORY_ALLOCATION_ERROR,
+ "Out of memory retrieving subformats", 0 TSRMLS_CC);
+ }
+
+ for (int i = 0; U_SUCCESS(err.code) && i < count; i++) {
+ DateFormat* df = dynamic_cast<DateFormat*>(
+ const_cast<Format *>(formats[i]));
+ if (df == NULL) {
+ continue;
+ }
+
+ if (used_tz == NULL) {
+ zval nullzv = zval_used_for_init,
+ *zvptr = &nullzv;
+ used_tz = timezone_process_timezone_argument(&zvptr, &err,
+ "msgfmt_format" TSRMLS_CC);
+ if (used_tz == NULL) {
+ continue;
+ }
+ }
+
+ df->setTimeZone(*used_tz);
+ }
+
+ if (U_SUCCESS(err.code)) {
+ mfo->mf_data.tz_set = 1;
+ }
+}
+
+U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo,
+ HashTable *args,
+ UChar **formatted,
+ int *formatted_len TSRMLS_DC)
+{
+ int arg_count = zend_hash_num_elements(args);
+ std::vector<Formattable> fargs;
+ std::vector<UnicodeString> farg_names;
+ MessageFormat *mf = (MessageFormat *)mfo->mf_data.umsgf;
+ HashTable *types;
+ intl_error& err = INTL_DATA_ERROR(mfo);
+
+ if (U_FAILURE(err.code)) {
+ return;
+ }
+
+ types = umsg_get_types(mfo, err TSRMLS_CC);
+
+ umsg_set_timezone(mfo, err TSRMLS_CC);
+
+ fargs.resize(arg_count);
+ farg_names.resize(arg_count);
+
+ int argNum = 0;
+ HashPosition pos;
+ zval **elem;
+
+ // Key related variables
+ int key_type;
+ char *str_index;
+ uint str_len;
+ ulong num_index;
+
+ for (zend_hash_internal_pointer_reset_ex(args, &pos);
+ U_SUCCESS(err.code) &&
+ (key_type = zend_hash_get_current_key_ex(
+ args, &str_index, &str_len, &num_index, 0, &pos),
+ zend_hash_get_current_data_ex(args, (void **)&elem, &pos)
+ ) == SUCCESS;
+ zend_hash_move_forward_ex(args, &pos), argNum++)
+ {
+ Formattable& formattable = fargs[argNum];
+ UnicodeString& key = farg_names[argNum];
+ Formattable::Type argType = Formattable::kObject, //unknown
+ *storedArgType = NULL;
+
+ /* Process key and retrieve type */
+ if (key_type == HASH_KEY_IS_LONG) {
+ /* includes case where index < 0 because it's exposed as unsigned */
+ if (num_index > (ulong)INT32_MAX) {
+ intl_errors_set(&err, U_ILLEGAL_ARGUMENT_ERROR,
+ "Found negative or too large array key", 0 TSRMLS_CC);
+ continue;
+ }
+
+ UChar temp[16];
+ int32_t len = u_sprintf(temp, "%u", (uint32_t)num_index);
+ key.append(temp, len);
+
+ zend_hash_index_find(types, (ulong)num_index, (void**)&storedArgType);
+ } else { //string; assumed to be in UTF-8
+ intl_stringFromChar(key, str_index, str_len-1, &err.code);
+
+ if (U_FAILURE(err.code)) {
+ char *message;
+ spprintf(&message, 0,
+ "Invalid UTF-8 data in argument key: '%s'", str_index);
+ intl_errors_set(&err, err.code, message, 1 TSRMLS_CC);
+ efree(message);
+ continue;
+ }
+
+ zend_hash_find(types, (char*)key.getBuffer(), key.length(),
+ (void**)&storedArgType);
+ }
+
+ if (storedArgType != NULL) {
+ argType = *storedArgType;
+ }
+
+ /* Convert zval to formattable according to message format type
+ * or (as a fallback) the zval type */
+ if (argType != Formattable::kObject) {
+ switch (argType) {
+ case Formattable::kString:
+ {
+ string_arg:
+ /* This implicitly converts objects
+ * Note that our vectors will leak if object conversion fails
+ * and PHP ends up with a fatal error and calls longjmp
+ * as a result of that.
+ */
+ convert_to_string_ex(elem);
+
+ UnicodeString *text = new UnicodeString();
+ intl_stringFromChar(*text,
+ Z_STRVAL_PP(elem), Z_STRLEN_PP(elem), &err.code);
+
+ if (U_FAILURE(err.code)) {
+ char *message;
+ spprintf(&message, 0, "Invalid UTF-8 data in string argument: "
+ "'%s'", Z_STRVAL_PP(elem));
+ intl_errors_set(&err, err.code, message, 1 TSRMLS_CC);
+ efree(message);
+ delete text;
+ continue;
+ }
+ formattable.adoptString(text);
+ break;
+ }
+ case Formattable::kDouble:
+ {
+ double d;
+ if (Z_TYPE_PP(elem) == IS_DOUBLE) {
+ d = Z_DVAL_PP(elem);
+ } else if (Z_TYPE_PP(elem) == IS_LONG) {
+ d = (double)Z_LVAL_PP(elem);
+ } else {
+ SEPARATE_ZVAL_IF_NOT_REF(elem);
+ convert_scalar_to_number(*elem TSRMLS_CC);
+ d = (Z_TYPE_PP(elem) == IS_DOUBLE)
+ ? Z_DVAL_PP(elem)
+ : (double)Z_LVAL_PP(elem);
+ }
+ formattable.setDouble(d);
+ break;
+ }
+ case Formattable::kLong:
+ {
+ int32_t tInt32;
+retry_klong:
+ if (Z_TYPE_PP(elem) == IS_DOUBLE) {
+ if (Z_DVAL_PP(elem) > (double)INT32_MAX ||
+ Z_DVAL_PP(elem) < (double)INT32_MIN) {
+ intl_errors_set(&err, U_ILLEGAL_ARGUMENT_ERROR,
+ "Found PHP float with absolute value too large for "
+ "32 bit integer argument", 0 TSRMLS_CC);
+ } else {
+ tInt32 = (int32_t)Z_DVAL_PP(elem);
+ }
+ } else if (Z_TYPE_PP(elem) == IS_LONG) {
+ if (Z_LVAL_PP(elem) > INT32_MAX ||
+ Z_LVAL_PP(elem) < INT32_MIN) {
+ intl_errors_set(&err, U_ILLEGAL_ARGUMENT_ERROR,
+ "Found PHP integer with absolute value too large "
+ "for 32 bit integer argument", 0 TSRMLS_CC);
+ } else {
+ tInt32 = (int32_t)Z_LVAL_PP(elem);
+ }
+ } else {
+ SEPARATE_ZVAL_IF_NOT_REF(elem);
+ convert_scalar_to_number(*elem TSRMLS_CC);
+ goto retry_klong;
+ }
+ formattable.setLong(tInt32);
+ break;
+ }
+ case Formattable::kInt64:
+ {
+ int64_t tInt64;
+retry_kint64:
+ if (Z_TYPE_PP(elem) == IS_DOUBLE) {
+ if (Z_DVAL_PP(elem) > (double)U_INT64_MAX ||
+ Z_DVAL_PP(elem) < (double)U_INT64_MIN) {
+ intl_errors_set(&err, U_ILLEGAL_ARGUMENT_ERROR,
+ "Found PHP float with absolute value too large for "
+ "64 bit integer argument", 0 TSRMLS_CC);
+ } else {
+ tInt64 = (int64_t)Z_DVAL_PP(elem);
+ }
+ } else if (Z_TYPE_PP(elem) == IS_LONG) {
+ /* assume long is not wider than 64 bits */
+ tInt64 = (int64_t)Z_LVAL_PP(elem);
+ } else {
+ SEPARATE_ZVAL_IF_NOT_REF(elem);
+ convert_scalar_to_number(*elem TSRMLS_CC);
+ goto retry_kint64;
+ }
+ formattable.setInt64(tInt64);
+ break;
+ }
+ case Formattable::kDate:
+ {
+ double dd = umsg_helper_zval_to_millis(*elem, &err.code TSRMLS_CC);
+ if (U_FAILURE(err.code)) {
+ char *message, *key_char;
+ int key_len;
+ UErrorCode status = UErrorCode();
+ if (intl_charFromString(key, &key_char, &key_len,
+ &status) == SUCCESS) {
+ spprintf(&message, 0, "The argument for key '%s' "
+ "cannot be used as a date or time", key_char);
+ intl_errors_set(&err, err.code, message, 1 TSRMLS_CC);
+ efree(key_char);
+ efree(message);
+ }
+ continue;
+ }
+ formattable.setDate(dd);
+ break;
+ }
+ default:
+ intl_errors_set(&err, U_ILLEGAL_ARGUMENT_ERROR,
+ "Found unsupported argument type", 0 TSRMLS_CC);
break;
-
- case Formattable::kString:
- convert_to_string_ex(&args[i]);
- intl_convert_utf8_to_utf16(&stringVal, &stringLen, Z_STRVAL_P(args[i]), Z_STRLEN_P(args[i]), status);
- if(U_FAILURE(*status)){
- delete[] fargs;
- return;
+ }
+ } else {
+ /* We couldn't find any information about the argument in the pattern, this
+ * means it's an extra argument. So convert it to a number if it's a number or
+ * bool or null and to a string if it's anything else except arrays . */
+ switch (Z_TYPE_PP(elem)) {
+ case IS_DOUBLE:
+ formattable.setDouble(Z_DVAL_PP(elem));
+ break;
+ case IS_BOOL:
+ convert_to_long_ex(elem);
+ /* Intentional fallthrough */
+ case IS_LONG:
+ formattable.setInt64((int64_t)Z_LVAL_PP(elem));
+ break;
+ case IS_NULL:
+ formattable.setInt64((int64_t)0);
+ break;
+ case IS_STRING:
+ case IS_OBJECT:
+ goto string_arg;
+ default:
+ {
+ char *message, *key_char;
+ int key_len;
+ UErrorCode status = UErrorCode();
+ if (intl_charFromString(key, &key_char, &key_len,
+ &status) == SUCCESS) {
+ spprintf(&message, 0, "No strategy to convert the "
+ "value given for the argument with key '%s' "
+ "is available", key_char);
+ intl_errors_set(&err,
+ U_ILLEGAL_ARGUMENT_ERROR, message, 1 TSRMLS_CC);
+ efree(key_char);
+ efree(message);
+ }
}
- fargs[i].setString(stringVal);
- efree(stringVal);
- break;
-
- case Formattable::kArray:
- case Formattable::kObject:
- *status = U_UNSUPPORTED_ERROR;
- delete[] fargs;
- return;
- }
+ }
+ }
+ } // visiting each argument
+
+ if (U_FAILURE(err.code)) {
+ return;
}
- UnicodeString resultStr;
- FieldPosition fieldPosition(0);
-
- /* format the message */
- ((const MessageFormat*)fmt)->format(fargs, fmt_count, resultStr, fieldPosition, *status);
+ UnicodeString resultStr;
+ FieldPosition fieldPosition(0);
- delete[] fargs;
+ /* format the message */
+ mf->format(farg_names.empty() ? NULL : &farg_names[0],
+ fargs.empty() ? NULL : &fargs[0], arg_count, resultStr, err.code);
- if(U_FAILURE(*status)){
- return;
- }
+ if (U_FAILURE(err.code)) {
+ intl_errors_set(&err, err.code,
+ "Call to ICU MessageFormat::format() has failed", 0 TSRMLS_CC);
+ return;
+ }
*formatted_len = resultStr.length();
*formatted = eumalloc(*formatted_len+1);
- resultStr.extract(*formatted, *formatted_len+1, *status);
+ resultStr.extract(*formatted, *formatted_len+1, err.code);
+ if (U_FAILURE(err.code)) {
+ intl_errors_set(&err, err.code,
+ "Error copying format() result", 0 TSRMLS_CC);
+ return;
+ }
}
#define cleanup_zvals() for(int j=i;j>=0;j--) { zval_ptr_dtor((*args)+i); }
@@ -154,15 +725,11 @@ U_CFUNC void umsg_parse_helper(UMessageFormat *fmt, int *count, zval ***args, UC
int stmp_len;
ALLOC_INIT_ZVAL((*args)[i]);
-
+
switch(fargs[i].getType()) {
case Formattable::kDate:
aDate = ((double)fargs[i].getDate())/U_MILLIS_PER_SECOND;
- if(aDate > LONG_MAX || aDate < -LONG_MAX) {
- ZVAL_DOUBLE((*args)[i], aDate<0?ceil(aDate):floor(aDate));
- } else {
- ZVAL_LONG((*args)[i], (long)aDate);
- }
+ ZVAL_DOUBLE((*args)[i], aDate);
break;
case Formattable::kDouble:
diff --git a/ext/intl/msgformat/msgformat_helpers.h b/ext/intl/msgformat/msgformat_helpers.h
index 30c7e39..e6eda08 100755
--- a/ext/intl/msgformat/msgformat_helpers.h
+++ b/ext/intl/msgformat/msgformat_helpers.h
@@ -17,9 +17,9 @@
#ifndef MSG_FORMAT_HELPERS_H
#define MSG_FORMAT_HELPERS_H
-int32_t umsg_format_arg_count(UMessageFormat *fmt);
-void umsg_format_helper(UMessageFormat *fmt, int arg_count, zval **args,
- UChar **formatted, int *formatted_len, UErrorCode *status TSRMLS_DC);
+int32_t umsg_format_arg_count(UMessageFormat *fmt);
+void umsg_format_helper(MessageFormatter_object *mfo, HashTable *args,
+ UChar **formatted, int *formatted_len TSRMLS_DC);
void umsg_parse_helper(UMessageFormat *fmt, int *count, zval ***args,
UChar *source, int source_len, UErrorCode *status);
#endif // MSG_FORMAT_HELPERS_H
diff --git a/ext/intl/php_intl.c b/ext/intl/php_intl.c
index efe0ddd..59272db 100755
--- a/ext/intl/php_intl.c
+++ b/ext/intl/php_intl.c
@@ -41,6 +41,8 @@
#include "formatter/formatter_main.h"
#include "formatter/formatter_parse.h"
+#include "grapheme/grapheme.h"
+
#include "msgformat/msgformat.h"
#include "msgformat/msgformat_class.h"
#include "msgformat/msgformat_attr.h"
@@ -58,6 +60,7 @@
#include "dateformat/dateformat.h"
#include "dateformat/dateformat_class.h"
#include "dateformat/dateformat_attr.h"
+#include "dateformat/dateformat_attrcpp.h"
#include "dateformat/dateformat_format.h"
#include "dateformat/dateformat_parse.h"
#include "dateformat/dateformat_data.h"
@@ -68,6 +71,13 @@
#include "transliterator/transliterator_class.h"
#include "transliterator/transliterator_methods.h"
+#include "timezone/timezone_class.h"
+#include "timezone/timezone_methods.h"
+
+#include "calendar/calendar_class.h"
+#include "calendar/calendar_methods.h"
+#include "calendar/gregoriancalendar_methods.h"
+
#include "idn/idn.h"
#if U_ICU_VERSION_MAJOR_NUM > 3 && U_ICU_VERSION_MINOR_NUM >=2
@@ -79,6 +89,7 @@
#include "msgformat/msgformat.h"
#include "common/common_error.h"
+#include "common/common_enum.h"
#include <unicode/uloc.h>
#include <ext/standard/info.h>
@@ -313,6 +324,11 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_datefmt_set_pattern, 0, 0, 2)
ZEND_ARG_INFO(0, pattern)
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO_EX(arginfo_datefmt_set_timezone, 0, 0, 2)
+ ZEND_ARG_INFO(0, mf)
+ ZEND_ARG_INFO(0, timezone)
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_INFO_EX(arginfo_datefmt_set_calendar, 0, 0, 2)
ZEND_ARG_INFO(0, mf)
ZEND_ARG_INFO(0, calendar)
@@ -402,6 +418,189 @@ ZEND_BEGIN_ARG_INFO_EX( arginfo_transliterator_error, 0, 0, 1 )
ZEND_ARG_OBJ_INFO( 0, trans, Transliterator, 0 )
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_idarg_static, 0, 0, 1 )
+ ZEND_ARG_INFO( 0, zoneId )
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_from_date_time_zone, 0, 0, 1 )
+ ZEND_ARG_OBJ_INFO( 0, dateTimeZone, IntlDateTimeZone, 0 )
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_create_enumeration, 0, 0, 0 )
+ ZEND_ARG_INFO( 0, countryOrRawOffset )
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_count_equivalent_ids, 0, 0, 1 )
+ ZEND_ARG_INFO( 0, zoneId )
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_create_time_zone_id_enumeration, 0, 0, 1 )
+ ZEND_ARG_INFO( 0, zoneType )
+ ZEND_ARG_INFO( 0, region )
+ ZEND_ARG_INFO( 0, rawOffset )
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_get_canonical_id, 0, 0, 1 )
+ ZEND_ARG_INFO( 0, zoneId )
+ ZEND_ARG_INFO( 1, isSystemID )
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_get_equivalent_id, 0, 0, 2 )
+ ZEND_ARG_INFO( 0, zoneId )
+ ZEND_ARG_INFO( 0, index )
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_get_offset, 0, 0, 5 )
+ ZEND_ARG_OBJ_INFO( 0, timeZone, IntlTimeZone, 0 )
+ ZEND_ARG_INFO( 0, date )
+ ZEND_ARG_INFO( 0, local )
+ ZEND_ARG_INFO( 1, rawOffset )
+ ZEND_ARG_INFO( 1, dstOffset )
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_has_same_rules, 0, 0, 1 )
+ ZEND_ARG_OBJ_INFO( 0, timeZone, IntlTimeZone, 0 )
+ ZEND_ARG_OBJ_INFO( 0, otherTimeZone, IntlTimeZone, 0 )
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_get_display_name, 0, 0, 1 )
+ ZEND_ARG_OBJ_INFO( 0, timeZone, IntlTimeZone, 0 )
+ ZEND_ARG_INFO( 0, isDaylight )
+ ZEND_ARG_INFO( 0, style )
+ ZEND_ARG_INFO( 0, locale )
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_only_tz, 0, 0, 1 )
+ ZEND_ARG_OBJ_INFO( 0, timeZone, IntlTimeZone, 0 )
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_void, 0, 0, 0 )
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_create_instance, 0, 0, 0 )
+ ZEND_ARG_INFO( 0, timeZone )
+ ZEND_ARG_INFO( 0, locale )
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_only_cal, 0, 0, 1 )
+ ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 )
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_void, 0, 0, 0 )
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_field, 0, 0, 2 )
+ ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 )
+ ZEND_ARG_INFO( 0, field )
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_dow, 0, 0, 2 )
+ ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 )
+ ZEND_ARG_INFO( 0, dayOfWeek )
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_other_cal, 0, 0, 2 )
+ ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 )
+ ZEND_ARG_OBJ_INFO( 0, otherCalendar, IntlCalendar, 0 )
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_date, 0, 0, 2 )
+ ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 )
+ ZEND_ARG_INFO( 0, date )
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_date_optional, 0, 0, 1 )
+ ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 )
+ ZEND_ARG_INFO( 0, date )
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_get_keyword_values_for_locale, 0, 0, 3)
+ ZEND_ARG_INFO( 0, key )
+ ZEND_ARG_INFO( 0, locale )
+ ZEND_ARG_INFO( 0, commonlyUsed )
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_add, 0, 0, 3 )
+ ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 )
+ ZEND_ARG_INFO( 0, field )
+ ZEND_ARG_INFO( 0, amount )
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_set_time_zone, 0, 0, 2 )
+ ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 )
+ ZEND_ARG_INFO( 0, timeZone )
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_set, 0, 0, 3 )
+ ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 )
+ ZEND_ARG_INFO( 0, fieldOrYear )
+ ZEND_ARG_INFO( 0, valueOrMonth )
+ ZEND_ARG_INFO( 0, dayOfMonth )
+ ZEND_ARG_INFO( 0, hour )
+ ZEND_ARG_INFO( 0, minute )
+ ZEND_ARG_INFO( 0, second )
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_roll, 0, 0, 2 )
+ ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 )
+ ZEND_ARG_INFO( 0, field )
+ ZEND_ARG_INFO( 0, amountOrUpOrDown )
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_clear, 0, 0, 1 )
+ ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 )
+ ZEND_ARG_INFO( 0, field )
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_field_difference, 0, 0, 3 )
+ ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 )
+ ZEND_ARG_INFO( 0, when )
+ ZEND_ARG_INFO( 0, field )
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_get_locale, 0, 0, 2 )
+ ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 )
+ ZEND_ARG_INFO( 0, localeType )
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_set_lenient, 0, 0, 2 )
+ ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 )
+ ZEND_ARG_INFO( 0, isLenient )
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_from_date_time, 0, 0, 1)
+ ZEND_ARG_INFO(0, dateTime)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_wall_time_option, 0, 0, 2 )
+ ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 )
+ ZEND_ARG_INFO( 0, wallTimeOption )
+ZEND_END_ARG_INFO()
+
+/* Gregorian Calendar */
+ZEND_BEGIN_ARG_INFO_EX( ainfo_gregcal_create_instance, 0, 0, 0 )
+ ZEND_ARG_INFO(0, timeZoneOrYear)
+ ZEND_ARG_INFO(0, localeOrMonth)
+ ZEND_ARG_INFO(0, dayOfMonth)
+ ZEND_ARG_INFO(0, hour)
+ ZEND_ARG_INFO(0, minute)
+ ZEND_ARG_INFO(0, second)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( ainfo_gregcal_is_leap_year, 0, 0, 2 )
+ ZEND_ARG_OBJ_INFO( 0, calendar, IntlGregorianCalendar, 0 )
+ ZEND_ARG_INFO( 0, year )
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( ainfo_gregcal_only_gregcal, 0, 0, 1 )
+ ZEND_ARG_OBJ_INFO( 0, calendar, IntlGregorianCalendar, 0 )
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX( ainfo_gregcal_set_gregorian_change, 0, 0, 2 )
+ ZEND_ARG_OBJ_INFO( 0, calendar, IntlGregorianCalendar, 0 )
+ ZEND_ARG_INFO( 0, date )
+ZEND_END_ARG_INFO()
+
/* }}} */
/* {{{ intl_functions
@@ -484,10 +683,13 @@ zend_function_entry intl_functions[] = {
PHP_FE( datefmt_get_datetype, arginfo_msgfmt_get_locale )
PHP_FE( datefmt_get_timetype, arginfo_msgfmt_get_locale )
PHP_FE( datefmt_get_calendar, arginfo_msgfmt_get_locale )
+ PHP_FE( datefmt_get_calendar_object, arginfo_msgfmt_get_locale )
PHP_FE( datefmt_set_calendar, arginfo_datefmt_set_calendar )
PHP_FE( datefmt_get_locale, arginfo_msgfmt_get_locale )
PHP_FE( datefmt_get_timezone_id, arginfo_msgfmt_get_locale )
- PHP_FE( datefmt_set_timezone_id, arginfo_msgfmt_get_locale )
+ PHP_FE( datefmt_set_timezone_id, arginfo_datefmt_set_timezone )
+ PHP_FE( datefmt_get_timezone, arginfo_msgfmt_get_locale )
+ PHP_FE( datefmt_set_timezone, arginfo_datefmt_set_timezone )
PHP_FE( datefmt_get_pattern, arginfo_msgfmt_get_locale )
PHP_FE( datefmt_set_pattern, arginfo_datefmt_set_pattern )
PHP_FE( datefmt_is_lenient, arginfo_msgfmt_get_locale )
@@ -530,6 +732,96 @@ zend_function_entry intl_functions[] = {
PHP_FE( transliterator_get_error_code, arginfo_transliterator_error )
PHP_FE( transliterator_get_error_message, arginfo_transliterator_error )
+ /* TimeZone functions */
+ PHP_FE( intltz_create_time_zone, arginfo_tz_idarg_static )
+ PHP_FE( intltz_from_date_time_zone, arginfo_tz_from_date_time_zone )
+ PHP_FE( intltz_create_default, arginfo_tz_void )
+ PHP_FE( intltz_get_id, arginfo_tz_only_tz )
+ PHP_FE( intltz_get_gmt, arginfo_tz_void )
+#if U_ICU_VERSION_MAJOR_NUM >= 49
+ PHP_FE( intltz_get_unknown, arginfo_tz_void )
+#endif
+ PHP_FE( intltz_create_enumeration, arginfo_tz_create_enumeration )
+ PHP_FE( intltz_count_equivalent_ids, arginfo_tz_idarg_static )
+#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 48
+ PHP_FE( intltz_create_time_zone_id_enumeration, arginfo_tz_create_time_zone_id_enumeration )
+#endif
+ PHP_FE( intltz_get_canonical_id, arginfo_tz_get_canonical_id )
+#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 48
+ PHP_FE( intltz_get_region, arginfo_tz_idarg_static )
+#endif
+ PHP_FE( intltz_get_tz_data_version, arginfo_tz_void )
+ PHP_FE( intltz_get_equivalent_id, arginfo_tz_get_equivalent_id )
+ PHP_FE( intltz_use_daylight_time, arginfo_tz_only_tz )
+ PHP_FE( intltz_get_offset, arginfo_tz_get_offset )
+ PHP_FE( intltz_get_raw_offset, arginfo_tz_only_tz )
+ PHP_FE( intltz_has_same_rules, arginfo_tz_has_same_rules )
+ PHP_FE( intltz_get_display_name, arginfo_tz_get_display_name )
+ PHP_FE( intltz_get_dst_savings, arginfo_tz_only_tz )
+ PHP_FE( intltz_to_date_time_zone, arginfo_tz_only_tz )
+ PHP_FE( intltz_get_error_code, arginfo_tz_only_tz )
+ PHP_FE( intltz_get_error_message, arginfo_tz_only_tz )
+
+ PHP_FE( intlcal_create_instance, ainfo_cal_create_instance )
+#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 42
+ PHP_FE( intlcal_get_keyword_values_for_locale, ainfo_cal_get_keyword_values_for_locale )
+#endif
+ PHP_FE( intlcal_get_now, ainfo_cal_void )
+ PHP_FE( intlcal_get_available_locales, ainfo_cal_void )
+ PHP_FE( intlcal_get, ainfo_cal_field )
+ PHP_FE( intlcal_get_time, ainfo_cal_only_cal )
+ PHP_FE( intlcal_set_time, ainfo_cal_date )
+ PHP_FE( intlcal_add, ainfo_cal_add )
+ PHP_FE( intlcal_set_time_zone, ainfo_cal_set_time_zone )
+ PHP_FE( intlcal_after, ainfo_cal_other_cal )
+ PHP_FE( intlcal_before, ainfo_cal_other_cal )
+ PHP_FE( intlcal_set, ainfo_cal_set )
+ PHP_FE( intlcal_roll, ainfo_cal_roll )
+ PHP_FE( intlcal_clear, ainfo_cal_clear )
+ PHP_FE( intlcal_field_difference, ainfo_cal_field_difference )
+ PHP_FE( intlcal_get_actual_maximum, ainfo_cal_field )
+ PHP_FE( intlcal_get_actual_minimum, ainfo_cal_field )
+#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44
+ PHP_FE( intlcal_get_day_of_week_type, ainfo_cal_dow )
+#endif
+ PHP_FE( intlcal_get_first_day_of_week, ainfo_cal_only_cal )
+ PHP_FE( intlcal_get_greatest_minimum, ainfo_cal_field )
+ PHP_FE( intlcal_get_least_maximum, ainfo_cal_field )
+ PHP_FE( intlcal_get_locale, ainfo_cal_get_locale )
+ PHP_FE( intlcal_get_maximum, ainfo_cal_field )
+ PHP_FE( intlcal_get_minimal_days_in_first_week, ainfo_cal_only_cal )
+ PHP_FE( intlcal_get_minimum, ainfo_cal_field )
+ PHP_FE( intlcal_get_time_zone, ainfo_cal_only_cal )
+ PHP_FE( intlcal_get_type, ainfo_cal_only_cal )
+#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44
+ PHP_FE( intlcal_get_weekend_transition, ainfo_cal_dow )
+#endif
+ PHP_FE( intlcal_in_daylight_time, ainfo_cal_only_cal )
+ PHP_FE( intlcal_is_equivalent_to, ainfo_cal_other_cal )
+ PHP_FE( intlcal_is_lenient, ainfo_cal_only_cal )
+ PHP_FE( intlcal_is_set, ainfo_cal_field )
+#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44
+ PHP_FE( intlcal_is_weekend, ainfo_cal_date_optional )
+#endif
+ PHP_FE( intlcal_set_first_day_of_week, ainfo_cal_dow )
+ PHP_FE( intlcal_set_lenient, ainfo_cal_set_lenient )
+ PHP_FE( intlcal_equals, ainfo_cal_other_cal )
+ PHP_FE( intlcal_from_date_time, ainfo_cal_from_date_time )
+ PHP_FE( intlcal_to_date_time, ainfo_cal_only_cal )
+#if U_ICU_VERSION_MAJOR_NUM >= 49
+ PHP_FE( intlcal_get_repeated_wall_time_option, ainfo_cal_only_cal )
+ PHP_FE( intlcal_get_skipped_wall_time_option, ainfo_cal_only_cal )
+ PHP_FE( intlcal_set_repeated_wall_time_option, ainfo_cal_wall_time_option )
+ PHP_FE( intlcal_set_skipped_wall_time_option, ainfo_cal_wall_time_option )
+#endif
+ PHP_FE( intlcal_get_error_code, ainfo_cal_only_cal )
+ PHP_FE( intlcal_get_error_message, ainfo_cal_only_cal )
+
+ PHP_FE( intlgregcal_create_instance, ainfo_gregcal_create_instance )
+ PHP_FE( intlgregcal_set_gregorian_change, ainfo_gregcal_set_gregorian_change )
+ PHP_FE( intlgregcal_get_gregorian_change, ainfo_gregcal_only_gregcal )
+ PHP_FE( intlgregcal_is_leap_year, ainfo_gregcal_is_leap_year )
+
/* common functions */
PHP_FE( intl_get_error_code, intl_0_args )
PHP_FE( intl_get_error_message, intl_0_args )
@@ -545,7 +837,7 @@ zend_function_entry intl_functions[] = {
PHP_INI_BEGIN()
STD_PHP_INI_ENTRY(LOCALE_INI_NAME, NULL, PHP_INI_ALL, OnUpdateStringUnempty, default_locale, zend_intl_globals, intl_globals)
STD_PHP_INI_ENTRY("intl.error_level", "0", PHP_INI_ALL, OnUpdateLong, error_level, zend_intl_globals, intl_globals)
-
+ STD_PHP_INI_ENTRY("intl.use_exceptions", "0", PHP_INI_ALL, OnUpdateBool, use_exceptions, zend_intl_globals, intl_globals)
PHP_INI_END()
/* }}} */
@@ -640,6 +932,12 @@ PHP_MINIT_FUNCTION( intl )
/* Register Transliterator constants */
transliterator_register_constants( INIT_FUNC_ARGS_PASSTHRU );
+ /* Register 'IntlTimeZone' PHP class */
+ timezone_register_IntlTimeZone_class( TSRMLS_C );
+
+ /* Register 'IntlCalendar' PHP class */
+ calendar_register_IntlCalendar_class( TSRMLS_C );
+
/* Expose ICU error codes to PHP scripts. */
intl_expose_icu_error_codes( INIT_FUNC_ARGS_PASSTHRU );
@@ -653,6 +951,13 @@ PHP_MINIT_FUNCTION( intl )
/* Expose Spoofchecker constants to PHP scripts */
spoofchecker_register_constants( INIT_FUNC_ARGS_PASSTHRU );
#endif
+
+ /* Register 'IntlException' PHP class */
+ intl_register_IntlException_class( TSRMLS_C );
+
+ /* Register 'IntlIterator' PHP class */
+ intl_register_IntlIterator_class( TSRMLS_C );
+
/* Global error handling. */
intl_error_init( NULL TSRMLS_CC );
diff --git a/ext/intl/php_intl.h b/ext/intl/php_intl.h
index 4ede069..c3d5c60 100755
--- a/ext/intl/php_intl.h
+++ b/ext/intl/php_intl.h
@@ -22,8 +22,13 @@
#include <php.h>
+/* Even if we're included from C++, don't introduce C++ definitions
+ * because we were included with extern "C". The effect would be that
+ * when the headers defined any method, they would do so with C linkage */
+#undef U_SHOW_CPLUSPLUS_API
+#define U_SHOW_CPLUSPLUS_API 0
#include "collator/collator_sort.h"
-#include "grapheme/grapheme.h"
+#include <unicode/ubrk.h>
#include "intl_error.h"
extern zend_module_entry intl_module_entry;
@@ -46,6 +51,7 @@ ZEND_BEGIN_MODULE_GLOBALS(intl)
UBreakIterator* grapheme_iterator;
intl_error g_error;
long error_level;
+ zend_bool use_exceptions;
ZEND_END_MODULE_GLOBALS(intl)
/* Macro to access request-wide global variables. */
diff --git a/ext/intl/resourcebundle/resourcebundle_class.c b/ext/intl/resourcebundle/resourcebundle_class.c
index 1205450..3d7fd5f 100644
--- a/ext/intl/resourcebundle/resourcebundle_class.c
+++ b/ext/intl/resourcebundle/resourcebundle_class.c
@@ -103,7 +103,7 @@ static void resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS)
INTL_CHECK_LOCALE_LEN_OBJ(locale_len, return_value);
if (locale == NULL) {
- locale = INTL_G(default_locale);
+ locale = intl_locale_get_default(TSRMLS_C);
}
if (fallback) {
diff --git a/ext/intl/tests/badargs.phpt b/ext/intl/tests/badargs.phpt
index 9232bbf..b8f48b3 100755
--- a/ext/intl/tests/badargs.phpt
+++ b/ext/intl/tests/badargs.phpt
@@ -13,7 +13,10 @@ foreach($funcs as $func) {
if($rfunc->getNumberOfRequiredParameters() == 0) {
continue;
}
- $res = $func($arg);
+
+ try {
+ $res = $func($arg);
+ } catch (Exception $e) { continue; }
if($res != false) {
echo "$func: ";
var_dump($res);
diff --git a/ext/intl/tests/bug50590.phpt b/ext/intl/tests/bug50590.phpt
index c39c333..4784d37 100644
--- a/ext/intl/tests/bug50590.phpt
+++ b/ext/intl/tests/bug50590.phpt
@@ -1,5 +1,7 @@
--TEST--
Bug #50590 (IntlDateFormatter::parse result is limited to the integer range)
+--INI--
+date.timezone=Atlantic/Azores
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
--FILE--
diff --git a/ext/intl/tests/bug58756_MessageFormatter.phpt b/ext/intl/tests/bug58756_MessageFormatter.phpt
new file mode 100644
index 0000000..bbe96b7
--- /dev/null
+++ b/ext/intl/tests/bug58756_MessageFormatter.phpt
@@ -0,0 +1,34 @@
+--TEST--
+Bug #58756: w.r.t MessageFormatter
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+//ini_set("intl.default_locale", "nl");
+
+$time = 1247013673;
+
+ini_set('date.timezone', 'America/New_York');
+
+$msgf = new MessageFormatter('en_US', '{0,date,full} {0,time,h:m:s a V}');
+
+echo "date: " . date('l, F j, Y g:i:s A T', $time) . "\n";
+echo "msgf: " . $msgf->format(array($time)) . "\n";
+
+//NOT FIXED:
+/*$msgf = new MessageFormatter('en_US',
+'{1, select, date {{0,date,full}} other {{0,time,h:m:s a V}}}');
+
+echo "msgf2: ", $msgf->format(array($time, 'date')), " ",
+ $msgf->format(array($time, 'time')), "\n";
+*/
+
+?>
+==DONE==
+--EXPECT--
+date: Tuesday, July 7, 2009 8:41:13 PM EDT
+msgf: Tuesday, July 7, 2009 8:41:13 PM EDT
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/bug62017.phpt b/ext/intl/tests/bug62017.phpt
index 13c4fe5..50aeae4 100644
--- a/ext/intl/tests/bug62017.phpt
+++ b/ext/intl/tests/bug62017.phpt
@@ -14,7 +14,7 @@ var_dump(
new IntlDateFormatter('', IntlDateFormatter::NONE, IntlDateFormatter::NONE, "Europe/Lisbon",
IntlDateFormatter::GREGORIAN, "\x80"));
--EXPECTF--
-Warning: datefmt_create(): datefmt_create: error converting timezone_str to UTF-16 in %s on line %d
+Warning: datefmt_create(): datefmt_create: Time zone identifier given is not a valid UTF-8 string in %s on line %d
NULL
Warning: IntlDateFormatter::__construct(): datefmt_create: error converting pattern to UTF-16 in %s on line %d
diff --git a/ext/intl/tests/bug62081.phpt b/ext/intl/tests/bug62081.phpt
index 7d9e2ce..44ad4be 100644
--- a/ext/intl/tests/bug62081.phpt
+++ b/ext/intl/tests/bug62081.phpt
@@ -1,5 +1,7 @@
--TEST--
Bug #62081: IntlDateFormatter leaks memory if called twice
+--INI--
+date.timezone=Atlantic/Azores
--SKIPIF--
<?php
if (!extension_loaded('intl'))
@@ -7,8 +9,8 @@ if (!extension_loaded('intl'))
--FILE--
<?php
ini_set('intl.error_level', E_WARNING);
-$x = new IntlDateFormatter(1,1,1,1,1);
-var_dump($x->__construct(1,1,1,1,1));
+$x = new IntlDateFormatter('en', 1, 1);
+var_dump($x->__construct('en', 1, 1));
--EXPECTF--
Warning: IntlDateFormatter::__construct(): datefmt_create: cannot call constructor twice in %s on line %d
NULL
diff --git a/ext/intl/tests/calendar_add_basic.phpt b/ext/intl/tests/calendar_add_basic.phpt
new file mode 100644
index 0000000..b0e44d5
--- /dev/null
+++ b/ext/intl/tests/calendar_add_basic.phpt
@@ -0,0 +1,33 @@
+--TEST--
+IntlCalendar::add() basic test
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+$time = strtotime('2012-02-29 00:00:00 +0000');
+$time2 = strtotime('2012-03-01 05:06:07 +0000');
+
+$intlcal = IntlCalendar::createInstance('UTC');
+$intlcal->setTime($time * 1000);
+$intlcal->add(IntlCalendar::FIELD_DAY_OF_MONTH, 1);
+$intlcal->add(IntlCalendar::FIELD_HOUR, 5);
+$intlcal->add(IntlCalendar::FIELD_MINUTE, 6);
+intlcal_add($intlcal, IntlCalendar::FIELD_SECOND, 7);
+
+var_dump(
+ (float)$time2*1000,
+ $intlcal->getTime());
+
+?>
+==DONE==
+--EXPECT--
+float(1330578367000)
+float(1330578367000)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/calendar_add_error.phpt b/ext/intl/tests/calendar_add_error.phpt
new file mode 100644
index 0000000..2e5fadb
--- /dev/null
+++ b/ext/intl/tests/calendar_add_error.phpt
@@ -0,0 +1,41 @@
+--TEST--
+IntlCalendar::add(): bad arguments
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$c = new IntlGregorianCalendar(NULL, 'pt_PT');
+
+var_dump($c->add(1, 2, 3));
+var_dump($c->add(-1, 2));
+var_dump($c->add(1));
+
+var_dump(intlcal_add($c, 1, 2, 3));
+var_dump(intlcal_add(1, 2, 3));
+--EXPECTF--
+
+Warning: IntlCalendar::add() expects exactly 2 parameters, 3 given in %s on line %d
+
+Warning: IntlCalendar::add(): intlcal_add: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::add(): intlcal_add: invalid field in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::add() expects exactly 2 parameters, 1 given in %s on line %d
+
+Warning: IntlCalendar::add(): intlcal_add: bad arguments in %s on line %d
+bool(false)
+
+Warning: intlcal_add() expects exactly 3 parameters, 4 given in %s on line %d
+
+Warning: intlcal_add(): intlcal_add: bad arguments in %s on line %d
+bool(false)
+
+Catchable fatal error: Argument 1 passed to intlcal_add() must be an instance of IntlCalendar, integer given in %s on line %d
diff --git a/ext/intl/tests/calendar_before_after_error.phpt b/ext/intl/tests/calendar_before_after_error.phpt
new file mode 100644
index 0000000..10011ef
--- /dev/null
+++ b/ext/intl/tests/calendar_before_after_error.phpt
@@ -0,0 +1,57 @@
+--TEST--
+IntlCalendar::before()/after(): bad arguments
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$c = new IntlGregorianCalendar(NULL, 'pt_PT');
+
+function eh($errno, $errstr) {
+echo "error: $errno, $errstr\n";
+}
+set_error_handler('eh');
+
+var_dump($c->after());
+var_dump($c->before());
+
+var_dump($c->after(1));
+var_dump($c->before(1));
+
+var_dump($c->after($c, 1));
+var_dump($c->before($c, 1));
+
+var_dump(intlcal_after($c));
+var_dump(intlcal_before($c));
+--EXPECT--
+error: 2, IntlCalendar::after() expects exactly 1 parameter, 0 given
+error: 2, IntlCalendar::after(): intlcal_before/after: bad arguments
+bool(false)
+error: 2, IntlCalendar::before() expects exactly 1 parameter, 0 given
+error: 2, IntlCalendar::before(): intlcal_before/after: bad arguments
+bool(false)
+error: 4096, Argument 1 passed to IntlCalendar::after() must be an instance of IntlCalendar, integer given
+error: 2, IntlCalendar::after() expects parameter 1 to be IntlCalendar, integer given
+error: 2, IntlCalendar::after(): intlcal_before/after: bad arguments
+bool(false)
+error: 4096, Argument 1 passed to IntlCalendar::before() must be an instance of IntlCalendar, integer given
+error: 2, IntlCalendar::before() expects parameter 1 to be IntlCalendar, integer given
+error: 2, IntlCalendar::before(): intlcal_before/after: bad arguments
+bool(false)
+error: 2, IntlCalendar::after() expects exactly 1 parameter, 2 given
+error: 2, IntlCalendar::after(): intlcal_before/after: bad arguments
+bool(false)
+error: 2, IntlCalendar::before() expects exactly 1 parameter, 2 given
+error: 2, IntlCalendar::before(): intlcal_before/after: bad arguments
+bool(false)
+error: 2, intlcal_after() expects exactly 2 parameters, 1 given
+error: 2, intlcal_after(): intlcal_before/after: bad arguments
+bool(false)
+error: 2, intlcal_before() expects exactly 2 parameters, 1 given
+error: 2, intlcal_before(): intlcal_before/after: bad arguments
+bool(false)
diff --git a/ext/intl/tests/calendar_clear_basic.phpt b/ext/intl/tests/calendar_clear_basic.phpt
new file mode 100644
index 0000000..f7e4371
--- /dev/null
+++ b/ext/intl/tests/calendar_clear_basic.phpt
@@ -0,0 +1,40 @@
+--TEST--
+IntlCalendar::clear() basic test
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+$intlcal = IntlCalendar::createInstance('UTC');
+var_dump($intlcal->clear());
+var_dump(
+ $intlcal->get(IntlCalendar::FIELD_YEAR),
+ $intlcal->get(IntlCalendar::FIELD_MONTH),
+ $intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH),
+ $intlcal->get(IntlCalendar::FIELD_HOUR),
+ $intlcal->get(IntlCalendar::FIELD_MINUTE),
+ $intlcal->get(IntlCalendar::FIELD_SECOND),
+ $intlcal->get(IntlCalendar::FIELD_MILLISECOND)
+);
+
+$intlcal2 = IntlCalendar::createInstance('Europe/Amsterdam');
+intlcal_clear($intlcal2, null);
+var_dump($intlcal2->getTime());
+
+?>
+==DONE==
+--EXPECT--
+bool(true)
+int(1970)
+int(0)
+int(1)
+int(0)
+int(0)
+int(0)
+int(0)
+float(-3600000)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/calendar_clear_error.phpt b/ext/intl/tests/calendar_clear_error.phpt
new file mode 100644
index 0000000..9bde7e2
--- /dev/null
+++ b/ext/intl/tests/calendar_clear_error.phpt
@@ -0,0 +1,31 @@
+--TEST--
+IntlCalendar::clear(): bad arguments
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$c = new IntlGregorianCalendar(NULL, 'pt_PT');
+
+var_dump($c->clear(1, 2));
+var_dump($c->clear(-1));
+
+var_dump(intlcal_clear($c, -1));
+var_dump(intlcal_clear(1, 2));
+--EXPECTF--
+
+Warning: IntlCalendar::clear(): intlcal_clear: too many arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::clear(): intlcal_clear: invalid field in %s on line %d
+bool(false)
+
+Warning: intlcal_clear(): intlcal_clear: invalid field in %s on line %d
+bool(false)
+
+Catchable fatal error: Argument 1 passed to intlcal_clear() must be an instance of IntlCalendar, integer given in %s on line %d
diff --git a/ext/intl/tests/calendar_clear_variation1.phpt b/ext/intl/tests/calendar_clear_variation1.phpt
new file mode 100644
index 0000000..6adbcaa
--- /dev/null
+++ b/ext/intl/tests/calendar_clear_variation1.phpt
@@ -0,0 +1,33 @@
+--TEST--
+IntlCalendar::clear() 1 arg variation
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+$intlcal = IntlCalendar::createInstance('UTC');
+$intlcal->setTime(strtotime('2012-02-29 05:06:07 +0000') * 1000);
+//print_R($intlcal);
+var_dump($intlcal->isSet(IntlCalendar::FIELD_MONTH));
+var_dump($intlcal->clear(IntlCalendar::FIELD_MONTH));
+var_dump($intlcal->isSet(IntlCalendar::FIELD_MONTH));
+//print_R($intlcal);
+var_dump(
+ $intlcal->getTime(),
+ strtotime('2012-01-29 05:06:07 +0000') * 1000.
+);
+?>
+==DONE==
+--EXPECT--
+bool(true)
+bool(true)
+bool(false)
+float(1327813567000)
+float(1327813567000)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/calendar_createInstance_basic.phpt b/ext/intl/tests/calendar_createInstance_basic.phpt
new file mode 100644
index 0000000..e062030
--- /dev/null
+++ b/ext/intl/tests/calendar_createInstance_basic.phpt
@@ -0,0 +1,42 @@
+--TEST--
+IntlCalendar::createInstance() basic test
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '4.8') < 0)
+ die('skip for ICU 4.8+');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+date_default_timezone_set('Europe/Amsterdam');
+
+$cal = IntlCalendar::createInstance();
+print_R($cal->getTimeZone());
+print_R($cal->getLocale(Locale::ACTUAL_LOCALE));
+echo "\n";
+print_R($cal->getType());
+echo "\n";
+
+$timeMillis = $cal->getTime();
+$time = time();
+
+var_dump(abs($timeMillis - $time * 1000) < 1000);
+
+?>
+==DONE==
+
+--EXPECTF--
+IntlTimeZone Object
+(
+ [valid] => 1
+ [id] => Europe/Amsterdam
+ [rawOffset] => 3600000
+ [currentOffset] => %d
+)
+nl
+gregorian
+bool(true)
+==DONE==
diff --git a/ext/intl/tests/calendar_createInstance_error.phpt b/ext/intl/tests/calendar_createInstance_error.phpt
new file mode 100644
index 0000000..bf655be
--- /dev/null
+++ b/ext/intl/tests/calendar_createInstance_error.phpt
@@ -0,0 +1,38 @@
+--TEST--
+IntlCalendar::createInstance: bad arguments
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+class X extends IntlTimeZone {
+function __construct() {}
+}
+
+var_dump(IntlCalendar::createInstance(1, 2, 3));
+var_dump(intlcal_create_instance(1, 2, 3));
+var_dump(intlcal_create_instance(new X, NULL));
+var_dump(intlcal_create_instance(NULL, array()));
+
+--EXPECTF--
+
+Warning: IntlCalendar::createInstance() expects at most 2 parameters, 3 given in %s on line %d
+
+Warning: IntlCalendar::createInstance(): intlcal_create_calendar: bad arguments in %s on line %d
+NULL
+
+Warning: intlcal_create_instance() expects at most 2 parameters, 3 given in %s on line %d
+
+Warning: intlcal_create_instance(): intlcal_create_calendar: bad arguments in %s on line %d
+NULL
+
+Warning: intlcal_create_instance(): intlcal_create_instance: passed IntlTimeZone is not properly constructed in %s on line %d
+NULL
+
+Warning: intlcal_create_instance() expects parameter 2 to be string, array given in %s on line %d
+
+Warning: intlcal_create_instance(): intlcal_create_calendar: bad arguments in %s on line %d
+NULL
diff --git a/ext/intl/tests/calendar_createInstance_variation1.phpt b/ext/intl/tests/calendar_createInstance_variation1.phpt
new file mode 100644
index 0000000..138f2a2
--- /dev/null
+++ b/ext/intl/tests/calendar_createInstance_variation1.phpt
@@ -0,0 +1,84 @@
+--TEST--
+IntlCalendar::createInstance() argument variations
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '4.8') < 0)
+ die('skip for ICU 4.8+');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+date_default_timezone_set('Europe/Amsterdam');
+
+$cal = intlcal_create_instance('Europe/Amsterdam');
+print_R($cal->getTimeZone());
+print_R($cal->getLocale(Locale::ACTUAL_LOCALE));
+echo "\n";
+
+$cal = intlcal_create_instance('Europe/Lisbon', null);
+print_R($cal->getTimeZone());
+print_R($cal->getLocale(Locale::ACTUAL_LOCALE));
+echo "\n";
+
+$cal = intlcal_create_instance(IntlTimeZone::createTimeZone('Europe/Lisbon'));
+print_R($cal->getTimeZone());
+print_R($cal->getLocale(Locale::ACTUAL_LOCALE));
+echo "\n";
+
+$cal = intlcal_create_instance(null, "pt");
+print_R($cal->getTimeZone());
+print_R($cal->getLocale(Locale::ACTUAL_LOCALE));
+echo "\n";
+
+$cal = intlcal_create_instance("Europe/Lisbon", "pt");
+print_R($cal->getTimeZone());
+print_R($cal->getLocale(Locale::ACTUAL_LOCALE));
+echo "\n";
+
+?>
+==DONE==
+--EXPECTF--
+IntlTimeZone Object
+(
+ [valid] => 1
+ [id] => Europe/Amsterdam
+ [rawOffset] => 3600000
+ [currentOffset] => %d
+)
+nl
+IntlTimeZone Object
+(
+ [valid] => 1
+ [id] => Europe/Lisbon
+ [rawOffset] => 0
+ [currentOffset] => %d
+)
+nl
+IntlTimeZone Object
+(
+ [valid] => 1
+ [id] => Europe/Lisbon
+ [rawOffset] => 0
+ [currentOffset] => %d
+)
+nl
+IntlTimeZone Object
+(
+ [valid] => 1
+ [id] => Europe/Amsterdam
+ [rawOffset] => 3600000
+ [currentOffset] => %d
+)
+pt
+IntlTimeZone Object
+(
+ [valid] => 1
+ [id] => Europe/Lisbon
+ [rawOffset] => 0
+ [currentOffset] => %d
+)
+pt
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/calendar_equals_before_after_basic.phpt b/ext/intl/tests/calendar_equals_before_after_basic.phpt
new file mode 100644
index 0000000..50543ad
--- /dev/null
+++ b/ext/intl/tests/calendar_equals_before_after_basic.phpt
@@ -0,0 +1,59 @@
+--TEST--
+IntlCalendar::equals(), ::before() and ::after() basic test
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+$intlcal1 = new IntlGregorianCalendar(2012, 1, 29, 16, 59, 59);
+$intlcal2 = IntlCalendar::createInstance(null, '@calendar=japanese');
+$intlcal3 = new IntlGregorianCalendar(2012, 1, 29, 17, 00, 00);
+$intlcal2->setTime($intlcal1->getTime());
+
+var_dump($intlcal2->getType());
+
+var_dump("1 eq 1", $intlcal1->equals($intlcal1));
+
+var_dump("1 eq 2", $intlcal1->equals($intlcal2));
+var_dump("1 before 2", $intlcal1->before($intlcal2));
+var_dump("1 after 2", $intlcal1->after($intlcal2));
+
+var_dump("1 eq 3", $intlcal1->equals($intlcal3));
+var_dump("1 before 3", $intlcal1->before($intlcal3));
+var_dump("1 after 3", $intlcal1->after($intlcal3));
+
+var_dump("3 eq 2", intlcal_equals($intlcal3, $intlcal2));
+var_dump("3 before 2", intlcal_before($intlcal3, $intlcal2));
+var_dump("3 after 2", intlcal_after($intlcal3, $intlcal2));
+
+?>
+==DONE==
+--EXPECT--
+string(8) "japanese"
+string(6) "1 eq 1"
+bool(true)
+string(6) "1 eq 2"
+bool(true)
+string(10) "1 before 2"
+bool(false)
+string(9) "1 after 2"
+bool(false)
+string(6) "1 eq 3"
+bool(false)
+string(10) "1 before 3"
+bool(true)
+string(9) "1 after 3"
+bool(false)
+string(6) "3 eq 2"
+bool(false)
+string(10) "3 before 2"
+bool(false)
+string(9) "3 after 2"
+bool(true)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/calendar_equals_error.phpt b/ext/intl/tests/calendar_equals_error.phpt
new file mode 100644
index 0000000..a947b42
--- /dev/null
+++ b/ext/intl/tests/calendar_equals_error.phpt
@@ -0,0 +1,46 @@
+--TEST--
+IntlCalendar::equals(): bad arguments
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$c = new IntlGregorianCalendar(NULL, 'pt_PT');
+
+function eh($errno, $errstr) {
+echo "error: $errno, $errstr\n";
+}
+set_error_handler('eh');
+
+var_dump($c->equals());
+var_dump($c->equals(new stdclass));
+var_dump($c->equals(1, 2));
+
+var_dump(intlcal_equals($c, array()));
+var_dump(intlcal_equals(1, $c));
+
+--EXPECT--
+error: 2, IntlCalendar::equals() expects exactly 1 parameter, 0 given
+error: 2, IntlCalendar::equals(): intlcal_equals: bad arguments
+bool(false)
+error: 4096, Argument 1 passed to IntlCalendar::equals() must be an instance of IntlCalendar, instance of stdClass given
+error: 2, IntlCalendar::equals() expects parameter 1 to be IntlCalendar, object given
+error: 2, IntlCalendar::equals(): intlcal_equals: bad arguments
+bool(false)
+error: 4096, Argument 1 passed to IntlCalendar::equals() must be an instance of IntlCalendar, integer given
+error: 2, IntlCalendar::equals() expects exactly 1 parameter, 2 given
+error: 2, IntlCalendar::equals(): intlcal_equals: bad arguments
+bool(false)
+error: 4096, Argument 2 passed to intlcal_equals() must be an instance of IntlCalendar, array given
+error: 2, intlcal_equals() expects parameter 2 to be IntlCalendar, array given
+error: 2, intlcal_equals(): intlcal_equals: bad arguments
+bool(false)
+error: 4096, Argument 1 passed to intlcal_equals() must be an instance of IntlCalendar, integer given
+error: 2, intlcal_equals() expects parameter 1 to be IntlCalendar, integer given
+error: 2, intlcal_equals(): intlcal_equals: bad arguments
+bool(false)
diff --git a/ext/intl/tests/calendar_fieldDifference_basic.phpt b/ext/intl/tests/calendar_fieldDifference_basic.phpt
new file mode 100644
index 0000000..3432420
--- /dev/null
+++ b/ext/intl/tests/calendar_fieldDifference_basic.phpt
@@ -0,0 +1,35 @@
+--TEST--
+IntlCalendar::fieldDifference() basic test
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+$intlcal = IntlCalendar::createInstance('UTC');
+$intlcal->setTime(strtotime('2012-02-29 05:06:07 +0000') * 1000);
+var_dump(
+ $intlcal->fieldDifference(
+ strtotime('2012-02-29 06:06:08 +0000') * 1000,
+ IntlCalendar::FIELD_SECOND),
+ $intlcal->get(IntlCalendar::FIELD_HOUR_OF_DAY));
+
+
+$intlcal->setTime(strtotime('2012-02-29 05:06:07 +0000') * 1000);
+var_dump(
+ intlcal_field_difference(
+ $intlcal,
+ strtotime('2012-02-29 06:07:08 +0000') * 1000,
+ IntlCalendar::FIELD_MINUTE));
+?>
+==DONE==
+--EXPECT--
+int(3601)
+int(6)
+int(61)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/calendar_fieldDifference_error.phpt b/ext/intl/tests/calendar_fieldDifference_error.phpt
new file mode 100644
index 0000000..ef7e4fc
--- /dev/null
+++ b/ext/intl/tests/calendar_fieldDifference_error.phpt
@@ -0,0 +1,42 @@
+--TEST--
+IntlCalendar::fieldDifference(): bad arguments
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$c = new IntlGregorianCalendar(NULL, 'pt_PT');
+
+var_dump($c->fieldDifference($c, 2, 3));
+var_dump($c->fieldDifference(INF, 2));
+var_dump($c->fieldDifference(1));
+
+var_dump(intlcal_field_difference($c, 0, 1, 2));
+var_dump(intlcal_field_difference(1, 0, 1));
+
+--EXPECTF--
+
+Warning: IntlCalendar::fieldDifference() expects exactly 2 parameters, 3 given in %s on line %d
+
+Warning: IntlCalendar::fieldDifference(): intlcal_field_difference: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::fieldDifference(): intlcal_field_difference: Call to ICU method has failed in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::fieldDifference() expects exactly 2 parameters, 1 given in %s on line %d
+
+Warning: IntlCalendar::fieldDifference(): intlcal_field_difference: bad arguments in %s on line %d
+bool(false)
+
+Warning: intlcal_field_difference() expects exactly 3 parameters, 4 given in %s on line %d
+
+Warning: intlcal_field_difference(): intlcal_field_difference: bad arguments in %s on line %d
+bool(false)
+
+Catchable fatal error: Argument 1 passed to intlcal_field_difference() must be an instance of IntlCalendar, integer given in %s on line %d
diff --git a/ext/intl/tests/calendar_fromDateTime_basic.phpt b/ext/intl/tests/calendar_fromDateTime_basic.phpt
new file mode 100644
index 0000000..1863b78
--- /dev/null
+++ b/ext/intl/tests/calendar_fromDateTime_basic.phpt
@@ -0,0 +1,52 @@
+--TEST--
+IntlCalendar::fromDateTime(): basic test
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl_NL");
+date_default_timezone_set('Europe/Lisbon');
+
+$cal = IntlCalendar::fromDateTime('2012-01-01 00:00:00 Europe/Rome');
+var_dump(
+ $cal->getTime(),
+ strtotime('2012-01-01 00:00:00 Europe/Rome') * 1000.,
+ $cal->getTimeZone()->getID(),
+ $cal->getLocale(1)
+);
+echo "\n";
+
+$cal = IntlCalendar::fromDateTime(new DateTime('2012-01-01 00:00:00 PST'), "pt_PT");
+var_dump(
+ $cal->getTime(),
+ strtotime('2012-01-01 00:00:00 PST') * 1000.,
+ $cal->getTimeZone()->getID(),
+ $cal->getLocale(1)
+);
+
+echo "\n";
+
+$cal = intlcal_from_date_time(new DateTime('2012-01-01 00:00:00 +03:40'));
+var_dump(
+ $cal->getTime(),
+ strtotime('2012-01-01 00:00:00 +03:40') * 1000.,
+ $cal->getTimeZone()->getID()
+);
+
+--EXPECTF--
+float(1325372400000)
+float(1325372400000)
+string(11) "Europe/Rome"
+string(5) "nl_NL"
+
+float(1325404800000)
+float(1325404800000)
+string(3) "PST"
+string(5) "pt_PT"
+
+float(1325362800000)
+float(1325362800000)
+string(%d) "GMT+03%S40"
diff --git a/ext/intl/tests/calendar_fromDateTime_error.phpt b/ext/intl/tests/calendar_fromDateTime_error.phpt
new file mode 100644
index 0000000..2fbf719
--- /dev/null
+++ b/ext/intl/tests/calendar_fromDateTime_error.phpt
@@ -0,0 +1,59 @@
+--TEST--
+IntlCalendar::fromDateTime(): errors
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+date_default_timezone_set('Europe/Lisbon');
+
+var_dump(IntlCalendar::fromDateTime());
+var_dump(IntlCalendar::fromDateTime(0,1,2));
+
+try {
+IntlCalendar::fromDateTime("foobar");
+} catch (Exception $e) {
+ echo "threw exception, OK";
+}
+class A extends DateTime {
+function __construct() {}
+}
+
+var_dump(IntlCalendar::fromDateTime(new A));
+
+$date = new DateTime('2012-01-01 00:00:00 +24:00');
+var_dump(IntlCalendar::fromDateTime($date));
+
+$date = new DateTime('2012-01-01 00:00:00 WEST');
+var_dump(IntlCalendar::fromDateTime($date));
+
+var_dump(intlcal_from_date_time());
+
+--EXPECTF--
+
+Warning: IntlCalendar::fromDateTime() expects at least 1 parameter, 0 given in %s on line %d
+
+Warning: IntlCalendar::fromDateTime(): intlcal_from_date_time: bad arguments in %s on line %d
+NULL
+
+Warning: IntlCalendar::fromDateTime() expects at most 2 parameters, 3 given in %s on line %d
+
+Warning: IntlCalendar::fromDateTime(): intlcal_from_date_time: bad arguments in %s on line %d
+NULL
+threw exception, OK
+Warning: IntlCalendar::fromDateTime(): intlcal_from_date_time: DateTime object is unconstructed in %s on line %d
+NULL
+
+Warning: IntlCalendar::fromDateTime(): intlcal_from_date_time: object has an time zone offset that's too large in %s on line %d
+NULL
+
+Warning: IntlCalendar::fromDateTime(): intlcal_from_date_time: time zone id 'WEST' extracted from ext/date DateTimeZone not recognized in %s on line %d
+NULL
+
+Warning: intlcal_from_date_time() expects at least 1 parameter, 0 given in %s on line %d
+
+Warning: intlcal_from_date_time(): intlcal_from_date_time: bad arguments in %s on line %d
+NULL
diff --git a/ext/intl/tests/calendar_getAvailableLocales_basic.phpt b/ext/intl/tests/calendar_getAvailableLocales_basic.phpt
new file mode 100644
index 0000000..5d5b79c
--- /dev/null
+++ b/ext/intl/tests/calendar_getAvailableLocales_basic.phpt
@@ -0,0 +1,23 @@
+--TEST--
+IntlCalendar::getAvailableLocales() basic test
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+$locales = IntlCalendar::getAvailableLocales();
+var_dump(count($locales) > 100);
+
+$locales = intlcal_get_available_locales();
+var_dump(in_array('pt', $locales));
+
+?>
+==DONE==
+--EXPECT--
+bool(true)
+bool(true)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/calendar_getAvailableLocales_error.phpt b/ext/intl/tests/calendar_getAvailableLocales_error.phpt
new file mode 100644
index 0000000..e9edc46
--- /dev/null
+++ b/ext/intl/tests/calendar_getAvailableLocales_error.phpt
@@ -0,0 +1,24 @@
+--TEST--
+IntlCalendar::getAvailableLocales(): bad arguments
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+var_dump(intlcal_get_available_locales(1));
+var_dump(IntlCalendar::getAvailableLocales(2));
+
+--EXPECTF--
+
+Warning: intlcal_get_available_locales() expects exactly 0 parameters, 1 given in %s on line %d
+
+Warning: intlcal_get_available_locales(): intlcal_get_available_locales: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::getAvailableLocales() expects exactly 0 parameters, 1 given in %s on line %d
+
+Warning: IntlCalendar::getAvailableLocales(): intlcal_get_available_locales: bad arguments in %s on line %d
+bool(false)
diff --git a/ext/intl/tests/calendar_getDayOfWeekType_basic.phpt b/ext/intl/tests/calendar_getDayOfWeekType_basic.phpt
new file mode 100644
index 0000000..d5319f1
--- /dev/null
+++ b/ext/intl/tests/calendar_getDayOfWeekType_basic.phpt
@@ -0,0 +1,34 @@
+--TEST--
+IntlCalendar::getDayOfWeekType() basic test
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '4.4') < 0)
+ die('skip for ICU 4.4+');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+$intlcal = IntlCalendar::createInstance('UTC');
+$intlcal->setTime(strtotime('2012-02-29 00:00:00 +0000') * 1000);
+var_dump(
+ intlcal_get_day_of_week_type($intlcal, IntlCalendar::DOW_SUNDAY),
+ $intlcal->getDayOfWeekType(IntlCalendar::DOW_MONDAY),
+ $intlcal->getDayOfWeekType(IntlCalendar::DOW_TUESDAY),
+ $intlcal->getDayOfWeekType(IntlCalendar::DOW_FRIDAY),
+ $intlcal->getDayOfWeekType(IntlCalendar::DOW_SATURDAY)
+);
+
+?>
+==DONE==
+--EXPECT--
+int(3)
+int(0)
+int(0)
+int(0)
+int(1)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/calendar_getDayOfWeekType_error.phpt b/ext/intl/tests/calendar_getDayOfWeekType_error.phpt
new file mode 100644
index 0000000..3926655
--- /dev/null
+++ b/ext/intl/tests/calendar_getDayOfWeekType_error.phpt
@@ -0,0 +1,44 @@
+--TEST--
+IntlCalendar::getDayOfWeekOfType(): bad arguments
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '4.4') < 0)
+ die('skip for ICU 4.4+');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$c = new IntlGregorianCalendar(NULL, 'pt_PT');
+
+var_dump($c->getDayOfWeekType(1, 2));
+var_dump($c->getDayOfWeekType(0));
+var_dump($c->getDayOfWeekType());
+
+var_dump(intlcal_get_day_of_week_type($c, "foo"));
+var_dump(intlcal_get_day_of_week_type(1, 1));
+
+--EXPECTF--
+
+Warning: IntlCalendar::getDayOfWeekType() expects exactly 1 parameter, 2 given in %s on line %d
+
+Warning: IntlCalendar::getDayOfWeekType(): intlcal_get_day_of_week_type: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::getDayOfWeekType(): intlcal_get_day_of_week_type: invalid day of week in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::getDayOfWeekType() expects exactly 1 parameter, 0 given in %s on line %d
+
+Warning: IntlCalendar::getDayOfWeekType(): intlcal_get_day_of_week_type: bad arguments in %s on line %d
+bool(false)
+
+Warning: intlcal_get_day_of_week_type() expects parameter 2 to be long, string given in %s on line %d
+
+Warning: intlcal_get_day_of_week_type(): intlcal_get_day_of_week_type: bad arguments in %s on line %d
+bool(false)
+
+Catchable fatal error: Argument 1 passed to intlcal_get_day_of_week_type() must be an instance of IntlCalendar, integer given in %s on line %d
diff --git a/ext/intl/tests/calendar_getErrorCode_error.phpt b/ext/intl/tests/calendar_getErrorCode_error.phpt
new file mode 100644
index 0000000..13aab81
--- /dev/null
+++ b/ext/intl/tests/calendar_getErrorCode_error.phpt
@@ -0,0 +1,26 @@
+--TEST--
+IntlCalendar::getErrorCode(): bad arguments
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$c = new IntlGregorianCalendar(NULL, 'pt_PT');
+
+var_dump($c->getErrorCode(array()));
+
+var_dump(intlcal_get_error_code(null));
+
+--EXPECTF--
+
+Warning: IntlCalendar::getErrorCode() expects exactly 0 parameters, 1 given in %s on line %d
+
+Warning: IntlCalendar::getErrorCode(): intlcal_get_error_code: bad arguments in %s on line %d
+bool(false)
+
+Catchable fatal error: Argument 1 passed to intlcal_get_error_code() must be an instance of IntlCalendar, null given in %s on line %d
diff --git a/ext/intl/tests/calendar_getErrorCode_getErrorMessage_basic.phpt b/ext/intl/tests/calendar_getErrorCode_getErrorMessage_basic.phpt
new file mode 100644
index 0000000..71c0534
--- /dev/null
+++ b/ext/intl/tests/calendar_getErrorCode_getErrorMessage_basic.phpt
@@ -0,0 +1,43 @@
+--TEST--
+IntlCalendar::getErrorCode(), ::getErrorMessage() basic test
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+$intlcal = new IntlGregorianCalendar(2012, 1, 29);
+var_dump(
+ $intlcal->getErrorCode(),
+ intlcal_get_error_code($intlcal),
+ $intlcal->getErrorMessage(),
+ intlcal_get_error_message($intlcal)
+);
+$intlcal->add(IntlCalendar::FIELD_SECOND, 2147483647);
+$intlcal->fieldDifference(-PHP_INT_MAX, IntlCalendar::FIELD_SECOND);
+
+var_dump(
+ $intlcal->getErrorCode(),
+ intlcal_get_error_code($intlcal),
+ $intlcal->getErrorMessage(),
+ intlcal_get_error_message($intlcal)
+);
+?>
+==DONE==
+--EXPECTF--
+int(0)
+int(0)
+string(12) "U_ZERO_ERROR"
+string(12) "U_ZERO_ERROR"
+
+Warning: IntlCalendar::fieldDifference(): intlcal_field_difference: Call to ICU method has failed in %s on line %d
+int(1)
+int(1)
+string(81) "intlcal_field_difference: Call to ICU method has failed: U_ILLEGAL_ARGUMENT_ERROR"
+string(81) "intlcal_field_difference: Call to ICU method has failed: U_ILLEGAL_ARGUMENT_ERROR"
+==DONE==
diff --git a/ext/intl/tests/calendar_getErrorMessage_error.phpt b/ext/intl/tests/calendar_getErrorMessage_error.phpt
new file mode 100644
index 0000000..6081833
--- /dev/null
+++ b/ext/intl/tests/calendar_getErrorMessage_error.phpt
@@ -0,0 +1,26 @@
+--TEST--
+IntlCalendar::getErrorMessage(): bad arguments
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$c = new IntlGregorianCalendar(NULL, 'pt_PT');
+
+var_dump($c->getErrorMessage(array()));
+
+var_dump(intlcal_get_error_message(null));
+
+--EXPECTF--
+
+Warning: IntlCalendar::getErrorMessage() expects exactly 0 parameters, 1 given in %s on line %d
+
+Warning: IntlCalendar::getErrorMessage(): intlcal_get_error_message: bad arguments in %s on line %d
+bool(false)
+
+Catchable fatal error: Argument 1 passed to intlcal_get_error_message() must be an instance of IntlCalendar, null given in %s on line %d
diff --git a/ext/intl/tests/calendar_getFirstDayOfWeek_basic.phpt b/ext/intl/tests/calendar_getFirstDayOfWeek_basic.phpt
new file mode 100644
index 0000000..82a0bc8
--- /dev/null
+++ b/ext/intl/tests/calendar_getFirstDayOfWeek_basic.phpt
@@ -0,0 +1,20 @@
+--TEST--
+IntlCalendar::getFirstDayOfWeek() basic test
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+$intlcal = IntlCalendar::createInstance('UTC');
+var_dump($intlcal->getFirstDayOfWeek());
+var_dump(intlcal_get_first_day_of_week($intlcal));
+?>
+==DONE==
+--EXPECT--
+int(2)
+int(2)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/calendar_getFirstDayOfWeek_error.phpt b/ext/intl/tests/calendar_getFirstDayOfWeek_error.phpt
new file mode 100644
index 0000000..e13b513
--- /dev/null
+++ b/ext/intl/tests/calendar_getFirstDayOfWeek_error.phpt
@@ -0,0 +1,32 @@
+--TEST--
+IntlCalendar::getFirstDayOfWeek(): bad arguments
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$c = new IntlGregorianCalendar(NULL, 'pt_PT');
+
+var_dump($c->getFirstDayOfWeek(1));
+
+var_dump(intlcal_get_first_day_of_week($c, 1));
+var_dump(intlcal_get_first_day_of_week(1));
+
+--EXPECTF--
+
+Warning: IntlCalendar::getFirstDayOfWeek() expects exactly 0 parameters, 1 given in %s on line %d
+
+Warning: IntlCalendar::getFirstDayOfWeek(): intlcal_get_first_day_of_week: bad arguments in %s on line %d
+bool(false)
+
+Warning: intlcal_get_first_day_of_week() expects exactly 1 parameter, 2 given in %s on line %d
+
+Warning: intlcal_get_first_day_of_week(): intlcal_get_first_day_of_week: bad arguments in %s on line %d
+bool(false)
+
+Catchable fatal error: Argument 1 passed to intlcal_get_first_day_of_week() must be an instance of IntlCalendar, integer given in %s on line %d
diff --git a/ext/intl/tests/calendar_getKeywordValuesForLocale_basic.phpt b/ext/intl/tests/calendar_getKeywordValuesForLocale_basic.phpt
new file mode 100644
index 0000000..dedfcea
--- /dev/null
+++ b/ext/intl/tests/calendar_getKeywordValuesForLocale_basic.phpt
@@ -0,0 +1,36 @@
+--TEST--
+IntlCalendar::getKeywordValuesForLocale() basic test
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '4.2') < 0)
+ die('skip for ICU 4.2+');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+print_r(
+iterator_to_array(
+IntlCalendar::getKeywordValuesForLocale('calendar', 'pt', true)
+));
+echo "\n";
+
+$var = iterator_to_array(
+intlcal_get_keyword_values_for_locale('calendar', 'pt', false)
+);
+var_dump(count($var) > 8);
+var_dump(in_array('japanese', $var));
+
+?>
+==DONE==
+--EXPECT--
+Array
+(
+ [0] => gregorian
+)
+
+bool(true)
+bool(true)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/calendar_getKeywordValuesForLocale_error.phpt b/ext/intl/tests/calendar_getKeywordValuesForLocale_error.phpt
new file mode 100644
index 0000000..2aa8002
--- /dev/null
+++ b/ext/intl/tests/calendar_getKeywordValuesForLocale_error.phpt
@@ -0,0 +1,26 @@
+--TEST--
+IntlCalendar::getKeywordValuesForLocale(): bad arguments
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '4.2') < 0)
+ die('skip for ICU 4.2+');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+var_dump(intlcal_get_keyword_values_for_locale(1, 2));
+var_dump(IntlCalendar::getKeywordValuesForLocale(1, 2, array()));
+
+--EXPECTF--
+
+Warning: intlcal_get_keyword_values_for_locale() expects exactly 3 parameters, 2 given in %s on line %d
+
+Warning: intlcal_get_keyword_values_for_locale(): intlcal_get_keyword_values_for_locale: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::getKeywordValuesForLocale() expects parameter 3 to be boolean, array given in %s on line %d
+
+Warning: IntlCalendar::getKeywordValuesForLocale(): intlcal_get_keyword_values_for_locale: bad arguments in %s on line %d
+bool(false)
diff --git a/ext/intl/tests/calendar_getLocale_basic.phpt b/ext/intl/tests/calendar_getLocale_basic.phpt
new file mode 100644
index 0000000..63f846f
--- /dev/null
+++ b/ext/intl/tests/calendar_getLocale_basic.phpt
@@ -0,0 +1,22 @@
+--TEST--
+IntlCalendar::getLocale() basic test
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '4.8') < 0)
+ die('skip for ICU 4.8+');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+$intlcal = IntlCalendar::createInstance('UTC');
+var_dump($intlcal->getLocale(Locale::ACTUAL_LOCALE));
+var_dump(intlcal_get_locale($intlcal, Locale::VALID_LOCALE));
+?>
+==DONE==
+--EXPECT--
+string(2) "nl"
+string(5) "nl_NL"
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/calendar_getLocale_error.phpt b/ext/intl/tests/calendar_getLocale_error.phpt
new file mode 100644
index 0000000..42970a9
--- /dev/null
+++ b/ext/intl/tests/calendar_getLocale_error.phpt
@@ -0,0 +1,42 @@
+--TEST--
+IntlCalendar::getLocale(): bad arguments
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$c = new IntlGregorianCalendar(NULL, 'pt_PT');
+
+var_dump($c->getLocale());
+var_dump($c->getLocale(2));
+var_dump($c->getLocale(2, 3));
+
+var_dump(intlcal_get_locale($c));
+var_dump(intlcal_get_locale(1));
+
+--EXPECTF--
+
+Warning: IntlCalendar::getLocale() expects exactly 1 parameter, 0 given in %s on line %d
+
+Warning: IntlCalendar::getLocale(): intlcal_get_locale: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::getLocale(): intlcal_get_locale: invalid locale type in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::getLocale() expects exactly 1 parameter, 2 given in %s on line %d
+
+Warning: IntlCalendar::getLocale(): intlcal_get_locale: bad arguments in %s on line %d
+bool(false)
+
+Warning: intlcal_get_locale() expects exactly 2 parameters, 1 given in %s on line %d
+
+Warning: intlcal_get_locale(): intlcal_get_locale: bad arguments in %s on line %d
+bool(false)
+
+Catchable fatal error: Argument 1 passed to intlcal_get_locale() must be an instance of IntlCalendar, integer given in %s on line %d
diff --git a/ext/intl/tests/calendar_getMinimalDaysInFirstWeek_basic.phpt b/ext/intl/tests/calendar_getMinimalDaysInFirstWeek_basic.phpt
new file mode 100644
index 0000000..eeaa310
--- /dev/null
+++ b/ext/intl/tests/calendar_getMinimalDaysInFirstWeek_basic.phpt
@@ -0,0 +1,22 @@
+--TEST--
+IntlCalendar::getMinimalDaysInFirstWeek() basic test
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '4.8') < 0)
+ die('skip for ICU 4.8+');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+$intlcal = IntlCalendar::createInstance('UTC');
+var_dump($intlcal->getMinimalDaysInFirstWeek());
+var_dump(intlcal_get_minimal_days_in_first_week($intlcal));
+?>
+==DONE==
+--EXPECT--
+int(4)
+int(4)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/calendar_getMinimalDaysInFirstWeek_error.phpt b/ext/intl/tests/calendar_getMinimalDaysInFirstWeek_error.phpt
new file mode 100644
index 0000000..8e1971d
--- /dev/null
+++ b/ext/intl/tests/calendar_getMinimalDaysInFirstWeek_error.phpt
@@ -0,0 +1,32 @@
+--TEST--
+IntlCalendar::getMinimalDaysInFirstWeek(): bad arguments
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$c = new IntlGregorianCalendar(NULL, 'pt_PT');
+
+var_dump($c->getMinimalDaysInFirstWeek(1));
+
+var_dump(intlcal_get_minimal_days_in_first_week($c, 1));
+var_dump(intlcal_get_minimal_days_in_first_week(1));
+
+--EXPECTF--
+
+Warning: IntlCalendar::getMinimalDaysInFirstWeek() expects exactly 0 parameters, 1 given in %s on line %d
+
+Warning: IntlCalendar::getMinimalDaysInFirstWeek(): intlcal_get_minimal_days_in_first_week: bad arguments in %s on line %d
+bool(false)
+
+Warning: intlcal_get_minimal_days_in_first_week() expects exactly 1 parameter, 2 given in %s on line %d
+
+Warning: intlcal_get_minimal_days_in_first_week(): intlcal_get_minimal_days_in_first_week: bad arguments in %s on line %d
+bool(false)
+
+Catchable fatal error: Argument 1 passed to intlcal_get_minimal_days_in_first_week() must be an instance of IntlCalendar, integer given in %s on line %d
diff --git a/ext/intl/tests/calendar_getNow_basic.phpt b/ext/intl/tests/calendar_getNow_basic.phpt
new file mode 100644
index 0000000..18325df
--- /dev/null
+++ b/ext/intl/tests/calendar_getNow_basic.phpt
@@ -0,0 +1,23 @@
+--TEST--
+IntlCalendar::getNow() basic test
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+$now = IntlCalendar::getNow();
+$proc_now = intlcal_get_now();
+$time = time();
+var_dump(abs($now - $proc_now) < 500);
+var_dump(abs($time * 1000 - $proc_now) < 1000);
+
+?>
+==DONE==
+--EXPECT--
+bool(true)
+bool(true)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/calendar_getNow_error.phpt b/ext/intl/tests/calendar_getNow_error.phpt
new file mode 100644
index 0000000..31991bb
--- /dev/null
+++ b/ext/intl/tests/calendar_getNow_error.phpt
@@ -0,0 +1,24 @@
+--TEST--
+IntlCalendar::getNow(): bad arguments
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+var_dump(intlcal_get_now(1));
+var_dump(IntlCalendar::getNow(2));
+
+--EXPECTF--
+
+Warning: intlcal_get_now() expects exactly 0 parameters, 1 given in %s on line %d
+
+Warning: intlcal_get_now(): intlcal_get_now: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::getNow() expects exactly 0 parameters, 1 given in %s on line %d
+
+Warning: IntlCalendar::getNow(): intlcal_get_now: bad arguments in %s on line %d
+bool(false)
diff --git a/ext/intl/tests/calendar_getSkipped_RepeatedWallTimeOption_error.phpt b/ext/intl/tests/calendar_getSkipped_RepeatedWallTimeOption_error.phpt
new file mode 100644
index 0000000..e071355
--- /dev/null
+++ b/ext/intl/tests/calendar_getSkipped_RepeatedWallTimeOption_error.phpt
@@ -0,0 +1,47 @@
+--TEST--
+IntlCalendar::getSkipped/RepeatedWallTimeOption(): bad arguments
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '49') < 0)
+ die('skip for ICU 49+');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$c = new IntlGregorianCalendar(NULL, 'pt_PT');
+
+var_dump($c->getSkippedWallTimeOption(1));
+var_dump($c->getRepeatedWallTimeOption(1));
+
+var_dump(intlcal_get_skipped_wall_time_option($c, 1));
+var_dump(intlcal_get_repeated_wall_time_option($c, 1));
+
+var_dump(intlcal_get_skipped_wall_time_option(1));
+
+--EXPECTF--
+
+Warning: IntlCalendar::getSkippedWallTimeOption() expects exactly 0 parameters, 1 given in %s on line %d
+
+Warning: IntlCalendar::getSkippedWallTimeOption(): intlcal_get_skipped_wall_time_option: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::getRepeatedWallTimeOption() expects exactly 0 parameters, 1 given in %s on line %d
+
+Warning: IntlCalendar::getRepeatedWallTimeOption(): intlcal_get_repeated_wall_time_option: bad arguments in %s on line %d
+bool(false)
+
+Warning: intlcal_get_skipped_wall_time_option() expects exactly 1 parameter, 2 given in %s on line %d
+
+Warning: intlcal_get_skipped_wall_time_option(): intlcal_get_skipped_wall_time_option: bad arguments in %s on line %d
+bool(false)
+
+Warning: intlcal_get_repeated_wall_time_option() expects exactly 1 parameter, 2 given in %s on line %d
+
+Warning: intlcal_get_repeated_wall_time_option(): intlcal_get_repeated_wall_time_option: bad arguments in %s on line %d
+bool(false)
+
+Catchable fatal error: Argument 1 passed to intlcal_get_skipped_wall_time_option() must be an instance of IntlCalendar, integer given in %s on line %d
diff --git a/ext/intl/tests/calendar_getTimeZone_basic.phpt b/ext/intl/tests/calendar_getTimeZone_basic.phpt
new file mode 100644
index 0000000..fd9aff1
--- /dev/null
+++ b/ext/intl/tests/calendar_getTimeZone_basic.phpt
@@ -0,0 +1,34 @@
+--TEST--
+IntlCalendar::getTimeZone() basic test
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '4.8') < 0)
+ die('skip for ICU 4.8+');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+$intlcal = IntlCalendar::createInstance('GMT+00:01');
+print_r($intlcal->getTimeZone());
+print_r(intlcal_get_time_zone($intlcal));
+?>
+==DONE==
+--EXPECT--
+IntlTimeZone Object
+(
+ [valid] => 1
+ [id] => GMT+00:01
+ [rawOffset] => 60000
+ [currentOffset] => 60000
+)
+IntlTimeZone Object
+(
+ [valid] => 1
+ [id] => GMT+00:01
+ [rawOffset] => 60000
+ [currentOffset] => 60000
+)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/calendar_getTimeZone_error.phpt b/ext/intl/tests/calendar_getTimeZone_error.phpt
new file mode 100644
index 0000000..470701c
--- /dev/null
+++ b/ext/intl/tests/calendar_getTimeZone_error.phpt
@@ -0,0 +1,32 @@
+--TEST--
+IntlCalendar::getTimeZone(): bad arguments
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$c = new IntlGregorianCalendar(NULL, 'pt_PT');
+
+var_dump($c->getTimeZone(1));
+
+var_dump(intlcal_get_time_zone($c, 1));
+var_dump(intlcal_get_time_zone(1));
+
+--EXPECTF--
+
+Warning: IntlCalendar::getTimeZone() expects exactly 0 parameters, 1 given in %s on line %d
+
+Warning: IntlCalendar::getTimeZone(): intlcal_get_time_zone: bad arguments in %s on line %d
+bool(false)
+
+Warning: intlcal_get_time_zone() expects exactly 1 parameter, 2 given in %s on line %d
+
+Warning: intlcal_get_time_zone(): intlcal_get_time_zone: bad arguments in %s on line %d
+bool(false)
+
+Catchable fatal error: Argument 1 passed to intlcal_get_time_zone() must be an instance of IntlCalendar, integer given in %s on line %d
diff --git a/ext/intl/tests/calendar_getTime_basic.phpt b/ext/intl/tests/calendar_getTime_basic.phpt
new file mode 100644
index 0000000..659c71c
--- /dev/null
+++ b/ext/intl/tests/calendar_getTime_basic.phpt
@@ -0,0 +1,29 @@
+--TEST--
+IntlCalendar::getTime() basic test
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+$intlcal = IntlCalendar::createInstance('UTC');
+$intlcal->clear();
+$intlcal->set(IntlCalendar::FIELD_YEAR, 2012);
+$intlcal->set(IntlCalendar::FIELD_MONTH, 1 /* Feb */);
+$intlcal->set(IntlCalendar::FIELD_DAY_OF_MONTH, 29);
+
+$time = strtotime('2012-02-29 00:00:00 +0000');
+
+var_dump((float)$time*1000, $intlcal->getTime());
+
+?>
+==DONE==
+--EXPECT--
+float(1330473600000)
+float(1330473600000)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/calendar_getTime_error.phpt b/ext/intl/tests/calendar_getTime_error.phpt
new file mode 100644
index 0000000..5d27e21
--- /dev/null
+++ b/ext/intl/tests/calendar_getTime_error.phpt
@@ -0,0 +1,31 @@
+--TEST--
+IntlCalendar::getTime(): bad arguments
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$c = new IntlGregorianCalendar(NULL, 'pt_PT');
+
+var_dump($c->getTime(1));
+
+var_dump(intlcal_get_time($c, 1));
+var_dump(intlcal_get_time(1));
+--EXPECTF--
+
+Warning: IntlCalendar::getTime() expects exactly 0 parameters, 1 given in %s on line %d
+
+Warning: IntlCalendar::getTime(): intlcal_get_time: bad arguments in %s on line %d
+bool(false)
+
+Warning: intlcal_get_time() expects exactly 1 parameter, 2 given in %s on line %d
+
+Warning: intlcal_get_time(): intlcal_get_time: bad arguments in %s on line %d
+bool(false)
+
+Catchable fatal error: Argument 1 passed to intlcal_get_time() must be an instance of IntlCalendar, integer given in %s on line %d
diff --git a/ext/intl/tests/calendar_getType_basic.phpt b/ext/intl/tests/calendar_getType_basic.phpt
new file mode 100644
index 0000000..ba32dd0
--- /dev/null
+++ b/ext/intl/tests/calendar_getType_basic.phpt
@@ -0,0 +1,23 @@
+--TEST--
+IntlCalendar::getType() basic test
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+$intlcal = IntlCalendar::createInstance();
+VAR_DUMP($intlcal->getType());
+$intlcal = IntlCalendar::createInstance(null, "nl_NL@calendar=hebrew");
+VAR_DUMP(intlcal_get_type($intlcal));
+?>
+==DONE==
+--EXPECT--
+string(9) "gregorian"
+string(6) "hebrew"
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/calendar_getType_error.phpt b/ext/intl/tests/calendar_getType_error.phpt
new file mode 100644
index 0000000..668ebea
--- /dev/null
+++ b/ext/intl/tests/calendar_getType_error.phpt
@@ -0,0 +1,32 @@
+--TEST--
+IntlCalendar::getType(): bad arguments
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$c = new IntlGregorianCalendar(NULL, 'pt_PT');
+
+var_dump($c->getType(1));
+
+var_dump(intlcal_get_type($c, 1));
+var_dump(intlcal_get_type(1));
+
+--EXPECTF--
+
+Warning: IntlCalendar::getType() expects exactly 0 parameters, 1 given in %s on line %d
+
+Warning: IntlCalendar::getType(): intlcal_get_type: bad arguments in %s on line %d
+bool(false)
+
+Warning: intlcal_get_type() expects exactly 1 parameter, 2 given in %s on line %d
+
+Warning: intlcal_get_type(): intlcal_get_type: bad arguments in %s on line %d
+bool(false)
+
+Catchable fatal error: Argument 1 passed to intlcal_get_type() must be an instance of IntlCalendar, integer given in %s on line %d
diff --git a/ext/intl/tests/calendar_getWeekendTransition_basic.phpt b/ext/intl/tests/calendar_getWeekendTransition_basic.phpt
new file mode 100644
index 0000000..e725743
--- /dev/null
+++ b/ext/intl/tests/calendar_getWeekendTransition_basic.phpt
@@ -0,0 +1,24 @@
+--TEST--
+IntlCalendar::getWeekendTransition() basic test
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '4.4') < 0)
+ die('skip for ICU 4.4+');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+$intlcal = IntlCalendar::createInstance();
+var_dump($intlcal->getWeekendTransition(IntlCalendar::DOW_SUNDAY));
+var_dump(intlcal_get_weekend_transition($intlcal, IntlCalendar::DOW_SUNDAY));
+?>
+==DONE==
+--EXPECT--
+int(86400000)
+int(86400000)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/calendar_getWeekendTransition_error.phpt b/ext/intl/tests/calendar_getWeekendTransition_error.phpt
new file mode 100644
index 0000000..f7c9cc7
--- /dev/null
+++ b/ext/intl/tests/calendar_getWeekendTransition_error.phpt
@@ -0,0 +1,44 @@
+--TEST--
+IntlCalendar::getWeekendTransition(): bad arguments
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '4.4') < 0)
+ die('skip for ICU 4.4+');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$c = new IntlGregorianCalendar(NULL, 'pt_PT');
+
+var_dump($c->getWeekendTransition());
+var_dump($c->getWeekendTransition(1, 2));
+var_dump($c->getWeekendTransition(0));
+
+var_dump(intlcal_get_weekend_transition($c));
+var_dump(intlcal_get_weekend_transition(1, 1));
+
+--EXPECTF--
+
+Warning: IntlCalendar::getWeekendTransition() expects exactly 1 parameter, 0 given in %s on line %d
+
+Warning: IntlCalendar::getWeekendTransition(): intlcal_get_weekend_transition: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::getWeekendTransition() expects exactly 1 parameter, 2 given in %s on line %d
+
+Warning: IntlCalendar::getWeekendTransition(): intlcal_get_weekend_transition: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::getWeekendTransition(): intlcal_get_weekend_transition: invalid day of week in %s on line %d
+bool(false)
+
+Warning: intlcal_get_weekend_transition() expects exactly 2 parameters, 1 given in %s on line %d
+
+Warning: intlcal_get_weekend_transition(): intlcal_get_weekend_transition: bad arguments in %s on line %d
+bool(false)
+
+Catchable fatal error: Argument 1 passed to intlcal_get_weekend_transition() must be an instance of IntlCalendar, integer given in %s on line %d
diff --git a/ext/intl/tests/calendar_getXMaximum_basic.phpt b/ext/intl/tests/calendar_getXMaximum_basic.phpt
new file mode 100644
index 0000000..9b84021
--- /dev/null
+++ b/ext/intl/tests/calendar_getXMaximum_basic.phpt
@@ -0,0 +1,34 @@
+--TEST--
+IntlCalendar::getMaximum(), ::getActualMaximum(), ::getLeastMaximum() basic test
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+$intlcal = IntlCalendar::createInstance('UTC');
+$intlcal->setTime(strtotime('2012-02-29 05:06:07 +0000') * 1000);
+var_dump(
+ $intlcal->getLeastMaximum(IntlCalendar::FIELD_DAY_OF_MONTH),
+ intlcal_get_least_maximum($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH),
+ $intlcal->getActualMaximum(IntlCalendar::FIELD_DAY_OF_MONTH),
+ intlcal_get_actual_maximum($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH),
+ $intlcal->getMaximum(IntlCalendar::FIELD_DAY_OF_MONTH),
+ intlcal_get_maximum($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH)
+);
+
+?>
+==DONE==
+--EXPECT--
+int(28)
+int(28)
+int(29)
+int(29)
+int(31)
+int(31)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/calendar_getXMinimum_basic.phpt b/ext/intl/tests/calendar_getXMinimum_basic.phpt
new file mode 100644
index 0000000..83fd163
--- /dev/null
+++ b/ext/intl/tests/calendar_getXMinimum_basic.phpt
@@ -0,0 +1,34 @@
+--TEST--
+IntlCalendar::getMinimum(), ::getActualMinimum(), ::getGreatestMinimum() basic test
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+$intlcal = IntlCalendar::createInstance('UTC');
+$intlcal->setTime(strtotime('2012-02-29 05:06:07 +0000') * 1000);
+var_dump(
+ $intlcal->getGreatestMinimum(IntlCalendar::FIELD_DAY_OF_MONTH),
+ intlcal_get_greatest_minimum($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH),
+ $intlcal->getActualMinimum(IntlCalendar::FIELD_DAY_OF_MONTH),
+ intlcal_get_actual_minimum($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH),
+ $intlcal->getMinimum(IntlCalendar::FIELD_DAY_OF_MONTH),
+ intlcal_get_minimum($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH)
+);
+
+?>
+==DONE==
+--EXPECT--
+int(1)
+int(1)
+int(1)
+int(1)
+int(1)
+int(1)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/calendar_get_Least_Greatest_Minimum_Maximum_error.phpt b/ext/intl/tests/calendar_get_Least_Greatest_Minimum_Maximum_error.phpt
new file mode 100644
index 0000000..acd9b58
--- /dev/null
+++ b/ext/intl/tests/calendar_get_Least_Greatest_Minimum_Maximum_error.phpt
@@ -0,0 +1,100 @@
+--TEST--
+IntlCalendar::get/Least/Greatest/Minimum/Maximum(): bad arguments
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$c = new IntlGregorianCalendar(NULL, 'pt_PT');
+
+var_dump($c->getLeastMaximum());
+var_dump($c->getMaximum());
+var_dump($c->getGreatestMinimum());
+var_dump($c->getMinimum());
+
+var_dump($c->getLeastMaximum(-1));
+var_dump($c->getMaximum(-1));
+var_dump($c->getGreatestMinimum(-1));
+var_dump($c->getMinimum(-1));
+
+var_dump(intlcal_get_least_maximum($c, -1));
+var_dump(intlcal_get_maximum($c, -1));
+var_dump(intlcal_get_greatest_minimum($c, -1));
+var_dump(intlcal_get_minimum($c, -1));
+
+function eh($errno, $errstr) {
+echo "error: $errno, $errstr\n";
+}
+set_error_handler('eh');
+
+var_dump(intlcal_get_least_maximum(1, 1));
+var_dump(intlcal_get_maximum(1, 1));
+var_dump(intlcal_get_greatest_minimum(1, -1));
+var_dump(intlcal_get_minimum(1, -1));
+
+--EXPECTF--
+
+Warning: IntlCalendar::getLeastMaximum() expects exactly 1 parameter, 0 given in %s on line %d
+
+Warning: IntlCalendar::getLeastMaximum(): intlcal_get_least_maximum: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::getMaximum() expects exactly 1 parameter, 0 given in %s on line %d
+
+Warning: IntlCalendar::getMaximum(): intlcal_get_maximum: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::getGreatestMinimum() expects exactly 1 parameter, 0 given in %s on line %d
+
+Warning: IntlCalendar::getGreatestMinimum(): intlcal_get_greatest_minimum: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::getMinimum() expects exactly 1 parameter, 0 given in %s on line %d
+
+Warning: IntlCalendar::getMinimum(): intlcal_get_minimum: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::getLeastMaximum(): intlcal_get_least_maximum: invalid field in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::getMaximum(): intlcal_get_maximum: invalid field in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::getGreatestMinimum(): intlcal_get_greatest_minimum: invalid field in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::getMinimum(): intlcal_get_minimum: invalid field in %s on line %d
+bool(false)
+
+Warning: intlcal_get_least_maximum(): intlcal_get_least_maximum: invalid field in %s on line %d
+bool(false)
+
+Warning: intlcal_get_maximum(): intlcal_get_maximum: invalid field in %s on line %d
+bool(false)
+
+Warning: intlcal_get_greatest_minimum(): intlcal_get_greatest_minimum: invalid field in %s on line %d
+bool(false)
+
+Warning: intlcal_get_minimum(): intlcal_get_minimum: invalid field in %s on line %d
+bool(false)
+error: 4096, Argument 1 passed to intlcal_get_least_maximum() must be an instance of IntlCalendar, integer given
+error: 2, intlcal_get_least_maximum() expects parameter 1 to be IntlCalendar, integer given
+error: 2, intlcal_get_least_maximum(): intlcal_get_least_maximum: bad arguments
+bool(false)
+error: 4096, Argument 1 passed to intlcal_get_maximum() must be an instance of IntlCalendar, integer given
+error: 2, intlcal_get_maximum() expects parameter 1 to be IntlCalendar, integer given
+error: 2, intlcal_get_maximum(): intlcal_get_maximum: bad arguments
+bool(false)
+error: 4096, Argument 1 passed to intlcal_get_greatest_minimum() must be an instance of IntlCalendar, integer given
+error: 2, intlcal_get_greatest_minimum() expects parameter 1 to be IntlCalendar, integer given
+error: 2, intlcal_get_greatest_minimum(): intlcal_get_greatest_minimum: bad arguments
+bool(false)
+error: 4096, Argument 1 passed to intlcal_get_minimum() must be an instance of IntlCalendar, integer given
+error: 2, intlcal_get_minimum() expects parameter 1 to be IntlCalendar, integer given
+error: 2, intlcal_get_minimum(): intlcal_get_minimum: bad arguments
+bool(false)
diff --git a/ext/intl/tests/calendar_get_basic.phpt b/ext/intl/tests/calendar_get_basic.phpt
new file mode 100644
index 0000000..c617639
--- /dev/null
+++ b/ext/intl/tests/calendar_get_basic.phpt
@@ -0,0 +1,23 @@
+--TEST--
+IntlCalendar::get() basic test
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+$intlcal = IntlCalendar::createInstance('UTC');
+$intlcal->set(IntlCalendar::FIELD_DAY_OF_MONTH, 4);
+
+var_dump($intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH));
+var_dump(intlcal_get($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH));
+
+?>
+==DONE==
+--EXPECT--
+int(4)
+int(4)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/calendar_get_getActualMaximum_Minumum_error.phpt b/ext/intl/tests/calendar_get_getActualMaximum_Minumum_error.phpt
new file mode 100644
index 0000000..f6ccb12
--- /dev/null
+++ b/ext/intl/tests/calendar_get_getActualMaximum_Minumum_error.phpt
@@ -0,0 +1,84 @@
+--TEST--
+IntlCalendar::get/getActualMaximum/getActualMinimum(): bad arguments
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$c = new IntlGregorianCalendar(NULL, 'pt_PT');
+
+var_dump($c->get());
+var_dump($c->getActualMaximum());
+var_dump($c->getActualMinimum());
+
+var_dump($c->get(-1));
+var_dump($c->getActualMaximum(-1));
+var_dump($c->getActualMinimum(-1));
+
+var_dump($c->get("s"));
+var_dump($c->getActualMaximum("s"));
+var_dump($c->getActualMinimum("s"));
+
+var_dump($c->get(1, 2));
+var_dump($c->getActualMaximum(1, 2));
+var_dump($c->getActualMinimum(1, 2));
+--EXPECTF--
+
+Warning: IntlCalendar::get() expects exactly 1 parameter, 0 given in %s on line %d
+
+Warning: IntlCalendar::get(): intlcal_get: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::getActualMaximum() expects exactly 1 parameter, 0 given in %s on line %d
+
+Warning: IntlCalendar::getActualMaximum(): intlcal_get_actual_maximum: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::getActualMinimum() expects exactly 1 parameter, 0 given in %s on line %d
+
+Warning: IntlCalendar::getActualMinimum(): intlcal_get_actual_minimum: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::get(): intlcal_get: invalid field in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::getActualMaximum(): intlcal_get_actual_maximum: invalid field in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::getActualMinimum(): intlcal_get_actual_minimum: invalid field in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::get() expects parameter 1 to be long, string given in %s on line %d
+
+Warning: IntlCalendar::get(): intlcal_get: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::getActualMaximum() expects parameter 1 to be long, string given in %s on line %d
+
+Warning: IntlCalendar::getActualMaximum(): intlcal_get_actual_maximum: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::getActualMinimum() expects parameter 1 to be long, string given in %s on line %d
+
+Warning: IntlCalendar::getActualMinimum(): intlcal_get_actual_minimum: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::get() expects exactly 1 parameter, 2 given in %s on line %d
+
+Warning: IntlCalendar::get(): intlcal_get: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::getActualMaximum() expects exactly 1 parameter, 2 given in %s on line %d
+
+Warning: IntlCalendar::getActualMaximum(): intlcal_get_actual_maximum: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::getActualMinimum() expects exactly 1 parameter, 2 given in %s on line %d
+
+Warning: IntlCalendar::getActualMinimum(): intlcal_get_actual_minimum: bad arguments in %s on line %d
+bool(false)
diff --git a/ext/intl/tests/calendar_get_getActualMaximum_Minumum_error2.phpt b/ext/intl/tests/calendar_get_getActualMaximum_Minumum_error2.phpt
new file mode 100644
index 0000000..a8d1a4a
--- /dev/null
+++ b/ext/intl/tests/calendar_get_getActualMaximum_Minumum_error2.phpt
@@ -0,0 +1,71 @@
+--TEST--
+IntlCalendar::get/getActualMaximum/getActualMinimum(): bad arguments (procedural)
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$c = new IntlGregorianCalendar(NULL, 'pt_PT');
+
+function eh($errno, $errstr) {
+echo "error: $errno, $errstr\n";
+}
+set_error_handler('eh');
+
+var_dump(intlcal_get($c));
+var_dump(intlcal_get_actual_maximum($c));
+var_dump(intlcal_get_actual_minimum($c));
+
+var_dump(intlcal_get($c, -1));
+var_dump(intlcal_get_actual_maximum($c, -1));
+var_dump(intlcal_get_actual_minimum($c, -1));
+
+var_dump(intlcal_get($c, "s"));
+var_dump(intlcal_get_actual_maximum($c, "s"));
+var_dump(intlcal_get_actual_minimum($c, "s"));
+
+var_dump(intlcal_get(1));
+var_dump(intlcal_get_actual_maximum(1));
+var_dump(intlcal_get_actual_minimum(1));
+--EXPECT--
+error: 2, intlcal_get() expects exactly 2 parameters, 1 given
+error: 2, intlcal_get(): intlcal_get: bad arguments
+bool(false)
+error: 2, intlcal_get_actual_maximum() expects exactly 2 parameters, 1 given
+error: 2, intlcal_get_actual_maximum(): intlcal_get_actual_maximum: bad arguments
+bool(false)
+error: 2, intlcal_get_actual_minimum() expects exactly 2 parameters, 1 given
+error: 2, intlcal_get_actual_minimum(): intlcal_get_actual_minimum: bad arguments
+bool(false)
+error: 2, intlcal_get(): intlcal_get: invalid field
+bool(false)
+error: 2, intlcal_get_actual_maximum(): intlcal_get_actual_maximum: invalid field
+bool(false)
+error: 2, intlcal_get_actual_minimum(): intlcal_get_actual_minimum: invalid field
+bool(false)
+error: 2, intlcal_get() expects parameter 2 to be long, string given
+error: 2, intlcal_get(): intlcal_get: bad arguments
+bool(false)
+error: 2, intlcal_get_actual_maximum() expects parameter 2 to be long, string given
+error: 2, intlcal_get_actual_maximum(): intlcal_get_actual_maximum: bad arguments
+bool(false)
+error: 2, intlcal_get_actual_minimum() expects parameter 2 to be long, string given
+error: 2, intlcal_get_actual_minimum(): intlcal_get_actual_minimum: bad arguments
+bool(false)
+error: 4096, Argument 1 passed to intlcal_get() must be an instance of IntlCalendar, integer given
+error: 2, intlcal_get() expects exactly 2 parameters, 1 given
+error: 2, intlcal_get(): intlcal_get: bad arguments
+bool(false)
+error: 4096, Argument 1 passed to intlcal_get_actual_maximum() must be an instance of IntlCalendar, integer given
+error: 2, intlcal_get_actual_maximum() expects exactly 2 parameters, 1 given
+error: 2, intlcal_get_actual_maximum(): intlcal_get_actual_maximum: bad arguments
+bool(false)
+error: 4096, Argument 1 passed to intlcal_get_actual_minimum() must be an instance of IntlCalendar, integer given
+error: 2, intlcal_get_actual_minimum() expects exactly 2 parameters, 1 given
+error: 2, intlcal_get_actual_minimum(): intlcal_get_actual_minimum: bad arguments
+bool(false)
diff --git a/ext/intl/tests/calendar_get_setRepeatedWallTimeOption_basic.phpt b/ext/intl/tests/calendar_get_setRepeatedWallTimeOption_basic.phpt
new file mode 100644
index 0000000..5276543
--- /dev/null
+++ b/ext/intl/tests/calendar_get_setRepeatedWallTimeOption_basic.phpt
@@ -0,0 +1,49 @@
+--TEST--
+IntlCalendar::get/setRepeatedWallTimeOption(): basic test
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '49') < 0)
+ die('skip for ICU 49+');
+--FILE--
+
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+date_default_timezone_set('Europe/Amsterdam');
+
+//28 October 2012, transition from DST
+$intlcal = new IntlGregorianCalendar(2012, 9, 28, 0, 0, 0);
+var_dump($intlcal->setRepeatedWallTimeOption(IntlCalendar::WALLTIME_LAST));
+var_dump($intlcal->getRepeatedWallTimeOption());
+$intlcal->set(IntlCalendar::FIELD_HOUR_OF_DAY, 2);
+$intlcal->set(IntlCalendar::FIELD_MINUTE, 30);
+var_dump(
+ strtotime('2012-10-28 02:30:00 +0100'),
+ (int)($intlcal->getTime() /1000)
+);
+
+var_dump(intlcal_set_repeated_wall_time_option($intlcal, IntlCalendar::WALLTIME_FIRST));
+var_dump(intlcal_get_repeated_wall_time_option($intlcal));
+$intlcal->set(IntlCalendar::FIELD_HOUR_OF_DAY, 2);
+$intlcal->set(IntlCalendar::FIELD_MINUTE, 30);
+var_dump(
+ strtotime('2012-10-28 02:30:00 +0200'),
+ (int)($intlcal->getTime() /1000)
+);
+
+?>
+==DONE==
+--EXPECT--
+
+bool(true)
+int(0)
+int(1351387800)
+int(1351387800)
+bool(true)
+int(1)
+int(1351384200)
+int(1351384200)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/calendar_get_setSkippedWallTimeOption_basic.phpt b/ext/intl/tests/calendar_get_setSkippedWallTimeOption_basic.phpt
new file mode 100644
index 0000000..bbbf031
--- /dev/null
+++ b/ext/intl/tests/calendar_get_setSkippedWallTimeOption_basic.phpt
@@ -0,0 +1,67 @@
+--TEST--
+IntlCalendar::get/setSkippedWallTimeOption(): basic test
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '49') < 0)
+ die('skip for ICU 49+');
+--FILE--
+
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+date_default_timezone_set('Europe/Amsterdam');
+
+//25 March 2012, transition to DST
+$intlcal = new IntlGregorianCalendar(2012, 2, 25, 0, 0, 0);
+var_dump($intlcal->getSkippedWallTimeOption());
+$intlcal->set(IntlCalendar::FIELD_HOUR_OF_DAY, 2);
+$intlcal->set(IntlCalendar::FIELD_MINUTE, 30);
+echo "Should be 3h30\n";
+var_dump(
+ $intlcal->get(IntlCalendar::FIELD_HOUR_OF_DAY),
+ $intlcal->get(IntlCalendar::FIELD_MINUTE)
+);
+
+var_dump($intlcal->setSkippedWallTimeOption(IntlCalendar::WALLTIME_FIRST));
+var_dump(intlcal_get_skipped_wall_time_option($intlcal));
+$intlcal->set(IntlCalendar::FIELD_HOUR_OF_DAY, 2);
+$intlcal->set(IntlCalendar::FIELD_MINUTE, 30);
+echo "Should be 1h30\n";
+var_dump(
+ $intlcal->get(IntlCalendar::FIELD_HOUR_OF_DAY),
+ $intlcal->get(IntlCalendar::FIELD_MINUTE)
+);
+
+var_dump(intlcal_set_skipped_wall_time_option($intlcal, IntlCalendar::WALLTIME_NEXT_VALID));
+var_dump($intlcal->getSkippedWallTimeOption());
+$intlcal->set(IntlCalendar::FIELD_HOUR_OF_DAY, 2);
+$intlcal->set(IntlCalendar::FIELD_MINUTE, 30);
+echo "Should be 3h00\n";
+var_dump(
+ $intlcal->get(IntlCalendar::FIELD_HOUR_OF_DAY),
+ $intlcal->get(IntlCalendar::FIELD_MINUTE)
+);
+
+
+?>
+==DONE==
+--EXPECT--
+
+int(0)
+Should be 3h30
+int(3)
+int(30)
+bool(true)
+int(1)
+Should be 1h30
+int(1)
+int(30)
+bool(true)
+int(2)
+Should be 3h00
+int(3)
+int(0)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/calendar_inDaylightTime_basic.phpt b/ext/intl/tests/calendar_inDaylightTime_basic.phpt
new file mode 100644
index 0000000..dff8ef5
--- /dev/null
+++ b/ext/intl/tests/calendar_inDaylightTime_basic.phpt
@@ -0,0 +1,24 @@
+--TEST--
+IntlCalendar::inDaylightTime() basic test
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+$intlcal = IntlCalendar::createInstance('Europe/Amsterdam');
+$intlcal->setTime(strtotime('2012-01-01') * 1000);
+var_dump($intlcal->inDaylightTime());
+$intlcal->setTime(strtotime('2012-04-01') * 1000);
+var_dump(intlcal_in_daylight_time($intlcal));
+?>
+==DONE==
+--EXPECT--
+bool(false)
+bool(true)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/calendar_inDaylightTime_error.phpt b/ext/intl/tests/calendar_inDaylightTime_error.phpt
new file mode 100644
index 0000000..9af9aa5
--- /dev/null
+++ b/ext/intl/tests/calendar_inDaylightTime_error.phpt
@@ -0,0 +1,32 @@
+--TEST--
+IntlCalendar::inDaylightTime(): bad arguments
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$c = new IntlGregorianCalendar(NULL, 'pt_PT');
+
+var_dump($c->inDaylightTime(1));
+
+var_dump(intlcal_in_daylight_time($c, 1));
+var_dump(intlcal_in_daylight_time(1));
+
+--EXPECTF--
+
+Warning: IntlCalendar::inDaylightTime() expects exactly 0 parameters, 1 given in %s on line %d
+
+Warning: IntlCalendar::inDaylightTime(): intlcal_in_daylight_time: bad arguments in %s on line %d
+bool(false)
+
+Warning: intlcal_in_daylight_time() expects exactly 1 parameter, 2 given in %s on line %d
+
+Warning: intlcal_in_daylight_time(): intlcal_in_daylight_time: bad arguments in %s on line %d
+bool(false)
+
+Catchable fatal error: Argument 1 passed to intlcal_in_daylight_time() must be an instance of IntlCalendar, integer given in %s on line %d
diff --git a/ext/intl/tests/calendar_isEquivalentTo_basic.phpt b/ext/intl/tests/calendar_isEquivalentTo_basic.phpt
new file mode 100644
index 0000000..f71fd8a
--- /dev/null
+++ b/ext/intl/tests/calendar_isEquivalentTo_basic.phpt
@@ -0,0 +1,40 @@
+--TEST--
+IntlCalendar::isEquivalentTo() basic test
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+$intlcal1 = IntlCalendar::createInstance('Europe/Amsterdam');
+$intlcal2 = IntlCalendar::createInstance('Europe/Lisbon');
+$intlcal3 = IntlCalendar::createInstance('Europe/Amsterdam', "nl_NL@calendar=islamic");
+$intlcal4 = IntlCalendar::createInstance('Europe/Amsterdam');
+$intlcal4->roll(IntlCalendar::FIELD_MONTH, true);
+
+var_dump(
+ "1 - 1",
+ $intlcal1->isEquivalentTo($intlcal1),
+ "1 - 2",
+ $intlcal1->isEquivalentTo($intlcal2),
+ "1 - 3",
+ $intlcal1->isEquivalentTo($intlcal3),
+ "1 - 4",
+ $intlcal1->isEquivalentTo($intlcal4)
+);
+
+?>
+==DONE==
+--EXPECT--
+string(5) "1 - 1"
+bool(true)
+string(5) "1 - 2"
+bool(false)
+string(5) "1 - 3"
+bool(false)
+string(5) "1 - 4"
+bool(true)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/calendar_isEquivalentTo_error.phpt b/ext/intl/tests/calendar_isEquivalentTo_error.phpt
new file mode 100644
index 0000000..4fa7da5
--- /dev/null
+++ b/ext/intl/tests/calendar_isEquivalentTo_error.phpt
@@ -0,0 +1,50 @@
+--TEST--
+IntlCalendar::isEquivalentTo(): bad arguments
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$c = new IntlGregorianCalendar(NULL, 'pt_PT');
+
+function eh($errno, $errstr) {
+echo "error: $errno, $errstr\n";
+}
+set_error_handler('eh');
+
+var_dump($c->isEquivalentTo(0));
+var_dump($c->isEquivalentTo($c, 1));
+var_dump($c->isEquivalentTo(1));
+
+var_dump(intlcal_is_equivalent_to($c));
+var_dump(intlcal_is_equivalent_to($c, 1));
+var_dump(intlcal_is_equivalent_to(1, $c));
+
+--EXPECT--
+error: 4096, Argument 1 passed to IntlCalendar::isEquivalentTo() must be an instance of IntlCalendar, integer given
+error: 2, IntlCalendar::isEquivalentTo() expects parameter 1 to be IntlCalendar, integer given
+error: 2, IntlCalendar::isEquivalentTo(): intlcal_is_equivalent_to: bad arguments
+bool(false)
+error: 2, IntlCalendar::isEquivalentTo() expects exactly 1 parameter, 2 given
+error: 2, IntlCalendar::isEquivalentTo(): intlcal_is_equivalent_to: bad arguments
+bool(false)
+error: 4096, Argument 1 passed to IntlCalendar::isEquivalentTo() must be an instance of IntlCalendar, integer given
+error: 2, IntlCalendar::isEquivalentTo() expects parameter 1 to be IntlCalendar, integer given
+error: 2, IntlCalendar::isEquivalentTo(): intlcal_is_equivalent_to: bad arguments
+bool(false)
+error: 2, intlcal_is_equivalent_to() expects exactly 2 parameters, 1 given
+error: 2, intlcal_is_equivalent_to(): intlcal_is_equivalent_to: bad arguments
+bool(false)
+error: 4096, Argument 2 passed to intlcal_is_equivalent_to() must be an instance of IntlCalendar, integer given
+error: 2, intlcal_is_equivalent_to() expects parameter 2 to be IntlCalendar, integer given
+error: 2, intlcal_is_equivalent_to(): intlcal_is_equivalent_to: bad arguments
+bool(false)
+error: 4096, Argument 1 passed to intlcal_is_equivalent_to() must be an instance of IntlCalendar, integer given
+error: 2, intlcal_is_equivalent_to() expects parameter 1 to be IntlCalendar, integer given
+error: 2, intlcal_is_equivalent_to(): intlcal_is_equivalent_to: bad arguments
+bool(false)
diff --git a/ext/intl/tests/calendar_isLenient_error.phpt b/ext/intl/tests/calendar_isLenient_error.phpt
new file mode 100644
index 0000000..7ddde1a
--- /dev/null
+++ b/ext/intl/tests/calendar_isLenient_error.phpt
@@ -0,0 +1,32 @@
+--TEST--
+IntlCalendar::isLenient(): bad arguments
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$c = new IntlGregorianCalendar(NULL, 'pt_PT');
+
+var_dump($c->isLenient(1));
+
+var_dump(intlcal_is_lenient($c, 1));
+var_dump(intlcal_is_lenient(1));
+
+--EXPECTF--
+
+Warning: IntlCalendar::isLenient() expects exactly 0 parameters, 1 given in %s on line %d
+
+Warning: IntlCalendar::isLenient(): intlcal_is_lenient: bad arguments in %s on line %d
+bool(false)
+
+Warning: intlcal_is_lenient() expects exactly 1 parameter, 2 given in %s on line %d
+
+Warning: intlcal_is_lenient(): intlcal_is_lenient: bad arguments in %s on line %d
+bool(false)
+
+Catchable fatal error: Argument 1 passed to intlcal_is_lenient() must be an instance of IntlCalendar, integer given in %s on line %d
diff --git a/ext/intl/tests/calendar_isSet_basic.phpt b/ext/intl/tests/calendar_isSet_basic.phpt
new file mode 100644
index 0000000..8ef0144
--- /dev/null
+++ b/ext/intl/tests/calendar_isSet_basic.phpt
@@ -0,0 +1,24 @@
+--TEST--
+IntlCalendar::isSet() basic test
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+$intlcal = IntlCalendar::createInstance('UTC');
+var_dump($intlcal->isSet(IntlCalendar::FIELD_MINUTE));
+$intlcal->clear(IntlCalendar::FIELD_MINUTE);
+var_dump($intlcal->isSet(IntlCalendar::FIELD_MINUTE));
+$intlcal->set(IntlCalendar::FIELD_MINUTE, 0);
+var_dump(intlcal_is_set($intlcal, IntlCalendar::FIELD_MINUTE));
+?>
+==DONE==
+--EXPECT--
+bool(true)
+bool(false)
+bool(true)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/calendar_isSet_error.phpt b/ext/intl/tests/calendar_isSet_error.phpt
new file mode 100644
index 0000000..f238d77
--- /dev/null
+++ b/ext/intl/tests/calendar_isSet_error.phpt
@@ -0,0 +1,42 @@
+--TEST--
+IntlCalendar::isSet(): bad arguments
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$c = new IntlGregorianCalendar(NULL, 'pt_PT');
+
+var_dump($c->isSet());
+var_dump($c->isSet(1, 2));
+var_dump($c->isSet(-1));
+
+var_dump(intlcal_is_set($c));
+var_dump(intlcal_is_set(1, 2));
+
+--EXPECTF--
+
+Warning: IntlCalendar::isSet() expects exactly 1 parameter, 0 given in %s on line %d
+
+Warning: IntlCalendar::isSet(): intlcal_is_set: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::isSet() expects exactly 1 parameter, 2 given in %s on line %d
+
+Warning: IntlCalendar::isSet(): intlcal_is_set: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::isSet(): intlcal_is_set: invalid field in %s on line %d
+bool(false)
+
+Warning: intlcal_is_set() expects exactly 2 parameters, 1 given in %s on line %d
+
+Warning: intlcal_is_set(): intlcal_is_set: bad arguments in %s on line %d
+bool(false)
+
+Catchable fatal error: Argument 1 passed to intlcal_is_set() must be an instance of IntlCalendar, integer given in %s on line %d
diff --git a/ext/intl/tests/calendar_isWeekend_basic.phpt b/ext/intl/tests/calendar_isWeekend_basic.phpt
new file mode 100644
index 0000000..d6452c7
--- /dev/null
+++ b/ext/intl/tests/calendar_isWeekend_basic.phpt
@@ -0,0 +1,26 @@
+--TEST--
+IntlCalendar::isWeekend basic test
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '4.4') < 0)
+ die('skip for ICU 4.4+');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+$intlcal = IntlCalendar::createInstance('UTC');
+var_dump($intlcal->isWeekend(strtotime('2012-02-29 12:00:00 +0000') * 1000));
+var_dump(intlcal_is_weekend($intlcal, strtotime('2012-02-29 12:00:00 +0000') * 1000));
+var_dump($intlcal->isWeekend(strtotime('2012-03-11 12:00:00 +0000') * 1000));
+?>
+==DONE==
+--EXPECT--
+bool(false)
+bool(false)
+bool(true)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/calendar_isWeekend_error.phpt b/ext/intl/tests/calendar_isWeekend_error.phpt
new file mode 100644
index 0000000..7939a66
--- /dev/null
+++ b/ext/intl/tests/calendar_isWeekend_error.phpt
@@ -0,0 +1,38 @@
+--TEST--
+IntlCalendar::isWeekend(): bad arguments
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '4.4') < 0)
+ die('skip for ICU 4.4+');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$c = new IntlGregorianCalendar(NULL, 'pt_PT');
+
+var_dump($c->isWeekend(1, 2));
+var_dump($c->isWeekend("jhhk"));
+
+var_dump(intlcal_is_weekend($c, "jj"));
+var_dump(intlcal_is_weekend(1));
+
+--EXPECTF--
+
+Warning: IntlCalendar::isWeekend(): intlcal_is_weekend: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::isWeekend() expects parameter 1 to be double, string given in %s on line %d
+
+Warning: IntlCalendar::isWeekend(): intlcal_is_weekend: bad arguments in %s on line %d
+bool(false)
+
+Warning: intlcal_is_weekend() expects parameter 2 to be double, string given in %s on line %d
+
+Warning: intlcal_is_weekend(): intlcal_is_weekend: bad arguments in %s on line %d
+bool(false)
+
+Catchable fatal error: Argument 1 passed to intlcal_is_weekend() must be an instance of IntlCalendar, integer given in %s on line %d
diff --git a/ext/intl/tests/calendar_is_set_lenient_basic.phpt b/ext/intl/tests/calendar_is_set_lenient_basic.phpt
new file mode 100644
index 0000000..64f537f
--- /dev/null
+++ b/ext/intl/tests/calendar_is_set_lenient_basic.phpt
@@ -0,0 +1,28 @@
+--TEST--
+IntlCalendar::isLenient(), ::setLenient() basic test
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+$intlcal1 = IntlCalendar::createInstance('UTC');
+var_dump($intlcal1->isLenient());
+var_dump(intlcal_is_lenient($intlcal1));
+var_dump($intlcal1->setLenient(false));
+var_dump($intlcal1->isLenient());
+var_dump(intlcal_set_lenient($intlcal1, true));
+var_dump($intlcal1->isLenient());
+?>
+==DONE==
+--EXPECT--
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+bool(true)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/calendar_roll_basic.phpt b/ext/intl/tests/calendar_roll_basic.phpt
new file mode 100644
index 0000000..971c362
--- /dev/null
+++ b/ext/intl/tests/calendar_roll_basic.phpt
@@ -0,0 +1,34 @@
+--TEST--
+IntlCalendar::roll() basic test
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+$intlcal = new IntlGregorianCalendar(2012, 1, 28);
+var_dump($intlcal->roll(IntlCalendar::FIELD_DAY_OF_MONTH, 2));
+var_dump($intlcal->get(IntlCalendar::FIELD_MONTH)); //1 (Feb)
+var_dump($intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH)); //1
+
+$intlcal = new IntlGregorianCalendar(2012, 1, 28);
+var_dump(intlcal_roll($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH, 2));
+var_dump($intlcal->get(IntlCalendar::FIELD_MONTH)); //1 (Feb)
+var_dump($intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH)); //1
+
+
+?>
+==DONE==
+--EXPECT--
+bool(true)
+int(1)
+int(1)
+bool(true)
+int(1)
+int(1)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/calendar_roll_error.phpt b/ext/intl/tests/calendar_roll_error.phpt
new file mode 100644
index 0000000..a567394
--- /dev/null
+++ b/ext/intl/tests/calendar_roll_error.phpt
@@ -0,0 +1,37 @@
+--TEST--
+IntlCalendar::roll(): bad arguments
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$c = new IntlGregorianCalendar(NULL, 'pt_PT');
+
+var_dump($c->roll(1, 2, 3));
+var_dump($c->roll(-1, 2));
+var_dump($c->roll(1));
+
+var_dump(intlcal_roll($c, 1, 2, 3));
+var_dump(intlcal_roll(1, 2, 3));
+--EXPECTF--
+
+Warning: IntlCalendar::roll(): intlcal_set: too many arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::roll(): intlcal_roll: invalid field in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::roll() expects exactly 2 parameters, 1 given in %s on line %d
+
+Warning: IntlCalendar::roll(): intlcal_roll: bad arguments in %s on line %d
+bool(false)
+
+Warning: intlcal_roll(): intlcal_set: too many arguments in %s on line %d
+bool(false)
+
+Catchable fatal error: Argument 1 passed to intlcal_roll() must be an instance of IntlCalendar, integer given in %s on line %d
diff --git a/ext/intl/tests/calendar_roll_variation1.phpt b/ext/intl/tests/calendar_roll_variation1.phpt
new file mode 100644
index 0000000..9fb8d75
--- /dev/null
+++ b/ext/intl/tests/calendar_roll_variation1.phpt
@@ -0,0 +1,32 @@
+--TEST--
+IntlCalendar::roll() bool argument variation
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+$intlcal = new IntlGregorianCalendar(2012, 1, 28);
+var_dump($intlcal->roll(IntlCalendar::FIELD_DAY_OF_MONTH, true));
+var_dump($intlcal->get(IntlCalendar::FIELD_MONTH)); //1 (Feb)
+var_dump($intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH)); //29
+
+var_dump(intlcal_roll($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH, false));
+var_dump($intlcal->get(IntlCalendar::FIELD_MONTH)); //1 (Feb)
+var_dump($intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH)); //28
+
+?>
+==DONE==
+--EXPECT--
+bool(true)
+int(1)
+int(29)
+bool(true)
+int(1)
+int(28)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/calendar_setFirstDayOfWeek_basic.phpt b/ext/intl/tests/calendar_setFirstDayOfWeek_basic.phpt
new file mode 100644
index 0000000..79b3810
--- /dev/null
+++ b/ext/intl/tests/calendar_setFirstDayOfWeek_basic.phpt
@@ -0,0 +1,28 @@
+--TEST--
+IntlCalendar::setFirstDayOfWeek() basic test
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+$intlcal = IntlCalendar::createInstance('UTC');
+var_dump(
+ IntlCalendar::DOW_TUESDAY,
+ $intlcal->setFirstDayOfWeek(IntlCalendar::DOW_TUESDAY),
+ $intlcal->getFirstDayOfWeek(),
+ intlcal_set_first_day_of_week($intlcal, IntlCalendar::DOW_WEDNESDAY),
+ $intlcal->getFirstDayOfWeek()
+);
+?>
+==DONE==
+--EXPECT--
+int(3)
+bool(true)
+int(3)
+bool(true)
+int(4)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/calendar_setFirstDayOfWeek_error.phpt b/ext/intl/tests/calendar_setFirstDayOfWeek_error.phpt
new file mode 100644
index 0000000..98237e5
--- /dev/null
+++ b/ext/intl/tests/calendar_setFirstDayOfWeek_error.phpt
@@ -0,0 +1,40 @@
+--TEST--
+IntlCalendar::setFirstDayOfWeek(): bad arguments
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$c = new IntlGregorianCalendar(NULL, 'pt_PT');
+
+var_dump($c->setFirstDayOfWeek());
+var_dump($c->setFirstDayOfWeek(1, 2));
+var_dump($c->setFirstDayOfWeek(0));
+
+var_dump(intlcal_set_first_day_of_week($c, 0));
+var_dump(intlcal_set_first_day_of_week(1, 2));
+
+--EXPECTF--
+
+Warning: IntlCalendar::setFirstDayOfWeek() expects exactly 1 parameter, 0 given in %s on line %d
+
+Warning: IntlCalendar::setFirstDayOfWeek(): intlcal_set_first_day_of_week: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::setFirstDayOfWeek() expects exactly 1 parameter, 2 given in %s on line %d
+
+Warning: IntlCalendar::setFirstDayOfWeek(): intlcal_set_first_day_of_week: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::setFirstDayOfWeek(): intlcal_set_first_day_of_week: invalid day of week in %s on line %d
+bool(false)
+
+Warning: intlcal_set_first_day_of_week(): intlcal_set_first_day_of_week: invalid day of week in %s on line %d
+bool(false)
+
+Catchable fatal error: Argument 1 passed to intlcal_set_first_day_of_week() must be an instance of IntlCalendar, integer given in %s on line %d
diff --git a/ext/intl/tests/calendar_setLenient_error.phpt b/ext/intl/tests/calendar_setLenient_error.phpt
new file mode 100644
index 0000000..2b1d7b0
--- /dev/null
+++ b/ext/intl/tests/calendar_setLenient_error.phpt
@@ -0,0 +1,44 @@
+--TEST--
+IntlCalendar::setLenient(): bad arguments
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$c = new IntlGregorianCalendar(NULL, 'pt_PT');
+
+var_dump($c->setLenient());
+var_dump($c->setLenient(array()));
+var_dump($c->setLenient(1, 2));
+
+var_dump(intlcal_set_lenient($c, array()));
+var_dump(intlcal_set_lenient(1, false));
+
+--EXPECTF--
+
+Warning: IntlCalendar::setLenient() expects exactly 1 parameter, 0 given in %s on line %d
+
+Warning: IntlCalendar::setLenient(): intlcal_set_lenient: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::setLenient() expects parameter 1 to be boolean, array given in %s on line %d
+
+Warning: IntlCalendar::setLenient(): intlcal_set_lenient: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::setLenient() expects exactly 1 parameter, 2 given in %s on line %d
+
+Warning: IntlCalendar::setLenient(): intlcal_set_lenient: bad arguments in %s on line %d
+bool(false)
+
+Warning: intlcal_set_lenient() expects parameter 2 to be boolean, array given in %s on line %d
+
+Warning: intlcal_set_lenient(): intlcal_set_lenient: bad arguments in %s on line %d
+bool(false)
+
+Catchable fatal error: Argument 1 passed to intlcal_set_lenient() must be an instance of IntlCalendar, integer given in %s on line %d
diff --git a/ext/intl/tests/calendar_setSkipped_RepeatedWallTimeOption_error.phpt b/ext/intl/tests/calendar_setSkipped_RepeatedWallTimeOption_error.phpt
new file mode 100644
index 0000000..dab55d2
--- /dev/null
+++ b/ext/intl/tests/calendar_setSkipped_RepeatedWallTimeOption_error.phpt
@@ -0,0 +1,82 @@
+--TEST--
+IntlCalendar::setSkipped/RepeatedWallTimeOption(): bad arguments
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '49') < 0)
+ die('skip for ICU 49+');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$c = new IntlGregorianCalendar(NULL, 'pt_PT');
+
+var_dump($c->setSkippedWallTimeOption());
+var_dump($c->setRepeatedWallTimeOption());
+
+var_dump($c->setSkippedWallTimeOption(1, 2));
+var_dump($c->setRepeatedWallTimeOption(1, 2));
+
+var_dump($c->setSkippedWallTimeOption(array()));
+var_dump($c->setRepeatedWallTimeOption(array()));
+
+var_dump($c->setSkippedWallTimeOption(3));
+var_dump($c->setRepeatedWallTimeOption(2));
+
+var_dump(intlcal_set_skipped_wall_time_option($c));
+var_dump(intlcal_set_repeated_wall_time_option($c));
+
+var_dump(intlcal_set_repeated_wall_time_option(1, 1));
+
+--EXPECTF--
+
+Warning: IntlCalendar::setSkippedWallTimeOption() expects exactly 1 parameter, 0 given in %s on line %d
+
+Warning: IntlCalendar::setSkippedWallTimeOption(): intlcal_set_skipped_wall_time_option: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::setRepeatedWallTimeOption() expects exactly 1 parameter, 0 given in %s on line %d
+
+Warning: IntlCalendar::setRepeatedWallTimeOption(): intlcal_set_repeated_wall_time_option: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::setSkippedWallTimeOption() expects exactly 1 parameter, 2 given in %s on line %d
+
+Warning: IntlCalendar::setSkippedWallTimeOption(): intlcal_set_skipped_wall_time_option: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::setRepeatedWallTimeOption() expects exactly 1 parameter, 2 given in %s on line %d
+
+Warning: IntlCalendar::setRepeatedWallTimeOption(): intlcal_set_repeated_wall_time_option: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::setSkippedWallTimeOption() expects parameter 1 to be long, array given in %s on line %d
+
+Warning: IntlCalendar::setSkippedWallTimeOption(): intlcal_set_skipped_wall_time_option: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::setRepeatedWallTimeOption() expects parameter 1 to be long, array given in %s on line %d
+
+Warning: IntlCalendar::setRepeatedWallTimeOption(): intlcal_set_repeated_wall_time_option: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::setSkippedWallTimeOption(): intlcal_set_skipped_wall_time_option: invalid option in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::setRepeatedWallTimeOption(): intlcal_set_repeated_wall_time_option: invalid option in %s on line %d
+bool(false)
+
+Warning: intlcal_set_skipped_wall_time_option() expects exactly 2 parameters, 1 given in %s on line %d
+
+Warning: intlcal_set_skipped_wall_time_option(): intlcal_set_skipped_wall_time_option: bad arguments in %s on line %d
+bool(false)
+
+Warning: intlcal_set_repeated_wall_time_option() expects exactly 2 parameters, 1 given in %s on line %d
+
+Warning: intlcal_set_repeated_wall_time_option(): intlcal_set_repeated_wall_time_option: bad arguments in %s on line %d
+bool(false)
+
+Catchable fatal error: Argument 1 passed to intlcal_set_repeated_wall_time_option() must be an instance of IntlCalendar, integer given in %s on line %d
diff --git a/ext/intl/tests/calendar_setTimeZone_basic.phpt b/ext/intl/tests/calendar_setTimeZone_basic.phpt
new file mode 100644
index 0000000..525840d
--- /dev/null
+++ b/ext/intl/tests/calendar_setTimeZone_basic.phpt
@@ -0,0 +1,39 @@
+--TEST--
+IntlCalendar::setTimeZone() basic test
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '4.8') < 0)
+ die('skip for ICU 4.8+');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+$intlcal = IntlCalendar::createInstance('Europe/Amsterdam');
+print_r($intlcal->getTimeZone()->getID());
+echo "\n";
+var_dump($intlcal->get(IntlCalendar::FIELD_ZONE_OFFSET));
+
+$intlcal->setTimeZone(IntlTimeZone::getGMT());
+print_r($intlcal->getTimeZone()->getID());
+echo "\n";
+var_dump($intlcal->get(IntlCalendar::FIELD_ZONE_OFFSET));
+
+intlcal_set_time_zone($intlcal,
+ IntlTimeZone::createTimeZone('GMT+05:30'));
+print_r($intlcal->getTimeZone()->getID());
+echo "\n";
+var_dump($intlcal->get(IntlCalendar::FIELD_ZONE_OFFSET));
+
+?>
+==DONE==
+--EXPECT--
+Europe/Amsterdam
+int(3600000)
+GMT
+int(0)
+GMT+05:30
+int(19800000)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/calendar_setTimeZone_error.phpt b/ext/intl/tests/calendar_setTimeZone_error.phpt
new file mode 100644
index 0000000..ebe4d11
--- /dev/null
+++ b/ext/intl/tests/calendar_setTimeZone_error.phpt
@@ -0,0 +1,41 @@
+--TEST--
+IntlCalendar::setTimeZone(): bad arguments
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$c = new IntlGregorianCalendar(NULL, 'pt_PT');
+
+$gmt = IntlTimeZone::getGMT();
+
+function eh($errno, $errstr) {
+echo "error: $errno, $errstr\n";
+}
+set_error_handler('eh');
+
+var_dump($c->setTimeZone($gmt, 2));
+var_dump($c->setTimeZone());
+
+var_dump(intlcal_set_time_zone($c, 1, 2));
+var_dump(intlcal_set_time_zone(1, $gmt));
+
+--EXPECT--
+error: 2, IntlCalendar::setTimeZone() expects exactly 1 parameter, 2 given
+error: 2, IntlCalendar::setTimeZone(): intlcal_set_time_zone: bad arguments
+bool(false)
+error: 2, IntlCalendar::setTimeZone() expects exactly 1 parameter, 0 given
+error: 2, IntlCalendar::setTimeZone(): intlcal_set_time_zone: bad arguments
+bool(false)
+error: 2, intlcal_set_time_zone() expects exactly 2 parameters, 3 given
+error: 2, intlcal_set_time_zone(): intlcal_set_time_zone: bad arguments
+bool(false)
+error: 4096, Argument 1 passed to intlcal_set_time_zone() must be an instance of IntlCalendar, integer given
+error: 2, intlcal_set_time_zone() expects parameter 1 to be IntlCalendar, integer given
+error: 2, intlcal_set_time_zone(): intlcal_set_time_zone: bad arguments
+bool(false)
diff --git a/ext/intl/tests/calendar_setTimeZone_error2.phpt b/ext/intl/tests/calendar_setTimeZone_error2.phpt
new file mode 100644
index 0000000..aa1eaba
--- /dev/null
+++ b/ext/intl/tests/calendar_setTimeZone_error2.phpt
@@ -0,0 +1,29 @@
+--TEST--
+IntlCalendar::setTimeZone(): valid time zones for DateTime but not ICU
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+date_default_timezone_set('Europe/Amsterdam');
+
+$intlcal = new IntlGregorianCalendar();
+
+$pstdate = new DateTime('2012-01-01 00:00:00 WEST');
+$intlcal->setTimeZone($pstdate->getTimeZone());
+var_dump($intlcal->getTimeZone()->getID());
+
+$pstdate = new DateTime('2012-01-01 00:00:00 +24:00');
+$intlcal->setTimeZone($pstdate->getTimeZone());
+var_dump($intlcal->getTimeZone()->getID());
+
+--EXPECTF--
+
+Warning: IntlCalendar::setTimeZone(): intlcal_set_time_zone: time zone id 'WEST' extracted from ext/date DateTimeZone not recognized in %s on line %d
+string(16) "Europe/Amsterdam"
+
+Warning: IntlCalendar::setTimeZone(): intlcal_set_time_zone: object has an time zone offset that's too large in %s on line %d
+string(16) "Europe/Amsterdam"
diff --git a/ext/intl/tests/calendar_setTimeZone_variation1.phpt b/ext/intl/tests/calendar_setTimeZone_variation1.phpt
new file mode 100644
index 0000000..b1cbb74
--- /dev/null
+++ b/ext/intl/tests/calendar_setTimeZone_variation1.phpt
@@ -0,0 +1,30 @@
+--TEST--
+IntlCalendar::setTimeZone() variation with NULL arg
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+$intlcal = IntlCalendar::createInstance('Europe/Amsterdam');
+print_r($intlcal->getTimeZone()->getID());
+echo "\n";
+var_dump($intlcal->get(IntlCalendar::FIELD_ZONE_OFFSET));
+
+/* passing NULL has no effect */
+$intlcal->setTimeZone(null);
+print_r($intlcal->getTimeZone()->getID());
+echo "\n";
+var_dump($intlcal->get(IntlCalendar::FIELD_ZONE_OFFSET));
+
+?>
+==DONE==
+--EXPECT--
+Europe/Amsterdam
+int(3600000)
+Europe/Amsterdam
+int(3600000)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/calendar_setTimeZone_variation2.phpt b/ext/intl/tests/calendar_setTimeZone_variation2.phpt
new file mode 100644
index 0000000..7f4a7ff
--- /dev/null
+++ b/ext/intl/tests/calendar_setTimeZone_variation2.phpt
@@ -0,0 +1,30 @@
+--TEST--
+IntlCalendar::setTimeZone(): different ways to specify time zone
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+date_default_timezone_set('Europe/Amsterdam');
+
+$intlcal = new IntlGregorianCalendar();
+$intlcal->setTimeZone('Europe/Paris');
+var_dump($intlcal->getTimeZone()->getID());
+$intlcal->setTimeZone(new DateTimeZone('Europe/Madrid'));
+var_dump($intlcal->getTimeZone()->getID());
+
+$pstdate = new DateTime('2012-01-01 00:00:00 PST');
+$intlcal->setTimeZone($pstdate->getTimeZone());
+var_dump($intlcal->getTimeZone()->getID());
+
+$offsetdate = new DateTime('2012-01-01 00:00:00 -02:30');
+$intlcal->setTimeZone($offsetdate->getTimeZone());
+var_dump($intlcal->getTimeZone()->getID());
+--EXPECTF--
+string(12) "Europe/Paris"
+string(13) "Europe/Madrid"
+string(3) "PST"
+string(%d) "GMT-02%S30"
diff --git a/ext/intl/tests/calendar_setTime_basic.phpt b/ext/intl/tests/calendar_setTime_basic.phpt
new file mode 100644
index 0000000..f7f213c
--- /dev/null
+++ b/ext/intl/tests/calendar_setTime_basic.phpt
@@ -0,0 +1,33 @@
+--TEST--
+IntlCalendar::setTime() basic test
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+$time = strtotime('2012-02-29 00:00:00 +0000');
+
+$intlcal = IntlCalendar::createInstance('UTC');
+$intlcal->setTime($time * 1000);
+
+var_dump(
+ (float)$time*1000,
+ $intlcal->getTime());
+
+$intlcal = IntlCalendar::createInstance('UTC');
+intlcal_set_time($intlcal,$time * 1000);
+var_dump(intlcal_get_time($intlcal));
+
+?>
+==DONE==
+--EXPECT--
+float(1330473600000)
+float(1330473600000)
+float(1330473600000)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/calendar_setTime_error.phpt b/ext/intl/tests/calendar_setTime_error.phpt
new file mode 100644
index 0000000..71c5b0a
--- /dev/null
+++ b/ext/intl/tests/calendar_setTime_error.phpt
@@ -0,0 +1,37 @@
+--TEST--
+IntlCalendar::setTime(): bad arguments
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$c = new IntlGregorianCalendar(NULL, 'pt_PT');
+
+var_dump($c->setTime(1, 2));
+var_dump($c->setTime("jjj"));
+
+var_dump(intlcal_set_time($c, 1, 2));
+var_dump(intlcal_set_time(1));
+--EXPECTF--
+
+Warning: IntlCalendar::setTime() expects exactly 1 parameter, 2 given in %s on line %d
+
+Warning: IntlCalendar::setTime(): intlcal_set_time: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::setTime() expects parameter 1 to be double, string given in %s on line %d
+
+Warning: IntlCalendar::setTime(): intlcal_set_time: bad arguments in %s on line %d
+bool(false)
+
+Warning: intlcal_set_time() expects exactly 2 parameters, 3 given in %s on line %d
+
+Warning: intlcal_set_time(): intlcal_set_time: bad arguments in %s on line %d
+bool(false)
+
+Catchable fatal error: Argument 1 passed to intlcal_set_time() must be an instance of IntlCalendar, integer given in %s on line %d
diff --git a/ext/intl/tests/calendar_set_basic.phpt b/ext/intl/tests/calendar_set_basic.phpt
new file mode 100644
index 0000000..8eccb32
--- /dev/null
+++ b/ext/intl/tests/calendar_set_basic.phpt
@@ -0,0 +1,27 @@
+--TEST--
+IntlCalendar::set() basic test
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+$intlcal = IntlCalendar::createInstance();
+var_dump($intlcal->set(IntlCalendar::FIELD_DAY_OF_MONTH, 2));
+var_dump($intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH));
+var_dump(intlcal_set($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH, 3));
+var_dump($intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH));
+
+?>
+==DONE==
+--EXPECT--
+bool(true)
+int(2)
+bool(true)
+int(3)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/calendar_set_error.phpt b/ext/intl/tests/calendar_set_error.phpt
new file mode 100644
index 0000000..669b188
--- /dev/null
+++ b/ext/intl/tests/calendar_set_error.phpt
@@ -0,0 +1,41 @@
+--TEST--
+IntlCalendar::set(): bad arguments
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$c = new IntlGregorianCalendar(NULL, 'pt_PT');
+
+var_dump($c->set(1));
+var_dump($c->set(1, 2, 3, 4));
+var_dump($c->set(1, 2, 3, 4, 5, 6, 7));
+var_dump($c->set(-1, 2));
+
+var_dump(intlcal_set($c, -1, 2));
+var_dump(intlcal_set(1, 2, 3));
+--EXPECTF--
+
+Warning: IntlCalendar::set() expects at least 2 parameters, 1 given in %s on line %d
+
+Warning: IntlCalendar::set(): intlcal_set: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::set(): intlcal_set: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::set(): intlcal_set: too many arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::set(): intlcal_set: invalid field in %s on line %d
+bool(false)
+
+Warning: intlcal_set(): intlcal_set: invalid field in %s on line %d
+bool(false)
+
+Catchable fatal error: Argument 1 passed to intlcal_set() must be an instance of IntlCalendar, integer given in %s on line %d
diff --git a/ext/intl/tests/calendar_set_variation1.phpt b/ext/intl/tests/calendar_set_variation1.phpt
new file mode 100644
index 0000000..8ea016e
--- /dev/null
+++ b/ext/intl/tests/calendar_set_variation1.phpt
@@ -0,0 +1,41 @@
+--TEST--
+IntlCalendar::set() argument variations
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+$intlcal = IntlCalendar::createInstance('UTC');
+$intlcal->clear();
+var_dump($intlcal->set(2012, 1, 29));
+var_dump($intlcal->getTime(),
+ strtotime('2012-02-29 00:00:00 +0000') * 1000.);
+
+//two minutes to midnight!
+var_dump($intlcal->set(2012, 1, 29, 23, 58));
+var_dump($intlcal->getTime(),
+ strtotime('2012-02-29 23:58:00 +0000') * 1000.);
+
+var_dump($intlcal->set(2012, 1, 29, 23, 58, 31));
+var_dump($intlcal->getTime(),
+ strtotime('2012-02-29 23:58:31 +0000') * 1000.);
+
+?>
+==DONE==
+--EXPECT--
+bool(true)
+float(1330473600000)
+float(1330473600000)
+bool(true)
+float(1330559880000)
+float(1330559880000)
+bool(true)
+float(1330559911000)
+float(1330559911000)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/calendar_toDateTime_basic.phpt b/ext/intl/tests/calendar_toDateTime_basic.phpt
new file mode 100644
index 0000000..d38487d
--- /dev/null
+++ b/ext/intl/tests/calendar_toDateTime_basic.phpt
@@ -0,0 +1,23 @@
+--TEST--
+IntlCalendar::toDateTime(): basic test
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+//ini_set("intl.default_locale", "nl");
+ini_set('date.timezone', 'Europe/Lisbon');
+
+$cal = new IntlGregorianCalendar(2012,04,17,17,35,36);
+
+$dt = $cal->toDateTime();
+
+var_dump($dt->format("c"), $dt->getTimeZone()->getName());
+?>
+==DONE==
+--EXPECT--
+string(25) "2012-05-17T17:35:36+01:00"
+string(13) "Europe/Lisbon"
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/calendar_toDateTime_error.phpt b/ext/intl/tests/calendar_toDateTime_error.phpt
new file mode 100644
index 0000000..961a9c8
--- /dev/null
+++ b/ext/intl/tests/calendar_toDateTime_error.phpt
@@ -0,0 +1,41 @@
+--TEST--
+IntlCalendar::toDateTime(): bad arguments
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set('date.timezone', 'Europe/Lisbon');
+
+$cal = new IntlGregorianCalendar();
+var_dump($cal->toDateTime(3));
+
+var_dump(intlcal_to_date_time($cal, 3));
+
+$cal = new IntlGregorianCalendar("Etc/Unknown");
+try {
+var_dump($cal->toDateTime());
+} catch (Exception $e) {
+var_dump("exception: {$e->getMessage()}");
+}
+
+var_dump(intlcal_to_date_time(3));
+
+--EXPECTF--
+
+Warning: IntlCalendar::toDateTime() expects exactly 0 parameters, 1 given in %s on line %d
+
+Warning: IntlCalendar::toDateTime(): intlcal_to_date_time: bad arguments in %s on line %d
+bool(false)
+
+Warning: intlcal_to_date_time() expects exactly 1 parameter, 2 given in %s on line %d
+
+Warning: intlcal_to_date_time(): intlcal_to_date_time: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlCalendar::toDateTime(): intlcal_to_date_time: DateTimeZone constructor threw exception in %s on line %d
+string(77) "exception: DateTimeZone::__construct(): Unknown or bad timezone (Etc/Unknown)"
+
+Catchable fatal error: Argument 1 passed to intlcal_to_date_time() must be an instance of IntlCalendar, integer given in %s on line %d
diff --git a/ext/intl/tests/dateformat___construct_bad_tz_cal.phpt b/ext/intl/tests/dateformat___construct_bad_tz_cal.phpt
new file mode 100644
index 0000000..1f682dd
--- /dev/null
+++ b/ext/intl/tests/dateformat___construct_bad_tz_cal.phpt
@@ -0,0 +1,28 @@
+--TEST--
+IntlDateFormatter::__construct(): bad timezone or calendar
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "pt_PT");
+ini_set("date.timezone", 'Atlantic/Azores');
+
+var_dump(new IntlDateFormatter(NULL, 0, 0, 'bad timezone'));
+
+var_dump(new IntlDateFormatter(NULL, 0, 0, NULL, 3));
+
+var_dump(new IntlDateFormatter(NULL, 0, 0, NULL, new stdclass));
+
+
+?>
+==DONE==
+--EXPECTF--
+
+Warning: IntlDateFormatter::__construct(): datefmt_create: no such time zone: 'bad timezone' in %s on line %d
+NULL
+
+Warning: IntlDateFormatter::__construct(): datefmt_create: invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object in %s on line %d
+NULL
+
+Warning: IntlDateFormatter::__construct(): datefmt_create: Invalid calendar argument; should be an integer or an IntlCalendar instance in %s on line %d
+NULL
+==DONE==
diff --git a/ext/intl/tests/dateformat_calendars.phpt b/ext/intl/tests/dateformat_calendars.phpt
index 27f380c..6af02e5 100644
--- a/ext/intl/tests/dateformat_calendars.phpt
+++ b/ext/intl/tests/dateformat_calendars.phpt
@@ -41,5 +41,5 @@ string(44) "Sunday, January 1, 2012 5:12:00 AM GMT+05:12"
string(44) "Sunday, January 1, 2012 5:12:00 AM GMT+05:12"
string(42) "Sunday, Tevet 6, 5772 5:12:00 AM GMT+05:12"
-Warning: IntlDateFormatter::__construct(): datefmt_create: invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN in %s on line %d
+Warning: IntlDateFormatter::__construct(): datefmt_create: invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object in %s on line %d
==DONE==
diff --git a/ext/intl/tests/dateformat_create_cal_arg.phpt b/ext/intl/tests/dateformat_create_cal_arg.phpt
new file mode 100644
index 0000000..8e5f942
--- /dev/null
+++ b/ext/intl/tests/dateformat_create_cal_arg.phpt
@@ -0,0 +1,49 @@
+--TEST--
+IntlDateFormatter: several forms of the calendar arg
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "pt_PT");
+ini_set("date.timezone", 'Atlantic/Azores');
+
+$ts = strtotime('2012-01-01 00:00:00 UTC');
+
+$cal = new IntlGregorianCalendar('UTC', NULL);
+$df = new IntlDateFormatter('es_ES', 0, 0, NULL, $cal);
+echo $df->format($ts), "\n";
+
+$cal = IntlCalendar::createInstance('UTC', 'en@calendar=islamic');
+$df = new IntlDateFormatter('es_ES', 0, 0, NULL, $cal);
+echo $df->format($ts), "\n";
+
+//override calendar's timezone
+$cal = new IntlGregorianCalendar('UTC', NULL);
+$df = new IntlDateFormatter('es_ES', 0, 0, 'Europe/Madrid', $cal);
+echo $df->format($ts), "\n";
+
+//default calendar is gregorian
+$df = new IntlDateFormatter('es_ES@calendar=islamic', 0, 0);
+echo $df->format($ts), "\n";
+
+//try now with traditional
+$df = new IntlDateFormatter('es_ES@calendar=islamic', 0, 0, NULL, IntlDateFormatter::TRADITIONAL);
+echo $df->format($ts), "\n";
+
+//the timezone can be overridden when not specifying a calendar
+$df = new IntlDateFormatter('es_ES@calendar=islamic', 0, 0, 'UTC', IntlDateFormatter::TRADITIONAL);
+echo $df->format($ts), "\n";
+
+$df = new IntlDateFormatter('es_ES', 0, 0, 'UTC', 0);
+echo $df->format($ts), "\n";
+
+?>
+==DONE==
+--EXPECT--
+domingo, 1 de enero de 2012 00:00:00 GMT
+domingo, 8 de Safar de 1433 00:00:00 GMT
+domingo, 1 de enero de 2012 01:00:00 Hora estándar de Europa Central
+sábado, 31 de diciembre de 2011 d.C. 23:00:00 Hora estándar de las Azores
+sábado, 7 de Safar de 1433 AH 23:00:00 Hora estándar de las Azores
+domingo, 8 de Safar de 1433 AH 00:00:00 GMT
+domingo, 1 de enero de 2012 00:00:00 GMT
+==DONE==
diff --git a/ext/intl/tests/dateformat_format.phpt b/ext/intl/tests/dateformat_format.phpt
index e554819..98f9d34 100755
--- a/ext/intl/tests/dateformat_format.phpt
+++ b/ext/intl/tests/dateformat_format.phpt
@@ -5,6 +5,8 @@ datefmt_format_code()
--FILE--
<?php
+//ini_set("intl.error_level", E_WARNING);
+
/*
* Test for the datefmt_format function
*/
@@ -12,7 +14,7 @@ datefmt_format_code()
function ut_main()
{
- $timezone = 'GMT-10';
+ $timezone = 'GMT-10:00';
$locale_arr = array (
'en_US'
diff --git a/ext/intl/tests/dateformat_format_parse.phpt b/ext/intl/tests/dateformat_format_parse.phpt
index bd41d71..6bd3d8a 100755
--- a/ext/intl/tests/dateformat_format_parse.phpt
+++ b/ext/intl/tests/dateformat_format_parse.phpt
@@ -12,7 +12,7 @@ datefmt_format_code() and datefmt_parse_code()
function ut_main()
{
- $timezone = 'GMT+5';
+ $timezone = 'GMT+05:00';
$locale_arr = array (
'en_US'
diff --git a/ext/intl/tests/dateformat_getCalendarObject_error.phpt b/ext/intl/tests/dateformat_getCalendarObject_error.phpt
new file mode 100644
index 0000000..22f12cb
--- /dev/null
+++ b/ext/intl/tests/dateformat_getCalendarObject_error.phpt
@@ -0,0 +1,39 @@
+--TEST--
+IntlDateFormatter::getCalendarObject(): bad args
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "pt_PT");
+ini_set("date.timezone", 'Atlantic/Azores');
+
+$df = new IntlDateFormatter(NULL, 0, 0);
+
+var_dump($df->getCalendarObject(9));
+var_dump(datefmt_get_calendar_object($df, 9));
+var_dump(datefmt_get_calendar_object($df, 9));
+var_dump(datefmt_get_calendar_object(new stdclass));
+
+?>
+==DONE==
+--EXPECTF--
+
+Warning: IntlDateFormatter::getCalendarObject() expects exactly 0 parameters, 1 given in %s on line %d
+
+Warning: IntlDateFormatter::getCalendarObject(): datefmt_get_calendar_object: unable to parse input params in %s on line %d
+bool(false)
+
+Warning: datefmt_get_calendar_object() expects exactly 1 parameter, 2 given in %s on line %d
+
+Warning: datefmt_get_calendar_object(): datefmt_get_calendar_object: unable to parse input params in %s on line %d
+bool(false)
+
+Warning: datefmt_get_calendar_object() expects exactly 1 parameter, 2 given in %s on line %d
+
+Warning: datefmt_get_calendar_object(): datefmt_get_calendar_object: unable to parse input params in %s on line %d
+bool(false)
+
+Warning: datefmt_get_calendar_object() expects parameter 1 to be IntlDateFormatter, object given in %s on line %d
+
+Warning: datefmt_get_calendar_object(): datefmt_get_calendar_object: unable to parse input params in %s on line %d
+bool(false)
+==DONE==
diff --git a/ext/intl/tests/dateformat_getTimeZone_error.phpt b/ext/intl/tests/dateformat_getTimeZone_error.phpt
new file mode 100644
index 0000000..c9d49fd
--- /dev/null
+++ b/ext/intl/tests/dateformat_getTimeZone_error.phpt
@@ -0,0 +1,39 @@
+--TEST--
+IntlDateFormatter::getTimeZone(): bad args
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "pt_PT");
+ini_set("date.timezone", 'Atlantic/Azores');
+
+$df = new IntlDateFormatter(NULL, 0, 0);
+
+var_dump($df->getTimeZone(9));
+var_dump(datefmt_get_timezone($df, 9));
+var_dump(datefmt_get_timezone($df, 9));
+var_dump(datefmt_get_timezone(new stdclass));
+
+?>
+==DONE==
+--EXPECTF--
+
+Warning: IntlDateFormatter::getTimeZone() expects exactly 0 parameters, 1 given in %s on line %d
+
+Warning: IntlDateFormatter::getTimeZone(): datefmt_get_timezone: unable to parse input params in %s on line %d
+bool(false)
+
+Warning: datefmt_get_timezone() expects exactly 1 parameter, 2 given in %s on line %d
+
+Warning: datefmt_get_timezone(): datefmt_get_timezone: unable to parse input params in %s on line %d
+bool(false)
+
+Warning: datefmt_get_timezone() expects exactly 1 parameter, 2 given in %s on line %d
+
+Warning: datefmt_get_timezone(): datefmt_get_timezone: unable to parse input params in %s on line %d
+bool(false)
+
+Warning: datefmt_get_timezone() expects parameter 1 to be IntlDateFormatter, object given in %s on line %d
+
+Warning: datefmt_get_timezone(): datefmt_get_timezone: unable to parse input params in %s on line %d
+bool(false)
+==DONE==
diff --git a/ext/intl/tests/dateformat_get_set_calendar.phpt b/ext/intl/tests/dateformat_get_set_calendar.phpt
index bfd4e57..e792ea3 100755
--- a/ext/intl/tests/dateformat_get_set_calendar.phpt
+++ b/ext/intl/tests/dateformat_get_set_calendar.phpt
@@ -1,60 +1,51 @@
--TEST--
-datefmt_get_calendar_code() datefmt_set_calendar_code()
---SKIPIF--
-<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+IntlDateFormatter: setCalendar()/getCalendar()/getCalendarObject()
--FILE--
<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "pt_PT");
+ini_set("date.timezone", 'Atlantic/Azores');
+
+$ts = strtotime('2012-01-01 00:00:00 UTC');
+
+function d(IntlDateFormatter $df) {
+global $ts;
+echo $df->format($ts), "\n";
+var_dump($df->getCalendar(),
+$df->getCalendarObject()->getType(),
+$df->getCalendarObject()->getTimeZone()->getId());
+echo "\n";
+}
-/*
- * Test for the datefmt_get_calendar and datefmt_set_calendar functions
- */
-
-
-function ut_main()
-{
- $calendar_arr = array (
- IntlDateFormatter::GREGORIAN,
- IntlDateFormatter::TRADITIONAL,
- 3
- );
-
- $res_str = '';
-
- $start_calendar = IntlDateFormatter::GREGORIAN;
- $res_str .= "\nCreating IntlDateFormatter with calendar = $start_calendar";
- $fmt = ut_datefmt_create( "de-DE", IntlDateFormatter::SHORT, IntlDateFormatter::SHORT ,'America/Los_Angeles', IntlDateFormatter::GREGORIAN);
- $calendar = ut_datefmt_get_calendar( $fmt);
- $res_str .= "\nAfter call to get_calendar : calendar= $calendar";
- $res_str .= "\n-------------------";
-
- foreach( $calendar_arr as $calendar_entry )
- {
- $res_str .= "\nSetting IntlDateFormatter with calendar = $calendar_entry";
- ut_datefmt_set_calendar( $fmt, $calendar_entry);
- $calendar = ut_datefmt_get_calendar( $fmt);
- $res_str .= "\nAfter call to get_calendar : calendar= $calendar";
- $res_str .= "\n-------------------";
- }
-
- return $res_str;
+$df = new IntlDateFormatter('fr@calendar=islamic', 0, 0, 'Europe/Minsk');
+d($df);
-}
-include_once( 'ut_common.inc' );
+//changing the calendar with a cal type should not change tz
+$df->setCalendar(IntlDateFormatter::TRADITIONAL);
+d($df);
+
+//but changing with an actual calendar should
+$cal = IntlCalendar::createInstance("UTC");
+$df->setCalendar($cal);
+d($df);
-// Run the test
-ut_run();
?>
+==DONE==
--EXPECT--
-Creating IntlDateFormatter with calendar = 1
-After call to get_calendar : calendar= 1
--------------------
-Setting IntlDateFormatter with calendar = 1
-After call to get_calendar : calendar= 1
--------------------
-Setting IntlDateFormatter with calendar = 0
-After call to get_calendar : calendar= 0
--------------------
-Setting IntlDateFormatter with calendar = 3
-After call to get_calendar : calendar= 0
-------------------- \ No newline at end of file
+dimanche 1 janvier 2012 ap. J.-C. 03:00:00 UTC+03:00
+int(1)
+string(9) "gregorian"
+string(12) "Europe/Minsk"
+
+dimanche 8 Safar 1433 AH 03:00:00 UTC+03:00
+int(0)
+string(7) "islamic"
+string(12) "Europe/Minsk"
+
+dimanche 1 janvier 2012 ap. J.-C. 00:00:00 UTC
+bool(false)
+string(9) "gregorian"
+string(3) "UTC"
+
+==DONE==
diff --git a/ext/intl/tests/dateformat_get_set_timezone.phpt b/ext/intl/tests/dateformat_get_set_timezone.phpt
new file mode 100644
index 0000000..50b036e
--- /dev/null
+++ b/ext/intl/tests/dateformat_get_set_timezone.phpt
@@ -0,0 +1,58 @@
+--TEST--
+IntlDateFormatter: get/setTimeZone()
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "pt_PT");
+ini_set("date.timezone", 'Atlantic/Azores');
+
+$ts = strtotime('2012-01-01 00:00:00 UTC');
+
+function d(IntlDateFormatter $df) {
+global $ts;
+echo $df->format($ts), "\n";
+var_dump(
+$df->getTimeZoneID(),
+$df->getTimeZone()->getID());
+echo "\n";
+}
+
+$df = new IntlDateFormatter('pt_PT', 0, 0, 'Europe/Minsk');
+d($df);
+
+$df->setTimeZone(NULL);
+d($df);
+
+$df->setTimeZone('Europe/Madrid');
+d($df);
+
+$df->setTimeZone(IntlTimeZone::createTimeZone('Europe/Paris'));
+d($df);
+
+$df->setTimeZone(new DateTimeZone('Europe/Amsterdam'));
+d($df);
+
+?>
+==DONE==
+--EXPECT--
+Domingo, 1 de Janeiro de 2012 3:00:00 GMT+03:00
+string(12) "Europe/Minsk"
+string(12) "Europe/Minsk"
+
+Sábado, 31 de Dezembro de 2011 23:00:00 Hora Padrão dos Açores
+string(15) "Atlantic/Azores"
+string(15) "Atlantic/Azores"
+
+Domingo, 1 de Janeiro de 2012 1:00:00 Hora Padrão da Europa Central
+string(13) "Europe/Madrid"
+string(13) "Europe/Madrid"
+
+Domingo, 1 de Janeiro de 2012 1:00:00 Hora Padrão da Europa Central
+string(12) "Europe/Paris"
+string(12) "Europe/Paris"
+
+Domingo, 1 de Janeiro de 2012 1:00:00 Hora Padrão da Europa Central
+string(16) "Europe/Amsterdam"
+string(16) "Europe/Amsterdam"
+
+==DONE==
diff --git a/ext/intl/tests/dateformat_get_timezone_id.phpt b/ext/intl/tests/dateformat_get_timezone_id.phpt
index 80cbdbb..a9701c3 100755
--- a/ext/intl/tests/dateformat_get_timezone_id.phpt
+++ b/ext/intl/tests/dateformat_get_timezone_id.phpt
@@ -1,5 +1,8 @@
--TEST--
datefmt_get_timezone_id_code()
+--INI--
+date.timezone=Atlantic/Azores
+intl.error_level=E_WARNING
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
--FILE--
@@ -14,8 +17,8 @@ function ut_main()
{
$timezone_id_arr = array (
'America/New_York',
- 'America/Los_Angeles',
- 'America/Dallas'
+ 'US/Pacific',
+ 'US/Central'
);
$res_str = '';
@@ -42,8 +45,8 @@ ut_run();
Creating IntlDateFormatter with timezone_id = America/New_York
After call to get_timezone_id : timezone_id= America/New_York
-Creating IntlDateFormatter with timezone_id = America/Los_Angeles
-After call to get_timezone_id : timezone_id= America/Los_Angeles
+Creating IntlDateFormatter with timezone_id = US/Pacific
+After call to get_timezone_id : timezone_id= US/Pacific
-Creating IntlDateFormatter with timezone_id = America/Dallas
-After call to get_timezone_id : timezone_id= America/Dallas
+Creating IntlDateFormatter with timezone_id = US/Central
+After call to get_timezone_id : timezone_id= US/Central
diff --git a/ext/intl/tests/dateformat_setTimeZoneID_deprecation.phpt b/ext/intl/tests/dateformat_setTimeZoneID_deprecation.phpt
new file mode 100644
index 0000000..ccc477d
--- /dev/null
+++ b/ext/intl/tests/dateformat_setTimeZoneID_deprecation.phpt
@@ -0,0 +1,18 @@
+--TEST--
+IntlDateFormatter: setTimeZoneID() deprecation
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "pt_PT");
+ini_set("date.timezone", 'Atlantic/Azores');
+
+$df = new IntlDateFormatter('pt_PT', 0, 0, 'Europe/Minsk');
+
+$df->setTimeZoneId('Europe/Madrid');
+
+?>
+==DONE==
+--EXPECTF--
+
+Deprecated: IntlDateFormatter::setTimeZoneId(): Use datefmt_set_timezone() instead, which also accepts a plain time zone identifier and for which this function is now an alias in %s on line %d
+==DONE==
diff --git a/ext/intl/tests/dateformat_setTimeZone_error.phpt b/ext/intl/tests/dateformat_setTimeZone_error.phpt
new file mode 100644
index 0000000..8200197
--- /dev/null
+++ b/ext/intl/tests/dateformat_setTimeZone_error.phpt
@@ -0,0 +1,49 @@
+--TEST--
+IntlDateFormatter::setTimeZone() bad args
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "pt_PT");
+ini_set("date.timezone", 'Atlantic/Azores');
+
+$df = new IntlDateFormatter(NULL, 0, 0);
+
+var_dump($df->setTimeZone());
+var_dump(datefmt_set_timezone());
+var_dump($df->setTimeZone(array()));
+var_dump($df->setTimeZone(1, 2));
+var_dump($df->setTimeZone('non existing timezone'));
+var_dump(datefmt_set_timezone(new stdclass, 'UTC'));
+
+?>
+==DONE==
+--EXPECTF--
+
+Warning: IntlDateFormatter::setTimeZone() expects exactly 1 parameter, 0 given in %s on line %d
+
+Warning: IntlDateFormatter::setTimeZone(): datefmt_set_timezone: unable to parse input params in %s on line %d
+bool(false)
+
+Warning: datefmt_set_timezone() expects exactly 2 parameters, 0 given in %s on line %d
+
+Warning: datefmt_set_timezone(): datefmt_set_timezone: unable to parse input params in %s on line %d
+bool(false)
+
+Notice: Array to string conversion in %s on line %d
+
+Warning: IntlDateFormatter::setTimeZone(): datefmt_set_timezone: no such time zone: 'Array' in %s on line %d
+bool(false)
+
+Warning: IntlDateFormatter::setTimeZone() expects exactly 1 parameter, 2 given in %s on line %d
+
+Warning: IntlDateFormatter::setTimeZone(): datefmt_set_timezone: unable to parse input params in %s on line %d
+bool(false)
+
+Warning: IntlDateFormatter::setTimeZone(): datefmt_set_timezone: no such time zone: 'non existing timezone' in %s on line %d
+bool(false)
+
+Warning: datefmt_set_timezone() expects parameter 1 to be IntlDateFormatter, object given in %s on line %d
+
+Warning: datefmt_set_timezone(): datefmt_set_timezone: unable to parse input params in %s on line %d
+bool(false)
+==DONE==
diff --git a/ext/intl/tests/dateformat_set_timezone_id2.phpt b/ext/intl/tests/dateformat_set_timezone_id2.phpt
index 23aacda..ce9b89d 100644
--- a/ext/intl/tests/dateformat_set_timezone_id2.phpt
+++ b/ext/intl/tests/dateformat_set_timezone_id2.phpt
@@ -1,11 +1,16 @@
--TEST--
datefmt_set_timezone_id_code() icu >= 4.8
+--INI--
+date.timezone=Atlantic/Azores
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip'; ?>
--FILE--
<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("error_reporting", ~E_DEPRECATED);
+
/*
* Test for the datefmt_set_timezone_id function
*/
@@ -23,7 +28,7 @@ function ut_main()
$res_str = '';
- $fmt = ut_datefmt_create( "en_US", IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/San_Francisco' , IntlDateFormatter::GREGORIAN );
+ $fmt = ut_datefmt_create( "en_US", IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'US/Pacific' , IntlDateFormatter::GREGORIAN );
$timezone_id = ut_datefmt_get_timezone_id( $fmt );
$res_str .= "\nAfter creation of the dateformatter : timezone_id= $timezone_id\n";
@@ -52,8 +57,13 @@ include_once( 'ut_common.inc' );
// Run the test
ut_run();
?>
---EXPECT--
-After creation of the dateformatter : timezone_id= America/San_Francisco
+--EXPECTF--
+
+Warning: IntlDateFormatter::setTimeZoneId(): datefmt_set_timezone: no such time zone: 'CN' in %s on line %d
+
+Warning: datefmt_set_timezone_id(): datefmt_set_timezone: no such time zone: 'CN' in %s on line %d
+
+After creation of the dateformatter : timezone_id= US/Pacific
-----------
Trying to set timezone_id= America/New_York
After call to set_timezone_id : timezone_id= America/New_York
@@ -71,6 +81,6 @@ Formatting timestamp=0 resulted in Wednesday, December 31, 1969 6:00:00 PM Cent
Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 7:00:00 PM Central Standard Time
-----------
Trying to set timezone_id= CN
-After call to set_timezone_id : timezone_id= CN
-Formatting timestamp=0 resulted in Thursday, January 1, 1970 12:00:00 AM GMT
-Formatting timestamp=3600 resulted in Thursday, January 1, 1970 1:00:00 AM GMT
+After call to set_timezone_id : timezone_id= America/Chicago
+Formatting timestamp=0 resulted in Wednesday, December 31, 1969 6:00:00 PM Central Standard Time
+Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 7:00:00 PM Central Standard Time
diff --git a/ext/intl/tests/dateformat_timezone_arg_variations.phpt b/ext/intl/tests/dateformat_timezone_arg_variations.phpt
new file mode 100644
index 0000000..df3ebd8
--- /dev/null
+++ b/ext/intl/tests/dateformat_timezone_arg_variations.phpt
@@ -0,0 +1,41 @@
+--TEST--
+IntlDateFormatter: several forms of the timezone arg
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("date.timezone", 'Atlantic/Azores');
+
+$ts = strtotime('2012-01-01 00:00:00 UTC');
+
+//should use Atlantic/Azores
+$df = new IntlDateFormatter('es_ES', 0, 0, NULL);
+echo $df->format($ts), "\n";
+
+$df = new IntlDateFormatter('es_ES', 0, 0, 'Europe/Amsterdam');
+echo $df->format($ts), "\n";
+
+$df = new IntlDateFormatter('es_ES', 0, 0, new DateTimeZone('Europe/Lisbon'));
+echo $df->format($ts), "\n";
+
+$df = new IntlDateFormatter('es_ES', 0, 0, IntlTimeZone::createTimeZone('America/New_York'));
+echo $df->format($ts), "\n";
+
+//time zone has priority
+$df = new IntlDateFormatter('es_ES', 0, 0, 'Europe/Amsterdam', new IntlGregorianCalendar('Europe/Lisbon'));
+echo $df->format($ts), "\n";
+
+//calendar has priority
+$df = new IntlDateFormatter('es_ES', 0, 0, NULL, new IntlGregorianCalendar('Europe/Lisbon'));
+echo $df->format($ts), "\n";
+
+$df = new IntlDateFormatter('es_ES', 0, 0, 'Europe/Amsterdam', 0);
+echo $df->format($ts), "\n";
+
+--EXPECTF--
+sábado%S 31 de diciembre de 2011 23:00:00 Hora%S de las Azores
+domingo%S 1 de enero de 2012 01:00:00 Hora estándar de Europa Central
+domingo%S 1 de enero de 2012 00:00:00 Hora%S de Europa Occidental
+sábado%S 31 de diciembre de 2011 19:00:00 Hora estándar oriental
+domingo%S 1 de enero de 2012 01:00:00 Hora estándar de Europa Central
+domingo%S 1 de enero de 2012 00:00:00 Hora%S de Europa Occidental
+domingo%S 1 de enero de 2012 01:00:00 Hora estándar de Europa Central
diff --git a/ext/intl/tests/gregoriancalendar___construct_basic.phpt b/ext/intl/tests/gregoriancalendar___construct_basic.phpt
new file mode 100644
index 0000000..bdbef67
--- /dev/null
+++ b/ext/intl/tests/gregoriancalendar___construct_basic.phpt
@@ -0,0 +1,51 @@
+--TEST--
+IntlGregorianCalendar::__construct(): basic
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '4.8') < 0)
+ die('skip for ICU 4.8+');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+date_default_timezone_set('Europe/Amsterdam');
+
+$intlcal = intlgregcal_create_instance();
+var_dump($intlcal->getTimeZone()->getId());
+var_dump($intlcal->getLocale(1));
+
+$intlcal = new IntlGregorianCalendar('Europe/Lisbon', NULL);
+var_dump($intlcal->getTimeZone()->getId());
+var_dump($intlcal->getLocale(1));
+
+$intlcal = new IntlGregorianCalendar(NULL, 'pt_PT');
+var_dump($intlcal->getTimeZone()->getId());
+var_dump($intlcal->getLocale(1));
+
+$intlcal = new IntlGregorianCalendar('Europe/Lisbon', 'pt_PT');
+var_dump($intlcal->getTimeZone()->getId());
+var_dump($intlcal->getLocale(1));
+
+$intlcal = new IntlGregorianCalendar('Europe/Paris', 'fr_CA', NULL, NULL, NULL, NULL);
+var_dump($intlcal->getTimeZone()->getId());
+var_dump($intlcal->getLocale(1));
+
+var_dump($intlcal->getType());
+?>
+==DONE==
+--EXPECT--
+string(16) "Europe/Amsterdam"
+string(5) "nl_NL"
+string(13) "Europe/Lisbon"
+string(5) "nl_NL"
+string(16) "Europe/Amsterdam"
+string(5) "pt_PT"
+string(13) "Europe/Lisbon"
+string(5) "pt_PT"
+string(12) "Europe/Paris"
+string(5) "fr_CA"
+string(9) "gregorian"
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/gregoriancalendar___construct_error.phpt b/ext/intl/tests/gregoriancalendar___construct_error.phpt
new file mode 100644
index 0000000..0e85394
--- /dev/null
+++ b/ext/intl/tests/gregoriancalendar___construct_error.phpt
@@ -0,0 +1,35 @@
+--TEST--
+IntlGregorianCalendar::__construct(): bad arguments
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+var_dump(intlgregcal_create_instance(1,2,3,4,5,6,7));
+var_dump(intlgregcal_create_instance(1,2,3,4,5,6,7,8));
+var_dump(intlgregcal_create_instance(1,2,3,4));
+var_dump(new IntlGregorianCalendar(1,2,NULL,4));
+var_dump(new IntlGregorianCalendar(1,2,3,4,NULL,array()));
+
+
+--EXPECTF--
+
+Warning: intlgregcal_create_instance(): intlgregcal_create_instance: too many arguments in %s on line %d
+NULL
+
+Warning: intlgregcal_create_instance(): intlgregcal_create_instance: too many arguments in %s on line %d
+NULL
+
+Warning: intlgregcal_create_instance(): intlgregcal_create_instance: no variant with 4 arguments (excluding trailing NULLs) in %s on line %d
+NULL
+
+Warning: IntlGregorianCalendar::__construct(): intlgregcal_create_instance: no variant with 4 arguments (excluding trailing NULLs) in %s on line %d
+NULL
+
+Warning: IntlGregorianCalendar::__construct() expects parameter 6 to be long, array given in %s on line %d
+
+Warning: IntlGregorianCalendar::__construct(): intlgregcal_create_instance: bad arguments in %s on line %d
+NULL
diff --git a/ext/intl/tests/gregoriancalendar___construct_variant1.phpt b/ext/intl/tests/gregoriancalendar___construct_variant1.phpt
new file mode 100644
index 0000000..63266b7
--- /dev/null
+++ b/ext/intl/tests/gregoriancalendar___construct_variant1.phpt
@@ -0,0 +1,30 @@
+--TEST--
+IntlGregorianCalendar::__construct(): argument variants
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+date_default_timezone_set('Europe/Amsterdam');
+
+$intlcal = intlgregcal_create_instance(2012, 1, 29, 16, 0, NULL);
+var_dump($intlcal->getTimeZone()->getId());
+var_dump($intlcal->getTime(), (float)strtotime('2012-02-29 16:00:00') * 1000);
+
+$intlcal = new IntlGregorianCalendar(2012, 1, 29, 16, 7, 8);
+var_dump($intlcal->getTime(), (float)strtotime('2012-02-29 16:07:08') * 1000);
+
+var_dump($intlcal->getType());
+?>
+==DONE==
+--EXPECT--
+string(16) "Europe/Amsterdam"
+float(1330527600000)
+float(1330527600000)
+float(1330528028000)
+float(1330528028000)
+string(9) "gregorian"
+==DONE==
diff --git a/ext/intl/tests/gregoriancalendar_getGregorianChange_error.phpt b/ext/intl/tests/gregoriancalendar_getGregorianChange_error.phpt
new file mode 100644
index 0000000..58d5662
--- /dev/null
+++ b/ext/intl/tests/gregoriancalendar_getGregorianChange_error.phpt
@@ -0,0 +1,30 @@
+--TEST--
+IntlGregorianCalendar::getGregorianChange(): bad arguments
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$c = new IntlGregorianCalendar(NULL, 'pt_PT');
+var_dump($c->getGregorianChange(1));
+
+var_dump(intlgregcal_get_gregorian_change($c, 1));
+var_dump(intlgregcal_get_gregorian_change(1));
+--EXPECTF--
+
+Warning: IntlGregorianCalendar::getGregorianChange() expects exactly 0 parameters, 1 given in %s on line %d
+
+Warning: IntlGregorianCalendar::getGregorianChange(): intlgregcal_get_gregorian_change: bad arguments in %s on line %d
+bool(false)
+
+Warning: intlgregcal_get_gregorian_change() expects exactly 1 parameter, 2 given in %s on line %d
+
+Warning: intlgregcal_get_gregorian_change(): intlgregcal_get_gregorian_change: bad arguments in %s on line %d
+bool(false)
+
+Catchable fatal error: Argument 1 passed to intlgregcal_get_gregorian_change() must be an instance of IntlGregorianCalendar, integer given in %s on line %d
diff --git a/ext/intl/tests/gregoriancalendar_get_setGregorianChange_basic.phpt b/ext/intl/tests/gregoriancalendar_get_setGregorianChange_basic.phpt
new file mode 100644
index 0000000..b08ad79
--- /dev/null
+++ b/ext/intl/tests/gregoriancalendar_get_setGregorianChange_basic.phpt
@@ -0,0 +1,32 @@
+--TEST--
+IntlGregorianCalendar::get/setGregorianChange(): basic test
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+date_default_timezone_set('Europe/Amsterdam');
+
+$intlcal = new IntlGregorianCalendar();
+
+var_dump($intlcal->getGregorianChange());
+
+var_dump($intlcal->setGregorianChange(0));
+var_dump(intlgregcal_get_gregorian_change($intlcal));
+
+var_dump(intlgregcal_set_gregorian_change($intlcal, 1));
+var_dump($intlcal->getGregorianChange());
+
+?>
+==DONE==
+--EXPECT--
+float(-12219292800000)
+bool(true)
+float(0)
+bool(true)
+float(1)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/gregoriancalendar_isLeapYear_basic.phpt b/ext/intl/tests/gregoriancalendar_isLeapYear_basic.phpt
new file mode 100644
index 0000000..b37452f
--- /dev/null
+++ b/ext/intl/tests/gregoriancalendar_isLeapYear_basic.phpt
@@ -0,0 +1,28 @@
+--TEST--
+IntlGregorianCalendar::isLeapYear(): basic test
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+
+date_default_timezone_set('Europe/Amsterdam');
+
+$intlcal = new IntlGregorianCalendar();
+
+var_dump($intlcal->isLeapYear(2012));
+var_dump($intlcal->isLeapYear(1900));
+
+var_dump(intlgregcal_is_leap_year($intlcal, 2012));
+var_dump(intlgregcal_is_leap_year($intlcal, 1900));
+?>
+==DONE==
+--EXPECT--
+bool(true)
+bool(false)
+bool(true)
+bool(false)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/gregoriancalendar_isLeapYear_error.phpt b/ext/intl/tests/gregoriancalendar_isLeapYear_error.phpt
new file mode 100644
index 0000000..40a6c85
--- /dev/null
+++ b/ext/intl/tests/gregoriancalendar_isLeapYear_error.phpt
@@ -0,0 +1,48 @@
+--TEST--
+IntlGregorianCalendar::isLeapYear(): bad arguments
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$c = new IntlGregorianCalendar(NULL, 'pt_PT');
+var_dump($c->isLeapYear(2000, 2011));
+var_dump($c->isLeapYear());
+var_dump($c->isLeapYear("fgdf"));
+
+var_dump(intlgregcal_is_leap_year($c, 1, 2));
+var_dump(intlgregcal_is_leap_year($c));
+var_dump(intlgregcal_is_leap_year(1, 2));
+--EXPECTF--
+
+Warning: IntlGregorianCalendar::isLeapYear() expects exactly 1 parameter, 2 given in %s on line %d
+
+Warning: IntlGregorianCalendar::isLeapYear(): intlgregcal_is_leap_year: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlGregorianCalendar::isLeapYear() expects exactly 1 parameter, 0 given in %s on line %d
+
+Warning: IntlGregorianCalendar::isLeapYear(): intlgregcal_is_leap_year: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlGregorianCalendar::isLeapYear() expects parameter 1 to be long, string given in %s on line %d
+
+Warning: IntlGregorianCalendar::isLeapYear(): intlgregcal_is_leap_year: bad arguments in %s on line %d
+bool(false)
+
+Warning: intlgregcal_is_leap_year() expects exactly 2 parameters, 3 given in %s on line %d
+
+Warning: intlgregcal_is_leap_year(): intlgregcal_is_leap_year: bad arguments in %s on line %d
+bool(false)
+
+Warning: intlgregcal_is_leap_year() expects exactly 2 parameters, 1 given in %s on line %d
+
+Warning: intlgregcal_is_leap_year(): intlgregcal_is_leap_year: bad arguments in %s on line %d
+bool(false)
+
+Catchable fatal error: Argument 1 passed to intlgregcal_is_leap_year() must be an instance of IntlGregorianCalendar, integer given in %s on line %d
diff --git a/ext/intl/tests/gregoriancalendar_setGregorianChange_error.phpt b/ext/intl/tests/gregoriancalendar_setGregorianChange_error.phpt
new file mode 100644
index 0000000..eac8deb
--- /dev/null
+++ b/ext/intl/tests/gregoriancalendar_setGregorianChange_error.phpt
@@ -0,0 +1,42 @@
+--TEST--
+IntlGregorianCalendar::setGregorianChange(): bad arguments
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$c = new IntlGregorianCalendar();
+var_dump($c->setGregorianChange());
+var_dump($c->setGregorianChange(1, 2));
+var_dump($c->setGregorianChange("sdfds"));
+
+var_dump(intlgregcal_set_gregorian_change($c));
+var_dump(intlgregcal_set_gregorian_change(1, 4.));
+--EXPECTF--
+
+Warning: IntlGregorianCalendar::setGregorianChange() expects exactly 1 parameter, 0 given in %s on line %d
+
+Warning: IntlGregorianCalendar::setGregorianChange(): intlgregcal_set_gregorian_change: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlGregorianCalendar::setGregorianChange() expects exactly 1 parameter, 2 given in %s on line %d
+
+Warning: IntlGregorianCalendar::setGregorianChange(): intlgregcal_set_gregorian_change: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlGregorianCalendar::setGregorianChange() expects parameter 1 to be double, string given in %s on line %d
+
+Warning: IntlGregorianCalendar::setGregorianChange(): intlgregcal_set_gregorian_change: bad arguments in %s on line %d
+bool(false)
+
+Warning: intlgregcal_set_gregorian_change() expects exactly 2 parameters, 1 given in %s on line %d
+
+Warning: intlgregcal_set_gregorian_change(): intlgregcal_set_gregorian_change: bad arguments in %s on line %d
+bool(false)
+
+Catchable fatal error: Argument 1 passed to intlgregcal_set_gregorian_change() must be an instance of IntlGregorianCalendar, integer given in %s on line %d
diff --git a/ext/intl/tests/ini_use_exceptions_basic.phpt b/ext/intl/tests/ini_use_exceptions_basic.phpt
new file mode 100644
index 0000000..36ccbcb
--- /dev/null
+++ b/ext/intl/tests/ini_use_exceptions_basic.phpt
@@ -0,0 +1,21 @@
+--TEST--
+intl.use_exceptions INI setting
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+ini_set("intl.use_exceptions", true);
+$t = transliterator_create('any-hex');
+try {
+ var_dump($t->transliterate('a', 3));
+} catch (IntlException $intlE) {
+ var_dump($intlE->getMessage());
+}
+ini_set("intl.use_exceptions", false);
+ini_set("intl.error_level", E_NOTICE);
+var_dump($t->transliterate('a', 3));
+--EXPECTF--
+string(130) "transliterator_transliterate: Neither "start" nor the "end" arguments can exceed the number of UTF-16 code units (in this case, 1)"
+
+Notice: Transliterator::transliterate(): transliterator_transliterate: Neither "start" nor the "end" arguments can exceed the number of UTF-16 code units (in this case, 1) in %s on line %d
+bool(false)
diff --git a/ext/intl/tests/msgfmt_format_datetime.phpt b/ext/intl/tests/msgfmt_format_datetime.phpt
new file mode 100644
index 0000000..07e7d68
--- /dev/null
+++ b/ext/intl/tests/msgfmt_format_datetime.phpt
@@ -0,0 +1,28 @@
+--TEST--
+MessageFormatter::format(): DateTime accepted to format dates and times
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+//ini_set("intl.default_locale", "nl");
+
+$fmt = <<<EOD
+{0,date} {0,time}
+EOD;
+
+$dt = new DateTime("2012-05-06 18:00:42", new DateTimeZone("Europe/Lisbon"));
+
+$mf = new MessageFormatter('en_US', $fmt);
+
+var_dump($mf->format(array($dt)));
+
+?>
+==DONE==
+--EXPECTF--
+string(%s) "May %d, 2012 %d:%d:42 %s"
+==DONE==
diff --git a/ext/intl/tests/msgfmt_format_error1.phpt b/ext/intl/tests/msgfmt_format_error1.phpt
new file mode 100644
index 0000000..684b059
--- /dev/null
+++ b/ext/intl/tests/msgfmt_format_error1.phpt
@@ -0,0 +1,19 @@
+--TEST--
+MessageFormatter::format() insufficient numeric arguments
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$fmt = <<<EOD
+{0} {1}
+EOD;
+
+$mf = new MessageFormatter('en_US', $fmt);
+var_dump($mf->format(array(7)));
+
+--EXPECTF--
+string(5) "7 {1}"
diff --git a/ext/intl/tests/msgfmt_format_error2.phpt b/ext/intl/tests/msgfmt_format_error2.phpt
new file mode 100644
index 0000000..85d1b1c
--- /dev/null
+++ b/ext/intl/tests/msgfmt_format_error2.phpt
@@ -0,0 +1,23 @@
+--TEST--
+MessageFormatter::format() inconsistent types in named argument
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '4.8') < 0)
+ die('skip for ICU 4.8+');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$fmt = <<<EOD
+{foo,number} {foo}
+EOD;
+
+$mf = new MessageFormatter('en_US', $fmt);
+var_dump($mf->format(array(7)));
+
+--EXPECTF--
+
+Warning: MessageFormatter::format(): Inconsistent types declared for an argument in %s on line %d
+bool(false)
diff --git a/ext/intl/tests/msgfmt_format_error3.phpt b/ext/intl/tests/msgfmt_format_error3.phpt
new file mode 100644
index 0000000..6dfbee3
--- /dev/null
+++ b/ext/intl/tests/msgfmt_format_error3.phpt
@@ -0,0 +1,23 @@
+--TEST--
+MessageFormatter::format() given negative arg key
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '4.8') < 0)
+ die('skip for ICU 4.8+');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$fmt = <<<EOD
+{foo,number,percent}
+EOD;
+
+$mf = new MessageFormatter('en_US', $fmt);
+var_dump($mf->format(array("foo" => 7, -1 => "bar")));
+
+--EXPECTF--
+
+Warning: MessageFormatter::format(): Found negative or too large array key in %s on line %d
+bool(false)
diff --git a/ext/intl/tests/msgfmt_format_error4.phpt b/ext/intl/tests/msgfmt_format_error4.phpt
new file mode 100644
index 0000000..3b92b48
--- /dev/null
+++ b/ext/intl/tests/msgfmt_format_error4.phpt
@@ -0,0 +1,28 @@
+--TEST--
+MessageFormatter::format() invalid UTF-8 for arg key or value
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '4.8') < 0)
+ die('skip for ICU 4.8+');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$fmt = <<<EOD
+{foo}
+EOD;
+
+$mf = new MessageFormatter('en_US', $fmt);
+var_dump($mf->format(array("foo" => 7, "\x80" => "bar")));
+
+var_dump($mf->format(array("foo" => "\x80")));
+
+--EXPECTF--
+
+Warning: MessageFormatter::format(): Invalid UTF-8 data in argument key: '' in %s on line %d
+bool(false)
+
+Warning: MessageFormatter::format(): Invalid UTF-8 data in string argument: '' in %s on line %d
+bool(false)
diff --git a/ext/intl/tests/msgfmt_format_error5.phpt b/ext/intl/tests/msgfmt_format_error5.phpt
new file mode 100644
index 0000000..052d0ef
--- /dev/null
+++ b/ext/intl/tests/msgfmt_format_error5.phpt
@@ -0,0 +1,25 @@
+--TEST--
+MessageFormatter::format() invalid date/time argument
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '4.8') < 0)
+ die('skip for ICU 4.8+');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$fmt = <<<EOD
+{foo,date}
+EOD;
+
+$mf = new MessageFormatter('en_US', $fmt);
+var_dump($mf->format(array("foo" => new stdclass())));
+
+--EXPECTF--
+
+Warning: MessageFormatter::format(): The argument for key 'foo' cannot be used as a date or time in %s on line %d
+bool(false)
diff --git a/ext/intl/tests/msgfmt_format_error6.phpt b/ext/intl/tests/msgfmt_format_error6.phpt
new file mode 100644
index 0000000..b07d2ab
--- /dev/null
+++ b/ext/intl/tests/msgfmt_format_error6.phpt
@@ -0,0 +1,23 @@
+--TEST--
+MessageFormatter::format() invalid type for key not in pattern
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '4.8') < 0)
+ die('skip for ICU 4.8+');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$fmt = <<<EOD
+{foo}
+EOD;
+
+$mf = new MessageFormatter('en_US', $fmt);
+var_dump($mf->format(array("foo" => 'bar', 7 => fopen('php://memory', 'r+'))));
+
+--EXPECTF--
+
+Warning: MessageFormatter::format(): No strategy to convert the value given for the argument with key '7' is available in %s on line %d
+bool(false)
diff --git a/ext/intl/tests/msgfmt_format_intlcalendar.phpt b/ext/intl/tests/msgfmt_format_intlcalendar.phpt
new file mode 100644
index 0000000..6ae78a9
--- /dev/null
+++ b/ext/intl/tests/msgfmt_format_intlcalendar.phpt
@@ -0,0 +1,30 @@
+--TEST--
+MessageFormat accepts IntlCalendar args
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+//ini_set("intl.default_locale", "nl");
+ini_set('date.timezone', 'Europe/Lisbon');
+
+$cal = new IntlGregorianCalendar(2012,04,17,17,35,36);
+
+$msgf = new MessageFormatter('pt_PT', '{0,date,full} {0,time,h:m:s a V}');
+echo $msgf->format(array($cal)), "\n";
+
+//NOT FIXED:
+/*$msgf = new MessageFormatter('en_US',
+'{1, select, date {{0,date,full}} other {{0,time,h:m:s a V}}}');
+
+echo "msgf2: ", $msgf->format(array($time, 'date')), " ",
+ $msgf->format(array($time, 'time')), "\n";
+*/
+
+?>
+==DONE==
+--EXPECT--
+Quinta-feira, 17 de Maio de 2012 5:35:36 p.m. WEST
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/msgfmt_format_mixed_params.phpt b/ext/intl/tests/msgfmt_format_mixed_params.phpt
new file mode 100644
index 0000000..93412f4
--- /dev/null
+++ b/ext/intl/tests/msgfmt_format_mixed_params.phpt
@@ -0,0 +1,25 @@
+--TEST--
+MessageFormatter::format(): mixed named and numeric parameters
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '4.8') < 0)
+ die('skip for ICU 4.8+');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+//ini_set("intl.default_locale", "nl");
+
+$mf = new MessageFormatter('en_US',
+ "{0,number} -- {foo,ordinal}");
+
+var_dump($mf->format(array(2.3, "foo" => 1.3)));
+var_dump($mf->format(array("foo" => 1.3, 0 => 2.3)));
+
+?>
+==DONE==
+--EXPECT--
+string(10) "2.3 -- 1st"
+string(10) "2.3 -- 1st"
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/msgfmt_format_simple_types_numeric_strings.phpt b/ext/intl/tests/msgfmt_format_simple_types_numeric_strings.phpt
new file mode 100644
index 0000000..299ae48
--- /dev/null
+++ b/ext/intl/tests/msgfmt_format_simple_types_numeric_strings.phpt
@@ -0,0 +1,58 @@
+--TEST--
+MessageFormatter::format(): simple types handling with numeric strings
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '4.8') < 0)
+ die('skip for ICU 4.8+');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+//ini_set("intl.default_locale", "nl");
+
+$mf = new MessageFormatter('en_US',"
+ none {a}
+ number {b,number}
+ number integer {c,number,integer}
+ number currency {d,number,currency}
+ number percent {e,number,percent}
+ date {f,date}
+ time {g,time}
+ spellout {h,spellout}
+ ordinal {i,ordinal}
+ duration {j,duration}
+ ");
+
+$ex = "1336317965.5 str";
+var_dump($mf->format(array(
+'a' => $ex,
+'b' => $ex,
+'c' => $ex,
+'d' => $ex,
+'e' => $ex,
+'f' => " 1336317965.5",
+'g' => " 1336317965.5",
+'h' => $ex,
+'i' => $ex,
+'j' => $ex,
+)));
+
+?>
+==DONE==
+--EXPECTF--
+string(%d) "
+ none 1336317965.5 str
+ number 1,336,317,965.5
+ number integer 1,336,317,965
+ number currency $1,336,317,965.50
+ number percent 133,631,796,550%
+ date May %d, 2012
+ time %d:%d:05 PM
+ spellout one billion three hundred thirty-six million three hundred seventeen thousand nine hundred sixty-five point five
+ ordinal 1,336,317,966th
+ duration 371,199:26:06
+ "
+==DONE==
diff --git a/ext/intl/tests/msgfmt_format_subpatterns.phpt b/ext/intl/tests/msgfmt_format_subpatterns.phpt
new file mode 100644
index 0000000..9f11e3e
--- /dev/null
+++ b/ext/intl/tests/msgfmt_format_subpatterns.phpt
@@ -0,0 +1,75 @@
+--TEST--
+msgfmt_format() with subpatterns
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '4.8') < 0)
+ die('skip for ICU 4.8+');
+--FILE--
+<?php
+
+/*
+ * Format a number using misc locales/patterns.
+ */
+
+
+function ut_main()
+{
+
+$pattern=<<<_MSG_
+{0, select,
+ female {{1, plural, offset:1
+ =0 {{2} does not give a party.}
+ =1 {{2} invites {3} to her party.}
+ =2 {{2} invites {3} and one other person to her party.}
+ other {{2} invites {3} as one of the # people invited to her party.}}}
+ male {{1, plural, offset:1
+ =0 {{2} does not give a party.}
+ =1 {{2} invites {3} to his party.}
+ =2 {{2} invites {3} and one other person to his party.}
+ other {{2} invites {3} as one of the # other people invited to his party.}}}
+ other {{1, plural, offset:1
+ =0 {{2} does not give a party.}
+ =1 {{2} invites {3} to their party.}
+ =2 {{2} invites {3} and one other person to their party.}
+ other {{2} invites {3} as one of the # other people invited to their party.}}}}
+_MSG_;
+
+
+$args = array(
+ array('female', 0, 'Alice', 'Bob'),
+ array('male', 1, 'Alice', 'Bob'),
+ array('none', 2, 'Alice', 'Bob'),
+ array('female', 27, 'Alice', 'Bob'),
+);
+
+$str_res = '';
+
+ $fmt = ut_msgfmt_create( 'en_US', $pattern );
+ if(!$fmt) {
+ $str_res .= dump(intl_get_error_message())."\n";
+ return $str_res;
+ }
+ foreach ($args as $arg) {
+ $str_res .= dump( ut_msgfmt_format($fmt, $arg) ). "\n";
+ $str_res .= dump( ut_msgfmt_format_message('en_US', $pattern, $arg) ) . "\n";
+ }
+ return $str_res;
+}
+
+include_once( 'ut_common.inc' );
+
+// Run the test
+ut_run();
+
+?>
+--EXPECT--
+'Alice does not give a party.'
+'Alice does not give a party.'
+'Alice invites Bob to his party.'
+'Alice invites Bob to his party.'
+'Alice invites Bob and one other person to their party.'
+'Alice invites Bob and one other person to their party.'
+'Alice invites Bob as one of the 26 people invited to her party.'
+'Alice invites Bob as one of the 26 people invited to her party.'
diff --git a/ext/intl/tests/msgfmt_format_subpatterns_named.phpt b/ext/intl/tests/msgfmt_format_subpatterns_named.phpt
new file mode 100644
index 0000000..f6af025
--- /dev/null
+++ b/ext/intl/tests/msgfmt_format_subpatterns_named.phpt
@@ -0,0 +1,75 @@
+--TEST--
+msgfmt_format() with named subpatterns
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '4.8') < 0)
+ die('skip for ICU 4.8+');
+--FILE--
+<?php
+
+/*
+ * Format a number using misc locales/patterns.
+ */
+
+
+function ut_main()
+{
+
+$pattern=<<<_MSG_
+{gender_of_host, select,
+ female {{num_guests, plural, offset:1
+ =0 {{host} does not give a party.}
+ =1 {{host} invites {guest} to her party.}
+ =2 {{host} invites {guest} and one other person to her party.}
+ other {{host} invites {guest} as one of the # people invited to her party.}}}
+ male {{num_guests, plural, offset:1
+ =0 {{host} does not give a party.}
+ =1 {{host} invites {guest} to his party.}
+ =2 {{host} invites {guest} and one other person to his party.}
+ other {{host} invites {guest} as one of the # people invited to his party.}}}
+ other {{num_guests, plural, offset:1
+ =0 {{host} does not give a party.}
+ =1 {{host} invites {guest} to their party.}
+ =2 {{host} invites {guest} and one other person to their party.}
+ other {{host} invites {guest} as one of the # people invited to their party.}}}}
+_MSG_;
+
+
+$args = array(
+ array('gender_of_host' => 'female', 'num_guests' => 0, 'host' => 'Alice', 'guest' => 'Bob'),
+ array('gender_of_host' => 'male', 'num_guests' => 1, 'host' => 'Alice', 'guest' => 'Bob'),
+ array('gender_of_host' => 'none', 'num_guests' => 2, 'host' => 'Alice', 'guest' => 'Bob'),
+ array('gender_of_host' => 'female', 'num_guests' => 27, 'host' => 'Alice', 'guest' => 'Bob'),
+);
+
+$str_res = '';
+
+ $fmt = ut_msgfmt_create( 'en_US', $pattern );
+ if(!$fmt) {
+ $str_res .= dump(intl_get_error_message())."\n";
+ return $str_res;
+ }
+ foreach ($args as $arg) {
+ $str_res .= dump( ut_msgfmt_format($fmt, $arg) ). "\n";
+ $str_res .= dump( ut_msgfmt_format_message('en_US', $pattern, $arg) ) . "\n";
+ }
+ return $str_res;
+}
+
+include_once( 'ut_common.inc' );
+
+// Run the test
+ut_run();
+
+?>
+--EXPECT--
+'Alice does not give a party.'
+'Alice does not give a party.'
+'Alice invites Bob to his party.'
+'Alice invites Bob to his party.'
+'Alice invites Bob and one other person to their party.'
+'Alice invites Bob and one other person to their party.'
+'Alice invites Bob as one of the 26 people invited to her party.'
+'Alice invites Bob as one of the 26 people invited to her party.'
diff --git a/ext/intl/tests/msgfmt_get_error.phpt b/ext/intl/tests/msgfmt_get_error.phpt
deleted file mode 100755
index 015c50d..0000000
--- a/ext/intl/tests/msgfmt_get_error.phpt
+++ /dev/null
@@ -1,29 +0,0 @@
---TEST--
-msgmfmt_get_error_message/code()
---SKIPIF--
-<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
---FILE--
-<?php
-
-/*
- * Error handling.
- */
-
-
-function ut_main()
-{
- $fmt = ut_msgfmt_create( "en_US", "{0, number} monkeys on {1, number} trees" );
- $num = ut_msgfmt_format( $fmt, array());
- if( $num === false )
- return $fmt->getErrorMessage() . " (" . $fmt->getErrorCode() . ")\n";
- else
- return "Ooops, an error should have occured.";
-}
-
-include_once( 'ut_common.inc' );
-
-// Run the test
-ut_run();
-?>
---EXPECT--
-msgfmt_format: not enough parameters: U_ILLEGAL_ARGUMENT_ERROR (1)
diff --git a/ext/intl/tests/msgfmt_millisecond_dates.phpt b/ext/intl/tests/msgfmt_millisecond_dates.phpt
new file mode 100644
index 0000000..7dd0514
--- /dev/null
+++ b/ext/intl/tests/msgfmt_millisecond_dates.phpt
@@ -0,0 +1,29 @@
+--TEST--
+MessageFrormatter parses and formats dates with millisecond precision
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+date_default_timezone_set('Europe/Lisbon'); //ignored for now, see bug #58756
+
+$d = 1336308097.123;
+$mf = new MessageFormatter('en_US',
+ "On {0,time,yyyy-MM-dd G 'at' HH:mm:ss.SSS zzz} something odd happened");
+
+var_dump($mf->format(array(1336310569.123)));
+
+$p = 'On 2012-05-06 AD at 15:22:49.123 GMT+02:00 something odd happened';
+var_dump($mf->parse($p));
+
+?>
+==DONE==
+--EXPECTF--
+string(%d) "On 2012-05-0%d AD at %d:%d:49.123 %s something odd happened"
+array(1) {
+ [0]=>
+ float(1336310569.123)
+}
+==DONE==
diff --git a/ext/intl/tests/msgfmt_setPattern_cache.phpt b/ext/intl/tests/msgfmt_setPattern_cache.phpt
new file mode 100644
index 0000000..35ec463
--- /dev/null
+++ b/ext/intl/tests/msgfmt_setPattern_cache.phpt
@@ -0,0 +1,26 @@
+--TEST--
+MessageFormatter::setPattern() invalidates arg types cache
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+//ini_set("intl.default_locale", "nl");
+
+$mf = new MessageFormatter('en_US',
+ "{0,number} -- {1,ordinal}");
+
+var_dump($mf->format(array(1.3, 1.3)));
+var_dump($mf->format(array(1.3, 1.3)));
+$mf->setPattern("{0,ordinal} -- {1,number}");
+var_dump($mf->format(array(1.3, 1.3)));
+
+?>
+==DONE==
+--EXPECT--
+string(10) "1.3 -- 1st"
+string(10) "1.3 -- 1st"
+string(10) "1st -- 1.3"
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/timezone_clone_basic.phpt b/ext/intl/tests/timezone_clone_basic.phpt
new file mode 100644
index 0000000..a8ef83f
--- /dev/null
+++ b/ext/intl/tests/timezone_clone_basic.phpt
@@ -0,0 +1,51 @@
+--TEST--
+IntlTimeZone clone handler: basic test
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$tz1 = IntlTimeZone::createTimeZone('Europe/Amsterdam');
+print_r($tz1);
+print_r(clone $tz1);
+
+//clone non-owned object
+$gmt = IntlTimeZone::getGMT();
+print_r($gmt);
+print_r(clone $gmt);
+
+?>
+==DONE==
+--EXPECTF--
+IntlTimeZone Object
+(
+ [valid] => 1
+ [id] => Europe/Amsterdam
+ [rawOffset] => 3600000
+ [currentOffset] => %d
+)
+IntlTimeZone Object
+(
+ [valid] => 1
+ [id] => Europe/Amsterdam
+ [rawOffset] => 3600000
+ [currentOffset] => %d
+)
+IntlTimeZone Object
+(
+ [valid] => 1
+ [id] => GMT
+ [rawOffset] => 0
+ [currentOffset] => 0
+)
+IntlTimeZone Object
+(
+ [valid] => 1
+ [id] => GMT
+ [rawOffset] => 0
+ [currentOffset] => 0
+)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/timezone_clone_error.phpt b/ext/intl/tests/timezone_clone_error.phpt
new file mode 100644
index 0000000..df501be
--- /dev/null
+++ b/ext/intl/tests/timezone_clone_error.phpt
@@ -0,0 +1,32 @@
+--TEST--
+IntlTimeZone clone handler: error test
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+class A extends IntlTimeZone {
+function __construct() {}
+}
+
+$tz = new A();
+var_dump($tz);
+try {
+var_dump(clone $tz);
+} catch (Exception $e) {
+ var_dump(get_class($e), $e->getMessage());
+}
+
+?>
+==DONE==
+--EXPECT--
+object(A)#1 (1) {
+ ["valid"]=>
+ bool(false)
+}
+string(9) "Exception"
+string(39) "Cannot clone unconstructed IntlTimeZone"
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/timezone_countEquivalentIDs_basic.phpt b/ext/intl/tests/timezone_countEquivalentIDs_basic.phpt
new file mode 100644
index 0000000..ec3e405
--- /dev/null
+++ b/ext/intl/tests/timezone_countEquivalentIDs_basic.phpt
@@ -0,0 +1,20 @@
+--TEST--
+IntlTimeZone::countEquivalentIDs(): basic test
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+$count = IntlTimeZone::countEquivalentIDs('Europe/Lisbon');
+var_dump($count >= 2);
+
+$count2 = intltz_count_equivalent_ids('Europe/Lisbon');
+var_dump($count2 == $count);
+?>
+==DONE==
+--EXPECT--
+bool(true)
+bool(true)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/timezone_countEquivalentIDs_error.phpt b/ext/intl/tests/timezone_countEquivalentIDs_error.phpt
new file mode 100644
index 0000000..4d8f4bc
--- /dev/null
+++ b/ext/intl/tests/timezone_countEquivalentIDs_error.phpt
@@ -0,0 +1,35 @@
+--TEST--
+IntlTimeZone::countEquivalentIDs(): errors
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+var_dump(IntlTimeZone::countEquivalentIDs());
+var_dump(IntlTimeZone::countEquivalentIDs(array()));
+var_dump(IntlTimeZone::countEquivalentIDs("foo\x80"));
+var_dump(IntlTimeZone::countEquivalentIDs("foo bar", 7));
+
+
+--EXPECTF--
+
+Warning: IntlTimeZone::countEquivalentIDs() expects exactly 1 parameter, 0 given in %s on line %d
+
+Warning: IntlTimeZone::countEquivalentIDs(): intltz_count_equivalent_ids: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlTimeZone::countEquivalentIDs() expects parameter 1 to be string, array given in %s on line %d
+
+Warning: IntlTimeZone::countEquivalentIDs(): intltz_count_equivalent_ids: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlTimeZone::countEquivalentIDs(): intltz_count_equivalent_ids: could not convert time zone id to UTF-16 in %s on line %d
+bool(false)
+
+Warning: IntlTimeZone::countEquivalentIDs() expects exactly 1 parameter, 2 given in %s on line %d
+
+Warning: IntlTimeZone::countEquivalentIDs(): intltz_count_equivalent_ids: bad arguments in %s on line %d
+bool(false)
diff --git a/ext/intl/tests/timezone_createDefault_basic.phpt b/ext/intl/tests/timezone_createDefault_basic.phpt
new file mode 100644
index 0000000..a18899f
--- /dev/null
+++ b/ext/intl/tests/timezone_createDefault_basic.phpt
@@ -0,0 +1,31 @@
+--TEST--
+IntlTimeZone::createDefault(): basic test
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+$tz = IntlTimeZone::createDefault();
+print_r($tz);
+$tz = intltz_create_default();
+print_r($tz);
+?>
+==DONE==
+--EXPECTF--
+IntlTimeZone Object
+(
+ [valid] => 1
+ [id] => %s
+ [rawOffset] => %d
+ [currentOffset] => %d
+)
+IntlTimeZone Object
+(
+ [valid] => 1
+ [id] => %s
+ [rawOffset] => %d
+ [currentOffset] => %d
+)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/timezone_createDefault_error.phpt b/ext/intl/tests/timezone_createDefault_error.phpt
new file mode 100644
index 0000000..0724898
--- /dev/null
+++ b/ext/intl/tests/timezone_createDefault_error.phpt
@@ -0,0 +1,19 @@
+--TEST--
+IntlTimeZone::createDefault(): errors
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+var_dump(IntlTimeZone::createDefault(4));
+
+
+--EXPECTF--
+
+Warning: IntlTimeZone::createDefault() expects exactly 0 parameters, 1 given in %s on line %d
+
+Warning: IntlTimeZone::createDefault(): intltz_create_default: bad arguments in %s on line %d
+NULL
diff --git a/ext/intl/tests/timezone_createEnumeration_basic.phpt b/ext/intl/tests/timezone_createEnumeration_basic.phpt
new file mode 100644
index 0000000..2df3256
--- /dev/null
+++ b/ext/intl/tests/timezone_createEnumeration_basic.phpt
@@ -0,0 +1,26 @@
+--TEST--
+IntlTimeZone::createEnumeration(): basic test
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+$tz = IntlTimeZone::createEnumeration();
+var_dump(get_class($tz));
+$count = count(iterator_to_array($tz));
+var_dump($count > 300);
+
+$tz = intltz_create_enumeration();
+var_dump(get_class($tz));
+$count2 = count(iterator_to_array($tz));
+var_dump($count == $count2);
+?>
+==DONE==
+--EXPECT--
+string(12) "IntlIterator"
+bool(true)
+string(12) "IntlIterator"
+bool(true)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/timezone_createEnumeration_error.phpt b/ext/intl/tests/timezone_createEnumeration_error.phpt
new file mode 100644
index 0000000..e1e7cb9
--- /dev/null
+++ b/ext/intl/tests/timezone_createEnumeration_error.phpt
@@ -0,0 +1,23 @@
+--TEST--
+IntlTimeZone::createEnumeration(): errors
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+var_dump(IntlTimeZone::createEnumeration(array()));
+var_dump(IntlTimeZone::createEnumeration(1, 2));
+
+
+--EXPECTF--
+
+Warning: IntlTimeZone::createEnumeration(): intltz_create_enumeration: invalid argument type in %s on line %d
+bool(false)
+
+Warning: IntlTimeZone::createEnumeration() expects at most 1 parameter, 2 given in %s on line %d
+
+Warning: IntlTimeZone::createEnumeration(): intltz_create_enumeration: bad arguments in %s on line %d
+bool(false)
diff --git a/ext/intl/tests/timezone_createEnumeration_variation1.phpt b/ext/intl/tests/timezone_createEnumeration_variation1.phpt
new file mode 100644
index 0000000..30fc436
--- /dev/null
+++ b/ext/intl/tests/timezone_createEnumeration_variation1.phpt
@@ -0,0 +1,24 @@
+--TEST--
+IntlTimeZone::createEnumeration(): variant with offset
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+$tz = IntlTimeZone::createEnumeration(3600000);
+var_dump(get_class($tz));
+$count = count(iterator_to_array($tz));
+var_dump($count > 20);
+
+$tz->rewind();
+var_dump(in_array('Europe/Amsterdam', iterator_to_array($tz)));
+
+?>
+==DONE==
+--EXPECT--
+string(12) "IntlIterator"
+bool(true)
+bool(true)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/timezone_createEnumeration_variation2.phpt b/ext/intl/tests/timezone_createEnumeration_variation2.phpt
new file mode 100644
index 0000000..ddf1a6e
--- /dev/null
+++ b/ext/intl/tests/timezone_createEnumeration_variation2.phpt
@@ -0,0 +1,24 @@
+--TEST--
+IntlTimeZone::createEnumeration(): variant with country
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+$tz = IntlTimeZone::createEnumeration('NL');
+var_dump(get_class($tz));
+$count = count(iterator_to_array($tz));
+var_dump($count >= 1);
+
+$tz->rewind();
+var_dump(in_array('Europe/Amsterdam', iterator_to_array($tz)));
+
+?>
+==DONE==
+--EXPECT--
+string(12) "IntlIterator"
+bool(true)
+bool(true)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/timezone_createTimeZoneIDEnumeration_basic.phpt b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_basic.phpt
new file mode 100644
index 0000000..9ceffc5
--- /dev/null
+++ b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_basic.phpt
@@ -0,0 +1,34 @@
+--TEST--
+IntlTimeZone::createTimeZoneIDEnumeration(): basic test
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '4.8') < 0)
+ die('skip for ICU 4.8+');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+$enum = IntlTimeZone::createTimeZoneIDEnumeration(
+ IntlTimeZone::TYPE_ANY,
+ 'PT',
+ -3600000);
+print_r(iterator_to_array($enum));
+
+$enum = intltz_create_time_zone_id_enumeration(
+ IntlTimeZone::TYPE_ANY,
+ 'PT',
+ -3600000);
+print_r(iterator_to_array($enum));
+?>
+==DONE==
+--EXPECT--
+Array
+(
+ [0] => Atlantic/Azores
+)
+Array
+(
+ [0] => Atlantic/Azores
+)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/timezone_createTimeZoneIDEnumeration_error.phpt b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_error.phpt
new file mode 100644
index 0000000..2cc2ac4
--- /dev/null
+++ b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_error.phpt
@@ -0,0 +1,42 @@
+--TEST--
+IntlTimeZone::createTimeZoneIDEnumeration(): errors
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '4.8') < 0)
+ die('skip for ICU 4.8+');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+var_dump(IntlTimeZone::createTimeZoneIDEnumeration());
+var_dump(IntlTimeZone::createTimeZoneIDEnumeration(array()));
+var_dump(IntlTimeZone::createTimeZoneIDEnumeration(-1));
+var_dump(IntlTimeZone::createTimeZoneIDEnumeration(IntlTimeZone::TYPE_ANY, array()));
+var_dump(IntlTimeZone::createTimeZoneIDEnumeration(IntlTimeZone::TYPE_ANY, "PT", "a80"));
+
+--EXPECTF--
+
+Warning: IntlTimeZone::createTimeZoneIDEnumeration() expects at least 1 parameter, 0 given in %s on line %d
+
+Warning: IntlTimeZone::createTimeZoneIDEnumeration(): intltz_create_time_zone_id_enumeration: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlTimeZone::createTimeZoneIDEnumeration() expects parameter 1 to be long, array given in %s on line %d
+
+Warning: IntlTimeZone::createTimeZoneIDEnumeration(): intltz_create_time_zone_id_enumeration: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlTimeZone::createTimeZoneIDEnumeration(): intltz_create_time_zone_id_enumeration: bad zone type in %s on line %d
+bool(false)
+
+Warning: IntlTimeZone::createTimeZoneIDEnumeration() expects parameter 2 to be string, array given in %s on line %d
+
+Warning: IntlTimeZone::createTimeZoneIDEnumeration(): intltz_create_time_zone_id_enumeration: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlTimeZone::createTimeZoneIDEnumeration() expects parameter 3 to be long, string given in %s on line %d
+
+Warning: IntlTimeZone::createTimeZoneIDEnumeration(): intltz_create_time_zone_id_enumeration: bad arguments in %s on line %d
+bool(false)
diff --git a/ext/intl/tests/timezone_createTimeZoneIDEnumeration_variant1.phpt b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_variant1.phpt
new file mode 100644
index 0000000..d57dfbf
--- /dev/null
+++ b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_variant1.phpt
@@ -0,0 +1,32 @@
+--TEST--
+IntlTimeZone::createTimeZoneIDEnumeration(): variant without offset
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '4.8') < 0)
+ die('skip for ICU 4.8+');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+$enum = IntlTimeZone::createTimeZoneIDEnumeration(
+ IntlTimeZone::TYPE_ANY,
+ 'PT');
+$values = iterator_to_array($enum);
+var_dump(in_array('Europe/Lisbon', $values));
+var_dump(in_array('Atlantic/Azores', $values));
+
+$enum = IntlTimeZone::createTimeZoneIDEnumeration(
+ IntlTimeZone::TYPE_ANY,
+ 'PT',
+ null);
+$values2 = iterator_to_array($enum);
+var_dump($values2 == $values);
+
+?>
+==DONE==
+--EXPECT--
+bool(true)
+bool(true)
+bool(true)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/timezone_createTimeZoneIDEnumeration_variant2.phpt b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_variant2.phpt
new file mode 100644
index 0000000..2afe171
--- /dev/null
+++ b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_variant2.phpt
@@ -0,0 +1,52 @@
+--TEST--
+IntlTimeZone::createTimeZoneIDEnumeration(): variant without region
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '4.8') < 0)
+ die('skip for ICU 4.8+');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+$enum = IntlTimeZone::createTimeZoneIDEnumeration(
+ IntlTimeZone::TYPE_ANY);
+$countAny = count(iterator_to_array($enum));
+$enum = IntlTimeZone::createTimeZoneIDEnumeration(
+ IntlTimeZone::TYPE_CANONICAL);
+$countCanonical = count(iterator_to_array($enum));
+$enum = IntlTimeZone::createTimeZoneIDEnumeration(
+ IntlTimeZone::TYPE_CANONICAL_LOCATION);
+$countCanonicalLocation = count(iterator_to_array($enum));
+
+var_dump($countAny > $countCanonical);
+var_dump($countCanonical > $countCanonicalLocation);
+
+$enum = IntlTimeZone::createTimeZoneIDEnumeration(
+ IntlTimeZone::TYPE_ANY, null, null);
+$countAny2 = count(iterator_to_array($enum));
+var_dump($countAny == $countAny2);
+
+$enum = IntlTimeZone::createTimeZoneIDEnumeration(
+ IntlTimeZone::TYPE_ANY, null, -3600000);
+$values = iterator_to_array($enum);
+
+print_r(
+array_values(
+array_intersect($values,
+array('Etc/GMT+1', 'Atlantic/Azores'))
+));
+
+
+?>
+==DONE==
+--EXPECT--
+bool(true)
+bool(true)
+bool(true)
+Array
+(
+ [0] => Atlantic/Azores
+ [1] => Etc/GMT+1
+)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/timezone_createTimeZone_basic.phpt b/ext/intl/tests/timezone_createTimeZone_basic.phpt
new file mode 100644
index 0000000..e79f5b5
--- /dev/null
+++ b/ext/intl/tests/timezone_createTimeZone_basic.phpt
@@ -0,0 +1,33 @@
+--TEST--
+IntlTimeZone::createTimeZone(): basic test
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '4.8') < 0)
+ die('skip for ICU 4.8+');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+$tz = IntlTimeZone::createTimeZone('GMT+01:00');
+print_r($tz);
+$tz = intltz_create_time_zone('GMT+01:00');
+print_r($tz);
+?>
+==DONE==
+--EXPECT--
+IntlTimeZone Object
+(
+ [valid] => 1
+ [id] => GMT+01:00
+ [rawOffset] => 3600000
+ [currentOffset] => 3600000
+)
+IntlTimeZone Object
+(
+ [valid] => 1
+ [id] => GMT+01:00
+ [rawOffset] => 3600000
+ [currentOffset] => 3600000
+)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/timezone_createTimeZone_error.phpt b/ext/intl/tests/timezone_createTimeZone_error.phpt
new file mode 100644
index 0000000..2be821a
--- /dev/null
+++ b/ext/intl/tests/timezone_createTimeZone_error.phpt
@@ -0,0 +1,34 @@
+--TEST--
+IntlTimeZone::createTimeZone(): errors
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+var_dump(IntlTimeZone::createTimeZone());
+var_dump(IntlTimeZone::createTimeZone(new stdClass));
+var_dump(IntlTimeZone::createTimeZone("foo bar", 4));
+var_dump(IntlTimeZone::createTimeZone("foo\x80"));
+
+--EXPECTF--
+
+Warning: IntlTimeZone::createTimeZone() expects exactly 1 parameter, 0 given in %s on line %d
+
+Warning: IntlTimeZone::createTimeZone(): intltz_create_time_zone: bad arguments in %s on line %d
+NULL
+
+Warning: IntlTimeZone::createTimeZone() expects parameter 1 to be string, object given in %s on line %d
+
+Warning: IntlTimeZone::createTimeZone(): intltz_create_time_zone: bad arguments in %s on line %d
+NULL
+
+Warning: IntlTimeZone::createTimeZone() expects exactly 1 parameter, 2 given in %s on line %d
+
+Warning: IntlTimeZone::createTimeZone(): intltz_create_time_zone: bad arguments in %s on line %d
+NULL
+
+Warning: IntlTimeZone::createTimeZone(): intltz_create_time_zone: could not convert time zone id to UTF-16 in %s on line %d
+NULL
diff --git a/ext/intl/tests/timezone_equals_basic.phpt b/ext/intl/tests/timezone_equals_basic.phpt
new file mode 100644
index 0000000..105ae85
--- /dev/null
+++ b/ext/intl/tests/timezone_equals_basic.phpt
@@ -0,0 +1,33 @@
+--TEST--
+IntlTimeZone equals handler: basic test
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$tz1 = intltz_create_time_zone('Europe/Lisbon');
+$tz2 = intltz_create_time_zone('Europe/Lisbon');
+echo "Comparison to self:\n";
+var_dump($tz1 == $tz1);
+echo "Comparison to equal instance:\n";
+var_dump($tz1 == $tz2);
+echo "Comparison to equivalent instance:\n";
+var_dump($tz1 == intltz_create_time_zone('Portugal'));
+echo "Comparison to GMT:\n";
+var_dump($tz1 == intltz_get_gmt());
+
+?>
+==DONE==
+--EXPECT--
+Comparison to self:
+bool(true)
+Comparison to equal instance:
+bool(true)
+Comparison to equivalent instance:
+bool(false)
+Comparison to GMT:
+bool(false)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/timezone_equals_error.phpt b/ext/intl/tests/timezone_equals_error.phpt
new file mode 100644
index 0000000..d8d027a
--- /dev/null
+++ b/ext/intl/tests/timezone_equals_error.phpt
@@ -0,0 +1,43 @@
+--TEST--
+IntlTimeZone equals handler: error test
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+class A extends IntlTimeZone {
+function __construct() {}
+}
+
+$tz = new A();
+$tz2 = intltz_get_gmt();
+var_dump($tz, $tz2);
+try {
+var_dump($tz == $tz2);
+} catch (Exception $e) {
+ var_dump(get_class($e), $e->getMessage());
+}
+
+?>
+==DONE==
+--EXPECT--
+object(A)#1 (1) {
+ ["valid"]=>
+ bool(false)
+}
+object(IntlTimeZone)#2 (4) {
+ ["valid"]=>
+ bool(true)
+ ["id"]=>
+ string(3) "GMT"
+ ["rawOffset"]=>
+ int(0)
+ ["currentOffset"]=>
+ int(0)
+}
+string(9) "Exception"
+string(63) "Comparison with at least one unconstructed IntlTimeZone operand"
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/timezone_fromDateTimeZone_basic.phpt b/ext/intl/tests/timezone_fromDateTimeZone_basic.phpt
new file mode 100644
index 0000000..10e2621
--- /dev/null
+++ b/ext/intl/tests/timezone_fromDateTimeZone_basic.phpt
@@ -0,0 +1,41 @@
+--TEST--
+IntlTimeZone::fromDateTimeZone(): basic test
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "nl");
+date_default_timezone_set('Europe/Lisbon');
+
+$tz = IntlTimeZone::fromDateTimeZone(new DateTimeZone('Europe/Amsterdam'));
+var_dump($tz->getID(), $tz->getRawOffset());
+
+
+$dt = new DateTime('2012-01-01 00:00:00 CET');
+$dtz = $dt->getTimeZone();
+/* this is different from new DateTimeZone('CET'),
+ * which gives a Europe/Berlin timezone */
+var_dump($dtz->getName());
+$tz = IntlTimeZone::fromDateTimeZone($dtz);
+var_dump($tz->getID(), $tz->getRawOffset());
+
+
+$dt = new DateTime('2012-01-01 00:00:00 +0340');
+$dtz = $dt->getTimeZone();
+/* I don't think this timezone can be generated without a DateTime object */
+var_dump($dtz->getName());
+$tz = IntlTimeZone::fromDateTimeZone($dtz);
+var_dump($tz->getID(), $tz->getRawOffset() /* (3*60+40)*60000 */);
+
+--EXPECTF--
+string(16) "Europe/Amsterdam"
+int(3600000)
+string(3) "CET"
+string(3) "CET"
+int(3600000)
+string(6) "+03:40"
+string(%d) "GMT+03%s0"
+int(13200000)
diff --git a/ext/intl/tests/timezone_fromDateTimeZone_error.phpt b/ext/intl/tests/timezone_fromDateTimeZone_error.phpt
new file mode 100644
index 0000000..0318822
--- /dev/null
+++ b/ext/intl/tests/timezone_fromDateTimeZone_error.phpt
@@ -0,0 +1,50 @@
+--TEST--
+IntlTimeZone::fromDateTimeZone(): argument errors
+--INI--
+date.timezone=Atlantic/Azores
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+var_dump(IntlTimeZone::fromDateTimeZone());
+var_dump(IntlTimeZone::fromDateTimeZone(1,2));
+var_dump(IntlTimeZone::fromDateTimeZone('sdfds'));
+var_dump(IntlTimeZone::fromDateTimeZone(new stdclass));
+$dt = new DateTime('2012-08-01 00:00:00 WEST');
+var_dump(IntlTimeZone::fromDateTimeZone($dt->getTimeZone()));
+
+var_dump(intltz_from_date_time_zone());
+
+--EXPECTF--
+
+Warning: IntlTimeZone::fromDateTimeZone() expects exactly 1 parameter, 0 given in %s on line %d
+
+Warning: IntlTimeZone::fromDateTimeZone(): intltz_from_date_time_zone: bad arguments in %s on line %d
+NULL
+
+Warning: IntlTimeZone::fromDateTimeZone() expects exactly 1 parameter, 2 given in %s on line %d
+
+Warning: IntlTimeZone::fromDateTimeZone(): intltz_from_date_time_zone: bad arguments in %s on line %d
+NULL
+
+Warning: IntlTimeZone::fromDateTimeZone() expects parameter 1 to be DateTimeZone, string given in %s on line %d
+
+Warning: IntlTimeZone::fromDateTimeZone(): intltz_from_date_time_zone: bad arguments in %s on line %d
+NULL
+
+Warning: IntlTimeZone::fromDateTimeZone() expects parameter 1 to be DateTimeZone, object given in %s on line %d
+
+Warning: IntlTimeZone::fromDateTimeZone(): intltz_from_date_time_zone: bad arguments in %s on line %d
+NULL
+
+Warning: IntlTimeZone::fromDateTimeZone(): intltz_from_date_time_zone: time zone id 'WEST' extracted from ext/date DateTimeZone not recognized in %s on line %d
+NULL
+
+Warning: intltz_from_date_time_zone() expects exactly 1 parameter, 0 given in %s on line %d
+
+Warning: intltz_from_date_time_zone(): intltz_from_date_time_zone: bad arguments in %s on line %d
+NULL
diff --git a/ext/intl/tests/timezone_getCanonicalID_basic.phpt b/ext/intl/tests/timezone_getCanonicalID_basic.phpt
new file mode 100644
index 0000000..897e9a9
--- /dev/null
+++ b/ext/intl/tests/timezone_getCanonicalID_basic.phpt
@@ -0,0 +1,19 @@
+--TEST--
+IntlTimeZone::getCanonicalID: basic test
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+print_R(IntlTimeZone::getCanonicalID('Portugal'));
+echo "\n";
+print_R(intltz_get_canonical_id('Portugal'));
+echo "\n";
+?>
+==DONE==
+--EXPECT--
+Europe/Lisbon
+Europe/Lisbon
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/timezone_getCanonicalID_error.phpt b/ext/intl/tests/timezone_getCanonicalID_error.phpt
new file mode 100644
index 0000000..c7ffb45
--- /dev/null
+++ b/ext/intl/tests/timezone_getCanonicalID_error.phpt
@@ -0,0 +1,32 @@
+--TEST--
+IntlTimeZone::getCanonicalID(): errors
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+var_dump(IntlTimeZone::getCanonicalID());
+var_dump(IntlTimeZone::getCanonicalID(array()));
+var_dump(IntlTimeZone::getCanonicalID("foo\x81"));
+var_dump(IntlTimeZone::getCanonicalID('foobar', null));
+
+
+--EXPECTF--
+
+Warning: IntlTimeZone::getCanonicalID() expects at least 1 parameter, 0 given in %s on line %d
+
+Warning: IntlTimeZone::getCanonicalID(): intltz_get_canonical_id: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlTimeZone::getCanonicalID() expects parameter 1 to be string, array given in %s on line %d
+
+Warning: IntlTimeZone::getCanonicalID(): intltz_get_canonical_id: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlTimeZone::getCanonicalID(): intltz_get_canonical_id: could not convert time zone id to UTF-16 in %s on line %d
+bool(false)
+
+Fatal error: Cannot pass parameter 2 by reference in %s on line %d
diff --git a/ext/intl/tests/timezone_getCanonicalID_variant1.phpt b/ext/intl/tests/timezone_getCanonicalID_variant1.phpt
new file mode 100644
index 0000000..92a7f07
--- /dev/null
+++ b/ext/intl/tests/timezone_getCanonicalID_variant1.phpt
@@ -0,0 +1,24 @@
+--TEST--
+IntlTimeZone::getCanonicalID(): second argument
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+var_dump(IntlTimeZone::getCanonicalID('Portugal', $isSystemId));
+var_dump($isSystemId);
+
+var_dump(IntlTimeZone::getCanonicalID('GMT +01:25', $isSystemId));
+var_dump($isSystemId);
+
+?>
+==DONE==
+--EXPECT--
+string(13) "Europe/Lisbon"
+bool(true)
+string(0) ""
+bool(false)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/timezone_getDSTSavings_basic.phpt b/ext/intl/tests/timezone_getDSTSavings_basic.phpt
new file mode 100644
index 0000000..8dee5b8
--- /dev/null
+++ b/ext/intl/tests/timezone_getDSTSavings_basic.phpt
@@ -0,0 +1,21 @@
+--TEST--
+IntlTimeZone::getDSTSavings(): basic test
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$lsb = IntlTimeZone::createTimeZone('Europe/Lisbon');
+var_dump($lsb->getDSTSavings());
+
+var_dump(intltz_get_dst_savings($lsb));
+
+?>
+==DONE==
+--EXPECT--
+int(3600000)
+int(3600000)
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/timezone_getDSTSavings_error.phpt b/ext/intl/tests/timezone_getDSTSavings_error.phpt
new file mode 100644
index 0000000..e1469f4
--- /dev/null
+++ b/ext/intl/tests/timezone_getDSTSavings_error.phpt
@@ -0,0 +1,23 @@
+--TEST--
+IntlTimeZone::getDSTSavings(): errors
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$tz = IntlTimeZone::createTimeZone('Europe/Lisbon');
+var_dump($tz->getDSTSavings(array()));
+
+var_dump(intltz_get_dst_savings(null));
+
+--EXPECTF--
+
+Warning: IntlTimeZone::getDSTSavings() expects exactly 0 parameters, 1 given in %s on line %d
+
+Warning: IntlTimeZone::getDSTSavings(): intltz_get_dst_savings: bad arguments in %s on line %d
+bool(false)
+
+Catchable fatal error: Argument 1 passed to intltz_get_dst_savings() must be an instance of IntlTimeZone, null given in %s on line %d
diff --git a/ext/intl/tests/timezone_getDisplayName_basic.phpt b/ext/intl/tests/timezone_getDisplayName_basic.phpt
new file mode 100644
index 0000000..e4fc2f3
--- /dev/null
+++ b/ext/intl/tests/timezone_getDisplayName_basic.phpt
@@ -0,0 +1,24 @@
+--TEST--
+IntlTimeZone::getDisplayName(): basic test
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$lsb = IntlTimeZone::createTimeZone('Europe/Lisbon');
+
+ini_set('intl.default_locale', 'en_US');
+var_dump($lsb->getDisplayName());
+
+ini_set('intl.default_locale', 'pt_PT');
+var_dump($lsb->getDisplayName());
+
+?>
+==DONE==
+--EXPECTF--
+string(%d) "Western European%sTime"
+string(%d) "Hora%sda Europa Ocidental"
+==DONE== \ No newline at end of file
diff --git a/ext/intl/tests/timezone_getDisplayName_error.phpt b/ext/intl/tests/timezone_getDisplayName_error.phpt
new file mode 100644
index 0000000..a12f85c
--- /dev/null
+++ b/ext/intl/tests/timezone_getDisplayName_error.phpt
@@ -0,0 +1,45 @@
+--TEST--
+IntlTimeZone::getDisplayName(): errors
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+
+$tz = IntlTimeZone::createTimeZone('Europe/Lisbon');
+var_dump($tz->getDisplayName(array()));
+var_dump($tz->getDisplayName(false, array()));
+var_dump($tz->getDisplayName(false, -1));
+var_dump($tz->getDisplayName(false, IntlTimeZone::DISPLAY_SHORT, array()));
+var_dump($tz->getDisplayName(false, IntlTimeZone::DISPLAY_SHORT, NULL, NULL));
+
+var_dump(intltz_get_display_name(null, IntlTimeZone::DISPLAY_SHORT, false, 'pt_PT'));
+
+--EXPECTF--
+
+Warning: IntlTimeZone::getDisplayName() expects parameter 1 to be boolean, array given in %s on line %d
+
+Warning: IntlTimeZone::getDisplayName(): intltz_get_display_name: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlTimeZone::getDisplayName() expects parameter 2 to be long, array given in %s on line %d
+
+Warning: IntlTimeZone::getDisplayName(): intltz_get_display_name: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlTimeZone::getDisplayName(): intltz_get_display_name: wrong display type in %s on line %d
+bool(false)
+
+Warning: IntlTimeZone::getDisplayName() expects parameter 3 to be string, array given in %s on line %d
+
+Warning: IntlTimeZone::getDisplayName(): intltz_get_display_name: bad arguments in %s on line %d
+bool(false)
+
+Warning: IntlTimeZone::getDisplayName() expects at most 3 parameters, 4 given in %s on line %d
+
+Warning: IntlTimeZone::getDisplayName(): intltz_get_display_name: bad arguments in %s on line %d
+bool(false)
+
+Catchable fatal error: Argument 1 passed to intltz_get_display_name() must be an instance of IntlTimeZone, null given in %s on line %d
diff --git a/ext/intl/tests/timezone_getDisplayName_variant1.phpt b/ext/intl/tests/timezone_getDisplayName_variant1.phpt
new file mode 100644
index 0000000..83922dd
--- /dev/null
+++ b/ext/intl/tests/timezone_getDisplayName_variant1.phpt
@@ -0,0 +1,26 @@
+--TEST--
+IntlTimeZone::getDisplayName(): daylight parameter effect
+--SKIPIF--