mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Fix copying of functions in variance obligations
Only copy sizeof(zend_internal_function) for internal functions.
This commit is contained in:
parent
a73f98eda9
commit
68596ed71e
2 changed files with 23 additions and 2 deletions
12
Zend/tests/type_declarations/variance/internal_parent.phpt
Normal file
12
Zend/tests/type_declarations/variance/internal_parent.phpt
Normal file
|
@ -0,0 +1,12 @@
|
|||
--TEST--
|
||||
Internal class as parent
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
class Test extends DateTime {
|
||||
public static function createFromFormat($format, $time, Wrong $timezone = null) { }
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: Could not check compatibility between Test::createFromFormat($format, $time, ?Wrong $timezone = NULL) and DateTime::createFromFormat($format, $time, ?DateTimeZone $object = NULL), because class Wrong is not available in %s on line %d
|
|
@ -2294,8 +2294,17 @@ static void add_compatibility_obligation(
|
|||
HashTable *obligations = get_or_init_obligations_for_class(ce);
|
||||
variance_obligation *obligation = emalloc(sizeof(variance_obligation));
|
||||
obligation->type = OBLIGATION_COMPATIBILITY;
|
||||
obligation->child_fn = *child_fn;
|
||||
obligation->parent_fn = *parent_fn;
|
||||
/* Copy functions, because they may be stack-allocated in the case of traits. */
|
||||
if (child_fn->common.type == ZEND_INTERNAL_FUNCTION) {
|
||||
memcpy(&obligation->child_fn, child_fn, sizeof(zend_internal_function));
|
||||
} else {
|
||||
memcpy(&obligation->child_fn, child_fn, sizeof(zend_op_array));
|
||||
}
|
||||
if (parent_fn->common.type == ZEND_INTERNAL_FUNCTION) {
|
||||
memcpy(&obligation->parent_fn, parent_fn, sizeof(zend_internal_function));
|
||||
} else {
|
||||
memcpy(&obligation->parent_fn, parent_fn, sizeof(zend_op_array));
|
||||
}
|
||||
obligation->always_error = always_error;
|
||||
zend_hash_next_index_insert_ptr(obligations, obligation);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue