mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Merge branch 'PHP-8.3'
* PHP-8.3: Fix GH-14183: XMLReader::open() can't be overridden
This commit is contained in:
@@ -162,12 +162,17 @@ zval *xmlreader_write_property(zend_object *object, zend_string *name, zval *val
|
||||
/* {{{ */
|
||||
static zend_function *xmlreader_get_method(zend_object **obj, zend_string *name, const zval *key)
|
||||
{
|
||||
if (zend_string_equals_literal_ci(name, "open")) {
|
||||
return (zend_function*)&xmlreader_open_fn;
|
||||
} else if (zend_string_equals_literal_ci(name, "xml")) {
|
||||
return (zend_function*)&xmlreader_xml_fn;
|
||||
zend_function *method = zend_std_get_method(obj, name, key);
|
||||
if (method && (method->common.fn_flags & ZEND_ACC_STATIC) && method->common.type == ZEND_INTERNAL_FUNCTION) {
|
||||
/* There are only two static internal methods and they both have overrides. */
|
||||
if (ZSTR_LEN(name) == sizeof("xml") - 1) {
|
||||
return (zend_function *) &xmlreader_xml_fn;
|
||||
} else {
|
||||
ZEND_ASSERT(ZSTR_LEN(name) == sizeof("open") - 1);
|
||||
return (zend_function *) &xmlreader_open_fn;
|
||||
}
|
||||
}
|
||||
return zend_std_get_method(obj, name, key);
|
||||
return method;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
24
ext/xmlreader/tests/gh14183.phpt
Normal file
24
ext/xmlreader/tests/gh14183.phpt
Normal file
@@ -0,0 +1,24 @@
|
||||
--TEST--
|
||||
GH-14183 (XMLReader::open() can't be overridden)
|
||||
--EXTENSIONS--
|
||||
xmlreader
|
||||
--FILE--
|
||||
<?php
|
||||
class MyXMLReader extends XMLReader
|
||||
{
|
||||
public static function open(string $uri, string $encoding = null, int $flags = 0): bool|\XMLReader
|
||||
{
|
||||
echo 'overridden', PHP_EOL;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
var_dump(MyXMLReader::open('asdf'));
|
||||
$o = new MyXMLReader;
|
||||
var_dump($o->open('asdf'));
|
||||
?>
|
||||
--EXPECT--
|
||||
overridden
|
||||
bool(true)
|
||||
overridden
|
||||
bool(true)
|
||||
Reference in New Issue
Block a user