Skip to content

Commit 3626e2d

Browse files
authored
Get rid of remaining usages of zval_try_get_string() (php#14041)
This isn't necessary because the cases where we use it will always succeed because the properties always have the type string|null.
1 parent f68d725 commit 3626e2d

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

ext/dom/document.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,8 @@ zend_result dom_document_version_write(dom_object *obj, zval *newval)
194194
{
195195
DOM_PROP_NODE(xmlDocPtr, docp, obj);
196196

197-
zend_string *str = zval_try_get_string(newval);
198-
if (UNEXPECTED(!str)) {
199-
return FAILURE;
200-
}
197+
/* Cannot fail because the type is either null or a string. */
198+
zend_string *str = zval_get_string(newval);
201199

202200
if (php_dom_follow_spec_intern(obj)) {
203201
if (!zend_string_equals_literal(str, "1.0") && !zend_string_equals_literal(str, "1.1")) {
@@ -396,10 +394,8 @@ zend_result dom_document_document_uri_write(dom_object *obj, zval *newval)
396394
{
397395
DOM_PROP_NODE(xmlDocPtr, docp, obj);
398396

399-
zend_string *str = zval_try_get_string(newval);
400-
if (UNEXPECTED(!str)) {
401-
return FAILURE;
402-
}
397+
/* Cannot fail because the type is either null or a string. */
398+
zend_string *str = zval_get_string(newval);
403399

404400
if (docp->URL != NULL) {
405401
xmlFree(BAD_CAST docp->URL);
@@ -1780,7 +1776,6 @@ PHP_METHOD(DOMDocument, xinclude)
17801776
} else {
17811777
RETVAL_FALSE;
17821778
}
1783-
17841779
}
17851780
/* }}} */
17861781

ext/dom/node.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,8 @@ zend_result dom_node_node_value_write(dom_object *obj, zval *newval)
179179
{
180180
DOM_PROP_NODE(xmlNodePtr, nodep, obj);
181181

182-
zend_string *str = zval_try_get_string(newval);
183-
if (UNEXPECTED(!str)) {
184-
return FAILURE;
185-
}
182+
/* Cannot fail because the type is either null or a string. */
183+
zend_string *str = zval_get_string(newval);
186184

187185
/* Access to Element node is implemented as a convenience method */
188186
switch (nodep->type) {

0 commit comments

Comments
 (0)