Get the content of the ressource
Return a result depending on the type of the resource
@param mixed $arg The possible argument(s) of the method to call
@return mixed
336239
public function content($arg=null)
	{
		switch($this->format)
		{
			case 'json':
				if(!isset($arg))
				{
					$arg = false;
				}
				return $this->json($arg);
				break;
			case 'xml' :
				if(!isset($arg))
				{
					$arg = 'dom';
				}
				return $this->xml($arg);
				break;
			default :
				return $this->getContent();
				break;
		}
	}
574098
protected static function _formatCalledArgument($arg)
        {
            $out = '';
            if (is_object($arg)) {
                $out .= sprintf("&%s#%s#", get_class($arg), spl_object_hash($arg));

            } else if (is_resource($arg)) {
                $out .= '#[' . get_resource_type($arg) . ']';
            } else if (Arrays::isArray($arg)) {
                $isAssociative = false;
                $args = array();
                foreach ($arg as $k => $v) {
                    if (!is_numeric($k)) {
                        $isAssociative = true;
                    }
                    $args[$k] = static::_formatCalledArgument($v);
                }
                if ($isAssociative) {
                    $arr = array();
                    foreach ($args as $k => $v) {
                        $arr[] = static::_formatCalledArgument($k) . ' => ' . $v;
                    }
                    $out .= 'array(' . join(', ', $arr) . ')';
                } else {
                    $out .= 'array(' . join(', ', $args) . ')';
                }
            } else if (is_null($arg)) {
                $out .= 'NULL';
            } else if (is_numeric($arg) || is_float($arg)) {
                $out .= $arg;
            } else if (is_string($arg)) {
                if (strlen($arg) > static::$argLength) {
                    $arg = substr($arg, 0, static::$argLength) . "...";
                }
                $arg = strtr($arg, array("\t" => '\t', "\r" => '\r', "\n" => '\n', "'" => '\\\''));
                $out .= "'" . $arg . "'";
            } else if (is_bool($arg)) {
                $out .= $arg === true ? 'true' : 'false';
            }

            return $out;
        }
96751
public static function getArgs($args)
    {
        $out = [];
        $last_arg = null;

        for ($i = 1, $il = sizeof($args); $i < $il; ++$i) {
            if (preg_match('~^--(.+)~', $args[$i], $match)) {
                $parts = explode('=', $match[1]);
                $key = preg_replace('~[^a-z0-9]+~', '', $parts[0]);

                if (isset($parts[1])) {
                    $out[$key] = $parts[1];
                } else {
                    $out[$key] = true;
                }

                $last_arg = $key;
            } elseif (preg_match('~^-([a-zA-Z0-9]+)~', $args[$i], $match)) {
                $key = null;
                for ($j = 0, $jl = mb_orig_strlen($match[1]); $j < $jl; ++$j) {
                    $key = $match[1]{$j};
                    $out[$key] = true;
                }

                $last_arg = $key;
            } elseif ($last_arg !== null) {
                $out[$last_arg] = $args[$i];
            }
        }

        return $out;
    }
810601
public function get(array $args)
    {
        if (count($args) === 0) {
            return $this->store;
        } elseif (isset($this->store[$args[0]]) === true) {
            return $this->store[$args[0]];
        } else {
            return null;
        }
    }
861008
function raw($arg) {
        $fw=Base::instance();
        return $fw->recursive($arg,
            function($val) use($fw) {
                return is_string($val)?$fw->decode($val):$val;
            }
        );
    }
590437
public function get_check( $arg ) {
		$item = $this->get( $arg );

		if ( ! $item ) {
			\WP_CLI::error( sprintf( $this->msg, $arg ) );
		}

		return $item;
	}
317638
private function parseArgs(array $args) : string
    {
        if (!is_array($args)) return false;
        $components = array();
        if (count($args) == 1 && is_string($args[0])) {
            $components['src'] = $args[0];
            return $this->makeLink($components);
        } elseif (count($args) == 1 && is_array($args)) {
            $components = $args[0];
            return $this->makeLink($components);
        } elseif (count($args) == 2 && is_string($args[0]) && is_array($args[1])) {
            $args[1]['src'] = $args[0];
            $components = $args[1];
            return $this->makeLink($components);
        } elseif (count($args) == 2 && is_string($args[0]) && is_string($args[1])) {
            return '<script type="'.$args[1].'">'."\n".$args[0]."\n</script>\n";
        }
        Core::i()->log->warning('Unable to interpret script. Not added.');
        return false;
    }
1131429
public static function getResourceParser($resource)
    {
        if(self::$_resourceLoader) {
            $type = preg_replace("/[^A-Za-z0-9_]/", " ", get_resource_type($resource));
            $type = str_replace(" ","", ucwords($type));
            return self::$_resourceLoader->load($type);
        }
        return false;
    }
296821
private function getArgumentResource()
    {
        $name = $this->argument('resource');
        if (str_contains($name, '/')) {
            $name = str_replace('/', '.', $name);
        }

        if (str_contains($name, '\\')) {
            $name = str_replace('\\', '.', $name);
        }

        // lowecase and singular
        $name = strtolower(str_singular($name));

        return $name;
    }
1216577
function getRequestToken($args = array()) {/*{{{*/
    $r = $this->oAuthRequest($this->requestTokenURL(), $args);
    $token = $this->oAuthParseResponse($r);
    $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
    return $token;
  }
1080527
public static function get($args, $lang = null)
    {
        $lang = !is_null($lang) ? $lang : self::getLanguage();
        $args = is_array($args) ? $args : [$args, null];

        $text = $args[0];
        //unset($args[0]);

        $hash = md5($text);

        if (count(self::$translations) == 0) {
            if (file_exists(self::getFilePath())) {
                $json = file_get_contents(self::getFilePath());
                self::$translations = json_decode($json, true);
            }
        }

        if (isset(self::$translations[$hash])
            && isset(self::$translations[$hash][$lang])
        ) {
            if (!empty(self::$translations[$hash][$lang])) {
                $args[0] = self::$translations[$hash][$lang];
                return call_user_func_array('sprintf', $args);
            }
        } else {
            self::$translations[$hash]['origin'] = $text;
            foreach (self::getAvailableLanguages() as $language) {
                if (!isset(self::$translations[$hash][$language])) {
                    self::$translations[$hash][$language] = '';
                }
            }
            $json = json_encode(
                self::$translations,
                JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE
            );
            file_put_contents(self::getFilePath(), $json);
            self::$translations = json_decode($json, true);
        }

        return call_user_func_array('sprintf', $args);
    }
464588
public function find($args = null)
    {
        $this->areArgumentsValid($args, ['getProgress', 'showTaskLists', 'showTasks']);

        return $this->client->get("$this->endpoint/$this->id", $args)->response();
    }
266660
private function _get_value($args){
    if ( $this->id ){
      $var =& $this->data;
      foreach ( $args as $a ){
        if ( !isset($var[$a]) ){
          return null;
        }
        $var =& $var[$a];
      }
      return $var;
    }
  }
333652
function get($args)
    {
        $cache = $this->get_cache();
        $data  = $cache->read($args['id']);

        if ($data !== null && $data !== false) {
            $args['data'] = base64_decode($data);
            $args['status'] = true;
        }
        else {
            $args['status'] = false;
        }

        return $args;
    }
214888
public function download($req, $res, $args)
    {
        $repoList = Container::get('remote')->getExtensionsInfoList();
        // not care about indexes, simple retrieve twice
        // get category
        $category = Utils::recursiveArraySearch($args['name'], $repoList);
        // get plugin
        $plugKey = Utils::recursiveArraySearch($args['name'], $repoList[$category]);
        $plug = $repoList[$category][$plugKey];

        return View::setPageInfo([
            'admin_console' => true,
            'active_page' => 'admin',
//            'key' => $args['name'],
            'package' => $plug['package'],
            'stability' => $plug['stability'],
            'category' => $category,
            'pluginInfo' => base64_encode(json_encode($plug)),
            'title' => [Utils::escape(ForumSettings::get('o_board_title')), __('Admin'), __('Extension')],
        ])->display('@forum/misc/modal', false);
/*
        $zipFile = ForumEnv::get('FORUM_ROOT') . 'plugins' . DIRECTORY_SEPARATOR .
$args['name'] . "-" . $args['version'] . '.zip';
        $zipResource = fopen($zipFile, "w");

        // Get the zip file straight from GitHub
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, 'https://codeload.github.com/featherbb/' . $args['name'] .
'/zip/' . $args['version']);
        curl_setopt($ch, CURLOPT_FAILONERROR, true);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_AUTOREFERER, true);
        curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
        curl_setopt($ch, CURLOPT_TIMEOUT, 10);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($ch, CURLOPT_FILE, $zipResource);
        $page = curl_exec($ch);
        curl_close($ch);
        fclose($zipResource);

        if (!$page) {
            unlink(ForumEnv::get('FORUM_ROOT') . 'plugins' . DIRECTORY_SEPARATOR . $args['name'] .
"-" . $args['version'] . '.zip');
            throw new  RunBBException(__('Bad request'), 400);
        }

        $zip = new ZipArchive;

        if ($zip->open($zipFile) != true) {
            throw new  RunBBException(__('Bad request'), 400);
        }

        $zip->extractTo(ForumEnv::get('FORUM_ROOT') . 'plugins');
        $zip->close();

        if (file_exists(ForumEnv::get('FORUM_ROOT') . 'plugins' . DIRECTORY_SEPARATOR . $args['name'])) {
            AdminUtils::deleteFolder(ForumEnv::get('FORUM_ROOT') . 'plugins' . DIRECTORY_SEPARATOR . $args['name']);
        }
        rename(ForumEnv::get('FORUM_ROOT') . 'plugins' . DIRECTORY_SEPARATOR . $args['name'] .
"-" . $args['version'], ForumEnv::get('FORUM_ROOT') . 'plugins' . DIRECTORY_SEPARATOR . $args['name']);
        unlink(ForumEnv::get('FORUM_ROOT') . 'plugins' . DIRECTORY_SEPARATOR . $args['name'] .
"-" . $args['version'] . '.zip');

        return Router::redirect(Router::pathFor('adminPlugins'), 'Plugin downloaded!');
*/
    }
334991
protected function processArgumentNull(Element $arg) {
		$definition = new stdClass();
		
		$definition->type  = 'value';
		$definition->value = null;
		
		return $definition;
	}
720602
protected function _backtrace_formatArgsHelper($arg) {
        $value = $arg;
        if (is_object($arg)) {
            $value = sprintf('OBJECT(%s)', get_class($arg));
        } elseif (is_resource($arg)) {
            $value = 'RESOURCE';
        } elseif (is_array($arg)) {
            $value = 'ARRAY[%s](%s)';
            $c = array();
            foreach ($arg as $k => $v) {
                $c[] = sprintf('%s => %s', $k,
                    $this->_backtrace_formatArgsHelper($v));
            }
            $value = sprintf($value, count($arg), implode(', ', $c));
        } elseif (is_string($arg)) {
            $value = sprintf('\'%s\'', $arg);
        } elseif (is_bool($arg)) {
            $value = $arg ? 'TRUE' : 'FALSE';
        } elseif (is_null($arg)) {
            $value = 'NULL';
        }
        return $value;
    }