File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / Zend / tests / traits / flattening001.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue May 29 12:34:36 2012 UTC (12 years, 11 months ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17p0, v5_4_17, HEAD
php 5.4.3+patches

--TEST--
Methods using object properties
--FILE--
<?php
error_reporting(E_ALL);

trait T1 {
  public function getText() {
    return $this->text;
  }
}

trait T2 {
  public function setTextT2($val) {
    $this->text = $val;
  }
}

class TraitsTest {
  use T1;
  use T2;
  private $text = 'test';
  public function setText($val) {
    $this->text = $val;
  }
}

$o = new TraitsTest();
var_dump($o->getText());

$o->setText('foo');

var_dump($o->getText());

$o->setText('bar');

var_dump($o->getText());
?>
--EXPECTF--	
string(4) "test"
string(3) "foo"
string(3) "bar"

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