summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Pena <felipe@php.net>2010-06-26 22:05:13 +0000
committerFelipe Pena <felipe@php.net>2010-06-26 22:05:13 +0000
commitdcb44b5ed7876e39b86b7ce7e9a80176ba4bfb30 (patch)
treedb983b17827acd8fbd6fc7e1d5e8040dadf6d226
parent2cd05f85795403b4dcb8babbd10408534dc1a690 (diff)
downloadphp-git-dcb44b5ed7876e39b86b7ce7e9a80176ba4bfb30.tar.gz
- Fixed bug #51421 (Abstract __construct constructor argument list not enforced)
-rw-r--r--Zend/tests/bug51421.phpt18
-rw-r--r--Zend/zend_compile.c13
2 files changed, 28 insertions, 3 deletions
diff --git a/Zend/tests/bug51421.phpt b/Zend/tests/bug51421.phpt
new file mode 100644
index 0000000000..825012a289
--- /dev/null
+++ b/Zend/tests/bug51421.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Bug #51421 (Abstract __construct constructor argument list not enforced)
+--FILE--
+<?php
+
+class ExampleClass {}
+
+abstract class TestInterface {
+ abstract public function __construct(ExampleClass $var);
+}
+
+class Test extends TestInterface {
+ public function __construct() {}
+}
+
+?>
+--EXPECTF--
+Fatal error: Declaration of Test::__construct() must be compatible with that of TestInterface::__construct() in %s on line %d
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 71bc0a6f39..22d91afbdb 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -2009,13 +2009,20 @@ static zend_bool zend_do_perform_implementation_check(zend_function *fe, zend_fu
{
zend_uint i;
- /* If it's a user function then arg_info == NULL means we don't have any parameters but we still need to do the arg number checks. We are only willing to ignore this for internal functions because extensions don't always define arg_info. */
+ /* If it's a user function then arg_info == NULL means we don't have any parameters but
+ * we still need to do the arg number checks. We are only willing to ignore this for internal
+ * functions because extensions don't always define arg_info.
+ */
if (!proto || (!proto->common.arg_info && proto->common.type != ZEND_USER_FUNCTION)) {
return 1;
}
- /* Checks for constructors only if they are declared in an interface */
- if ((fe->common.fn_flags & ZEND_ACC_CTOR) && !(proto->common.scope->ce_flags & ZEND_ACC_INTERFACE)) {
+ /* Checks for constructors only if they are declared in an interface,
+ * or explicitly marked as abstract
+ */
+ if ((fe->common.fn_flags & ZEND_ACC_CTOR)
+ && ((proto->common.scope->ce_flags & ZEND_ACC_INTERFACE) == 0
+ && (proto->common.fn_flags & ZEND_ACC_ABSTRACT) == 0)) {
return 1;
}