Merge branch 'PHP-8.4'

* PHP-8.4:
  Revert 746b1cf4 "Access long value directly for call to count() in simplexml"
This commit is contained in:
Niels Dossche 2024-12-29 14:38:06 +01:00
commit 8120c7988a
No known key found for this signature in database
GPG key ID: B8A8AD166DF0E2E5
2 changed files with 23 additions and 2 deletions

View file

@ -1928,8 +1928,9 @@ static zend_result sxe_count_elements(zend_object *object, zend_long *count) /*
zval rv; zval rv;
zend_call_method_with_0_params(object, intern->zo.ce, &intern->fptr_count, "count", &rv); zend_call_method_with_0_params(object, intern->zo.ce, &intern->fptr_count, "count", &rv);
if (!Z_ISUNDEF(rv)) { if (!Z_ISUNDEF(rv)) {
ZEND_ASSERT(Z_TYPE(rv) == IS_LONG); /* TODO: change this to Z_LVAL_P() once the tentative type on count() is gone. */
*count = Z_LVAL(rv); *count = zval_get_long(&rv);
zval_ptr_dtor(&rv);
return SUCCESS; return SUCCESS;
} }
return FAILURE; return FAILURE;

View file

@ -0,0 +1,20 @@
--TEST--
SimpleXMLElement::count() interaction with ReturnTypeWillChange
--EXTENSIONS--
simplexml
--FILE--
<?php
class CustomClass extends SimpleXMLElement {
#[\ReturnTypeWillChange]
public function count(): string {
return "3";
}
}
$sxe = simplexml_load_string("<root/>", CustomClass::class);
var_dump(count($sxe));
?>
--EXPECT--
int(3)