Skip to content

Commit 250028a

Browse files
committed
Forbid explicit construction of XmlParser
1 parent db10ff0 commit 250028a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

ext/xml/xml.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ PHP_FUNCTION(xml_parse_into_struct);
177177
static zend_object *xml_parser_create_object(zend_class_entry *class_type);
178178
static void xml_parser_free_obj(zend_object *object);
179179
static HashTable *xml_parser_get_gc(zval *object, zval **table, int *n);
180+
static zend_function *xml_parser_get_constructor(zend_object *object);
180181

181182
static zend_string *xml_utf8_decode(const XML_Char *, size_t, const XML_Char *);
182183
static void xml_set_handler(zval *, zval *);
@@ -408,7 +409,6 @@ static void php_xml_free_wrapper(void *ptr)
408409
}
409410

410411
static const zend_function_entry xml_parser_methods[] = {
411-
// TODO
412412
PHP_FE_END
413413
};
414414

@@ -424,6 +424,7 @@ PHP_MINIT_FUNCTION(xml)
424424
xml_parser_object_handlers.offset = XtOffsetOf(xml_parser, std);
425425
xml_parser_object_handlers.free_obj = xml_parser_free_obj;
426426
xml_parser_object_handlers.get_gc = xml_parser_get_gc;
427+
xml_parser_object_handlers.get_constructor = xml_parser_get_constructor;
427428

428429
REGISTER_LONG_CONSTANT("XML_ERROR_NONE", XML_ERROR_NONE, CONST_CS|CONST_PERSISTENT);
429430
REGISTER_LONG_CONSTANT("XML_ERROR_NO_MEMORY", XML_ERROR_NO_MEMORY, CONST_CS|CONST_PERSISTENT);
@@ -579,6 +580,11 @@ static HashTable *xml_parser_get_gc(zval *object, zval **table, int *n)
579580
return zend_std_get_properties(object);
580581
}
581582

583+
static zend_function *xml_parser_get_constructor(zend_object *object) {
584+
zend_throw_error(NULL, "Cannot directly construct XmlParser, use xml_parser_create() or xml_parser_create_ns() instead");
585+
return NULL;
586+
}
587+
582588
/* {{{ xml_set_handler() */
583589
static void xml_set_handler(zval *handler, zval *data)
584590
{
@@ -1577,7 +1583,6 @@ PHP_FUNCTION(xml_parser_free)
15771583
RETURN_FALSE;
15781584
}
15791585

1580-
// TODO ???
15811586
RETURN_TRUE;
15821587
}
15831588
/* }}} */

0 commit comments

Comments
 (0)