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

1.1       misho       1: --TEST--
                      2: Statics work like expected for language-based copy'n'paste. No link between methods from the same trait.
                      3: --FILE--
                      4: <?php
                      5: error_reporting(E_ALL);
                      6: 
                      7: trait Counter {
                      8:    public function inc() {
                      9:      static $c = 0;
                     10:      $c = $c + 1;
                     11:      echo "$c\n";
                     12:    }
                     13: }
                     14: 
                     15: 
                     16: class C1 {
                     17:    use Counter;
                     18: }
                     19: 
                     20: class C2 {
                     21:    use Counter;
                     22: }
                     23: 
                     24: $o = new C1();
                     25: $o->inc();
                     26: $o->inc();
                     27: 
                     28: $p = new C2();
                     29: $p->inc();
                     30: $p->inc();
                     31: 
                     32: ?>
                     33: --EXPECTF--    
                     34: 1
                     35: 2
                     36: 1
                     37: 2

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