Selaa lähdekoodia

No need for elseif with returns :)

/cc @keradus
Justin Hileman 11 vuotta sitten
vanhempi
sitoutus
c0bd7efe39
2 muutettua tiedostoa jossa 11 lisäystä ja 5 poistoa
  1. 5 3
      src/Mustache/Compiler.php
  2. 6 2
      src/Mustache/Context.php

+ 5 - 3
src/Mustache/Compiler.php

@@ -631,11 +631,13 @@ class Mustache_Compiler
     {
         if ($id === '.') {
             return 'last';
-        } elseif (strpos($id, '.') === false) {
+        }
+
+        if (strpos($id, '.') === false) {
             return 'find';
-        } else {
-            return 'findDot';
         }
+
+        return 'findDot';
     }
 
     const IS_CALLABLE        = '!is_string(%s) && is_callable(%s)';

+ 6 - 2
src/Mustache/Context.php

@@ -181,9 +181,13 @@ class Mustache_Context
                         // See https://github.com/bobthecow/mustache.php/wiki/Magic-Methods
                         if (method_exists($frame, $id)) {
                             return $frame->$id();
-                        } elseif (isset($frame->$id)) {
+                        }
+
+                        if (isset($frame->$id)) {
                             return $frame->$id;
-                        } elseif ($frame instanceof ArrayAccess && isset($frame[$id])) {
+                        }
+
+                        if ($frame instanceof ArrayAccess && isset($frame[$id])) {
                             return $frame[$id];
                         }
                     }