summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjellyNoone <jelly.legend@gmail.com>2020-12-14 23:03:12 +0100
committerNikita Popov <nikita.ppv@gmail.com>2020-12-15 10:04:39 +0100
commitc1e977f1bbd29bffc2404d96acc1dd7773aeea4a (patch)
treef8f65d3eed9e1e086921d020bd8a64a4a39a5c8b
parentf9942b061d980113193930b4e22b1e95bbec1c38 (diff)
downloadphp-git-c1e977f1bbd29bffc2404d96acc1dd7773aeea4a.tar.gz
Add more tests that document late static binding
Closes GH-6515.
-rw-r--r--Zend/tests/lsb_023.phpt26
-rw-r--r--Zend/tests/lsb_024.phpt25
2 files changed, 51 insertions, 0 deletions
diff --git a/Zend/tests/lsb_023.phpt b/Zend/tests/lsb_023.phpt
new file mode 100644
index 0000000000..a8051aa85f
--- /dev/null
+++ b/Zend/tests/lsb_023.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Late Static Binding static:: calls protected / public method of child class even then
+the method is private in parent class
+--FILE--
+<?php
+class A {
+ public static function out() {
+ echo static::value(), PHP_EOL;
+ }
+
+ private static function value() { return 'A'; }
+}
+class B extends A {
+ protected static function value() { return 'B'; }
+}
+class C extends A {
+ public static function value() { return 'C'; }
+}
+A::out();
+B::out();
+C::out();
+echo PHP_EOL;
+--EXPECT--
+A
+B
+C
diff --git a/Zend/tests/lsb_024.phpt b/Zend/tests/lsb_024.phpt
new file mode 100644
index 0000000000..2c71c678d3
--- /dev/null
+++ b/Zend/tests/lsb_024.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Late Static Binding static:: accesses protected / public static variables of child
+class when the variable is private in parent class
+--FILE--
+<?php
+class A {
+ private static $value = 'A';
+
+ public static function out() {
+ echo static::$value, PHP_EOL;
+ }
+}
+class B extends A {
+ protected static $value = 'B';
+}
+class C extends A {
+ public static $value = 'C';
+}
+A::out();
+B::out();
+C::out();
+--EXPECT--
+A
+B
+C