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

Generated by: LCOV version 1.10

Generated at Sat, 22 Nov 2014 23:01:17 +0000 (2 days ago)

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