@@ -1714,4 +1714,103 @@ PHP_METHOD(DOMElement, toggleAttribute)
17141714}
17151715/* }}} end DOMElement::prepend */
17161716
1717+ zend_result dom_modern_element_substituted_node_value_read (dom_object * obj , zval * retval )
1718+ {
1719+ DOM_PROP_NODE (xmlNodePtr , nodep , obj );
1720+
1721+ xmlChar * content = xmlNodeGetContent (nodep );
1722+
1723+ if (UNEXPECTED (content == NULL )) {
1724+ php_dom_throw_error (INVALID_STATE_ERR , true);
1725+ return FAILURE ;
1726+ } else {
1727+ ZVAL_STRING (retval , (const char * ) content );
1728+ xmlFree (content );
1729+ }
1730+
1731+ return SUCCESS ;
1732+ }
1733+
1734+ zend_result dom_modern_element_substituted_node_value_write (dom_object * obj , zval * newval )
1735+ {
1736+ DOM_PROP_NODE (xmlNodePtr , nodep , obj );
1737+
1738+ php_libxml_invalidate_node_list_cache (obj -> document );
1739+ dom_remove_all_children (nodep );
1740+ xmlNodeSetContentLen (nodep , (xmlChar * ) Z_STRVAL_P (newval ), Z_STRLEN_P (newval ));
1741+
1742+ return SUCCESS ;
1743+ }
1744+
1745+ PHP_METHOD (DOM_Element , getInScopeNamespaces )
1746+ {
1747+ zval * id ;
1748+ xmlNode * nodep ;
1749+ dom_object * intern ;
1750+
1751+ if (zend_parse_parameters_none () != SUCCESS ) {
1752+ RETURN_THROWS ();
1753+ }
1754+
1755+ DOM_GET_THIS_OBJ (nodep , id , xmlNodePtr , intern );
1756+
1757+ php_dom_libxml_ns_mapper * ns_mapper = php_dom_get_ns_mapper (intern );
1758+ php_dom_in_scope_ns namespaces = php_dom_get_in_scope_ns (ns_mapper , nodep , true);
1759+
1760+ array_init_size (return_value , namespaces .count );
1761+
1762+ for (size_t i = 0 ; i < namespaces .count ; i ++ ) {
1763+ xmlNsPtr ns = namespaces .list [i ];
1764+ if (ns == NULL ) {
1765+ /* This case corresponds to xmlns="" */
1766+ add_assoc_null (return_value , "" );
1767+ } else {
1768+ const char * prefix = (const char * ) ns -> prefix ;
1769+ add_assoc_stringl (return_value , prefix == NULL ? "" : prefix , (const char * ) ns -> href , xmlStrlen (ns -> href ));
1770+ }
1771+ }
1772+
1773+ php_dom_in_scope_ns_destroy (& namespaces );
1774+ }
1775+
1776+ PHP_METHOD (DOM_Element , rename )
1777+ {
1778+ zend_string * namespace_uri , * qualified_name ;
1779+ ZEND_PARSE_PARAMETERS_START (2 , 2 )
1780+ Z_PARAM_STR_OR_NULL (namespace_uri )
1781+ Z_PARAM_STR (qualified_name )
1782+ ZEND_PARSE_PARAMETERS_END ();
1783+
1784+ zval * id ;
1785+ dom_object * intern ;
1786+ xmlNodePtr nodep ;
1787+ DOM_GET_THIS_OBJ (nodep , id , xmlNodePtr , intern );
1788+
1789+ xmlChar * localname = NULL , * prefix = NULL ;
1790+ int errorcode = dom_validate_and_extract (namespace_uri , qualified_name , & localname , & prefix );
1791+ if (UNEXPECTED (errorcode != 0 )) {
1792+ php_dom_throw_error (errorcode , /* strict */ true);
1793+ goto cleanup ;
1794+ }
1795+
1796+ php_libxml_invalidate_node_list_cache (intern -> document );
1797+
1798+ php_dom_libxml_ns_mapper * ns_mapper = php_dom_get_ns_mapper (intern );
1799+
1800+ /* Update namespace uri + prefix by querying the namespace mapper */
1801+ /* prefix can be NULL here, but that is taken care of by the called APIs. */
1802+ nodep -> ns = php_dom_libxml_ns_mapper_get_ns_raw_prefix_string (ns_mapper , prefix , xmlStrlen (prefix ), namespace_uri );
1803+
1804+ /* Change the local name */
1805+ if (xmlDictOwns (nodep -> doc -> dict , nodep -> name ) == 0 ) {
1806+ xmlFree ((xmlChar * ) nodep -> name );
1807+ }
1808+ nodep -> name = localname ;
1809+ localname = NULL ;
1810+
1811+ cleanup :
1812+ xmlFree (localname );
1813+ xmlFree (prefix );
1814+ }
1815+
17171816#endif
0 commit comments