]> granicus.if.org Git - php/commitdiff
add test for self:: and static::
authorStanislav Malyshev <stas@php.net>
Tue, 20 Apr 2010 19:46:30 +0000 (19:46 +0000)
committerStanislav Malyshev <stas@php.net>
Tue, 20 Apr 2010 19:46:30 +0000 (19:46 +0000)
Zend/tests/closure_037.phpt [new file with mode: 0755]

diff --git a/Zend/tests/closure_037.phpt b/Zend/tests/closure_037.phpt
new file mode 100755 (executable)
index 0000000..4b24c85
--- /dev/null
@@ -0,0 +1,47 @@
+--TEST--
+Closure 037: self:: and static:: within closures
+--FILE--
+<?php
+class A {
+       private $x = 0;
+
+       function getClosure () {
+                       return function () {
+                               $this->x++;
+                               self::printX();
+                               self::print42();
+                               static::print42();
+                       };
+       }
+
+       function printX () {
+               echo $this->x."\n";
+       }
+
+       function print42() {
+               echo "42\n";
+       }
+}
+
+class B extends A {
+       function print42() {
+               echo "forty two\n";
+       }
+}
+
+$a = new A;
+$closure = $a->getClosure();
+$closure();
+$b = new B;
+$closure = $b->getClosure();
+$closure();
+?>
+Done.
+--EXPECTF--
+1
+42
+42
+1
+42
+forty two
+Done.
\ No newline at end of file