Minor clean up.

Change-Id: I64b9519aed56d8ae4f7d6b42e94acf60a9c386ea
diff --git a/classes/Project.class.php b/classes/Project.class.php
index f3f39c0..522398a 100644
--- a/classes/Project.class.php
+++ b/classes/Project.class.php
@@ -252,12 +252,12 @@
     ));
   }
 
-  public static function visit($function, $pre, $post) {
-    $pre(null);
+  public static function visit($callable, $pre = null, $post = null) {
+    if ($pre) call_user_func($pre);
     foreach (self::getTopLevelProjects() as $project) {
-      $project->visitHierarchy($function, $pre, $post, 0);
+      $project->visitHierarchy($callable, $pre, $post, 0);
     }
-    $post(null);
+    if ($post) call_user_func($post);
   }
 
   private static function getProjects($conditions) {
@@ -420,13 +420,13 @@
     return Forge::getForgeForProjectId($this->getId());
   }
 
-  public function visitHierarchy($function, $pre, $post, $level) {
-    $function($this, $level);
-    $pre($this);
+  public function visitHierarchy($function, $pre = null, $post = null, $level) {
+    call_user_func($function, $this, $level);
+    if ($pre) call_user_func($pre, $this);
     foreach ($this->getChildren() as $child) {
       $child->visitHierarchy($function, $pre, $post, $level + 1);
     }
-    $post($this);
+    if ($post) call_user_func($post, $this);
   }
 
   /**