1
0
mirror of https://github.com/php/php-src.git synced 2026-04-28 02:33:17 +02:00

- Fixed bug #51421 (Abstract __construct constructor argument list not enforced)

This commit is contained in:
Felipe Pena
2010-06-26 22:05:13 +00:00
parent d98de7d248
commit cb6bf19bfa
2 changed files with 28 additions and 3 deletions
+18
View File
@@ -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
+10 -3
View File
@@ -2909,13 +2909,20 @@ static zend_bool zend_do_perform_implementation_check(const zend_function *fe, c
{
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;
}