PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LCOV - code coverage report
Current view: top level - ext/intl/timezone - timezone_class.cpp (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 174 198 87.9 %
Date: 2019-05-06 Functions: 11 11 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    +----------------------------------------------------------------------+
       3             :    | PHP Version 7                                                        |
       4             :    +----------------------------------------------------------------------+
       5             :    | This source file is subject to version 3.01 of the PHP license,      |
       6             :    | that is bundled with this package in the file LICENSE, and is        |
       7             :    | available through the world-wide-web at the following url:           |
       8             :    | http://www.php.net/license/3_01.txt                                  |
       9             :    | If you did not receive a copy of the PHP license and are unable to   |
      10             :    | obtain it through the world-wide-web, please send a note to          |
      11             :    | license@php.net so we can mail you a copy immediately.               |
      12             :    +----------------------------------------------------------------------+
      13             :    | Authors: Gustavo Lopes <cataphract@php.net>                          |
      14             :    +----------------------------------------------------------------------+
      15             : */
      16             : 
      17             : 
      18             : #ifdef HAVE_CONFIG_H
      19             : #include "config.h"
      20             : #endif
      21             : 
      22             : #include "../intl_cppshims.h"
      23             : 
      24             : #include <unicode/timezone.h>
      25             : #include <unicode/calendar.h>
      26             : #include "../intl_convertcpp.h"
      27             : 
      28             : #include "../common/common_date.h"
      29             : 
      30             : extern "C" {
      31             : #include "../intl_convert.h"
      32             : #define USE_TIMEZONE_POINTER 1
      33             : #include "timezone_class.h"
      34             : #include "timezone_methods.h"
      35             : #include <zend_exceptions.h>
      36             : #include <zend_interfaces.h>
      37             : #include <ext/date/php_date.h>
      38             : }
      39             : 
      40             : using icu::Calendar;
      41             : 
      42             : /* {{{ Global variables */
      43             : U_CDECL_BEGIN
      44             : zend_class_entry *TimeZone_ce_ptr = NULL;
      45             : zend_object_handlers TimeZone_handlers;
      46             : U_CDECL_END
      47             : /* }}} */
      48             : 
      49             : /* {{{ timezone_object_construct */
      50          81 : U_CFUNC void timezone_object_construct(const TimeZone *zone, zval *object, int owned)
      51             : {
      52             :         TimeZone_object *to;
      53             : 
      54          81 :         object_init_ex(object, TimeZone_ce_ptr);
      55          81 :         TIMEZONE_METHOD_FETCH_OBJECT_NO_CHECK; /* fetch zend object from zval "object" into "to" */
      56          81 :         to->utimezone = zone;
      57          81 :         to->should_delete = owned;
      58          81 : }
      59             : /* }}} */
      60             : 
      61             : /* {{{ timezone_convert_to_datetimezone
      62             :  *         Convert from TimeZone to DateTimeZone object */
      63           6 : U_CFUNC zval *timezone_convert_to_datetimezone(const TimeZone *timeZone,
      64             :                                                                                            intl_error *outside_error,
      65             :                                                                                            const char *func, zval *ret)
      66             : {
      67          12 :         UnicodeString           id;
      68           6 :         char                            *message = NULL;
      69             :         php_timezone_obj        *tzobj;
      70             :         zval                            arg;
      71             : 
      72           6 :         timeZone->getID(id);
      73           6 :         if (id.isBogus()) {
      74           0 :                 spprintf(&message, 0, "%s: could not obtain TimeZone id", func);
      75           0 :                 intl_errors_set(outside_error, U_ILLEGAL_ARGUMENT_ERROR,
      76             :                         message, 1);
      77           0 :                 goto error;
      78             :         }
      79             : 
      80           6 :         object_init_ex(ret, php_date_get_timezone_ce());
      81           6 :         tzobj = Z_PHPTIMEZONE_P(ret);
      82             : 
      83           6 :         if (id.compare(0, 3, UnicodeString("GMT", sizeof("GMT")-1, US_INV)) == 0) {
      84             :                 /* The DateTimeZone constructor doesn't support offset time zones,
      85             :                  * so we must mess with DateTimeZone structure ourselves */
      86           1 :                 tzobj->initialized     = 1;
      87           1 :                 tzobj->type                    = TIMELIB_ZONETYPE_OFFSET;
      88             :                 //convert offset from milliseconds to seconds
      89           1 :                 tzobj->tzi.utc_offset = timeZone->getRawOffset() / 1000;
      90             :         } else {
      91             :                 zend_string *u8str;
      92             :                 /* Call the constructor! */
      93           5 :                 u8str = intl_charFromString(id, &INTL_ERROR_CODE(*outside_error));
      94           5 :                 if (!u8str) {
      95           0 :                         spprintf(&message, 0, "%s: could not convert id to UTF-8", func);
      96           0 :                         intl_errors_set(outside_error, INTL_ERROR_CODE(*outside_error),
      97             :                                 message, 1);
      98           0 :                         goto error;
      99             :                 }
     100          10 :                 ZVAL_STR(&arg, u8str);
     101           5 :                 zend_call_method_with_1_params(Z_OBJ_P(ret), NULL, &Z_OBJCE_P(ret)->constructor, "__construct", NULL, &arg);
     102           5 :                 if (EG(exception)) {
     103           2 :                         spprintf(&message, 0,
     104             :                                 "%s: DateTimeZone constructor threw exception", func);
     105           2 :                         intl_errors_set(outside_error, U_ILLEGAL_ARGUMENT_ERROR,
     106             :                                 message, 1);
     107           2 :                         zend_object_store_ctor_failed(Z_OBJ_P(ret));
     108           2 :                         zval_ptr_dtor(&arg);
     109           2 :                         goto error;
     110             :                 }
     111           3 :                 zval_ptr_dtor(&arg);
     112             :         }
     113             : 
     114             :         if (0) {
     115           2 : error:
     116           2 :                 if (ret) {
     117           2 :                         zval_ptr_dtor(ret);
     118             :                 }
     119           2 :                 ret = NULL;
     120             :         }
     121             : 
     122           6 :         if (message) {
     123           2 :                 efree(message);
     124             :         }
     125          12 :         return ret;
     126             : }
     127             : /* }}} */
     128             : 
     129             : /* {{{ timezone_process_timezone_argument
     130             :  * TimeZone argument processor. outside_error may be NULL (for static functions/constructors) */
     131         385 : U_CFUNC TimeZone *timezone_process_timezone_argument(zval *zv_timezone,
     132             :                                                                                                          intl_error *outside_error,
     133             :                                                                                                          const char *func)
     134             : {
     135             :         zval            local_zv_tz;
     136         385 :         char            *message = NULL;
     137             :         TimeZone        *timeZone;
     138             : 
     139         736 :         if (zv_timezone == NULL || Z_TYPE_P(zv_timezone) == IS_NULL) {
     140          47 :                 timelib_tzinfo *tzinfo = get_timezone_info();
     141          94 :                 ZVAL_STRING(&local_zv_tz, tzinfo->name);
     142          47 :                 zv_timezone = &local_zv_tz;
     143             :         } else {
     144         338 :                 ZVAL_NULL(&local_zv_tz);
     145             :         }
     146             : 
     147         402 :         if (Z_TYPE_P(zv_timezone) == IS_OBJECT &&
     148          17 :                         instanceof_function(Z_OBJCE_P(zv_timezone), TimeZone_ce_ptr)) {
     149           6 :                 TimeZone_object *to = Z_INTL_TIMEZONE_P(zv_timezone);
     150           6 :                 if (to->utimezone == NULL) {
     151           1 :                         spprintf(&message, 0, "%s: passed IntlTimeZone is not "
     152             :                                 "properly constructed", func);
     153           1 :                         if (message) {
     154           1 :                                 intl_errors_set(outside_error, U_ILLEGAL_ARGUMENT_ERROR, message, 1);
     155           1 :                                 efree(message);
     156             :                         }
     157             :                         zval_ptr_dtor_str(&local_zv_tz);
     158           1 :                         return NULL;
     159             :                 }
     160           5 :                 timeZone = to->utimezone->clone();
     161           5 :                 if (timeZone == NULL) {
     162           0 :                         spprintf(&message, 0, "%s: could not clone TimeZone", func);
     163           0 :                         if (message) {
     164           0 :                                 intl_errors_set(outside_error, U_MEMORY_ALLOCATION_ERROR, message, 1);
     165           0 :                                 efree(message);
     166             :                         }
     167             :                         zval_ptr_dtor_str(&local_zv_tz);
     168           0 :                         return NULL;
     169             :                 }
     170         390 :         } else if (Z_TYPE_P(zv_timezone) == IS_OBJECT &&
     171          11 :                         instanceof_function(Z_OBJCE_P(zv_timezone), php_date_get_timezone_ce())) {
     172             : 
     173          11 :                 php_timezone_obj *tzobj = Z_PHPTIMEZONE_P(zv_timezone);
     174             : 
     175             :                 zval_ptr_dtor_str(&local_zv_tz);
     176          11 :                 return timezone_convert_datetimezone(tzobj->type, tzobj, 0,
     177          11 :                         outside_error, func);
     178             :         } else {
     179         730 :                 UnicodeString   id,
     180         730 :                                                 gottenId;
     181         368 :                 UErrorCode              status = U_ZERO_ERROR; /* outside_error may be NULL */
     182         369 :                 convert_to_string_ex(zv_timezone);
     183         736 :                 if (intl_stringFromChar(id, Z_STRVAL_P(zv_timezone), Z_STRLEN_P(zv_timezone),
     184         368 :                                 &status) == FAILURE) {
     185           1 :                         spprintf(&message, 0, "%s: Time zone identifier given is not a "
     186             :                                 "valid UTF-8 string", func);
     187           1 :                         if (message) {
     188           1 :                                 intl_errors_set(outside_error, status, message, 1);
     189           1 :                                 efree(message);
     190             :                         }
     191             :                         zval_ptr_dtor_str(&local_zv_tz);
     192           1 :                         return NULL;
     193             :                 }
     194         367 :                 timeZone = TimeZone::createTimeZone(id);
     195         367 :                 if (timeZone == NULL) {
     196           0 :                         spprintf(&message, 0, "%s: could not create time zone", func);
     197           0 :                         if (message) {
     198           0 :                                 intl_errors_set(outside_error, U_MEMORY_ALLOCATION_ERROR, message, 1);
     199           0 :                                 efree(message);
     200             :                         }
     201             :                         zval_ptr_dtor_str(&local_zv_tz);
     202           0 :                         return NULL;
     203             :                 }
     204         367 :                 if (timeZone->getID(gottenId) != id) {
     205           5 :                         spprintf(&message, 0, "%s: no such time zone: '%s'",
     206           5 :                                 func, Z_STRVAL_P(zv_timezone));
     207           5 :                         if (message) {
     208           5 :                                 intl_errors_set(outside_error, U_ILLEGAL_ARGUMENT_ERROR, message, 1);
     209           5 :                                 efree(message);
     210             :                         }
     211             :                         zval_ptr_dtor_str(&local_zv_tz);
     212           5 :                         delete timeZone;
     213           5 :                         return NULL;
     214             :                 }
     215             :         }
     216             : 
     217             :         zval_ptr_dtor_str(&local_zv_tz);
     218             : 
     219         367 :         return timeZone;
     220             : }
     221             : /* }}} */
     222             : 
     223             : /* {{{ clone handler for TimeZone */
     224           4 : static zend_object *TimeZone_clone_obj(zend_object *object)
     225             : {
     226             :         TimeZone_object         *to_orig,
     227             :                                                 *to_new;
     228             :         zend_object                     *ret_val;
     229           4 :         intl_error_reset(NULL);
     230             : 
     231           4 :         to_orig = php_intl_timezone_fetch_object(object);
     232           4 :         intl_error_reset(TIMEZONE_ERROR_P(to_orig));
     233             : 
     234           4 :         ret_val = TimeZone_ce_ptr->create_object(object->ce);
     235           4 :         to_new  = php_intl_timezone_fetch_object(ret_val);
     236             : 
     237           4 :         zend_objects_clone_members(&to_new->zo, &to_orig->zo);
     238             : 
     239           4 :         if (to_orig->utimezone != NULL) {
     240             :                 TimeZone        *newTimeZone;
     241             : 
     242           2 :                 newTimeZone = to_orig->utimezone->clone();
     243           2 :                 to_new->should_delete = 1;
     244           2 :                 if (!newTimeZone) {
     245             :                         zend_string *err_msg;
     246           0 :                         intl_errors_set_code(TIMEZONE_ERROR_P(to_orig),
     247             :                                 U_MEMORY_ALLOCATION_ERROR);
     248           0 :                         intl_errors_set_custom_msg(TIMEZONE_ERROR_P(to_orig),
     249             :                                 "Could not clone IntlTimeZone", 0);
     250           0 :                         err_msg = intl_error_get_message(TIMEZONE_ERROR_P(to_orig));
     251           0 :                         zend_throw_exception(NULL, ZSTR_VAL(err_msg), 0);
     252             :                         zend_string_free(err_msg);
     253             :                 } else {
     254           2 :                         to_new->utimezone = newTimeZone;
     255             :                 }
     256             :         } else {
     257           2 :                 zend_throw_exception(NULL, "Cannot clone unconstructed IntlTimeZone", 0);
     258             :         }
     259             : 
     260           4 :         return ret_val;
     261             : }
     262             : /* }}} */
     263             : 
     264             : /* {{{ compare_objects handler for TimeZone
     265             :  *     Can't be used for >, >=, <, <= comparisons */
     266           4 : static int TimeZone_compare_objects(zval *object1, zval *object2)
     267             : {
     268             :         TimeZone_object         *to1,
     269             :                                                 *to2;
     270           4 :         to1 = Z_INTL_TIMEZONE_P(object1);
     271           4 :         to2 = Z_INTL_TIMEZONE_P(object2);
     272             : 
     273           4 :         if (to1->utimezone == NULL || to2->utimezone == NULL) {
     274           1 :                 zend_throw_exception(NULL, "Comparison with at least one unconstructed "
     275             :                                 "IntlTimeZone operand", 0);
     276             :                 /* intentionally not returning */
     277             :         } else {
     278           3 :                 if (*to1->utimezone == *to2->utimezone) {
     279           1 :                         return 0;
     280             :                 }
     281             :         }
     282             : 
     283           3 :         return 1;
     284             : }
     285             : /* }}} */
     286             : 
     287             : /* {{{ get_debug_info handler for TimeZone */
     288          23 : static HashTable *TimeZone_get_debug_info(zend_object *object, int *is_temp)
     289             : {
     290             :         zval                    zv;
     291             :         TimeZone_object *to;
     292             :         const TimeZone  *tz;
     293          46 :         UnicodeString   ustr;
     294             :         zend_string     *u8str;
     295             :         HashTable               *debug_info;
     296          23 :         UErrorCode              uec = U_ZERO_ERROR;
     297             : 
     298          23 :         *is_temp = 1;
     299             : 
     300          23 :         debug_info = zend_new_array(8);
     301             : 
     302          23 :         to = php_intl_timezone_fetch_object(object);
     303          23 :         tz = to->utimezone;
     304             : 
     305          23 :         if (tz == NULL) {
     306           2 :                 ZVAL_FALSE(&zv);
     307           2 :                 zend_hash_str_update(debug_info, "valid", sizeof("valid") - 1, &zv);
     308           2 :                 return debug_info;
     309             :         }
     310             : 
     311          21 :         ZVAL_TRUE(&zv);
     312          21 :         zend_hash_str_update(debug_info, "valid", sizeof("valid") - 1, &zv);
     313             : 
     314          21 :         tz->getID(ustr);
     315          21 :         u8str = intl_convert_utf16_to_utf8(
     316             :                 ustr.getBuffer(), ustr.length(), &uec);
     317          21 :         if (!u8str) {
     318           0 :                 return debug_info;
     319             :         }
     320          21 :         ZVAL_NEW_STR(&zv, u8str);
     321          21 :         zend_hash_str_update(debug_info, "id", sizeof("id") - 1, &zv);
     322             : 
     323             :         int32_t rawOffset, dstOffset;
     324          21 :         UDate now = Calendar::getNow();
     325          21 :         tz->getOffset(now, FALSE, rawOffset, dstOffset, uec);
     326          21 :         if (U_FAILURE(uec)) {
     327           0 :                 return debug_info;
     328             :         }
     329             : 
     330          21 :         ZVAL_LONG(&zv, (zend_long)rawOffset);
     331          21 :         zend_hash_str_update(debug_info,"rawOffset", sizeof("rawOffset") - 1, &zv);
     332          21 :         ZVAL_LONG(&zv, (zend_long)(rawOffset + dstOffset));
     333          21 :         zend_hash_str_update(debug_info,"currentOffset", sizeof("currentOffset") - 1, &zv);
     334             : 
     335          21 :         return debug_info;
     336             : }
     337             : /* }}} */
     338             : 
     339             : /* {{{ void TimeZone_object_init(TimeZone_object* to)
     340             :  * Initialize internals of TImeZone_object not specific to zend standard objects.
     341             :  */
     342          89 : static void TimeZone_object_init(TimeZone_object *to)
     343             : {
     344          89 :         intl_error_init(TIMEZONE_ERROR_P(to));
     345          89 :         to->utimezone = NULL;
     346          89 :         to->should_delete = 0;
     347          89 : }
     348             : /* }}} */
     349             : 
     350             : /* {{{ TimeZone_objects_dtor */
     351          86 : static void TimeZone_objects_dtor(zend_object *object)
     352             : {
     353          86 :         zend_objects_destroy_object(object);
     354          86 : }
     355             : /* }}} */
     356             : 
     357             : /* {{{ TimeZone_objects_free */
     358          89 : static void TimeZone_objects_free(zend_object *object)
     359             : {
     360          89 :         TimeZone_object* to = php_intl_timezone_fetch_object(object);
     361             : 
     362          89 :         if (to->utimezone && to->should_delete) {
     363          73 :                 delete to->utimezone;
     364          73 :                 to->utimezone = NULL;
     365             :         }
     366          89 :         intl_error_reset(TIMEZONE_ERROR_P(to));
     367             : 
     368          89 :         zend_object_std_dtor(&to->zo);
     369          89 : }
     370             : /* }}} */
     371             : 
     372             : /* {{{ TimeZone_object_create */
     373          89 : static zend_object *TimeZone_object_create(zend_class_entry *ce)
     374             : {
     375             :         TimeZone_object*        intern;
     376             : 
     377          89 :         intern = (TimeZone_object*)ecalloc(1, sizeof(TimeZone_object) + sizeof(zval) * (ce->default_properties_count - 1));
     378             : 
     379          89 :         zend_object_std_init(&intern->zo, ce);
     380          89 :     object_properties_init(&intern->zo, ce);
     381          89 :         TimeZone_object_init(intern);
     382             : 
     383          89 :         intern->zo.handlers = &TimeZone_handlers;
     384             : 
     385          89 :         return &intern->zo;
     386             : }
     387             : /* }}} */
     388             : 
     389             : /* {{{ TimeZone methods arguments info */
     390             : 
     391             : ZEND_BEGIN_ARG_INFO_EX(ainfo_tz_idarg, 0, 0, 1)
     392             :         ZEND_ARG_INFO(0, zoneId)
     393             : ZEND_END_ARG_INFO()
     394             : 
     395             : ZEND_BEGIN_ARG_INFO_EX(ainfo_tz_fromDateTimeZone, 0, 0, 1)
     396             :         ZEND_ARG_OBJ_INFO(0, otherTimeZone, IntlTimeZone, 0)
     397             : ZEND_END_ARG_INFO()
     398             : 
     399             : ZEND_BEGIN_ARG_INFO_EX(ainfo_tz_createEnumeration, 0, 0, 0)
     400             :         ZEND_ARG_INFO(0, countryOrRawOffset)
     401             : ZEND_END_ARG_INFO()
     402             : 
     403             : ZEND_BEGIN_ARG_INFO_EX(ainfo_tz_countEquivalentIDs, 0, 0, 1)
     404             :         ZEND_ARG_INFO(0, zoneId)
     405             : ZEND_END_ARG_INFO()
     406             : 
     407             : ZEND_BEGIN_ARG_INFO_EX(ainfo_tz_createTimeZoneIDEnumeration, 0, 0, 1)
     408             :         ZEND_ARG_INFO(0, zoneType)
     409             :         ZEND_ARG_INFO(0, region)
     410             :         ZEND_ARG_INFO(0, rawOffset)
     411             : ZEND_END_ARG_INFO()
     412             : 
     413             : ZEND_BEGIN_ARG_INFO_EX(ainfo_tz_getCanonicalID, 0, 0, 1)
     414             :         ZEND_ARG_INFO(0, zoneId)
     415             :         ZEND_ARG_INFO(1, isSystemID)
     416             : ZEND_END_ARG_INFO()
     417             : 
     418             : ZEND_BEGIN_ARG_INFO_EX(ainfo_tz_getEquivalentID, 0, 0, 2)
     419             :         ZEND_ARG_INFO(0, zoneId)
     420             :         ZEND_ARG_INFO(0, index)
     421             : ZEND_END_ARG_INFO()
     422             : 
     423             : ZEND_BEGIN_ARG_INFO_EX(ainfo_tz_getOffset, 0, 0, 4)
     424             :         ZEND_ARG_INFO(0, date)
     425             :         ZEND_ARG_INFO(0, local)
     426             :         ZEND_ARG_INFO(1, rawOffset)
     427             :         ZEND_ARG_INFO(1, dstOffset)
     428             : ZEND_END_ARG_INFO()
     429             : 
     430             : ZEND_BEGIN_ARG_INFO_EX(ainfo_tz_hasSameRules, 0, 0, 1)
     431             :         ZEND_ARG_OBJ_INFO(0, otherTimeZone, IntlTimeZone, 0)
     432             : ZEND_END_ARG_INFO()
     433             : 
     434             : ZEND_BEGIN_ARG_INFO_EX(ainfo_tz_getDisplayName, 0, 0, 0)
     435             :         ZEND_ARG_INFO(0, isDaylight)
     436             :         ZEND_ARG_INFO(0, style)
     437             :         ZEND_ARG_INFO(0, locale)
     438             : ZEND_END_ARG_INFO()
     439             : 
     440             : ZEND_BEGIN_ARG_INFO_EX(ainfo_tz_void, 0, 0, 0)
     441             : ZEND_END_ARG_INFO()
     442             : 
     443             : #if U_ICU_VERSION_MAJOR_NUM >= 52
     444             : ZEND_BEGIN_ARG_INFO_EX(ainfo_tz_getWindowsID, 0, ZEND_RETURN_VALUE, 1)
     445             :         ZEND_ARG_INFO(0, timezone)
     446             : ZEND_END_ARG_INFO()
     447             : 
     448             : ZEND_BEGIN_ARG_INFO_EX(ainfo_tz_getIDForWindowsID, 0, ZEND_RETURN_VALUE, 1)
     449             :         ZEND_ARG_INFO(0, timezone)
     450             :         ZEND_ARG_INFO(0, region)
     451             : ZEND_END_ARG_INFO()
     452             : #endif
     453             : 
     454             : /* }}} */
     455             : 
     456             : /* {{{ TimeZone_class_functions
     457             :  * Every 'IntlTimeZone' class method has an entry in this table
     458             :  */
     459             : static const zend_function_entry TimeZone_class_functions[] = {
     460             :         PHP_ME(IntlTimeZone,                            __construct,                                    ainfo_tz_void,                          ZEND_ACC_PRIVATE)
     461             :         PHP_ME_MAPPING(createTimeZone,          intltz_create_time_zone,                ainfo_tz_idarg,                         ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
     462             :         PHP_ME_MAPPING(fromDateTimeZone,        intltz_from_date_time_zone,             ainfo_tz_idarg,                         ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
     463             :         PHP_ME_MAPPING(createDefault,           intltz_create_default,                  ainfo_tz_void,                          ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
     464             :         PHP_ME_MAPPING(getGMT,                          intltz_get_gmt,                                 ainfo_tz_void,                          ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
     465             :         PHP_ME_MAPPING(getUnknown,                      intltz_get_unknown,                             ainfo_tz_void,                          ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
     466             :         PHP_ME_MAPPING(createEnumeration,       intltz_create_enumeration,              ainfo_tz_createEnumeration,     ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
     467             :         PHP_ME_MAPPING(countEquivalentIDs,      intltz_count_equivalent_ids,    ainfo_tz_idarg,                         ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
     468             :         PHP_ME_MAPPING(createTimeZoneIDEnumeration, intltz_create_time_zone_id_enumeration, ainfo_tz_createTimeZoneIDEnumeration, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
     469             :         PHP_ME_MAPPING(getCanonicalID,          intltz_get_canonical_id,                ainfo_tz_getCanonicalID,        ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
     470             :         PHP_ME_MAPPING(getRegion,                       intltz_get_region,                              ainfo_tz_idarg,                         ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
     471             :         PHP_ME_MAPPING(getTZDataVersion,        intltz_get_tz_data_version,             ainfo_tz_void,                          ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
     472             :         PHP_ME_MAPPING(getEquivalentID,         intltz_get_equivalent_id,               ainfo_tz_getEquivalentID,       ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
     473             : 
     474             :         PHP_ME_MAPPING(getID,                           intltz_get_id,                                  ainfo_tz_void,                          ZEND_ACC_PUBLIC)
     475             :         PHP_ME_MAPPING(useDaylightTime,         intltz_use_daylight_time,               ainfo_tz_void,                          ZEND_ACC_PUBLIC)
     476             :         PHP_ME_MAPPING(getOffset,                       intltz_get_offset,                              ainfo_tz_getOffset,                     ZEND_ACC_PUBLIC)
     477             :         PHP_ME_MAPPING(getRawOffset,            intltz_get_raw_offset,                  ainfo_tz_void,                          ZEND_ACC_PUBLIC)
     478             :         PHP_ME_MAPPING(hasSameRules,            intltz_has_same_rules,                  ainfo_tz_hasSameRules,          ZEND_ACC_PUBLIC)
     479             :         PHP_ME_MAPPING(getDisplayName,          intltz_get_display_name,                ainfo_tz_getDisplayName,        ZEND_ACC_PUBLIC)
     480             :         PHP_ME_MAPPING(getDSTSavings,           intltz_get_dst_savings,                 ainfo_tz_void,                          ZEND_ACC_PUBLIC)
     481             :         PHP_ME_MAPPING(toDateTimeZone,          intltz_to_date_time_zone,               ainfo_tz_void,                          ZEND_ACC_PUBLIC)
     482             :         PHP_ME_MAPPING(getErrorCode,            intltz_get_error_code,                  ainfo_tz_void,                          ZEND_ACC_PUBLIC)
     483             :         PHP_ME_MAPPING(getErrorMessage,         intltz_get_error_message,               ainfo_tz_void,                          ZEND_ACC_PUBLIC)
     484             : #if U_ICU_VERSION_MAJOR_NUM >= 52
     485             :         PHP_ME_MAPPING(getWindowsID,            intltz_get_windows_id,                  ainfo_tz_getWindowsID,          ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
     486             :         PHP_ME_MAPPING(getIDForWindowsID,       intltz_get_id_for_windows_id,           ainfo_tz_getIDForWindowsID,     ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
     487             : #endif
     488             :         PHP_FE_END
     489             : };
     490             : /* }}} */
     491             : 
     492             : /* {{{ timezone_register_IntlTimeZone_class
     493             :  * Initialize 'IntlTimeZone' class
     494             :  */
     495       23043 : U_CFUNC void timezone_register_IntlTimeZone_class(void)
     496             : {
     497             :         zend_class_entry ce;
     498             : 
     499             :         /* Create and register 'IntlTimeZone' class. */
     500       23043 :         INIT_CLASS_ENTRY(ce, "IntlTimeZone", TimeZone_class_functions);
     501       23043 :         ce.create_object = TimeZone_object_create;
     502       23043 :         TimeZone_ce_ptr = zend_register_internal_class(&ce);
     503       23043 :         if (!TimeZone_ce_ptr) {
     504             :                 //can't happen now without bigger problems before
     505           0 :                 php_error_docref0(NULL, E_ERROR,
     506             :                         "IntlTimeZone: class registration has failed.");
     507           0 :                 return;
     508             :         }
     509             : 
     510       23043 :         memcpy(&TimeZone_handlers, &std_object_handlers,
     511             :                 sizeof TimeZone_handlers);
     512       23043 :         TimeZone_handlers.offset = XtOffsetOf(TimeZone_object, zo);
     513       23043 :         TimeZone_handlers.clone_obj = TimeZone_clone_obj;
     514       23043 :         TimeZone_handlers.compare_objects = TimeZone_compare_objects;
     515       23043 :         TimeZone_handlers.get_debug_info = TimeZone_get_debug_info;
     516       23043 :         TimeZone_handlers.dtor_obj = TimeZone_objects_dtor;
     517       23043 :         TimeZone_handlers.free_obj = TimeZone_objects_free;
     518             : 
     519             : 
     520             :         /* Declare 'IntlTimeZone' class constants */
     521             : #define TIMEZONE_DECL_LONG_CONST(name, val) \
     522             :         zend_declare_class_constant_long(TimeZone_ce_ptr, name, sizeof(name) - 1, \
     523             :                 val)
     524             : 
     525       23043 :         TIMEZONE_DECL_LONG_CONST("DISPLAY_SHORT", TimeZone::SHORT);
     526       23043 :         TIMEZONE_DECL_LONG_CONST("DISPLAY_LONG", TimeZone::LONG);
     527             : 
     528       23043 :         TIMEZONE_DECL_LONG_CONST("DISPLAY_SHORT_GENERIC", TimeZone::SHORT_GENERIC);
     529       23043 :         TIMEZONE_DECL_LONG_CONST("DISPLAY_LONG_GENERIC", TimeZone::LONG_GENERIC);
     530       23043 :         TIMEZONE_DECL_LONG_CONST("DISPLAY_SHORT_GMT", TimeZone::SHORT_GMT);
     531       23043 :         TIMEZONE_DECL_LONG_CONST("DISPLAY_LONG_GMT", TimeZone::LONG_GMT);
     532       23043 :         TIMEZONE_DECL_LONG_CONST("DISPLAY_SHORT_COMMONLY_USED", TimeZone::SHORT_COMMONLY_USED);
     533       23043 :         TIMEZONE_DECL_LONG_CONST("DISPLAY_GENERIC_LOCATION", TimeZone::GENERIC_LOCATION);
     534             : 
     535       23043 :         TIMEZONE_DECL_LONG_CONST("TYPE_ANY", UCAL_ZONE_TYPE_ANY);
     536       23043 :         TIMEZONE_DECL_LONG_CONST("TYPE_CANONICAL", UCAL_ZONE_TYPE_CANONICAL);
     537       23043 :         TIMEZONE_DECL_LONG_CONST("TYPE_CANONICAL_LOCATION", UCAL_ZONE_TYPE_CANONICAL_LOCATION);
     538             : 
     539             :         /* Declare 'IntlTimeZone' class properties */
     540             : 
     541             : }
     542             : /* }}} */

Generated by: LCOV version 1.10

Generated at Mon, 06 May 2019 17:58:16 +0000 (992 days ago)

Copyright © 2005-2022 The PHP Group
All rights reserved.