From 40bf33e78380e6bf13fe78697d2d358cff4006ea Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 29 Aug 2013 12:08:54 +0200 Subject: [PATCH] Signature is valid if there are less args --- Zend/tests/argument_restriction_001.phpt | 2 +- Zend/tests/argument_restriction_002.phpt | 2 +- Zend/tests/argument_restriction_003.phpt | 2 +- Zend/tests/argument_restriction_005.phpt | 2 +- Zend/tests/bug47981.phpt | 2 +- Zend/tests/bug51421.phpt | 2 +- Zend/tests/bug64988.phpt | 2 +- Zend/tests/traits/bug60153.phpt | 4 ++-- Zend/tests/traits/bug60217b.phpt | 4 ++-- Zend/tests/traits/bug60217c.phpt | 4 ++-- Zend/zend_compile.c | 9 +++++---- ext/standard/tests/filters/php_user_filter_01.phpt | 3 ++- tests/classes/ctor_in_interface_02.phpt | 6 +++--- tests/classes/inheritance_003.phpt | 2 -- tests/classes/method_override_optional_arg_001.phpt | 1 - tests/classes/method_override_optional_arg_002.phpt | 1 - 16 files changed, 23 insertions(+), 25 deletions(-) diff --git a/Zend/tests/argument_restriction_001.phpt b/Zend/tests/argument_restriction_001.phpt index e62ad300c97b..2db819a45c20 100644 --- a/Zend/tests/argument_restriction_001.phpt +++ b/Zend/tests/argument_restriction_001.phpt @@ -8,7 +8,7 @@ Class Base { } class Sub extends Base { - public function &test() { + public function &test(array $bar) { } } ?> diff --git a/Zend/tests/argument_restriction_002.phpt b/Zend/tests/argument_restriction_002.phpt index c6a472e0f566..0af4298a83f9 100644 --- a/Zend/tests/argument_restriction_002.phpt +++ b/Zend/tests/argument_restriction_002.phpt @@ -8,7 +8,7 @@ Abstract Class Base { } class Sub extends Base { - public function test($foo, array &$bar) { + public function test($foo, array $bar) { } } ?> diff --git a/Zend/tests/argument_restriction_003.phpt b/Zend/tests/argument_restriction_003.phpt index 393581fcfccf..691f432f8ca7 100644 --- a/Zend/tests/argument_restriction_003.phpt +++ b/Zend/tests/argument_restriction_003.phpt @@ -11,7 +11,7 @@ Abstract Class Base { } class Sub extends Base { - public function test() { + public function test(Bar $foo) { } } ?> diff --git a/Zend/tests/argument_restriction_005.phpt b/Zend/tests/argument_restriction_005.phpt index 2826fe6a81f6..150de0a1c6c5 100644 --- a/Zend/tests/argument_restriction_005.phpt +++ b/Zend/tests/argument_restriction_005.phpt @@ -3,7 +3,7 @@ Bug #55719 (Argument restriction should come with a more specific error message) --FILE-- diff --git a/Zend/tests/bug47981.phpt b/Zend/tests/bug47981.phpt index c0fd69abf948..e814d8e451a5 100644 --- a/Zend/tests/bug47981.phpt +++ b/Zend/tests/bug47981.phpt @@ -11,7 +11,7 @@ set_error_handler("errh"); interface a{} class b implements a { function f($a=1) {}} -class c extends b {function f() {}} +class c extends b {function f($a) {}} ?> --EXPECTF-- string(60) "Declaration of c::f() should be compatible with b::f($a = 1)" diff --git a/Zend/tests/bug51421.phpt b/Zend/tests/bug51421.phpt index bc1758c30080..a22de7dcde58 100644 --- a/Zend/tests/bug51421.phpt +++ b/Zend/tests/bug51421.phpt @@ -10,7 +10,7 @@ abstract class TestInterface { } class Test extends TestInterface { - public function __construct() {} + public function __construct(OtherClass $var) {} } ?> diff --git a/Zend/tests/bug64988.phpt b/Zend/tests/bug64988.phpt index 34fd482f384e..e0e9606b2525 100644 --- a/Zend/tests/bug64988.phpt +++ b/Zend/tests/bug64988.phpt @@ -17,7 +17,7 @@ class Noisy1 extends Base1 { } } class Smooth1 extends Noisy1 { - public function insert(array $data) { + public function insert(array $data, $option1) { return parent::insert($data, count($data)); } } diff --git a/Zend/tests/traits/bug60153.phpt b/Zend/tests/traits/bug60153.phpt index 979eced1fb27..4470c0653036 100644 --- a/Zend/tests/traits/bug60153.phpt +++ b/Zend/tests/traits/bug60153.phpt @@ -8,7 +8,7 @@ interface IFoo { } trait TFoo { - public function oneArgument() {} + public function oneArgument($a, $b) {} } class C implements IFoo { @@ -16,4 +16,4 @@ class C implements IFoo { } --EXPECTF-- -Fatal error: Declaration of TFoo::oneArgument() must be compatible with IFoo::oneArgument($a) in %s on line %d +Fatal error: Declaration of TFoo::oneArgument($a, $b) must be compatible with IFoo::oneArgument($a) in %s on line %d diff --git a/Zend/tests/traits/bug60217b.phpt b/Zend/tests/traits/bug60217b.phpt index eb852a4fb43c..23c2a6cd2af1 100644 --- a/Zend/tests/traits/bug60217b.phpt +++ b/Zend/tests/traits/bug60217b.phpt @@ -8,7 +8,7 @@ trait TBroken1 { } trait TBroken2 { - public abstract function foo($a, $b = 0); + public abstract function foo($a, $b); } class CBroken { @@ -23,4 +23,4 @@ $o = new CBroken; $o->foo(1); --EXPECTF-- -Fatal error: Declaration of TBroken2::foo($a, $b = 0) must be compatible with TBroken1::foo($a) in %s on line %d +Fatal error: Declaration of TBroken2::foo($a, $b) must be compatible with TBroken1::foo($a) in %s on line %d diff --git a/Zend/tests/traits/bug60217c.phpt b/Zend/tests/traits/bug60217c.phpt index baa4314a61ad..7bba3f5045a7 100644 --- a/Zend/tests/traits/bug60217c.phpt +++ b/Zend/tests/traits/bug60217c.phpt @@ -4,7 +4,7 @@ Bug #60217 (Requiring the same method from different traits and abstract methods foo(1); --EXPECTF-- -Fatal error: Declaration of TBroken2::foo($a) must be compatible with TBroken1::foo($a, $b = 0) in %s on line %d +Fatal error: Declaration of TBroken2::foo($a) must be compatible with TBroken1::foo($a, $b) in %s on line %d diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index f250b2be2087..f8f80e3391a3 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -3115,7 +3115,7 @@ static void do_inherit_method(zend_function *function) /* {{{ */ static zend_bool zend_do_perform_implementation_check(const zend_function *fe, const zend_function *proto TSRMLS_DC) /* {{{ */ { - zend_uint i; + zend_uint i, num_args; /* 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 @@ -3140,8 +3140,7 @@ static zend_bool zend_do_perform_implementation_check(const zend_function *fe, c } /* check number of arguments */ - if (proto->common.required_num_args < fe->common.required_num_args - || proto->common.num_args > fe->common.num_args) { + if (proto->common.required_num_args < fe->common.required_num_args) { return 0; } @@ -3157,7 +3156,9 @@ static zend_bool zend_do_perform_implementation_check(const zend_function *fe, c return 0; } - for (i=0; i < proto->common.num_args; i++) { + num_args = MIN(proto->common.num_args, fe->common.num_args); + + for (i = 0; i < num_args; i++) { if (ZEND_LOG_XOR(fe->common.arg_info[i].class_name, proto->common.arg_info[i].class_name)) { /* Only one has a type hint and the other one doesn't */ return 0; diff --git a/ext/standard/tests/filters/php_user_filter_01.phpt b/ext/standard/tests/filters/php_user_filter_01.phpt index e4a9c6853cdf..db806329a2bd 100644 --- a/ext/standard/tests/filters/php_user_filter_01.phpt +++ b/ext/standard/tests/filters/php_user_filter_01.phpt @@ -13,5 +13,6 @@ class bar extends php_user_filter { function onClose() {} } ?> +===DONE=== --EXPECTF-- -Strict Standards: Declaration of bar::filter() should be compatible with php_user_filter::filter($in, $out, &$consumed, $closing) in %s on line %d +===DONE=== diff --git a/tests/classes/ctor_in_interface_02.phpt b/tests/classes/ctor_in_interface_02.phpt index 08e6f36e0e68..e2a6d87295d8 100644 --- a/tests/classes/ctor_in_interface_02.phpt +++ b/tests/classes/ctor_in_interface_02.phpt @@ -4,7 +4,7 @@ ZE2 A class constructor must keep the signature of all interfaces ===DONE=== --EXPECTF-- - -Strict Standards: Declaration of B::f() should be compatible with A::f($x) in %sinheritance_003.php on line %d ===DONE=== diff --git a/tests/classes/method_override_optional_arg_001.phpt b/tests/classes/method_override_optional_arg_001.phpt index 333c29d12890..5136681389b4 100644 --- a/tests/classes/method_override_optional_arg_001.phpt +++ b/tests/classes/method_override_optional_arg_001.phpt @@ -28,6 +28,5 @@ $b->foo(1); ?> --EXPECTF-- -Strict Standards: Declaration of C::foo() should be compatible with A::foo($arg1 = 1) in %s on line %d int(1) int(3) diff --git a/tests/classes/method_override_optional_arg_002.phpt b/tests/classes/method_override_optional_arg_002.phpt index 669a8ca83669..16973a923013 100644 --- a/tests/classes/method_override_optional_arg_002.phpt +++ b/tests/classes/method_override_optional_arg_002.phpt @@ -18,5 +18,4 @@ $b->foo(); ?> --EXPECTF-- -Strict Standards: Declaration of B::foo() should be compatible with A::foo($arg = 1) in %s on line %d foo