svn: /web/presentations/trunk/slides/intro/ php54_imc.xml

From: Date: Sun, 06 Nov 2011 17:58:55 +0000
Subject: svn: /web/presentations/trunk/slides/intro/ php54_imc.xml
Groups: php.pres 
Request: Send a blank email to pres+get-1764@lists.php.net to get a copy of this message
rasmus Sun, 06 Nov 2011 17:58:55 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=318848 Log: Instance Method Call slide Changed paths: A web/presentations/trunk/slides/intro/php54_imc.xml Added: web/presentations/trunk/slides/intro/php54_imc.xml =================================================================== --- web/presentations/trunk/slides/intro/php54_imc.xml (rev 0) +++ web/presentations/trunk/slides/intro/php54_imc.xml 2011-11-06 17:58:55 UTC (rev 318848) @@ -0,0 +1,54 @@ +<slide title="IMC"> + +<blurb fontsize="4em">Instance Method Call</blurb> +<example fontsize="2em" result="0" title=""><![CDATA[<?php +class foo { + public $x = 1; + + public function getX() { + return $this->x; + } + public function setX($val) { + $this->x = $val; + return $this; + } +} + +$X = (new foo)->setX(20)->getX(); +echo $X; // 20 +]]></example> + +<break lines="1"/> + +<blurb fontsize="4em">Combine with Function Array Dereferencing</blurb> +<example fontsize="2em" result="0" title=""><![CDATA[<?php +class foo2 { + public $x = []; + + public function getX() { + return $this->x; + } + public function setX($arr) { + $this->x = $arr; + return $this; + } +} + +$X = (new foo2)->setX([0,10,20,30])->getX()[2]; +echo $X; // 20 +]]></example> + +<break lines="1"/> + +<blurb fontsize="4em">Instance Method Array Dereferencing</blurb> +<example fontsize="2em" result='0' title=""><![CDATA[<?php +class foo extends ArrayObject { + public function __construct($arr) { + parent::__construct($arr); + } +} + +echo (new foo( [1, [4, 5], 3] ))[1][0]; // 4 +]]></example> + +</slide>

« previous php.pres (#1764) next »