mirror of
https://github.com/php/php-src.git
synced 2024-11-27 20:03:40 +08:00
Fixed variance check for abstract constructor during erlay binding
This commit is contained in:
parent
ccbc121cb1
commit
f09d41ffc0
@ -0,0 +1,18 @@
|
||||
--TEST--
|
||||
Variance check for abstract constructor
|
||||
--FILE--
|
||||
<?php
|
||||
class X {
|
||||
}
|
||||
abstract class A {
|
||||
abstract function __construct(X $x);
|
||||
}
|
||||
class B extends A {
|
||||
function __construct(object $x) {}
|
||||
}
|
||||
class C extends B {
|
||||
function __construct(Y $x) {}
|
||||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Could not check compatibility between C::__construct(Y $x) and A::__construct(X $x), because class Y is not available in %s on line %d
|
@ -2395,9 +2395,19 @@ zend_bool zend_can_early_bind(zend_class_entry *ce, zend_class_entry *parent_ce)
|
||||
zval *zv;
|
||||
zend_string *unresolved_class;
|
||||
|
||||
if ((parent_flags & ZEND_ACC_PRIVATE) ||
|
||||
((parent_flags & ZEND_ACC_CTOR) && !(parent_flags & ZEND_ACC_ABSTRACT))) {
|
||||
if (parent_flags & ZEND_ACC_PRIVATE) {
|
||||
continue;
|
||||
} else if (parent_flags & ZEND_ACC_CTOR) {
|
||||
zend_function *proto = parent_func->common.prototype ?
|
||||
parent_func->common.prototype : parent_func;
|
||||
|
||||
/* ctors only have a prototype if is abstract (or comes from an interface) */
|
||||
/* and if that is the case, we want to check inheritance against it */
|
||||
if (proto->common.fn_flags & ZEND_ACC_ABSTRACT) {
|
||||
parent_func = proto;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
zv = zend_hash_find_ex(&ce->function_table, key, 1);
|
||||
|
Loading…
Reference in New Issue
Block a user