--- /dev/null
+--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
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);