Skip to content

Commit

Permalink
Merge branch 'PHP-8.4'
Browse files Browse the repository at this point in the history
* PHP-8.4:
  Revert 746b1cf "Access long value directly for call to count() in simplexml"
  • Loading branch information
nielsdos committed Dec 29, 2024
2 parents b00c72c + 9eaee68 commit 8120c79
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ext/simplexml/simplexml.c
Original file line number Diff line number Diff line change
Expand Up @@ -1928,8 +1928,9 @@ static zend_result sxe_count_elements(zend_object *object, zend_long *count) /*
zval rv;
zend_call_method_with_0_params(object, intern->zo.ce, &intern->fptr_count, "count", &rv);
if (!Z_ISUNDEF(rv)) {
ZEND_ASSERT(Z_TYPE(rv) == IS_LONG);
*count = Z_LVAL(rv);
/* TODO: change this to Z_LVAL_P() once the tentative type on count() is gone. */
*count = zval_get_long(&rv);
zval_ptr_dtor(&rv);
return SUCCESS;
}
return FAILURE;
Expand Down
20 changes: 20 additions & 0 deletions ext/simplexml/tests/count_return_type_will_change.phpt
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 8120c79

Please sign in to comment.