helly           Sat Feb  2 21:02:08 2008 UTC

  Modified files:              
    /php-src/ext/spl/examples   class_tree.php 
  Log:
  - Show interfaces
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/examples/class_tree.php?r1=1.7&r2=1.8&diff_format=u
Index: php-src/ext/spl/examples/class_tree.php
diff -u php-src/ext/spl/examples/class_tree.php:1.7 
php-src/ext/spl/examples/class_tree.php:1.8
--- php-src/ext/spl/examples/class_tree.php:1.7 Tue Feb 21 23:21:53 2006
+++ php-src/ext/spl/examples/class_tree.php     Sat Feb  2 21:02:08 2008
@@ -4,7 +4,7 @@
  * @brief   Class Tree example
  * @ingroup Examples
  * @author  Marcus Boerger
- * @date    2003 - 2006
+ * @date    2003 - 2008
  * @version 1.1
  *
  * Usage: php class_tree.php \<class\>
@@ -76,12 +76,29 @@
                }
                $this->uksort('strnatcasecmp');
        }
-       
+
        /** @return key() since that is the name we need
         */
        function current()
        {
-               return parent::key();
+               $result = parent::key();
+               $parent = get_parent_class($result);
+               if ($parent)
+               {
+                       $interfaces = array_diff(class_implements($result), 
class_implements($parent));
+                       if ($interfaces)
+                       {
+                               $implements = array();
+                               foreach($interfaces as $interface)
+                               {
+                                       $implements = array_merge($implements, 
class_implements($interface));
+                               }
+                               $interfaces = array_diff($interfaces, 
$implements);
+                               natcasesort($interfaces);
+                               $result .= ' (' . join(', ', $interfaces) . ')';
+                       }
+               }
+               return $result;
        }
 }
 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to