private function findVariableInStack($id, array $stack)
    {
        for ($i = count($stack) - 1; $i >= 0; $i--) {
            $frame = &$stack[$i];

            switch (gettype($frame)) {
                case 'object':
                    if (!($frame instanceof Closure)) {
                        // Note that is_callable() *will not work here*
                        // See https://github.com/bobthecow/mustache.php/wiki/Magic-Methods
                        if (method_exists($frame, $id)) {
                            return $frame->$id();
                        }

                        if (isset($frame->$id)) {
                            return $frame->$id;
                        }

                        if ($frame instanceof ArrayAccess && isset($frame[$id])) {
                            return $frame[$id];
                        }
                    }
                    break;

                case 'array':
                    if (array_key_exists($id, $frame)) {
                        return $frame[$id];
                    }
                    break;
            }
        }

        return '';
    }
private function findVariableInStack($id, array $stack)
    {
        for ($i = count($stack) - 1; $i >= 0; $i--) {
            $frame = &$stack[$i];

            switch (gettype($frame)) {
                case 'object':
                    if (!($frame instanceof Closure)) {
                        // Note that is_callable() *will not work here*
                        // See https://github.com/bobthecow/mustache.php/wiki/Magic-Methods
                        if (method_exists($frame, $id)) {
                            return $frame->$id();
                        }

                        if (isset($frame->$id)) {
                            return $frame->$id;
                        }

                        if ($frame instanceof ArrayAccess && isset($frame[$id])) {
                            return $frame[$id];
                        }
                    }
                    break;

                case 'array':
                    if (array_key_exists($id, $frame)) {
                        return $frame[$id];
                    }
                    break;
            }
        }

        return '';
    }
private function findVariableInStack ( $ id , array $ stack ) { for ( $ i = count ( $ stack ) - 1 ; $ i >= 0 ; $ i -- ) { $ frame = & $ stack [ $ i ] ; switch ( gettype ( $ frame ) ) { case 'object' : if ( ! ( $ frame instanceof Closure ) ) { // Note that is_callable() *will not work here* // See https://github.com/bobthecow/mustache.php/wiki/Magic-Methods if ( method_exists ( $ frame , $ id ) ) { return $ frame -> $ id ( ) ; } if ( isset ( $ frame -> $ id ) ) { return $ frame -> $ id ; } if ( $ frame instanceof ArrayAccess && isset ( $ frame [ $ id ] ) ) { return $ frame [ $ id ] ; } } break ; case 'array' : if ( array_key_exists ( $ id , $ frame ) ) { return $ frame [ $ id ] ; } break ; } } return '' ; }
Helper function to find a variable in the Context stack.

@see Mustache_Context::find

@param string $id    Variable name
@param array  $stack Context stack

@return mixed Variable value, or '' if not found
Helper function to find a variable in the Context stack .