Merge branch 'PHP-7.0'

* PHP-7.0:
  Fixed bug #71248 (Wrong interface is enforced)
  Update NEWS
This commit is contained in:
Dmitry Stogov 2016-01-13 11:42:50 +03:00
commit d47285648c
2 changed files with 42 additions and 1 deletions

28
Zend/tests/bug71248.phpt Normal file
View 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

View File

@ -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;
}