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

Generated by: LCOV version 1.10

Generated at Wed, 02 Sep 2015 17:19:11 +0000 (45 hours ago)

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