Skip to content

Commit 7951279

Browse files
nielsdosGirgias
authored andcommittedJun 4, 2023
Remove double class entry variable
1 parent c6bffff commit 7951279

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed
 

‎ext/simplexml/simplexml.c

+15-19
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,12 @@
3333
#include "zend_interfaces.h"
3434
#include "ext/spl/spl_iterators.h"
3535

36-
zend_class_entry *sxe_class_entry = NULL;
3736
PHP_SXE_API zend_class_entry *ce_SimpleXMLIterator;
3837
PHP_SXE_API zend_class_entry *ce_SimpleXMLElement;
3938

4039
PHP_SXE_API zend_class_entry *sxe_get_element_class_entry(void) /* {{{ */
4140
{
42-
return sxe_class_entry;
41+
return ce_SimpleXMLElement;
4342
}
4443
/* }}} */
4544

@@ -471,7 +470,7 @@ static zval *sxe_prop_dim_write(zend_object *object, zval *member, zval *value,
471470
value_str = zval_get_string(value);
472471
break;
473472
case IS_OBJECT:
474-
if (Z_OBJCE_P(value) == sxe_class_entry) {
473+
if (Z_OBJCE_P(value) == ce_SimpleXMLElement) {
475474
zval zval_copy;
476475
if (sxe_object_cast_ex(Z_OBJ_P(value), &zval_copy, IS_STRING) == FAILURE) {
477476
zend_throw_error(NULL, "Unable to cast node to string");
@@ -2184,7 +2183,7 @@ static zend_function* php_sxe_find_fptr_count(zend_class_entry *ce)
21842183
int inherited = 0;
21852184

21862185
while (parent) {
2187-
if (parent == sxe_class_entry) {
2186+
if (parent == ce_SimpleXMLElement) {
21882187
break;
21892188
}
21902189
parent = parent->parent;
@@ -2242,7 +2241,7 @@ PHP_FUNCTION(simplexml_load_file)
22422241
char *ns = NULL;
22432242
size_t ns_len = 0;
22442243
zend_long options = 0;
2245-
zend_class_entry *ce= sxe_class_entry;
2244+
zend_class_entry *ce= ce_SimpleXMLElement;
22462245
zend_function *fptr_count;
22472246
bool isprefix = 0;
22482247

@@ -2262,7 +2261,7 @@ PHP_FUNCTION(simplexml_load_file)
22622261
}
22632262

22642263
if (!ce) {
2265-
ce = sxe_class_entry;
2264+
ce = ce_SimpleXMLElement;
22662265
fptr_count = NULL;
22672266
} else {
22682267
fptr_count = php_sxe_find_fptr_count(ce);
@@ -2287,7 +2286,7 @@ PHP_FUNCTION(simplexml_load_string)
22872286
char *ns = NULL;
22882287
size_t ns_len = 0;
22892288
zend_long options = 0;
2290-
zend_class_entry *ce= sxe_class_entry;
2289+
zend_class_entry *ce= ce_SimpleXMLElement;
22912290
zend_function *fptr_count;
22922291
bool isprefix = 0;
22932292

@@ -2315,7 +2314,7 @@ PHP_FUNCTION(simplexml_load_string)
23152314
}
23162315

23172316
if (!ce) {
2318-
ce = sxe_class_entry;
2317+
ce = ce_SimpleXMLElement;
23192318
fptr_count = NULL;
23202319
} else {
23212320
fptr_count = php_sxe_find_fptr_count(ce);
@@ -2589,7 +2588,7 @@ PHP_FUNCTION(simplexml_import_dom)
25892588
zval *node;
25902589
php_libxml_node_object *object;
25912590
xmlNodePtr nodep = NULL;
2592-
zend_class_entry *ce = sxe_class_entry;
2591+
zend_class_entry *ce = ce_SimpleXMLElement;
25932592
zend_function *fptr_count;
25942593

25952594
if (zend_parse_parameters(ZEND_NUM_ARGS(), "o|C!", &node, &ce) == FAILURE) {
@@ -2614,7 +2613,7 @@ PHP_FUNCTION(simplexml_import_dom)
26142613

26152614
if (nodep && nodep->type == XML_ELEMENT_NODE) {
26162615
if (!ce) {
2617-
ce = sxe_class_entry;
2616+
ce = ce_SimpleXMLElement;
26182617
fptr_count = NULL;
26192618
} else {
26202619
fptr_count = php_sxe_find_fptr_count(ce);
@@ -2664,10 +2663,10 @@ ZEND_GET_MODULE(simplexml)
26642663
/* {{{ PHP_MINIT_FUNCTION(simplexml) */
26652664
PHP_MINIT_FUNCTION(simplexml)
26662665
{
2667-
sxe_class_entry = register_class_SimpleXMLElement(zend_ce_stringable, zend_ce_countable, spl_ce_RecursiveIterator);
2668-
sxe_class_entry->create_object = sxe_object_new;
2669-
sxe_class_entry->default_object_handlers = &sxe_object_handlers;
2670-
sxe_class_entry->get_iterator = php_sxe_get_iterator;
2666+
ce_SimpleXMLElement = register_class_SimpleXMLElement(zend_ce_stringable, zend_ce_countable, spl_ce_RecursiveIterator);
2667+
ce_SimpleXMLElement->create_object = sxe_object_new;
2668+
ce_SimpleXMLElement->default_object_handlers = &sxe_object_handlers;
2669+
ce_SimpleXMLElement->get_iterator = php_sxe_get_iterator;
26712670

26722671
memcpy(&sxe_object_handlers, &std_object_handlers, sizeof(zend_object_handlers));
26732672
sxe_object_handlers.offset = XtOffsetOf(php_sxe_object, zo);
@@ -2690,12 +2689,9 @@ PHP_MINIT_FUNCTION(simplexml)
26902689
sxe_object_handlers.get_closure = NULL;
26912690
sxe_object_handlers.get_gc = sxe_get_gc;
26922691

2693-
/* TODO: Why do we have two variables for this? */
2694-
ce_SimpleXMLElement = sxe_class_entry;
2695-
26962692
ce_SimpleXMLIterator = register_class_SimpleXMLIterator(ce_SimpleXMLElement);
26972693

2698-
php_libxml_register_export(sxe_class_entry, simplexml_export_node);
2694+
php_libxml_register_export(ce_SimpleXMLElement, simplexml_export_node);
26992695

27002696
return SUCCESS;
27012697
}
@@ -2704,7 +2700,7 @@ PHP_MINIT_FUNCTION(simplexml)
27042700
/* {{{ PHP_MSHUTDOWN_FUNCTION(simplexml) */
27052701
PHP_MSHUTDOWN_FUNCTION(simplexml)
27062702
{
2707-
sxe_class_entry = NULL;
2703+
ce_SimpleXMLElement = NULL;
27082704
return SUCCESS;
27092705
}
27102706
/* }}} */

0 commit comments

Comments
 (0)