Skip to content

Commit 442fa31

Browse files
committed
Merge branch 'PHP-8.0'
* PHP-8.0: Fix bug #80537
2 parents 4c5e47d + 27e2508 commit 442fa31

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

Zend/zend_execute.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,17 @@ static zend_bool zend_verify_weak_scalar_type_hint(uint32_t type_mask, zval *arg
763763
}
764764

765765
#if ZEND_DEBUG
766+
static bool can_convert_to_string(zval *zv) {
767+
/* We don't call cast_object here, because this check must be side-effect free. As this
768+
* is only used for a sanity check of arginfo/zpp consistency, it's okay if we accept
769+
* more than actually allowed here. */
770+
if (Z_TYPE_P(zv) == IS_OBJECT) {
771+
return Z_OBJ_HT_P(zv)->cast_object != zend_std_cast_object_tostring
772+
|| Z_OBJCE_P(zv)->__tostring;
773+
}
774+
return Z_TYPE_P(zv) <= IS_STRING;
775+
}
776+
766777
/* Used to sanity-check internal arginfo types without performing any actual type conversions. */
767778
static zend_bool zend_verify_weak_scalar_type_hint_no_sideeffect(uint32_t type_mask, zval *arg)
768779
{
@@ -776,10 +787,7 @@ static zend_bool zend_verify_weak_scalar_type_hint_no_sideeffect(uint32_t type_m
776787
if ((type_mask & MAY_BE_DOUBLE) && zend_parse_arg_double_weak(arg, &dval)) {
777788
return 1;
778789
}
779-
/* We don't call cast_object here, because this check must be side-effect free. As this
780-
* is only used for a sanity check of arginfo/zpp consistency, it's okay if we accept
781-
* more than actually allowed here. */
782-
if ((type_mask & MAY_BE_STRING) && (Z_TYPE_P(arg) < IS_STRING || Z_TYPE_P(arg) == IS_OBJECT)) {
790+
if ((type_mask & MAY_BE_STRING) && can_convert_to_string(arg)) {
783791
return 1;
784792
}
785793
if ((type_mask & MAY_BE_BOOL) == MAY_BE_BOOL && zend_parse_arg_bool_weak(arg, &bval)) {

ext/dom/php_dom.stub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public function removeAttribute(string $qualifiedName) {}
205205
public function removeAttributeNS(?string $namespace, string $localName) {}
206206

207207
/** @return DOMAttr|false */
208-
public function removeAttributeNode(string $qualifiedName) {}
208+
public function removeAttributeNode(DOMAttr $attr) {}
209209

210210
/** @return DOMAttr|bool */
211211
public function setAttribute(string $qualifiedName, string $value) {}

ext/dom/php_dom_arginfo.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 128108b08807ce0b125fc7b963bf3c5b77e6987a */
2+
* Stub hash: 3cf19e361d130ab881091f38e1c354d81f17d967 */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_dom_import_simplexml, 0, 1, DOMElement, 1)
55
ZEND_ARG_TYPE_INFO(0, node, IS_OBJECT, 0)
@@ -197,7 +197,9 @@ ZEND_END_ARG_INFO()
197197

198198
#define arginfo_class_DOMElement_removeAttributeNS arginfo_class_DOMElement_getAttributeNS
199199

200-
#define arginfo_class_DOMElement_removeAttributeNode arginfo_class_DOMElement_getAttribute
200+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DOMElement_removeAttributeNode, 0, 0, 1)
201+
ZEND_ARG_OBJ_INFO(0, attr, DOMAttr, 0)
202+
ZEND_END_ARG_INFO()
201203

202204
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DOMElement_setAttribute, 0, 0, 2)
203205
ZEND_ARG_TYPE_INFO(0, qualifiedName, IS_STRING, 0)
@@ -210,11 +212,9 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DOMElement_setAttributeNS, 0, 0, 3)
210212
ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0)
211213
ZEND_END_ARG_INFO()
212214

213-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DOMElement_setAttributeNode, 0, 0, 1)
214-
ZEND_ARG_OBJ_INFO(0, attr, DOMAttr, 0)
215-
ZEND_END_ARG_INFO()
215+
#define arginfo_class_DOMElement_setAttributeNode arginfo_class_DOMElement_removeAttributeNode
216216

217-
#define arginfo_class_DOMElement_setAttributeNodeNS arginfo_class_DOMElement_setAttributeNode
217+
#define arginfo_class_DOMElement_setAttributeNodeNS arginfo_class_DOMElement_removeAttributeNode
218218

219219
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DOMElement_setIdAttribute, 0, 0, 2)
220220
ZEND_ARG_TYPE_INFO(0, qualifiedName, IS_STRING, 0)

0 commit comments

Comments
 (0)