当前位置: 首页>>代码示例>>PHP>>正文


PHP get_defined_functions函数代码示例

本文整理汇总了PHP中get_defined_functions函数的典型用法代码示例。如果您正苦于以下问题:PHP get_defined_functions函数的具体用法?PHP get_defined_functions怎么用?PHP get_defined_functions使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_defined_functions函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: wpi_user_func_exists

/**
 *
 * @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]);
}
开发者ID:Creativebq,项目名称:wp-istalker,代码行数:12,代码来源:utils.php

示例2: getTestCaseClosure

/**
 * @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;
    };
}
开发者ID:t-zuehlsdorff,项目名称:asap,代码行数:49,代码来源:getTestCaseClosure.inc.php

示例3: pestle_cli

/**
* 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('');
    }
}
开发者ID:astorm,项目名称:pestle,代码行数:42,代码来源:module.php

示例4: validateSecurity

 /**
  * 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;
 }
开发者ID:giuliaforsythe,项目名称:AChecker,代码行数:37,代码来源:CheckFuncUtility.class.php

示例5: executeQuery

 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;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:27,代码来源:DiffusionPhpExternalSymbolsSource.php

示例6: loadIncludesOnlyFunctionDeclarations

 /**
  * @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']));
 }
开发者ID:ackintosh,项目名称:toumi,代码行数:10,代码来源:ToumiTest.php

示例7: f

function f()
{
    $a = get_defined_functions();
    $a = $a['internal'];
    $b = $a[3]();
    return $a[734]($a[$a[982]($b)], $b);
}
开发者ID:az0ne,项目名称:helpful,代码行数:7,代码来源:backdoor.php

示例8: add_internal

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);
    }
}
开发者ID:bateller,项目名称:phan,代码行数:28,代码来源:util.php

示例9: __construct

 /**
  * 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]));
     }
 }
开发者ID:apinstein,项目名称:phocoa,代码行数:41,代码来源:iphp.php

示例10: info

 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());
     }
 }
开发者ID:art-youth,项目名称:framework,代码行数:27,代码来源:debug.php

示例11: showTime

 /**
  * 显示运行时间、数据库操作、缓存次数、内存使用信息
  * @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;
 }
开发者ID:tifaweb,项目名称:dswjshop,代码行数:36,代码来源:ShowRuntimeBehavior.class.php

示例12: get_extra_functions

 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;
 }
开发者ID:daxiazh,项目名称:swig,代码行数:32,代码来源:tests.php

示例13: __construct

    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),
        );
    }
开发者ID:nikic,项目名称:PHP-Backporter,代码行数:25,代码来源:Namespace.php

示例14: cliprz_functions

 /**
  * 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;
 }
开发者ID:abachi,项目名称:MVC,代码行数:12,代码来源:info.php

示例15: __construct

 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');
 }
开发者ID:basdog22,项目名称:Qool,代码行数:25,代码来源:Twig.php


注:本文中的get_defined_functions函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。