name_valid = xmlValidateName((xmlChar *) name, 0);
if (name_valid != 0) {
php_dom_throw_error(INVALID_CHARACTER_ERR, 1);
- RETURN_FALSE;
+ RETURN_THROWS();
}
nodep = xmlNewProp(NULL, (xmlChar *) name, (xmlChar *) value);
if (!nodep) {
php_dom_throw_error(INVALID_STATE_ERR, 1);
- RETURN_FALSE;
+ RETURN_THROWS();
}
oldnode = dom_object_get_node(intern);
if (!nodep) {
php_dom_throw_error(INVALID_STATE_ERR, 1);
- return;
+ RETURN_THROWS();
}
intern = Z_DOMOBJ_P(ZEND_THIS);
if (!nodep) {
php_dom_throw_error(INVALID_STATE_ERR, 1);
- return;
+ RETURN_THROWS();
}
intern = Z_DOMOBJ_P(ZEND_THIS);
return SUCCESS;
}
-int dom_document_encoding_write(dom_object *obj, zval *newval)
+zend_result dom_document_encoding_write(dom_object *obj, zval *newval)
{
xmlDoc *docp = (xmlDocPtr) dom_object_get_node(obj);
zend_string *str;
}
docp->encoding = xmlStrdup((const xmlChar *) ZSTR_VAL(str));
} else {
- php_error_docref(NULL, E_WARNING, "Invalid Document Encoding");
+ zend_value_error("Invalid document encoding");
+ return FAILURE;
}
zend_string_release_ex(str, 0);
if (!nodep) {
php_dom_throw_error(INVALID_STATE_ERR, 1);
- return;
+ RETURN_THROWS();
}
intern = Z_DOMOBJ_P(ZEND_THIS);
}
if (name_len == 0) {
- php_error_docref(NULL, E_WARNING, "qualifiedName is required");
- RETURN_FALSE;
+ zend_argument_value_error(1, "cannot be empty");
+ RETURN_THROWS();
}
if (publicid_len > 0) {
if (node != NULL) {
DOM_GET_OBJ(doctype, node, xmlDtdPtr, doctobj);
if (doctype->type == XML_DOCUMENT_TYPE_NODE) {
- php_error_docref(NULL, E_WARNING, "Invalid DocumentType object");
- RETURN_FALSE;
+ zend_argument_value_error(3, "is an invalid DocumentType object");
+ RETURN_THROWS();
}
if (doctype->doc != NULL) {
php_dom_throw_error(WRONG_DOCUMENT_ERR, 1);
- RETURN_FALSE;
+ RETURN_THROWS();
}
} else {
doctobj = NULL;
xmlFree(localname);
}
php_dom_throw_error(errorcode, 1);
- RETURN_FALSE;
+ RETURN_THROWS();
}
/* currently letting libxml2 set the version string */
}
xmlFreeDoc(docp);
xmlFree(localname);
- /* Need some type of error here */
- php_error_docref(NULL, E_WARNING, "Unexpected Error");
- RETURN_FALSE;
+ /* Need some better type of error here */
+ php_dom_throw_error(PHP_ERR, 1);
+ RETURN_THROWS();
}
nodep->nsDef = nsptr;
name_valid = xmlValidateName((xmlChar *) name, 0);
if (name_valid != 0) {
php_dom_throw_error(INVALID_CHARACTER_ERR, 1);
- return;
+ RETURN_THROWS();
}
/* Namespace logic is separate and only when uri passed in to insure no BC breakage */
xmlFreeNode(nodep);
}
php_dom_throw_error(errorcode, 1);
- return;
+ RETURN_THROWS();
}
} else {
/* If you don't pass a namespace uri, then you can't set a prefix */
xmlFree(localname);
xmlFree(prefix);
php_dom_throw_error(NAMESPACE_ERR, 1);
- return;
+ RETURN_THROWS();
}
nodep = xmlNewNode(NULL, (xmlChar *) name);
}
if (!nodep) {
php_dom_throw_error(INVALID_STATE_ERR, 1);
- return;
+ RETURN_THROWS();
}
if (value_len > 0) {
}
if (name_len == 0) {
- php_error_docref(NULL, E_WARNING, "Attribute Name is required");
- RETURN_FALSE;
+ zend_argument_value_error(1, "cannot be empty");
+ RETURN_THROWS();
}
name_valid = xmlValidateName((xmlChar *) name, 0);
if (name_valid != 0) {
php_dom_throw_error(INVALID_CHARACTER_ERR, 1);
- RETURN_FALSE;
+ RETURN_THROWS();
}
DOM_GET_OBJ(nodep, id, xmlNodePtr, intern);
attr = (xmlNodePtr)xmlSetProp(nodep, (xmlChar *) name, (xmlChar *)value);
}
if (!attr) {
- php_error_docref(NULL, E_WARNING, "No such attribute '%s'", name);
- RETURN_FALSE;
+ zend_argument_value_error(1, "must be a valid XML attribute");
+ RETURN_THROWS();
}
DOM_RET_OBJ(attr, &ret, intern);
DOM_GET_OBJ(attrp, node, xmlAttrPtr, attrobj);
if (attrp->type != XML_ATTRIBUTE_NODE) {
- php_error_docref(NULL, E_WARNING, "Attribute node is required");
- RETURN_FALSE;
+ zend_argument_value_error(1, "must have the node attribute");
+ RETURN_THROWS();
}
if (!(attrp->doc == NULL || attrp->doc == nodep->doc)) {
}
if (name_len == 0) {
- php_error_docref(NULL, E_WARNING, "Attribute Name is required");
- RETURN_FALSE;
+ zend_argument_value_error(2, "cannot be empty");
+ RETURN_THROWS();
}
DOM_GET_OBJ(elemp, id, xmlNodePtr, intern);
DOM_GET_OBJ(attrp, node, xmlAttrPtr, attrobj);
- if (attrp->type != XML_ATTRIBUTE_NODE) {
- php_error_docref(NULL, E_WARNING, "Attribute node is required");
- RETURN_FALSE;
- }
+ /* ZPP Guarantees that a DOMAttr class is given, as it is converted to a xmlAttr
+ * to pass to libxml (see http://www.xmlsoft.org/html/libxml-tree.html#xmlAttr)
+ * if it is not of type XML_ATTRIBUTE_NODE it indicates a bug somewhere */
+ ZEND_ASSERT(attrp->type == XML_ATTRIBUTE_NODE);
if (!(attrp->doc == NULL || attrp->doc == nodep->doc)) {
php_dom_throw_error(WRONG_DOCUMENT_ERR, dom_get_strict_error(intern->document));
name_valid = xmlValidateName((xmlChar *) name, 0);
if (name_valid != 0) {
php_dom_throw_error(INVALID_CHARACTER_ERR, 1);
- RETURN_FALSE;
+ RETURN_THROWS();
}
node = xmlNewReference(NULL, (xmlChar *) name);
if (!node) {
php_dom_throw_error(INVALID_STATE_ERR, 1);
- RETURN_FALSE;
+ RETURN_THROWS();
}
intern = Z_DOMOBJ_P(ZEND_THIS);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &index) == FAILURE) {
RETURN_THROWS();
}
- if (index >= 0) {
- if (ZEND_LONG_INT_OVFL(index)) {
- php_error_docref(NULL, E_WARNING, "Invalid index");
- RETURN_NULL();
- }
+ if (index < 0 || ZEND_LONG_INT_OVFL(index)) {
+ zend_argument_value_error(1, "must be between 0 and %d", INT_MAX);
+ RETURN_THROWS();
+ }
- intern = Z_DOMOBJ_P(id);
+ intern = Z_DOMOBJ_P(id);
- objmap = (dom_nnodemap_object *)intern->ptr;
+ objmap = (dom_nnodemap_object *)intern->ptr;
- if (objmap != NULL) {
- if ((objmap->nodetype == XML_NOTATION_NODE) ||
- objmap->nodetype == XML_ENTITY_NODE) {
- if (objmap->ht) {
- if (objmap->nodetype == XML_ENTITY_NODE) {
- itemnode = php_dom_libxml_hash_iter(objmap->ht, index);
- } else {
- itemnode = php_dom_libxml_notation_iter(objmap->ht, index);
- }
+ if (objmap != NULL) {
+ if ((objmap->nodetype == XML_NOTATION_NODE) ||
+ objmap->nodetype == XML_ENTITY_NODE) {
+ if (objmap->ht) {
+ if (objmap->nodetype == XML_ENTITY_NODE) {
+ itemnode = php_dom_libxml_hash_iter(objmap->ht, index);
+ } else {
+ itemnode = php_dom_libxml_notation_iter(objmap->ht, index);
}
- } else {
- nodep = dom_object_get_node(objmap->baseobj);
- if (nodep) {
- curnode = (xmlNodePtr)nodep->properties;
- count = 0;
- while (count < index && curnode != NULL) {
- count++;
- curnode = (xmlNodePtr)curnode->next;
- }
- itemnode = curnode;
+ }
+ } else {
+ nodep = dom_object_get_node(objmap->baseobj);
+ if (nodep) {
+ curnode = (xmlNodePtr)nodep->properties;
+ count = 0;
+ while (count < index && curnode != NULL) {
+ count++;
+ curnode = (xmlNodePtr)curnode->next;
}
+ itemnode = curnode;
}
}
+ }
- if (itemnode) {
- DOM_RET_OBJ(itemnode, &ret, objmap->baseobj);
- return;
- }
+ if (itemnode) {
+ DOM_RET_OBJ(itemnode, &ret, objmap->baseobj);
+ return;
}
RETVAL_NULL();
case XML_TEXT_NODE:
str = "#text";
break;
- default:
- php_error_docref(NULL, E_WARNING, "Invalid Node Type");
+ EMPTY_SWITCH_DEFAULT_CASE();
}
if (str != NULL) {
}
if (child->type == XML_DOCUMENT_FRAG_NODE && child->children == NULL) {
+ /* TODO Drop Warning? */
php_error_docref(NULL, E_WARNING, "Document Fragment is empty");
RETURN_FALSE;
}
}
if (NULL == new_child) {
- php_error_docref(NULL, E_WARNING, "Couldn't add newnode as the previous sibling of refnode");
- RETURN_FALSE;
+ zend_throw_error(NULL, "Cannot add newnode as the previous sibling of refnode");
+ RETURN_THROWS();
}
dom_reconcile_ns(parentp->doc, new_child);
DOM_RET_OBJ(oldchild, &ret, intern);
return;
} else {
- php_dom_throw_error(NOT_FOUND_ERR, dom_get_strict_error(intern->document));
+ php_dom_throw_error(NOT_FOUND_ERR, stricterror);
RETURN_FALSE;
}
}
}
if (child->type == XML_DOCUMENT_FRAG_NODE && child->children == NULL) {
+ /* TODO Drop Warning? */
php_error_docref(NULL, E_WARNING, "Document Fragment is empty");
RETURN_FALSE;
}
if (new_child == NULL) {
new_child = xmlAddChild(nodep, child);
if (new_child == NULL) {
+ // TODO Convert to Error?
php_error_docref(NULL, E_WARNING, "Couldn't append node");
RETURN_FALSE;
}
docp = nodep->doc;
if (! docp) {
- php_error_docref(NULL, E_WARNING, "Node must be associated with a document");
- RETURN_FALSE;
+ zend_throw_error(NULL, "Node must be associated with a document");
+ RETURN_THROWS();
}
if (xpath_array == NULL) {
xmlXPathFreeObject(xpathobjp);
}
xmlXPathFreeContext(ctxp);
- php_error_docref(NULL, E_WARNING, "XPath query did not return a nodeset.");
- RETURN_FALSE;
+ zend_throw_error(NULL, "XPath query did not return a nodeset");
+ RETURN_THROWS();
}
}
} else {
char *xquery;
tmp = zend_hash_str_find(ht, "query", sizeof("query")-1);
- if (tmp && Z_TYPE_P(tmp) == IS_STRING) {
- xquery = Z_STRVAL_P(tmp);
- } else {
- php_error_docref(NULL, E_WARNING, "'query' missing from xpath array or is not a string");
- RETURN_FALSE;
+ if (!tmp) {
+ /* if mode == 0 then $xpath arg is 3, if mode == 1 then $xpath is 4 */
+ zend_argument_value_error(3 + mode, "must have a \"query\" key");
+ RETURN_THROWS();
+ }
+ if (Z_TYPE_P(tmp) != IS_STRING) {
+ /* if mode == 0 then $xpath arg is 3, if mode == 1 then $xpath is 4 */
+ zend_argument_type_error(3 + mode, "\"query\" option must be a string, %s given", zend_zval_type_name(tmp));
+ RETURN_THROWS();
}
+ xquery = Z_STRVAL_P(tmp);
ctxp = xmlXPathNewContext(docp);
ctxp->node = nodep;
xmlXPathFreeObject(xpathobjp);
}
xmlXPathFreeContext(ctxp);
- php_error_docref(NULL, E_WARNING, "XPath query did not return a nodeset.");
- RETURN_FALSE;
+ zend_throw_error(NULL, "XPath query did not return a nodeset");
+ RETURN_THROWS();
}
}
value = (char *) xmlGetNodePath(nodep);
if (value == NULL) {
+ /* TODO Research if can return empty string */
RETURN_NULL();
} else {
RETVAL_STRING(value);
if (obj->prop_handler != NULL) {
hnd = zend_hash_find_ptr(obj->prop_handler, name);
} else if (instanceof_function(obj->std.ce, dom_node_class_entry)) {
- php_error(E_WARNING, "Couldn't fetch %s. Node no longer exists", ZSTR_VAL(obj->std.ce->name));
+ zend_throw_error(NULL, "Couldn't fetch %s. Node no longer exists", ZSTR_VAL(obj->std.ce->name));
+ retval = &EG(uninitialized_zval);
+ return retval;
}
if (hnd) {
if (nodep && nodeobj && (nodep->type == XML_ELEMENT_NODE || nodep->type == XML_ATTRIBUTE_NODE)) {
DOM_RET_OBJ((xmlNodePtr) nodep, &ret, (dom_object *)nodeobj);
} else {
- php_error_docref(NULL, E_WARNING, "Invalid Nodetype to import");
- RETURN_NULL();
+ zend_argument_value_error(1, "is not a valid node type");
+ RETURN_THROWS();
}
}
/* }}} */
break;
}
default:
- php_error_docref(NULL, E_WARNING, "Unsupported node type: %d", obj->type);
+ /* TODO Convert to a ZEND assertion? */
+ zend_throw_error(NULL, "Unsupported node type: %d", obj->type);
ZVAL_NULL(return_value);
return 0;
}
}
#define DOM_NOT_IMPLEMENTED() \
- php_error_docref(NULL, E_WARNING, "Not yet implemented"); \
- return;
+ zend_throw_error(NULL, "Not yet implemented"); \
+ RETURN_THROWS();
#define DOM_NODELIST 0
#define DOM_NAMEDNODEMAP 1
/** @return bool */
public function removeAttribute(string $qualifiedName) {}
- /** @return DOMAttr|false */
+ /** @return void */
public function removeAttributeNS(?string $namespace, string $localName) {}
/** @return DOMAttr|false */
/** @return DOMAttr|bool */
public function setAttribute(string $qualifiedName, string $value) {}
- /** @return bool|null */
+ /** @return void */
public function setAttributeNS(?string $namespace, string $qualifiedName, string $value) {}
/** @return DOMAttr|null|false */
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 8ac9356f9b19b84e98d335bc9d091b022a0f549d */
+ * Stub hash: 128108b08807ce0b125fc7b963bf3c5b77e6987a */
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_dom_import_simplexml, 0, 1, DOMElement, 1)
ZEND_ARG_TYPE_INFO(0, node, IS_OBJECT, 0)
name_valid = xmlValidateName((xmlChar *) name, 0);
if (name_valid != 0) {
php_dom_throw_error(INVALID_CHARACTER_ERR, 1);
- RETURN_FALSE;
+ RETURN_THROWS();
}
nodep = xmlNewPI((xmlChar *) name, (xmlChar *) value);
if (!nodep) {
php_dom_throw_error(INVALID_STATE_ERR, 1);
- RETURN_FALSE;
+ RETURN_THROWS();
}
intern = Z_DOMOBJ_P(ZEND_THIS);
$attr = $root->setAttribute('category', 'books');
$document->removeChild($root);
$root = null;
-var_dump($attr->ownerElement);
+try {
+ var_dump($attr->ownerElement);
+} catch (\Error $e) {
+ echo get_class($e) . ': ' . $e->getMessage() . \PHP_EOL;
+}
?>
---EXPECTF--
-Warning: Couldn't fetch DOMAttr. Node no longer exists in %s on line %d
-
-Warning: Undefined property: DOMAttr::$ownerElement in %s on line %d
-NULL
+--EXPECT--
+Error: Couldn't fetch DOMAttr. Node no longer exists
$dom = new DOMDocument();
$dom->loadXML("<root />");
-$dom->adoptNode($dom->documentElement);
+try {
+ $dom->adoptNode($dom->documentElement);
+} catch (\Error $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
?>
---EXPECTF--
-Warning: DOMDocument::adoptNode(): Not yet implemented in %s
+--EXPECT--
+Not yet implemented
exit;
}
-echo "Empty Encoding Read: {$dom->encoding}\n";
+echo "Empty Encoding Read: '{$dom->encoding}'\n";
-$ret = $dom->encoding = 'NYPHP DOMinatrix';
-echo "Adding invalid encoding: $ret\n";
+try {
+ $ret = $dom->encoding = 'NYPHP DOMinatrix';
+ echo "Adding invalid encoding: $ret\n";
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
$ret = $dom->encoding = 'ISO-8859-1';
echo "Adding ISO-8859-1 encoding: $ret\n";
?>
---EXPECTF--
-Empty Encoding Read:
-
-Warning: main(): Invalid Document Encoding in %s on line %d
-Adding invalid encoding: NYPHP DOMinatrix
+--EXPECT--
+Empty Encoding Read: ''
+Invalid document encoding
Adding ISO-8859-1 encoding: ISO-8859-1
ISO-8859-1 Encoding Read: ISO-8859-1
Adding UTF-8 encoding: UTF-8
var_dump($node->C14NFile($output));
$content = file_get_contents($output);
var_dump($content);
+try {
+ var_dump($node->C14NFile($output, false, false, []));
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
+try {
+ var_dump($node->C14NFile($output, false, false, ['query' => []]));
+} catch (\TypeError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
?>
--CLEAN--
<?php
--EXPECT--
int(34)
string(34) "<title>The Grapes of Wrath</title>"
+DOMNode::C14NFile(): Argument #4 ($xpath) must have a "query" key
+DOMNode::C14NFile(): Argument #4 ($xpath) "query" option must be a string, array given
$doc->loadXML($xml);
$node = $doc->getElementsByTagName('title')->item(0);
var_dump($node->C14N());
+
+try {
+ var_dump($node->C14N(false, false, []));
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
+try {
+ var_dump($node->C14N(false, false, ['query' => []]));
+} catch (\TypeError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
?>
--EXPECT--
string(34) "<title>The Grapes of Wrath</title>"
+DOMNode::C14N(): Argument #3 ($xpath) must have a "query" key
+DOMNode::C14N(): Argument #3 ($xpath) "query" option must be a string, array given
echo $node->nodeName . "\n";
$dom->removeChild($GLOBALS['dom']->firstChild);
echo "nodeType: " . $node->nodeType . "\n";
-
/* Node gets destroyed during removeChild */
$dom->loadXML('<root><child/></root>');
$xpath = new DOMXpath($dom);
echo $node->nodeName . "\n";
$GLOBALS['dom']->removeChild($GLOBALS['dom']->firstChild);
-echo "nodeType: " . $node->nodeType . "\n";
+try {
+ echo "nodeType: " . $node->nodeType . "\n";
+} catch (\Error $e) {
+ echo get_class($e) . ': ' . $e->getMessage() .\PHP_EOL;
+}
?>
---EXPECTF--
+--EXPECT--
root
nodeType: 1
child
-
-Warning: Couldn't fetch DOMElement. Node no longer exists in %sbug36756.php on line %d
-
-Warning: Undefined property: DOMElement::$nodeType in %s on line %d
-nodeType:
+Error: Couldn't fetch DOMElement. Node no longer exists
<?php
$imp = new DOMImplementation;
$dom = $imp->createDocument("", "");
-$dom->encoding = null;
+try {
+ $dom->encoding = null;
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
?>
---EXPECTF--
-Warning: main(): Invalid Document Encoding in %s on line %d
+--EXPECT--
+Invalid document encoding
$avg = $xpath->evaluate('number(php:function("MyAverage", //def:testnode))');
var_dump($avg);
+
+try {
+ $xpath->registerPHPFunctions('non_existent');
+ $avg = $xpath->evaluate('number(php:function("non_existent", //def:testnode))');
+} catch (\Error $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
+try {
+ $xpath->registerPhpFunctions(['non_existant']);
+ $avg = $xpath->evaluate('number(php:function("non_existent", //def:testnode))');
+} catch (\Error $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
?>
--EXPECT--
myval
float(1)
bool(true)
float(4)
+Unable to call handler non_existent()
+Unable to call handler non_existent()
if (!nodep) {
php_dom_throw_error(INVALID_STATE_ERR, 1);
- RETURN_FALSE;
+ RETURN_THROWS();
}
intern = Z_DOMOBJ_P(ZEND_THIS);
}
DOM_GET_OBJ(node, id, xmlNodePtr, intern);
+ if (offset < 0) {
+ zend_argument_value_error(1, "must be greater than or equal to 0");
+ RETURN_THROWS();
+ }
+
if (node->type != XML_TEXT_NODE && node->type != XML_CDATA_SECTION_NODE) {
+ /* TODO Add warning? */
RETURN_FALSE;
}
cur = xmlNodeGetContent(node);
if (cur == NULL) {
+ /* TODO Add warning? */
RETURN_FALSE;
}
length = xmlUTF8Strlen(cur);
- if (ZEND_LONG_INT_OVFL(offset) || (int)offset > length || offset < 0) {
+ if (ZEND_LONG_INT_OVFL(offset) || (int)offset > length) {
+ /* TODO Add warning? */
xmlFree(cur);
RETURN_FALSE;
}
xmlFree(second);
if (nnode == NULL) {
+ /* TODO Add warning? */
RETURN_FALSE;
}
obj = valuePop(ctxt);
if (obj->stringval == NULL) {
- php_error_docref(NULL, E_WARNING, "Handler name must be a string");
+ zend_type_error("Handler name must be a string");
xmlXPathFreeObject(obj);
- if (fci.param_count > 0) {
- for (i = 0; i < nargs - 1; i++) {
- zval_ptr_dtor(&fci.params[i]);
- }
- efree(fci.params);
- }
- return;
+ goto cleanup;
}
ZVAL_STRING(&fci.function_name, (char *) obj->stringval);
xmlXPathFreeObject(obj);
fci.retval = &retval;
if (!zend_make_callable(&fci.function_name, &callable)) {
- php_error_docref(NULL, E_WARNING, "Unable to call handler %s()", ZSTR_VAL(callable));
+ zend_throw_error(NULL, "Unable to call handler %s()", ZSTR_VAL(callable));
+ goto cleanup;
} else if (intern->registerPhpFunctions == 2 && zend_hash_exists(intern->registered_phpfunctions, callable) == 0) {
- php_error_docref(NULL, E_WARNING, "Not allowed to call handler '%s()'.", ZSTR_VAL(callable));
- /* Push an empty string, so that we at least have an xslt result... */
- valuePush(ctxt, xmlXPathNewString((xmlChar *)""));
+ zend_throw_error(NULL, "Not allowed to call handler '%s()'.", ZSTR_VAL(callable));
+ goto cleanup;
} else {
result = zend_call_function(&fci, NULL);
if (result == SUCCESS && Z_TYPE(retval) != IS_UNDEF) {
} else if (Z_TYPE(retval) == IS_FALSE || Z_TYPE(retval) == IS_TRUE) {
valuePush(ctxt, xmlXPathNewBoolean(Z_TYPE(retval) == IS_TRUE));
} else if (Z_TYPE(retval) == IS_OBJECT) {
- php_error_docref(NULL, E_WARNING, "A PHP Object cannot be converted to a XPath-string");
- valuePush(ctxt, xmlXPathNewString((xmlChar *)""));
+ zend_type_error("A PHP Object cannot be converted to a XPath-string");
+ return;
} else {
zend_string *str = zval_get_string(&retval);
valuePush(ctxt, xmlXPathNewString((xmlChar *) ZSTR_VAL(str)));
zval_ptr_dtor(&retval);
}
}
+cleanup:
zend_string_release_ex(callable, 0);
zval_ptr_dtor_str(&fci.function_name);
if (fci.param_count > 0) {
ctx = xmlXPathNewContext(docp);
if (ctx == NULL) {
php_dom_throw_error(INVALID_STATE_ERR, 1);
- RETURN_FALSE;
+ RETURN_THROWS();
}
intern = Z_XPATHOBJ_P(ZEND_THIS);
ctxp = (xmlXPathContextPtr) intern->dom.ptr;
if (ctxp == NULL) {
- php_error_docref(NULL, E_WARNING, "Invalid XPath Context");
- RETURN_FALSE;
+ zend_throw_error(NULL, "Invalid XPath Context");
+ RETURN_THROWS();
}
if (xmlXPathRegisterNs(ctxp, prefix, ns_uri) != 0) {
ctxp = (xmlXPathContextPtr) intern->dom.ptr;
if (ctxp == NULL) {
- php_error_docref(NULL, E_WARNING, "Invalid XPath Context");
- RETURN_FALSE;
+ zend_throw_error(NULL, "Invalid XPath Context");
+ RETURN_THROWS();
}
docp = (xmlDocPtr) ctxp->doc;
}
if (nodep && docp != nodep->doc) {
- php_error_docref(NULL, E_WARNING, "Node From Wrong Document");
- RETURN_FALSE;
+ zend_throw_error(NULL, "Node from wrong document");
+ RETURN_THROWS();
}
ctxp->node = nodep;
}
if (! xpathobjp) {
+ /* TODO Add Warning? */
RETURN_FALSE;
}