]> granicus.if.org Git - php/commitdiff
Add additional protected visibility prototype test
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 28 Mar 2019 09:14:14 +0000 (10:14 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 28 Mar 2019 09:14:58 +0000 (10:14 +0100)
See https://github.com/php/php-src/pull/3993 for context.

Zend/tests/grandparent_prototype.phpt [new file with mode: 0644]

diff --git a/Zend/tests/grandparent_prototype.phpt b/Zend/tests/grandparent_prototype.phpt
new file mode 100644 (file)
index 0000000..8729696
--- /dev/null
@@ -0,0 +1,26 @@
+--TEST--
+Protected visibility test case with a grandparent prototype
+--FILE--
+<?php
+
+class A {
+    protected function test() {}
+}
+class B extends A {
+    public function test2($x) {
+        $x->test(); // Uncaught Error: Call to protected method D::test() from context 'B'
+    }
+}
+class C extends A {
+    protected function test() {}
+}
+class D extends C {
+    protected function test() {
+        echo "Hello World!\n";
+    }
+}
+(new B)->test2(new D);
+
+?>
+--EXPECT--
+Hello World!