]> granicus.if.org Git - php/commitdiff
MFH: Allow implementation of abstract methods with optional parameters (Christian
authorJohannes Schlüter <johannes@php.net>
Sat, 1 Mar 2008 13:53:32 +0000 (13:53 +0000)
committerJohannes Schlüter <johannes@php.net>
Sat, 1 Mar 2008 13:53:32 +0000 (13:53 +0000)
  Schneider)

Zend/tests/022.phpt [new file with mode: 0644]
Zend/zend_compile.c

diff --git a/Zend/tests/022.phpt b/Zend/tests/022.phpt
new file mode 100644 (file)
index 0000000..1226e27
--- /dev/null
@@ -0,0 +1,24 @@
+--TEST--
+Implementating abstracting methods and optional parameters
+--FILE--
+<?php
+
+abstract class Base
+{
+       abstract function someMethod($param);
+}
+
+class Ext extends Base
+{
+       function someMethod($param = "default")
+       {
+               echo $param, "\n";
+       }
+}
+
+$a = new Ext();
+$a->someMethod("foo");
+$a->someMethod();
+--EXPECT--
+foo
+default
index 18082c60bbce3bd4a7e5724cee618edc090e5767..f8b380388dffc55720c6e769010a8221f22ff785 100644 (file)
@@ -2283,7 +2283,7 @@ static zend_bool zend_do_perform_implementation_check(zend_function *fe, zend_fu
        }
 
        /* check number of arguments */
-       if (proto->common.required_num_args != fe->common.required_num_args
+       if (proto->common.required_num_args < fe->common.required_num_args
                || proto->common.num_args > fe->common.num_args) {
                return 0;
        }