mirror of
https://github.com/php/php-src.git
synced 2025-01-23 04:04:16 +08:00
Merge branch 'PHP-7.0'
* PHP-7.0: Fixed bug #71248 (Wrong interface is enforced) Update NEWS
This commit is contained in:
commit
d47285648c
28
Zend/tests/bug71248.phpt
Normal file
28
Zend/tests/bug71248.phpt
Normal file
@ -0,0 +1,28 @@
|
||||
--TEST--
|
||||
Bug #71248 (Wrong interface is enforced)
|
||||
--FILE--
|
||||
<?php
|
||||
class Hint1 { }
|
||||
class Hint2 { }
|
||||
|
||||
abstract class Base {
|
||||
public function __construct(Hint1 $x) { }
|
||||
}
|
||||
|
||||
interface Iface {
|
||||
public function __construct(Hint1 $x);
|
||||
}
|
||||
|
||||
class Foo extends Base implements Iface {
|
||||
}
|
||||
|
||||
$code = <<<'PHP'
|
||||
abstract class Bar extends Base {
|
||||
public function __construct(Hint2 $x) { }
|
||||
}
|
||||
PHP;
|
||||
eval($code);
|
||||
?>
|
||||
OK
|
||||
--EXPECT--
|
||||
OK
|
@ -585,7 +585,20 @@ static zend_function *do_inherit_method(zend_string *key, zend_function *parent,
|
||||
zval *child = zend_hash_find(&ce->function_table, key);
|
||||
|
||||
if (child) {
|
||||
do_inheritance_check_on_method((zend_function*)Z_PTR_P(child), parent);
|
||||
zend_function *func = (zend_function*)Z_PTR_P(child);
|
||||
zend_function *orig_prototype = func->common.prototype;
|
||||
|
||||
do_inheritance_check_on_method(func, parent);
|
||||
if (func->common.prototype != orig_prototype &&
|
||||
func->type == ZEND_USER_FUNCTION &&
|
||||
func->common.scope != ce &&
|
||||
!func->op_array.static_variables) {
|
||||
/* Lazy duplication */
|
||||
zend_function *new_function = zend_arena_alloc(&CG(arena), sizeof(zend_op_array));
|
||||
memcpy(new_function, func, sizeof(zend_op_array));
|
||||
Z_PTR_P(child) = new_function;
|
||||
func->common.prototype = orig_prototype;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user