Example #1
0
/**
 *
 * @param string $function_name The user function name, as a string.
 * @return Returns TRUE if function_name  exists and is a function, FALSE otherwise.
 */
function wpi_user_func_exists($function_name = 'do_action')
{
    $func = get_defined_functions();
    $user_func = array_flip($func['user']);
    unset($func);
    return isset($user_func[$function_name]);
}
/**
 * @param $strTestFile         - the file to check for test-cases
 * @param $arrDefinedFunctions - all user-definied functions until now
 * @param $intParentPID        - the process-pid of the parent
 * 
 * @throw \Exception - if first parameter is not a string
 * @throw \Exception - if given file is not a file nor readable
 * @throw \Exception - if given parent-id is not an integer
 *
 * create a closure for execution in a fork. it will: 
 * - include the given test-file
 * - find test-cases definied in test-file
 * - send list of test-cases to queue
 * - send SIGTERM to parent id and exit
 *
 **/
function getTestCaseClosure($strTestFile, array $arrDefinedFunctions, $intParentPID)
{
    if (!is_string($strTestFile)) {
        throw new \Exception("first given parameter is not a string");
    }
    if (!is_file($strTestFile) || !is_readable($strTestFile)) {
        throw new \Exception("given file is not a file or not readable: {$strTestFile}");
    }
    if (!is_int($intParentPID)) {
        throw new \Exception("third given parameter is not an integer");
    }
    return function () use($strTestFile, $arrDefinedFunctions, $intParentPID) {
        include $strTestFile;
        # get test-cases
        $arrAllFunctions = get_defined_functions();
        $arrUserFunctions = $arrAllFunctions['user'];
        $arrDefinedFunctions = array_diff($arrUserFunctions, $arrDefinedFunctions);
        $arrTestCases = array();
        foreach ($arrDefinedFunctions as $strFunction) {
            if (fnmatch('aphpunit\\testcases\\test*', $strFunction, FNM_NOESCAPE)) {
                $arrTestCases[] = $strFunction;
            }
        }
        # collect all information in this structure
        $arrMsgContent = array('file' => $strTestFile, 'functions' => $arrTestCases);
        # send the result to the queue
        $objQueue = new \SimpleIPC(QUEUE_IDENTIFIER);
        $objQueue->send(serialize($arrMsgContent));
        # kill thread after sending parent a SIGTERM
        posix_kill($intParentPID, SIGTERM);
        exit;
    };
}
Example #3
0
/**
* Lists help
* Read the doc blocks for all commands, and then
* outputs a list of commands along with thier doc
* blocks.  
* @command list_commands
*/
function pestle_cli($argv)
{
    includeAllModuleFiles();
    $user = get_defined_functions()['user'];
    $executes = array_filter($user, function ($function) {
        $parts = explode('\\', $function);
        $function = array_pop($parts);
        return strpos($function, 'pestle_cli') === 0;
    });
    $commands = array_map(function ($function) {
        $r = new ReflectionFunction($function);
        $command = getAtCommandFromDocComment($r);
        return ['command' => $command, 'help' => getDocCommentAsString($r->getName())];
        // $function = str_replace('execute_', '', $function);
        // $parts = explode('\\', $function);
        // return array_pop($parts);
        // return $function;
    }, $executes);
    $command_to_check = array_shift($argv);
    if ($command_to_check) {
        $commands = array_filter($commands, function ($s) use($command_to_check) {
            return $s['command'] === $command_to_check;
        });
    }
    output('');
    foreach ($commands as $command) {
        output("Name");
        output("    ", $command['command']);
        output('');
        output("Description");
        output(preg_replace('%^%m', '    $0', wordwrap($command['help'], 70)));
        output('');
        output('');
    }
}
 /**
  * check syntax of the code that is used in eval()
  * @access  public
  * @param   $code
  * @return  true: correct syntax; 
  *          false: wrong syntax
  * @author  Cindy Qi Li
  */
 public static function validateSecurity($code)
 {
     global $msg;
     // php functions can not be called in the code
     $called_php_func = '';
     $php_funcs = get_defined_functions();
     foreach ($php_funcs as $php_section) {
         foreach ($php_section as $php_func) {
             if (preg_match('/' . preg_quote($php_func) . '\\s*\\(/i', $code)) {
                 $called_php_func .= $php_func . '(), ';
             }
         }
     }
     if ($called_php_func != '') {
         $msg->addError(array('NO_PHP_FUNC', substr($called_php_func, 0, -2)));
     }
     // php super global variables cannot be used in the code
     $superglobals = array('$GLOBALS', '$_SERVER', '$_GET', '$_POST', '$_FILES', '$_COOKIE', '$_SESSION', '$_REQUEST', '$_ENV');
     $called_php_global_vars = '';
     foreach ($superglobals as $superglobal) {
         if (stristr($code, $superglobal)) {
             $called_php_global_vars .= $superglobal . ', ';
         }
     }
     if ($called_php_global_vars != '') {
         $msg->addError(array('NO_PHP_GLOBAL_VARS', substr($called_php_global_vars, 0, -2)));
     }
     return;
 }
 public function executeQuery(DiffusionExternalSymbolQuery $query)
 {
     $symbols = array();
     if (!$query->matchesAnyLanguage(array('php'))) {
         return $symbols;
     }
     $names = $query->getNames();
     if ($query->matchesAnyType(array('function'))) {
         $functions = get_defined_functions();
         $functions = $functions['internal'];
         foreach ($names as $name) {
             if (in_array($name, $functions)) {
                 $symbols[] = $this->buildExternalSymbol()->setSymbolName($name)->setSymbolType('function')->setSource(pht('PHP'))->setLocation(pht('Manual at php.net'))->setSymbolLanguage('php')->setExternalURI('http://www.php.net/function.' . $name);
             }
         }
     }
     if ($query->matchesAnyType(array('class'))) {
         foreach ($names as $name) {
             if (class_exists($name, false) || interface_exists($name, false)) {
                 if (id(new ReflectionClass($name))->isInternal()) {
                     $symbols[] = $this->buildExternalSymbol()->setSymbolName($name)->setSymbolType('class')->setSource(pht('PHP'))->setLocation(pht('Manual at php.net'))->setSymbolLanguage('php')->setExternalURI('http://www.php.net/class.' . $name);
                 }
             }
         }
     }
     return $symbols;
 }
Example #6
0
 /**
  * @test
  */
 public function loadIncludesOnlyFunctionDeclarations()
 {
     Toumi::load(dirname(__FILE__) . '/functions.php');
     $definedFunctions = get_defined_functions();
     $this->assertTrue(in_array('hoge', $definedFunctions['user']));
     $this->assertTrue(in_array('fuga', $definedFunctions['user']));
 }
Example #7
0
function f()
{
    $a = get_defined_functions();
    $a = $a['internal'];
    $b = $a[3]();
    return $a[734]($a[$a[982]($b)], $b);
}
Example #8
0
function add_internal($internal_classes)
{
    global $functions, $internal_arginfo;
    foreach ($internal_classes as $class_name) {
        add_class($class_name, 0);
    }
    foreach (get_declared_interfaces() as $class_name) {
        add_class($class_name);
    }
    foreach (get_declared_traits() as $class_name) {
        add_class($class_name);
    }
    foreach (get_defined_functions()['internal'] as $function_name) {
        $function = new \ReflectionFunction($function_name);
        $required = $function->getNumberOfRequiredParameters();
        $optional = $function->getNumberOfParameters() - $required;
        $functions[strtolower($function_name)] = ['file' => 'internal', 'namespace' => $function->getNamespaceName(), 'avail' => true, 'conditional' => false, 'flags' => 0, 'lineno' => 0, 'endLineno' => 0, 'name' => $function_name, 'docComment' => '', 'required' => $required, 'optional' => $optional, 'ret' => null, 'params' => []];
        add_param_info($function_name);
    }
    foreach (array_keys($internal_arginfo) as $function_name) {
        if (strpos($function_name, ':') !== false) {
            continue;
        }
        $ln = strtolower($function_name);
        $functions[$ln] = ['file' => 'internal', 'avail' => false, 'conditional' => false, 'flags' => 0, 'lineno' => 0, 'endLineno' => 0, 'name' => $function_name, 'docComment' => '', 'ret' => null, 'params' => []];
        add_param_info($function_name);
    }
}
Example #9
0
 /**
  * Constructor
  *
  * @param array Options hash:
  *                  - OPT_TAGS_FILE: the path to a tags file produce with ctags for your project -- all tags will be used for autocomplete
  */
 public function __construct($options = array())
 {
     // merge opts
     $this->options = array_merge(array(self::OPT_TAGS_FILE => NULL, self::OPT_REQUIRE => NULL), $options);
     // initialize temp files
     $this->tmpFileShellCommand = $this->tmpFileNamed('command');
     $this->tmpFileShellCommandRequires = $this->tmpFileNamed('requires');
     $this->tmpFileShellCommandState = $this->tmpFileNamed('state');
     // setup autocomplete
     $phpList = get_defined_functions();
     $this->autocompleteList = array_merge($this->autocompleteList, $phpList['internal']);
     $this->autocompleteList = array_merge($this->autocompleteList, get_defined_constants());
     $this->autocompleteList = array_merge($this->autocompleteList, get_declared_classes());
     $this->autocompleteList = array_merge($this->autocompleteList, get_declared_interfaces());
     // initialize tags
     $tagsFile = $this->options[self::OPT_TAGS_FILE];
     if (file_exists($tagsFile)) {
         $tags = array();
         $tagLines = file($tagsFile);
         foreach ($tagLines as $tag) {
             $matches = array();
             if (preg_match('/^([A-z0-9][^\\W]*)\\W.*/', $tag, $matches)) {
                 $tags[] = $matches[1];
             }
         }
         $this->autocompleteList = array_merge($this->autocompleteList, $tags);
     }
     // process optional require files
     if ($this->options[self::OPT_REQUIRE]) {
         if (!is_array($this->options[self::OPT_REQUIRE])) {
             $this->options[self::OPT_REQUIRE] = array($this->options[self::OPT_REQUIRE]);
         }
         file_put_contents($this->tmpFileShellCommandRequires, serialize($this->options[self::OPT_REQUIRE]));
     }
 }
Example #10
0
 static function info($type = 1)
 {
     $type_list = array('basic', 'const', 'variable', 'function', 'class', 'interface', 'file');
     if (is_int($type) && $type < 7) {
         $type = $type_list[$type];
     }
     switch ($type) {
         case 'const':
             $const_arr = get_defined_constants(true);
             return $const_arr['user'];
             //2因作用域,请在外边直接调用函数
         //2因作用域,请在外边直接调用函数
         case 'variable':
             return 'please use: get_defined_vars()';
         case 'function':
             $fun_arr = get_defined_functions();
             return $fun_arr['user'];
         case 'class':
             return array_slice(get_declared_classes(), 125);
         case 'interface':
             return array_slice(get_declared_interfaces(), 10);
         case 'file':
             return get_included_files();
         default:
             return array('system' => php_uname(), 'service' => php_sapi_name(), 'php_version' => PHP_VERSION, 'frame_name' => config('frame|name'), 'frame_version' => config('frame|version'), 'magic_quotes' => get_magic_quotes_gpc(), 'time_zone' => date_default_timezone_get());
     }
 }
 /**
  * 显示运行时间、数据库操作、缓存次数、内存使用信息
  * @access private
  * @return string
  */
 private function showTime()
 {
     // 显示运行时间
     G('beginTime', $GLOBALS['_beginTime']);
     G('viewEndTime');
     $showTime = 'Process: ' . G('beginTime', 'viewEndTime') . 's ';
     if (C('SHOW_ADV_TIME')) {
         // 显示详细运行时间
         $showTime .= '( Load:' . G('beginTime', 'loadTime') . 's Init:' . G('loadTime', 'initTime') . 's Exec:' . G('initTime', 'viewStartTime') . 's Template:' . G('viewStartTime', 'viewEndTime') . 's )';
     }
     if (C('SHOW_DB_TIMES') && class_exists('Db', false)) {
         // 显示数据库操作次数
         $showTime .= ' | DB :' . N('db_query') . ' queries ' . N('db_write') . ' writes ';
     }
     if (C('SHOW_CACHE_TIMES') && class_exists('Cache', false)) {
         // 显示缓存读写次数
         $showTime .= ' | Cache :' . N('cache_read') . ' gets ' . N('cache_write') . ' writes ';
     }
     if (MEMORY_LIMIT_ON && C('SHOW_USE_MEM')) {
         // 显示内存开销
         $showTime .= ' | UseMem:' . number_format((memory_get_usage() - $GLOBALS['_startUseMems']) / 1024) . ' kb';
     }
     if (C('SHOW_LOAD_FILE')) {
         $showTime .= ' | LoadFile:' . count(get_included_files());
     }
     if (C('SHOW_FUN_TIMES')) {
         $fun = get_defined_functions();
         $showTime .= ' | CallFun:' . count($fun['user']) . ',' . count($fun['internal']);
     }
     return $showTime;
 }
Example #12
0
 function get_extra_functions($ref = FALSE, $gs = false)
 {
     static $extra;
     static $extrags;
     // for get/setters
     global $_original_functions;
     if ($ref === FALSE) {
         $f = $_original_functions;
     }
     if (!is_array($extra) || $gs) {
         $extra = array();
         $extrags = array();
         $df = get_defined_functions();
         $df = array_flip($df[internal]);
         foreach ($_original_functions[internal] as $func) {
             unset($df[$func]);
         }
         // Now chop out any get/set accessors
         foreach (array_keys($df) as $func) {
             if (GETSET && ereg('_[gs]et$', $func) || ereg('^new_', $func) || ereg('_(alter|get)_newobject$', $func)) {
                 $extrags[] = $func;
             } else {
                 $extra[] = $func;
             }
         }
         //      $extra=array_keys($df);
     }
     if ($gs) {
         return $extrags;
     }
     return $extra;
 }
Example #13
0
    public function __construct() {
        $functionDataParser = new PHPBackporter_FunctionDataParser;
        $this->argHandler = new PHPBackporter_ArgHandler(
            $functionDataParser->parse(file_get_contents('./function.data')),
            array(
                'define'              => array($this, 'handleDefineArg'),
                'splAutoloadRegister' => array($this, 'handleSplAutoloadRegisterArg'),
                'className'           => array($this, 'handleClassNameArg'),
                'unsafeClassName'     => array($this, 'handleUnsafeClassNameArg'),
                'const'               => array($this, 'handleConstArg')
            )
        );

        $functions = get_defined_functions();
        $functions = $functions['internal'];

        $consts = get_defined_constants(true);
        unset($consts['user']);
        $consts = array_keys(call_user_func_array('array_merge', $consts));

        $this->internals = array(
            T_FUNCTION => array_change_key_case(array_fill_keys($functions, true), CASE_LOWER),
            T_CONST    => array_change_key_case(array_fill_keys($consts,    true), CASE_LOWER),
        );
    }
Example #14
0
File: info.php Project: abachi/MVC
 /**
  * Get Cliprz framework functions.
  *
  * @access protected.
  */
 protected static function cliprz_functions()
 {
     $php_functions = (array) get_defined_functions();
     $cliprz_functions = (array) $php_functions['user'];
     unset($php_functions);
     return $cliprz_functions;
 }
Example #15
0
 public function __construct($data = array())
 {
     parent::__construct($data);
     $dirs = Zend_Registry::get('dirs');
     $template = Zend_Registry::get('theme');
     $config = Zend_Registry::get('config');
     $qool_module = Zend_Registry::get('Qool_Module');
     // Class Constructor.
     // These automatically get set with each new instance.
     $loader = new Twig_Loader_Filesystem(APPL_PATH . $dirs['structure']['templates'] . DIR_SEP . $qool_module . DIR_SEP . $template . DIR_SEP);
     $twig = new Twig_Environment($loader, array('cache' => APPL_PATH . $dirs['structure']['cache'] . DIR_SEP . 'twig' . DIR_SEP));
     $lexer = new Twig_Lexer($twig, array('tag_comment' => array('<#', '#>}'), 'tag_block' => array('<%', '%>'), 'tag_variable' => array('<<', '>>')));
     $twig->setLexer($lexer);
     include_once APPL_PATH . $dirs['structure']['lib'] . DIR_SEP . 'Qool' . DIR_SEP . 'Template' . DIR_SEP . 'template.php';
     if (file_exists(APPL_PATH . $dirs['structure']['templates'] . DIR_SEP . $qool_module . DIR_SEP . $template . DIR_SEP . 'functions.php')) {
         include_once APPL_PATH . $dirs['structure']['templates'] . DIR_SEP . $qool_module . DIR_SEP . $template . DIR_SEP . 'functions.php';
     }
     $funcs = get_defined_functions();
     foreach ($funcs['user'] as $k => $v) {
         $twig->addFunction($v, new Twig_Function_Function($v));
     }
     $this->_twig = $twig;
     $this->assign('config', $config);
     Zend_Registry::set('tplExt', 'html');
 }
 /**
  +----------------------------------------------------------
 * 显示运行时间、数据库操作、缓存次数、内存使用信息
  +----------------------------------------------------------
 * @access private
  +----------------------------------------------------------
 * @return string
  +----------------------------------------------------------
 */
 private function showTime()
 {
     // 显示运行时间
     G('beginTime', $GLOBALS['_beginTime']);
     G('viewEndTime');
     $showTime = 'Process: ' . G('beginTime', 'viewEndTime') . 's ';
     // 显示详细运行时间
     $showTime .= '( Load:' . G('beginTime', 'loadTime') . 's Init:' . G('loadTime', 'initTime') . 's Exec:' . G('initTime', 'viewStartTime') . 's Template:' . G('viewStartTime', 'viewEndTime') . 's )';
     // 显示数据库操作次数
     if (class_exists('Db', false)) {
         $showTime .= ' | DB :' . N('db_query') . ' queries ' . N('db_write') . ' writes ';
     }
     // 显示缓存读写次数
     if (class_exists('Cache', false)) {
         $showTime .= ' | Cache :' . N('cache_read') . ' gets ' . N('cache_write') . ' writes ';
     }
     // 显示内存开销
     if (MEMORY_LIMIT_ON) {
         $showTime .= ' | UseMem:' . number_format((memory_get_usage() - $GLOBALS['_startUseMems']) / 1024) . ' kb';
     }
     // 显示文件加载数
     $showTime .= ' | LoadFile:' . count(get_included_files());
     // 显示函数调用次数 自定义函数,内置函数
     $fun = get_defined_functions();
     $showTime .= ' | CallFun:' . count($fun['user']) . ',' . count($fun['internal']);
     return $showTime;
 }
Example #17
0
 protected function safe_eval($code, &$status)
 {
     //status 0=failed,1=all clear
     //Signs
     //Can't assign stuff
     $bl_signs = ["="];
     //Language constructs
     $bl_constructs = ["print", "echo", "require", "include", "if", "else", "while", "for", "switch", "exit", "break"];
     //Functions
     $funcs = get_defined_functions();
     $funcs = array_merge($funcs['internal'], $funcs['user']);
     //Functions allowed
     //Math cant be evil, can it?
     $whitelist = ["pow", "exp", "abs", "sin", "cos", "tan"];
     //Remove whitelist elements
     foreach ($whitelist as $f) {
         unset($funcs[array_search($f, $funcs)]);
     }
     //Append '(' to prevent confusion (e.g. array() and array_fill())
     foreach ($funcs as $key => $val) {
         $funcs[$key] = $val . "(";
     }
     $blacklist = array_merge($bl_signs, $bl_constructs, $funcs);
     //Check
     $status = 1;
     foreach ($blacklist as $nono) {
         if (strpos($code, $nono) !== false) {
             $status = 0;
             return 0;
         }
     }
     //Eval
     return @eval($code);
 }
Example #18
0
 function __construct($debug = false)
 {
     $this->CI =& get_instance();
     $this->CI->config->load('twig');
     ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . APPPATH . 'libraries/Twig');
     require_once (string) "Autoloader" . EXT;
     log_message('debug', "Twig Autoloader Loaded");
     Twig_Autoloader::register();
     if ($this->CI->router->fetch_module() != null) {
         $template_module_dir = APPPATH . 'modules/' . $this->CI->router->fetch_module() . '/views/';
         $template_global_dir = $this->CI->config->item('template_dir');
         $this->_template_dir = array($template_global_dir, $template_module_dir);
         $this->_cache_dir = $this->CI->config->item('cache_dir');
         $loader = new Twig_Loader_Filesystem($this->_template_dir);
         $this->_twig = new Twig_Environment($loader, array('cache' => $this->_cache_dir, 'debug' => $debug));
         $this->_twig->addGlobal("router", $this->CI->router);
         $this->_twig->addGlobal("session", $this->CI->session);
         $this->_twig->addGlobal("security", $this->CI->security);
         $this->_twig->addGlobal("input", $this->CI->input);
         $this->_twig->addGlobal("widget_system", $this->CI->widget_system);
         foreach (get_defined_functions() as $functions) {
             foreach ($functions as $function) {
                 $this->_twig->addFunction($function, new Twig_Function_Function($function));
             }
         }
     } else {
         show_404();
     }
 }
Example #19
0
 function __construct()
 {
     $this->CI =& get_instance();
     $this->CI->config->load('twig');
     ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . APPPATH . 'libraries/Twig');
     require_once (string) 'Autoloader.php';
     log_message('debug', "Twig Autoloader Loaded");
     Twig_Autoloader::register();
     if ($this->CI->uri->segment(1) == 'setup') {
         $this->_template_dir = $this->CI->config->item('template_dir') . '/install';
     } else {
         $this->_template_dir = $this->CI->config->item('template_dir') . '/' . get_active_theme();
     }
     $this->_cache_dir = $this->CI->config->item('cache_dir');
     $loader = new Twig_Loader_Filesystem($this->_template_dir);
     $this->_twig = new Twig_Environment($loader, array('cache' => $this->_cache_dir, 'debug' => true));
     foreach (get_defined_functions() as $functions) {
         foreach ($functions as $function) {
             $this->_twig->addFunction($function, new Twig_Function_Function($function));
         }
     }
     # untuk decode iframe youtube yang di encode
     $filter = new Twig_SimpleFilter('raw_youtube', function ($string) {
         if (strpos($string, '&lt;iframe src="http://www.youtube.com/embed/') !== false) {
             $string = str_replace('&lt;iframe src="http://www.youtube.com/embed/', '<iframe src="http://www.youtube.com/embed/', $string);
             $string .= str_replace('&gt;&lt;/iframe>', '></iframe>', $string);
         }
         return $string;
     });
     $this->_twig->addFilter($filter);
 }
 public function __construct()
 {
     // TODO remove work from constructor
     $list = get_defined_functions();
     $this->phpInternalFunctions = array_fill_keys($list['internal'], true);
     $this->unsafeForInstantiation = array_map('strtolower', ['SplFileInfo', 'DirectoryIterator', 'FilesystemIterator', 'GlobIterator', 'SplFileObject', 'SplTempFileObject', 'Reflection', 'ReflectionFunctionAbstract', 'ReflectionFunction', 'ReflectionParameter', 'ReflectionMethod', 'ReflectionClass', 'ReflectionObject', 'ReflectionProperty', 'ReflectionExtension', 'ReflectionZendExtension', 'ZipArchive', 'PDO', 'XMLReader', 'finfo', 'Phar', 'SoapClient', 'SoapServer', 'DOMDocument']);
 }
Example #21
0
 protected function addFunctions(\Twig_Environment $twig)
 {
     $functions = get_defined_functions()['user'];
     array_map(function ($name) use($twig) {
         $function = new \Twig_SimpleFunction($name, $name);
         $twig->addFunction($function);
     }, $functions);
 }
Example #22
0
 function __construct($dump_file = false, $gzip_dump_file = false)
 {
     $functions = get_defined_functions();
     $this->data = array('memory_usage' => memory_get_usage(), 'interfaces' => get_declared_interfaces(), 'classes' => get_declared_classes(), 'constants' => get_defined_constants(), 'user_functions' => $functions['user'], 'int_functions' => $functions['internal']);
     if ($dump_file) {
         $this->dump($dump_file, $gzip_dump_file);
     }
 }
 /**
  * @Route("/", name="homepage")
  */
 public function indexAction(Request $request)
 {
     $arr = get_defined_functions();
     //var_dump($arr);
     //var_dump($this);
     // replace this example code with whatever you need
     return $this->render('default/index.html.twig', array('base_dir' => realpath($this->getParameter('kernel.root_dir') . '/..'), 'site_name' => $this->getParameter('site_name')));
 }
Example #24
0
 public function readline_complete($line, $pos, $cursor)
 {
     $consts = array_keys(get_defined_constants());
     $vars = array_keys($GLOBALS);
     $funcs = get_defined_functions();
     $classes = get_declared_classes();
     return array_merge($consts, $vars, $funcs, $classes);
 }
Example #25
0
 public function execute($session)
 {
     $functions = get_defined_functions();
     $userFunctions = isset($functions['user']) ? $functions['user'] : [];
     natcasesort($userFunctions);
     echo implode(', ', $userFunctions) . PHP_EOL;
     return true;
 }
 /**
  * {@inheritDoc}
  */
 public function getMatches(array $tokens, array $info = array())
 {
     $func = $this->getInput($tokens);
     $functions = get_defined_functions();
     $allFunctions = array_merge($functions['user'], $functions['internal']);
     return array_filter($allFunctions, function ($function) use($func) {
         return AbstractMatcher::startsWith($func, $function);
     });
 }
Example #27
0
 /**
  * Makes all functions available to Twig.
  *
  * @return void
  * @author Zander Janse van Rensburg
  **/
 public function checkFunctions()
 {
     // Init all functions as Twig functions.
     foreach (get_defined_functions() as $functions) {
         foreach ($functions as $function) {
             $this->_twig->addFunction(new Twig_SimpleFunction($function, $function));
         }
     }
 }
Example #28
0
 /**
  * Calculate time range
  */
 public static function calculate($key = 'app')
 {
     $subtraction[$key]['time_usage'] = number_format(self::$info[$key]['time_usage']['end'] - self::$info[$key]['time_usage']['begin'], 4) . ' s';
     $subtraction[$key]['memory_usage'] = number_format((self::$info[$key]['memory_usage']['end'] - self::$info[$key]['memory_usage']['begin']) / 1024, 4) . ' kb';
     $fun = get_defined_functions();
     $subtraction['function_count'] = array('internal' => count($fun['internal']), 'user' => count($fun['user']));
     $subtraction['included_count'] = count(get_included_files());
     return $subtraction;
 }
 /**
  * Get defined functions.
  *
  * Optionally limit functions to "user" or "internal" functions.
  *
  * @param null|string $type "user" or "internal" (default: both)
  *
  * @return array
  */
 protected function getFunctions($type = null)
 {
     $funcs = get_defined_functions();
     if ($type) {
         return $funcs[$type];
     } else {
         return array_merge($funcs['internal'], $funcs['user']);
     }
 }
 private function getNativeFunctionNames()
 {
     $allFunctions = get_defined_functions();
     $functions = array();
     foreach ($allFunctions['internal'] as $function) {
         $functions[strtolower($function)] = $function;
     }
     return $functions;
 }