Ruby-style mixins in PHP

screenshot

This is a rather hackish way to accomplish something resembling ruby’s mixins, I doubt it we will ever be able to do this as elegantly as in ruby. This is the closest I can come to true mixins, without using ext/runkit. <?php class TargetTest { var $prepend = "Printing: %s\n"; static $__mixins__ = array(); function __call($func, $args) { if ($function = @self::$__mixins__[$func]) { array_unshift($args, $this); return call_user_func_array($function, $args); } } function print_int($integer) { printf(...

http://loveandtheft.org/2008/03/22/php-style-mixins/

symfonyでもmixinは実装されている http://www.symfony-project.org/book/1_0/17-Extending-Symfony

http://b.hatena.ne.jp/entry/http://loveandtheft.org/2008/03/22/php-style-mixins/