rfc:mixin

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
rfc:mixin [2008/09/10 00:15] – created jbondcrfc:mixin [2017/09/22 13:28] (current) – external edit 127.0.0.1
Line 12: Line 12:
 For a good summary and detailed research on the advantages, see: For a good summary and detailed research on the advantages, see:
  
-[[http://www.slideshare.net/gron/traits-a-new-language-feature-for-php?src=embed]]+[[http://www.slideshare.net/gron/traits-a-new-language-feature-for-php?src=embed|Presentation on Traits]]
  
-[[http://wiki.php.net/rfc/traits?s[]=trait]]+[[rfc/traits|Traits RFC]]
  
-More background about mixins here: +More background about [[http://en.wikipedia.org/wiki/Mixin|mixins on Wikipedia]].
-[[http://en.wikipedia.org/wiki/Mixin]]+
  
 This proposal only introduces 1 keyword 'mixin' and the function class_mixin().  This proposal only introduces 1 keyword 'mixin' and the function class_mixin(). 
Line 82: Line 81:
     echo "called";     echo "called";
  
-    // mixin::save(); would call eventSave->save()+    // mixin::save(); would call eventSave::save()
    }    }
 } }
  
 $s = new  shoppingCart2; $s = new  shoppingCart2;
-$s->save(); // calls shoppingCart2->save(); "called"+$s->save(); // calls shoppingCart2::save(); "called"
  
 </code> </code>
Line 103: Line 102:
    function getAddressBilling()    function getAddressBilling()
    {    {
-      // implement...+      echo "mixin address";
    }    }
  
Line 123: Line 122:
    }    }
 } }
 +
 +class Company_Rogers extends Company_Telecom {
 +
 +   function getAddressBilling()
 +   {
 +      echo parent::getAddressBilling(); // "I stay the same"
 +      echo mixin::getAddressBilling(); // "mixin address"
 +   }
 +
 +   function getAccount()
 +   
 +      echo "different";
 +   }
 +}
 +
 </code> </code>
  
Line 152: Line 166:
 The default php.ini would contain ~: The default php.ini would contain ~:
  
-mixin.security = true # default and CANNOT be changed using set_ini()+mixin.security = true # default and CANNOT be changed using ini_set()
  
 <code php> <code php>
-class_mixin('PHPUnit_Framework_Assert', 'MY_Assert_Methods'); // throws an E_FATAL Error+class_mixin('PHPUnit_Framework_Assert', 'MY_Assert_Methods'); // throws an E_ERROR
 </code> </code>
  
Line 176: Line 190:
 ===== Notes ===== ===== Notes =====
  
-There was interesting paper in the ACM (2006) about "intuitive OO design" available here: +There was an [[http://edu.technion.ac.il/Faculty/uril/Papers/Hadar_Leron_Intuitive_OOD.pdf|interesting paper]] in the ACM (2006) about "intuitive OO design".
-[[http://edu.technion.ac.il/Faculty/uril/Papers/Hadar_Leron_Intuitive_OOD.pdf]]+
  
 The goal here is to keep OO intuitive and allow for multiple inheritance "PHP style".   The goal here is to keep OO intuitive and allow for multiple inheritance "PHP style".  
rfc/mixin.1221005741.txt.gz · Last modified: 2017/09/22 13:28 (external edit)