Skip to content

Commit 5d2ca4c

Browse files
disable cloning and use different functions
1 parent a7e9a29 commit 5d2ca4c

File tree

6 files changed

+30
-8
lines changed

6 files changed

+30
-8
lines changed

ext/intl/listformatter/listformatter_class.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,19 +113,18 @@ PHP_METHOD(IntlListFormatter, __construct)
113113
PHP_METHOD(IntlListFormatter, format)
114114
{
115115
ListFormatter_object *obj = Z_INTL_LISTFORMATTER_P(ZEND_THIS);
116-
zval *strings;
116+
HashTable *ht;
117117

118118
ZEND_PARSE_PARAMETERS_START(1, 1)
119-
Z_PARAM_ARRAY(strings)
119+
Z_PARAM_ARRAY_HT(ht)
120120
ZEND_PARSE_PARAMETERS_END();
121121

122122
if (!LISTFORMATTER_OBJECT(obj)) {
123123
zend_throw_exception(NULL, "ListFormatter not properly constructed", 0);
124124
RETURN_FALSE;
125125
}
126126

127-
HashTable *ht = Z_ARRVAL_P(strings);
128-
uint32_t count = zend_array_count(ht);
127+
uint32_t count = zend_hash_num_elements(ht);
129128
if (count == 0) {
130129
RETURN_EMPTY_STRING();
131130
}
@@ -238,4 +237,5 @@ void listformatter_register_class(void)
238237
memcpy(&listformatter_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
239238
listformatter_handlers.offset = XtOffsetOf(ListFormatter_object, zo);
240239
listformatter_handlers.free_obj = listformatter_free_obj;
240+
listformatter_handlers.clone_obj = NULL;
241241
}

ext/intl/listformatter/listformatter_class.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ static inline ListFormatter_object *php_intl_listformatter_fetch_object(zend_obj
4949
void listformatter_register_class( void );
5050
extern zend_class_entry *ListFormatter_ce_ptr;
5151

52-
#endif // LISTFORMATTER_CLASS_H
52+
#endif // LISTFORMATTER_CLASS_H

ext/intl/tests/listformatter/listformatter_basic.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ test, test2, and test
5858
FR
5959
1, 2 et 3
6060
1, 2 et 3
61-
1.2, 2.3 et 3.4
61+
1.2, 2.3 et 3.4
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Test IntlListFormatter cannot be cloned
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('intl')) {
6+
die('skip intl extension not available');
7+
}
8+
?>
9+
--FILE--
10+
<?php
11+
12+
$formatter = new IntlListFormatter('en_US', IntlListFormatter::TYPE_AND, IntlListFormatter::WIDTH_WIDE);
13+
14+
try {
15+
$clonedFormatter = clone $formatter;
16+
} catch(Error $error) {
17+
echo $error->getMessage();
18+
}
19+
20+
?>
21+
--EXPECT--
22+
Trying to clone an uncloneable object of class IntlListFormatter

ext/intl/tests/listformatter/listformatter_error.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ try {
3535
IntlListFormatter::__construct(): Argument #1 ($locale) "f" is invalid
3636
IntlListFormatter::__construct(): Argument #1 ($locale) Locale string too long, should be no longer than 156 characters
3737
Object of class stdClass could not be converted to string
38-
Object of class stdClass could not be converted to string
38+
Object of class stdClass could not be converted to string

ext/intl/tests/listformatter/listformatter_with_paramaters.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,4 @@ FR
123123
1, 2 ou 3
124124
1, 2 et 3
125125
1, 2 et 3
126-
1 2 3
126+
1 2 3

0 commit comments

Comments
 (0)