summaryrefslogtreecommitdiff
path: root/Zend/RFCs
diff options
context:
space:
mode:
authorSebastian Bergmann <sebastian@php.net>2002-06-06 21:13:39 +0000
committerSebastian Bergmann <sebastian@php.net>2002-06-06 21:13:39 +0000
commitb0d61f9bd305af5735313d670a50b2461f4da751 (patch)
treead3f771719b381c8971ad9ed7e54d375bba355f8 /Zend/RFCs
parent8a65d5d3cb2623de1a43ad1090e0f333fbb0da61 (diff)
downloadphp-git-b0d61f9bd305af5735313d670a50b2461f4da751.tar.gz
Add RFC on delegation.
Diffstat (limited to 'Zend/RFCs')
-rw-r--r--Zend/RFCs/004.txt76
1 files changed, 76 insertions, 0 deletions
diff --git a/Zend/RFCs/004.txt b/Zend/RFCs/004.txt
new file mode 100644
index 0000000000..6d973698ef
--- /dev/null
+++ b/Zend/RFCs/004.txt
@@ -0,0 +1,76 @@
+Title: Delegation
+ (a/k/a. Object-Based Inheritance)
+Version: $Revision$
+Status: draft
+Maintainer: Sebastian Bergmann <sb@sebastian-bergmann.de>
+
+
+Dynamic Delegation
+
+ Syntax / Example
+
+ <?php
+ class aDelegatee {
+ function doSomething() {
+ echo 'hubu';
+ }
+ }
+
+ class anotherDelegatee {
+ function doSomething() {
+ echo 'tubu';
+ }
+ }
+
+ class Foo {
+ delegatee $bar;
+
+ function setDelegatee($delegatee) {
+ $this->delegatee = $delegatee;
+ }
+ }
+
+ $foo = new Foo;
+
+ $foo->setDelegatee(new aDelegatee);
+ $foo->doSomething(); /* prints "hubu" */
+
+ $foo->setDelegatee(new anotherDelegatee);
+ $foo->doSomething(); /* prints "tubu" */
+ ?>
+
+ Semantics / Synopsis
+
+ The "Foo" class may use all methods available in "$bar" as if they
+ where locally defined or inherited from a superclass. The essential
+ difference is that by assigning another object to "$bar" it is
+ possible to dynamically switch between different implementations for
+ these methods.
+
+
+Fixed Delegation
+
+ Syntax / Example
+
+ <?php
+ class aDelegatee {
+ function doSomething() {
+ echo 'hubu';
+ }
+ }
+
+ class Foo {
+ final delegatee $bar = new aDelegatee;
+ }
+
+ $foo = new Foo;
+
+ $foo->doSomething(); /* prints "hubu" */
+ ?>
+
+ Semantics / Synopsis
+
+ The "Foo" class may use all methods available in "$bar" as if they
+ where locally defined or inherited from a superclass. The difference
+ to the dynamic delegation is that once the delegatee object is set,
+ it cannot be changed.