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


PHP ReflectionFunction::isUserDefined方法代码示例

本文整理汇总了PHP中ReflectionFunction::isUserDefined方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionFunction::isUserDefined方法的具体用法?PHP ReflectionFunction::isUserDefined怎么用?PHP ReflectionFunction::isUserDefined使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ReflectionFunction的用法示例。


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

示例1: XLLoop_reflection_handler

function XLLoop_reflection_handler()
{
    try {
        $input = file_get_contents('php://input');
        $value = json_decode($input);
        if ($value != NULL) {
            $argc = count($value->args);
            $args = array();
            for ($i = 0; $i < $argc; $i++) {
                $args[$i] = XLLoop_decode($value->args[$i]);
            }
            $function = new ReflectionFunction($value->name);
            if ($function->isUserDefined()) {
                $reqArgc = $function->getNumberOfParameters();
                for ($i = $argc; $i < $reqArgc; $i++) {
                    $args[$i] = 0;
                }
                $result = $function->invokeArgs($args);
                $enc = XLLoop_encode($result);
                print json_encode($enc);
            } else {
                print json_encode(XLLoop_encode("#Function " . $value->name . "() does not exist"));
            }
        } else {
            print "<html><body><code>XLLoop function handler alive</code></body></html>";
        }
    } catch (Exception $e) {
        print json_encode(XLLoop_encode("#" . $e->getMessage()));
    }
}
开发者ID:mnar53,项目名称:xlloop,代码行数:30,代码来源:XLLoop.php

示例2: isUserDefined

 /**
  * Returns whether this is a user-defined function
  *
  * @return boolean True if this is a user-defined function
  */
 public function isUserDefined()
 {
     if ($this->reflectionSource instanceof ReflectionFunction) {
         return $this->reflectionSource->isUserDefined();
     } else {
         return parent::isUserDefined();
     }
 }
开发者ID:zetacomponents,项目名称:reflection,代码行数:13,代码来源:function.php

示例3: dumpFuncInfo

function dumpFuncInfo($name)
{
    $funcInfo = new ReflectionFunction($name);
    var_dump($funcInfo->getName());
    var_dump($funcInfo->isInternal());
    var_dump($funcInfo->isUserDefined());
    var_dump($funcInfo->getStartLine());
    var_dump($funcInfo->getEndLine());
    var_dump($funcInfo->getStaticVariables());
}
开发者ID:badlamer,项目名称:hhvm,代码行数:10,代码来源:ReflectionFunction_001.php

示例4: startTestSuite

    public function startTestSuite(\PHPUnit_Framework_TestSuite $mainSuite)
    {
        if (null !== self::$enabledPolyfills) {
            return;
        }
        self::$enabledPolyfills = false;
        foreach ($mainSuite->tests() as $suite) {
            $testClass = $suite->getName();
            if (!($tests = $suite->tests())) {
                continue;
            }
            if (!preg_match('/^(.+)\\\\Tests(\\\\.*)Test$/', $testClass, $m)) {
                $mainSuite->addTest(self::warning('Unknown naming convention for ' . $testClass));
                continue;
            }
            $testedClass = new \ReflectionClass($m[1] . $m[2]);
            $bootstrap = new \SplFileObject(dirname($testedClass->getFileName()) . '/bootstrap.php');
            $warnings = array();
            $defLine = null;
            foreach (new \RegexIterator($bootstrap, '/return p\\\\' . $testedClass->getShortName() . '::/') as $defLine) {
                if (!preg_match('/^\\s*function (?P<name>[^\\(]++)(?P<signature>\\([^\\)]*+\\)) \\{ (?<return>return p\\\\' . $testedClass->getShortName() . '::[^\\(]++)(?P<args>\\([^\\)]*+\\)); \\}$/', $defLine, $f)) {
                    $warnings[] = self::warning('Invalid line in bootstrap.php: ' . trim($defLine));
                    continue;
                }
                $testNamespace = substr($testClass, 0, strrpos($testClass, '\\'));
                if (function_exists($testNamespace . '\\' . $f['name'])) {
                    continue;
                }
                try {
                    $r = new \ReflectionFunction($f['name']);
                    if ($r->isUserDefined()) {
                        throw new \ReflectionException();
                    }
                    if (false !== strpos($f['signature'], '&')) {
                        $defLine = sprintf('return \\%s%s', $f['name'], $f['args']);
                    } else {
                        $defLine = sprintf("return \\call_user_func_array('%s', func_get_args())", $f['name']);
                    }
                } catch (\ReflectionException $e) {
                    $defLine = sprintf("throw new \\PHPUnit_Framework_SkippedTestError('Internal function not found: %s')", $f['name']);
                }
                eval(<<<EOPHP
namespace {$testNamespace};

use Symfony\\Polyfill\\Util\\TestListener;
use {$testedClass->getNamespaceName()} as p;

function {$f['name']}{$f['signature']}
{
    if ('{$testClass}' === TestListener::\$enabledPolyfills) {
        {$f['return']}{$f['args']};
    }

    {$defLine};
}
EOPHP
);
            }
            if (!$warnings && null === $defLine) {
                $warnings[] = new \PHPUnit_Framework_SkippedTestCase('No Polyfills found in bootstrap.php for ' . $testClass);
            } else {
                $mainSuite->addTest(new static($suite));
            }
        }
        foreach ($warnings as $w) {
            $mainSuite->addTest($w);
        }
    }
开发者ID:Kyra2778,项目名称:AMR,代码行数:68,代码来源:TestListener.php

示例5: getNumberOfRequiredParameters

var_dump($rf->getNumberOfParameters());
print "\n";
print "--- getNumberOfRequiredParameters(\"f\") ---\n";
var_dump($rf->getNumberOfRequiredParameters());
print "\n";
print "--- getParameters(\"f\") ---\n";
var_dump($rf->getParameters());
print "\n";
print "--- getStaticVariables(\"f\") ---\n";
var_dump($rf->getStaticVariables());
print "\n";
print "--- isInternal(\"f\") ---\n";
var_dump($rf->isInternal());
print "\n";
print "--- isUserDefined(\"f\") ---\n";
var_dump($rf->isUserDefined());
print "\n";
print "--- returnsReference(\"f\") ---\n";
var_dump($rf->returnsReference());
print "\n";
print "--- export(\"f\") ---\n";
var_dump($rf->export('f', true));
print "\n";
# invoke() can't be used because $b is pass-by-reference.
print "--- invokeArgs(\"f\") ---\n";
$b = "b";
var_dump($rf->invokeArgs(array("a", &$b, "c")));
var_dump($rf->invokeArgs(array("a", &$b, "c")));
print "\n";
print "--- getStaticVariables(\"f\") ---\n";
$rf = new ReflectionFunction("f");
开发者ID:alphaxxl,项目名称:hhvm,代码行数:31,代码来源:reflection.php

示例6: foreach

    $funcs = get_defined_functions();
    foreach ($funcs['internal'] as $func) {
        $rf = new ReflectionFunction($func);
        $info = array('kind' => 'f', 'namespace' => $rf->getNamespaceName());
        $params = array();
        foreach ($rf->getParameters() as $rp) {
            $class = '';
            if (!defined('HHVM_VERSION')) {
                $class = $rp->getClass();
            }
            $param = '';
            if ($class) {
                $param = $class->getName() . ' ';
            } elseif ($rp->isArray()) {
                $param = 'array ';
            }
            $param .= '$' . $rp->getName();
            if ($rp->isOptional() && $rf->isUserDefined()) {
                $param .= '=' . json_encode($rp->getDefaultValue());
            }
            $params[] = $param;
        }
        $info['type'] = '(' . implode(', ', $params) . ')';
        if ($rf->isInternal()) {
            $filename = '(ext-' . $rf->getExtensionName() . ')';
        } else {
            $filename = str_replace($base, '', $rf->getFileName());
        }
        fwrite($fp, implode("\t", array($rf->getName(), $filename, $rf->getStartLine() . ';"', '')) . $build($info) . PHP_EOL);
    }
});
开发者ID:DQNEO,项目名称:prestissimo,代码行数:31,代码来源:bootstrap.php

示例7: start

    /**
     * Routing and controller initialization
     *
     * @static
     * @return void
     */
    public static function start()
    {
        global $request, $response;
        // TODO: move to method?
        $request = new Bottle_Request;
        $response = new Bottle_Response;

        $functions = get_defined_functions();
        $controllers = $functions['user'];
        $controllers_list = array();
        $views_list = array();
        foreach($controllers as $controller) {
            if (substr($controller, 0, 2) != '__') {
                $controller = new ReflectionFunction($controller);

                if ($controller->isUserDefined()) {
                    $docline = $controller->getDocComment();

                    if (preg_match('#^( |\t)*\*( )?@route (?P<route>.+?)$#umsi', $docline, $matches)) {

                        $route = new Bottle_Route($controller->getName());
                        $route->setMask($matches['route']);
                        $route->bindController($controller);

                        $controllers_list[$controller->getName()] = $route->getMask();


                        if ($route->isServed($request->uri())) {
                            if (preg_match('#^( |\t)*\*( )?@view (?P<view>.+?)$#umsi', $docline, $matches)) {
                                $view = new Bottle_View($matches['view']);
                                $response->setView($view);
                                $views_list[] = $view;
                            }

                            /*
                             * optional controller condition support
                             * decorator param may be a single word (function
                             * name), or a function name followed by an argument
                             * list (separated by spaces). If an argument starts
                             * with a $, and the controller also have an
                             * argument with the same name, that value will be
                             * passed in the function.
                             */
                            if (preg_match('#^( |\t)*\*( )?@requires (?P<condition>.+?)$#umsi', $docline, $matches)) {
                                // checking if the condition function has params
                                if(strpos($matches['condition'], ' ')) {
                                    $condition_parts = explode(' ', $matches['condition']);
                                    $condition_name = array_shift($condition_parts);
                                    $route->setCondition($condition_name, $condition_parts);
                                } else {
                                    if(!function_exists($matches['condition'])) {
                                        throw new Bottle_Exception('Unknown condition: '.$matches['condition'].
                                                                   ' for controller '.$controller->getName());
                                    }
                                    $route->setCondition($matches['condition']);
                                }
                            }

                            $request->setRouter($route);
                            //break;
                        } else {
                            // fetching all views for the url() function
                            if (preg_match('#^( |\t)*\*( )?@view (?P<view>.+?)$#umsi', $docline, $matches)) {
                                $view = new Bottle_View($matches['view']);
                                $views_list[] = $view;
                            }
                        }
                    }
                }
            }
        }

        // giving the route list to each view
        foreach($views_list as $view) {

            $view->setRoutes($controllers_list);
        }


        $response->dispatch($request);
    }
开发者ID:nergal,项目名称:php-bottle,代码行数:87,代码来源:core.php

示例8: test

/**
hoho
*/
function test($a, $b = 1, $c = "")
{
    static $var = 1;
}
$func = new ReflectionFunction("test");
var_dump($func->export("test"));
echo "--getName--\n";
var_dump($func->getName());
echo "--isInternal--\n";
var_dump($func->isInternal());
echo "--isUserDefined--\n";
var_dump($func->isUserDefined());
echo "--getFilename--\n";
var_dump($func->getFilename());
echo "--getStartline--\n";
var_dump($func->getStartline());
echo "--getEndline--\n";
var_dump($func->getEndline());
echo "--getDocComment--\n";
var_dump($func->getDocComment());
echo "--getStaticVariables--\n";
var_dump($func->getStaticVariables());
echo "--invoke--\n";
var_dump($func->invoke(array(1, 2, 3)));
echo "--invokeArgs--\n";
var_dump($func->invokeArgs(array(1, 2, 3)));
echo "--returnsReference--\n";
开发者ID:badlamer,项目名称:hhvm,代码行数:30,代码来源:025.php

示例9: addStars

<?php

function addStars($message)
{
    return "** {$message} **";
}
$reflection = new ReflectionFunction('addStars');
var_dump($reflection->getName());
var_dump($reflection->getParameters());
var_dump($reflection->isUserDefined());
var_dump($reflection->getFileName());
/* foreach (get_class_methods($reflection) as $method) {
  echo $method . ":";
  var_dump($reflection->$method());
} */
class Robot
{
    public $name;
    public function __construct($name)
    {
        $this->name = $name;
    }
    public function sayHello()
    {
        return 'Hello ' . $this->name;
    }
}
$reflection = new ReflectionClass('Robot');
var_dump($reflection->getMethods());
var_dump($reflection->getProperties());
var_dump($reflection->newInstance('R2D2'));
开发者ID:pixlr,项目名称:Zce,代码行数:31,代码来源:reflection.php


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