]> granicus.if.org Git - php/commitdiff
Don't enforce LSP if prototype method is private
authorPedro Magalhães <pkemo85@gmail.com>
Thu, 30 Jun 2016 07:00:33 +0000 (09:00 +0200)
committerNikita Popov <nikic@php.net>
Tue, 5 Jul 2016 12:30:22 +0000 (14:30 +0200)
Fixes bug #72496.

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

diff --git a/NEWS b/NEWS
index a884dbbbeb79df7fac0ff0ab118db53069bc0a2c..eda6726a8ce4d5db84d8645729e028d86f566de9 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,8 @@ PHP                                                                        NEWS
 - Core:
   . Fix bug #71936 (Segmentation fault destroying HTTP_RAW_POST_DATA).
     (mike dot laspina at gmail dot com, Remi)
+  . Fix bug #72496 (Cannot declare public method with signature incompatible
+    with parent private method). (Pedro Magalhães)
 
 - bz2:
   . Fix bug #72447 (Type Confusion in php_bz2_filter_create()). (gogil at 
diff --git a/Zend/tests/bug72496.phpt b/Zend/tests/bug72496.phpt
new file mode 100644 (file)
index 0000000..62e55cb
--- /dev/null
@@ -0,0 +1,43 @@
+--TEST--
+Bug #72496 (declare public method with signature incompatible with parent private method should not throw a warning)
+--FILE--
+<?php
+class Foo
+{
+    private function getFoo()
+    {
+        return 'Foo';
+    }
+
+    private function getBar()
+    {
+        return 'Bar';
+    }
+
+    private function getBaz()
+    {
+        return 'Baz';
+    }
+}
+
+class Bar extends Foo
+{
+    public function getFoo($extraArgument)
+    {
+        return $extraArgument;
+    }
+
+    protected function getBar($extraArgument)
+    {
+        return $extraArgument;
+    }
+
+    private function getBaz($extraArgument)
+    {
+        return $extraArgument;
+    }
+}
+
+echo "OK\n";
+--EXPECT--
+OK
index ef152a38f1be1761008a84a3cc9a1e2d5018a5c0..5b67ef8295e51510a296c075eb26f50065c58606 100644 (file)
@@ -3252,8 +3252,8 @@ static zend_bool zend_do_perform_implementation_check(const zend_function *fe, c
                return 1;
        }
 
-       /* If both methods are private do not enforce a signature */
-    if ((fe->common.fn_flags & ZEND_ACC_PRIVATE) && (proto->common.fn_flags & ZEND_ACC_PRIVATE)) {
+       /* If the prototype method is private do not enforce a signature */
+       if (proto->common.fn_flags & ZEND_ACC_PRIVATE) {
                return 1;
        }