Annotation of embedaddon/php/Zend/tests/closure_037.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Closure 037: self:: and static:: within closures
                      3: --FILE--
                      4: <?php
                      5: class A {
                      6:        private $x = 0;
                      7: 
                      8:        function getClosure () {
                      9:                        return function () {
                     10:                                $this->x++;
                     11:                                self::printX();
                     12:                                self::print42();
                     13:                                static::print42();
                     14:                        };
                     15:        }
                     16: 
                     17:        function printX () {
                     18:                echo $this->x."\n";
                     19:        }
                     20: 
                     21:        function print42() {
                     22:                echo "42\n";
                     23:        }
                     24: }
                     25: 
                     26: class B extends A {
                     27:        function print42() {
                     28:                echo "forty two\n";
                     29:        }
                     30: }
                     31: 
                     32: $a = new A;
                     33: $closure = $a->getClosure();
                     34: $closure();
                     35: $b = new B;
                     36: $closure = $b->getClosure();
                     37: $closure();
                     38: ?>
                     39: Done.
                     40: --EXPECTF--
                     41: 1
                     42: 42
                     43: 42
                     44: 1
                     45: 42
                     46: forty two
                     47: Done.

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>