diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2019-03-27 18:11:00 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-03-27 18:11:00 +0100 |
commit | 73a59eff52e92b1c8ede73df3de3eb602f65f14f (patch) | |
tree | 0be5cad110a38969a2a65ca2cae8cc5d241bc35d | |
parent | 6d71d983dac4557653f935efebdff843d5bea891 (diff) | |
parent | 058554810649da431efa3ab851be17b0d2f96fb8 (diff) | |
download | php-git-73a59eff52e92b1c8ede73df3de3eb602f65f14f.tar.gz |
Merge branch 'PHP-7.4'
-rw-r--r-- | Zend/tests/bug61970_2.phpt | 2 | ||||
-rw-r--r-- | Zend/tests/constructor_abstract_grantparent.phpt | 18 | ||||
-rw-r--r-- | Zend/zend_inheritance.c | 8 |
3 files changed, 23 insertions, 5 deletions
diff --git a/Zend/tests/bug61970_2.phpt b/Zend/tests/bug61970_2.phpt index 3e4b5222be..403ba7510a 100644 --- a/Zend/tests/bug61970_2.phpt +++ b/Zend/tests/bug61970_2.phpt @@ -15,4 +15,4 @@ class Baz extends Bar { protected function __construct(){} } --EXPECTF-- -Fatal error: Access level to Baz::__construct() must be public (as in class Bar) in %s on line 12 +Fatal error: Access level to Baz::__construct() must be public (as in class Foo) in %s on line 12 diff --git a/Zend/tests/constructor_abstract_grantparent.phpt b/Zend/tests/constructor_abstract_grantparent.phpt new file mode 100644 index 0000000000..b813c4c1f7 --- /dev/null +++ b/Zend/tests/constructor_abstract_grantparent.phpt @@ -0,0 +1,18 @@ +--TEST-- +LSP checks are performed against an abstract constructor even if it is not a direct parent +--FILE-- +<?php + +abstract class A { + abstract function __construct(X $x); +} +class B extends A { + function __construct(X $x) {} +} +class C extends B { + function __construct() {} +} + +?> +--EXPECTF-- +Fatal error: Declaration of C::__construct() must be compatible with A::__construct(X $x) in %s on line 10 diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index 9626434f05..a4e437f271 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -597,11 +597,11 @@ static void do_inheritance_check_on_method(zend_function *child, zend_function * proto = parent; } } else if (proto) { - if (proto->common.scope->ce_flags & ZEND_ACC_INTERFACE) { - /* ctors only have a prototype if it comes from an interface */ - /* and if that is the case, we want to check inheritance against it */ + /* 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 = proto; - } else if (!(proto->common.fn_flags & ZEND_ACC_ABSTRACT)) { + } else { break; } } else { |