Skip to content

Commit 22c5bcd

Browse files
committed
split MINIT for WeekInfo
1 parent 0f2f52e commit 22c5bcd

File tree

8 files changed

+150
-115
lines changed

8 files changed

+150
-115
lines changed

package.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ Fix: remove package.xml from manifest to avoid md5 checksum errors when installi
9191
<file name="locale_week_day.h" role="src"/>
9292
<file name="locale_week_info.c" role="src"/>
9393
<file name="locale_week_info.h" role="src"/>
94+
<file name="locale_week_info_arginfo.h" role="src"/>
95+
<file name="locale_week_info.stub.php" role="src"/>
9496
</dir>
9597
<file name="ecma_intl.c" role="src"/>
9698
<file name="ecma_intl.h" role="src"/>

src/php/classes/locale_week_info.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
#include "php/classes/locale_week_day.h"
1616

17+
#include "php/classes/locale_week_info_arginfo.h"
18+
1719
#include <ext/json/php_json.h>
1820

1921
zend_class_entry *ecma_ce_IntlLocaleWeekInfo = NULL;
@@ -121,3 +123,9 @@ static void freeLocaleWeekInfoObj(zend_object *object) {
121123
ecma_IntlLocaleWeekInfoFromObj(object);
122124
zend_object_std_dtor(&intlLocaleWeekInfo->std);
123125
}
126+
127+
PHP_MINIT_FUNCTION(ecma_intl_locale_weekinfo) {
128+
registerEcmaIntlLocaleWeekInfo();
129+
130+
return SUCCESS;
131+
}

src/php/classes/locale_week_info.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,6 @@ extern zend_object_handlers ecma_handlers_IntlLocaleWeekInfo;
3333
void registerEcmaIntlLocaleWeekInfo(void);
3434
zend_object *ecma_createIntlLocaleWeekInfo(zend_class_entry *classEntry);
3535

36+
PHP_MINIT_FUNCTION(ecma_intl_locale_weekinfo);
37+
3638
#endif /* ECMA_INTL_PHP_CLASSES_LOCALE_WEEK_INFO_H */
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?php
2+
3+
/**
4+
* Copyright (c) php-ecma-intl contributors.
5+
*
6+
* This source file is subject to the BSD-3-Clause license that is bundled with
7+
* this package in the file LICENSE and is available at the following web
8+
* address: https://opensource.org/license/bsd-3-clause/
9+
*
10+
* This source file may utilize copyrighted material from third-party open
11+
* source projects, the use of which is acknowledged in the NOTICE file bundled
12+
* with this package.
13+
*
14+
* @generate-class-entries
15+
*/
16+
17+
namespace Ecma\Intl\Locale
18+
{
19+
/**
20+
* WeekInfo represents locale-specific information about the days of the
21+
* week, for calendar purposes.
22+
*
23+
* @link https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.getWeekInfo Intl Locale Info Proposal: getTextInfo()
24+
* @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getWeekInfo Intl.Locale.prototype.getWeekInfo()
25+
* @link https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Patterns_Week_Elements UTS 35: Week Elements
26+
*/
27+
readonly class WeekInfo implements \JsonSerializable
28+
{
29+
/**
30+
* The week day that is considered the first day of the week
31+
* for the locale.
32+
*/
33+
public readonly WeekDay $firstDay;
34+
35+
/**
36+
* The minimum days required in the first week of a month or year
37+
* for the locale.
38+
*
39+
* @phpstan-var int<1, 7>
40+
*/
41+
public readonly int $minimalDays;
42+
43+
/**
44+
* A list of week days that are considered part of the weekend
45+
* for the locale.
46+
*
47+
* Please note, the number of weekend days in each locale may be
48+
* different, and they may not be contiguous.
49+
*
50+
* @var WeekDay[]
51+
*/
52+
public readonly array $weekend;
53+
54+
/**
55+
* WeekInfo represents locale-specific information about the days of the
56+
* week, for calendar purposes.
57+
*
58+
* @link https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.getWeekInfo Intl Locale Info Proposal: getTextInfo()
59+
* @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getWeekInfo Intl.Locale.prototype.getWeekInfo()
60+
* @link https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Patterns_Week_Elements UTS 35: Week Elements
61+
*
62+
* @param WeekDay $firstDay The week day that is considered the _first_ day of the week.
63+
* @param WeekDay[] $weekend A list of week days that are considered part of the weekend.
64+
* @phpstan-param int<1, 7> $minimalDays The minimum days required in the first week of a month or year.
65+
*/
66+
public function __construct(
67+
WeekDay $firstDay,
68+
array $weekend,
69+
int $minimalDays,
70+
) {
71+
}
72+
73+
/**
74+
* Returns an object of WeekInfo properties and their values, suitable
75+
* for serializing to JSON.
76+
*
77+
* @return object
78+
*/
79+
public function jsonSerialize(): object
80+
{
81+
}
82+
}
83+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/* This is a generated file, edit the .stub.php file instead.
2+
* Stub hash: 3051c3b438167cf62f52ffb9330009339345353b */
3+
4+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Ecma_Intl_Locale_WeekInfo___construct, 0, 0, 3)
5+
ZEND_ARG_OBJ_INFO(0, firstDay, Ecma\\Intl\\Locale\\WeekDay, 0)
6+
ZEND_ARG_TYPE_INFO(0, weekend, IS_ARRAY, 0)
7+
ZEND_ARG_TYPE_INFO(0, minimalDays, IS_LONG, 0)
8+
ZEND_END_ARG_INFO()
9+
10+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Ecma_Intl_Locale_WeekInfo_jsonSerialize, 0, 0, IS_OBJECT, 0)
11+
ZEND_END_ARG_INFO()
12+
13+
14+
ZEND_METHOD(Ecma_Intl_Locale_WeekInfo, __construct);
15+
ZEND_METHOD(Ecma_Intl_Locale_WeekInfo, jsonSerialize);
16+
17+
18+
static const zend_function_entry class_Ecma_Intl_Locale_WeekInfo_methods[] = {
19+
ZEND_ME(Ecma_Intl_Locale_WeekInfo, __construct, arginfo_class_Ecma_Intl_Locale_WeekInfo___construct, ZEND_ACC_PUBLIC)
20+
ZEND_ME(Ecma_Intl_Locale_WeekInfo, jsonSerialize, arginfo_class_Ecma_Intl_Locale_WeekInfo_jsonSerialize, ZEND_ACC_PUBLIC)
21+
ZEND_FE_END
22+
};
23+
24+
static zend_class_entry *register_class_Ecma_Intl_Locale_WeekInfo(zend_class_entry *class_entry_JsonSerializable)
25+
{
26+
zend_class_entry ce, *class_entry;
27+
28+
INIT_NS_CLASS_ENTRY(ce, "Ecma\\Intl\\Locale", "WeekInfo", class_Ecma_Intl_Locale_WeekInfo_methods);
29+
class_entry = zend_register_internal_class_ex(&ce, NULL);
30+
class_entry->ce_flags |= ZEND_ACC_READONLY_CLASS;
31+
zend_class_implements(class_entry, 1, class_entry_JsonSerializable);
32+
33+
zend_string *property_firstDay_class_Ecma_Intl_Locale_WeekDay = zend_string_init("Ecma\\Intl\\Locale\\WeekDay", sizeof("Ecma\\Intl\\Locale\\WeekDay")-1, 1);
34+
zval property_firstDay_default_value;
35+
ZVAL_UNDEF(&property_firstDay_default_value);
36+
zend_string *property_firstDay_name = zend_string_init("firstDay", sizeof("firstDay") - 1, 1);
37+
zend_declare_typed_property(class_entry, property_firstDay_name, &property_firstDay_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_firstDay_class_Ecma_Intl_Locale_WeekDay, 0, 0));
38+
zend_string_release(property_firstDay_name);
39+
40+
zval property_minimalDays_default_value;
41+
ZVAL_UNDEF(&property_minimalDays_default_value);
42+
zend_string *property_minimalDays_name = zend_string_init("minimalDays", sizeof("minimalDays") - 1, 1);
43+
zend_declare_typed_property(class_entry, property_minimalDays_name, &property_minimalDays_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG));
44+
zend_string_release(property_minimalDays_name);
45+
46+
zval property_weekend_default_value;
47+
ZVAL_UNDEF(&property_weekend_default_value);
48+
zend_string *property_weekend_name = zend_string_init("weekend", sizeof("weekend") - 1, 1);
49+
zend_declare_typed_property(class_entry, property_weekend_name, &property_weekend_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ARRAY));
50+
zend_string_release(property_weekend_name);
51+
52+
return class_entry;
53+
}

src/php/ecma_intl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ PHP_MINIT_FUNCTION(ecma_intl) {
5454
registerEcmaIntlLocaleOptions();
5555
registerEcmaIntlLocaleTextInfo();
5656
registerEcmaIntlLocaleWeekDay();
57-
registerEcmaIntlLocaleWeekInfo();
57+
PHP_MINIT(ecma_intl_locale_weekinfo)(INIT_FUNC_ARGS_PASSTHRU);
5858

5959
return SUCCESS;
6060
}

src/php/ecma_intl.stub.php

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -727,69 +727,4 @@ enum WeekDay: int
727727
case Saturday = 6;
728728
case Sunday = 7;
729729
}
730-
731-
/**
732-
* WeekInfo represents locale-specific information about the days of the
733-
* week, for calendar purposes.
734-
*
735-
* @link https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.getWeekInfo Intl Locale Info Proposal: getTextInfo()
736-
* @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getWeekInfo Intl.Locale.prototype.getWeekInfo()
737-
* @link https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Patterns_Week_Elements UTS 35: Week Elements
738-
*/
739-
readonly class WeekInfo implements \JsonSerializable
740-
{
741-
/**
742-
* The week day that is considered the first day of the week
743-
* for the locale.
744-
*/
745-
public readonly WeekDay $firstDay;
746-
747-
/**
748-
* The minimum days required in the first week of a month or year
749-
* for the locale.
750-
*
751-
* @phpstan-var int<1, 7>
752-
*/
753-
public readonly int $minimalDays;
754-
755-
/**
756-
* A list of week days that are considered part of the weekend
757-
* for the locale.
758-
*
759-
* Please note, the number of weekend days in each locale may be
760-
* different, and they may not be contiguous.
761-
*
762-
* @var WeekDay[]
763-
*/
764-
public readonly array $weekend;
765-
766-
/**
767-
* WeekInfo represents locale-specific information about the days of the
768-
* week, for calendar purposes.
769-
*
770-
* @link https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.getWeekInfo Intl Locale Info Proposal: getTextInfo()
771-
* @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getWeekInfo Intl.Locale.prototype.getWeekInfo()
772-
* @link https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Patterns_Week_Elements UTS 35: Week Elements
773-
*
774-
* @param WeekDay $firstDay The week day that is considered the _first_ day of the week.
775-
* @param WeekDay[] $weekend A list of week days that are considered part of the weekend.
776-
* @phpstan-param int<1, 7> $minimalDays The minimum days required in the first week of a month or year.
777-
*/
778-
public function __construct(
779-
WeekDay $firstDay,
780-
array $weekend,
781-
int $minimalDays,
782-
) {
783-
}
784-
785-
/**
786-
* Returns an object of WeekInfo properties and their values, suitable
787-
* for serializing to JSON.
788-
*
789-
* @return object
790-
*/
791-
public function jsonSerialize(): object
792-
{
793-
}
794-
}
795730
}

src/php/ecma_intl_arginfo.h

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 7ddfa21a419a4884073bf5764537976a096ec5d3 */
2+
* Stub hash: 072a04a13d5217758e021d976cd7ca954937a184 */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Ecma_Intl_getCanonicalLocales, 0, 1, IS_ARRAY, 0)
55
ZEND_ARG_OBJ_TYPE_MASK(0, locales, Traversable|Stringable, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, NULL)
@@ -83,14 +83,6 @@ ZEND_END_ARG_INFO()
8383

8484
#define arginfo_class_Ecma_Intl_Locale_TextInfo_jsonSerialize arginfo_class_Ecma_Intl_Locale_jsonSerialize
8585

86-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Ecma_Intl_Locale_WeekInfo___construct, 0, 0, 3)
87-
ZEND_ARG_OBJ_INFO(0, firstDay, Ecma\\Intl\\Locale\\WeekDay, 0)
88-
ZEND_ARG_TYPE_INFO(0, weekend, IS_ARRAY, 0)
89-
ZEND_ARG_TYPE_INFO(0, minimalDays, IS_LONG, 0)
90-
ZEND_END_ARG_INFO()
91-
92-
#define arginfo_class_Ecma_Intl_Locale_WeekInfo_jsonSerialize arginfo_class_Ecma_Intl_Locale_jsonSerialize
93-
9486

9587
ZEND_METHOD(Ecma_Intl, getCanonicalLocales);
9688
ZEND_METHOD(Ecma_Intl, supportedValuesOf);
@@ -117,8 +109,6 @@ ZEND_METHOD(Ecma_Intl_Locale_Options, valid);
117109
ZEND_METHOD(Ecma_Intl_Locale_Options, rewind);
118110
ZEND_METHOD(Ecma_Intl_Locale_TextInfo, __construct);
119111
ZEND_METHOD(Ecma_Intl_Locale_TextInfo, jsonSerialize);
120-
ZEND_METHOD(Ecma_Intl_Locale_WeekInfo, __construct);
121-
ZEND_METHOD(Ecma_Intl_Locale_WeekInfo, jsonSerialize);
122112

123113

124114
static const zend_function_entry class_Ecma_Intl_methods[] = {
@@ -181,13 +171,6 @@ static const zend_function_entry class_Ecma_Intl_Locale_WeekDay_methods[] = {
181171
ZEND_FE_END
182172
};
183173

184-
185-
static const zend_function_entry class_Ecma_Intl_Locale_WeekInfo_methods[] = {
186-
ZEND_ME(Ecma_Intl_Locale_WeekInfo, __construct, arginfo_class_Ecma_Intl_Locale_WeekInfo___construct, ZEND_ACC_PUBLIC)
187-
ZEND_ME(Ecma_Intl_Locale_WeekInfo, jsonSerialize, arginfo_class_Ecma_Intl_Locale_WeekInfo_jsonSerialize, ZEND_ACC_PUBLIC)
188-
ZEND_FE_END
189-
};
190-
191174
static zend_class_entry *register_class_Ecma_Intl(void)
192175
{
193176
zend_class_entry ce, *class_entry;
@@ -508,34 +491,3 @@ static zend_class_entry *register_class_Ecma_Intl_Locale_WeekDay(void)
508491

509492
return class_entry;
510493
}
511-
512-
static zend_class_entry *register_class_Ecma_Intl_Locale_WeekInfo(zend_class_entry *class_entry_JsonSerializable)
513-
{
514-
zend_class_entry ce, *class_entry;
515-
516-
INIT_NS_CLASS_ENTRY(ce, "Ecma\\Intl\\Locale", "WeekInfo", class_Ecma_Intl_Locale_WeekInfo_methods);
517-
class_entry = zend_register_internal_class_ex(&ce, NULL);
518-
class_entry->ce_flags |= ZEND_ACC_READONLY_CLASS;
519-
zend_class_implements(class_entry, 1, class_entry_JsonSerializable);
520-
521-
zend_string *property_firstDay_class_Ecma_Intl_Locale_WeekDay = zend_string_init("Ecma\\Intl\\Locale\\WeekDay", sizeof("Ecma\\Intl\\Locale\\WeekDay")-1, 1);
522-
zval property_firstDay_default_value;
523-
ZVAL_UNDEF(&property_firstDay_default_value);
524-
zend_string *property_firstDay_name = zend_string_init("firstDay", sizeof("firstDay") - 1, 1);
525-
zend_declare_typed_property(class_entry, property_firstDay_name, &property_firstDay_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_firstDay_class_Ecma_Intl_Locale_WeekDay, 0, 0));
526-
zend_string_release(property_firstDay_name);
527-
528-
zval property_minimalDays_default_value;
529-
ZVAL_UNDEF(&property_minimalDays_default_value);
530-
zend_string *property_minimalDays_name = zend_string_init("minimalDays", sizeof("minimalDays") - 1, 1);
531-
zend_declare_typed_property(class_entry, property_minimalDays_name, &property_minimalDays_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG));
532-
zend_string_release(property_minimalDays_name);
533-
534-
zval property_weekend_default_value;
535-
ZVAL_UNDEF(&property_weekend_default_value);
536-
zend_string *property_weekend_name = zend_string_init("weekend", sizeof("weekend") - 1, 1);
537-
zend_declare_typed_property(class_entry, property_weekend_name, &property_weekend_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ARRAY));
538-
zend_string_release(property_weekend_name);
539-
540-
return class_entry;
541-
}

0 commit comments

Comments
 (0)