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


PHP ReflectionFunction::getFilename方法代码示例

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


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

示例1: testConfigure

 public function testConfigure()
 {
     $prevDumper = $this->getDumpHandler();
     $container = new ContainerBuilder();
     $container->setDefinition('var_dumper.cloner', new Definition('Symfony\\Component\\HttpKernel\\Tests\\EventListener\\MockCloner'));
     $container->setDefinition('mock_dumper', new Definition('Symfony\\Component\\HttpKernel\\Tests\\EventListener\\MockDumper'));
     ob_start();
     $exception = null;
     $listener = new DumpListener($container, 'mock_dumper');
     try {
         $listener->configure();
         $lazyDumper = $this->getDumpHandler();
         VarDumper::dump('foo');
         $loadedDumper = $this->getDumpHandler();
         VarDumper::dump('bar');
         $this->assertSame('+foo-+bar-', ob_get_clean());
         $listenerReflector = new \ReflectionClass($listener);
         $lazyReflector = new \ReflectionFunction($lazyDumper);
         $loadedReflector = new \ReflectionFunction($loadedDumper);
         $this->assertSame($listenerReflector->getFilename(), $lazyReflector->getFilename());
         $this->assertSame($listenerReflector->getFilename(), $loadedReflector->getFilename());
         $this->assertGreaterThan($lazyReflector->getStartLine(), $loadedReflector->getStartLine());
     } catch (\Exception $exception) {
     }
     VarDumper::setHandler($prevDumper);
     if (null !== $exception) {
         throw $exception;
     }
 }
开发者ID:vomasmic,项目名称:symfony,代码行数:29,代码来源:DumpListenerTest.php

示例2: filterResponse

 public function filterResponse($response)
 {
     if (!$response->getStatusCode()) {
         /*
         keep in mind: 
         self::$statusCode refers to the value declared in this file (500)
         get_called_class()::$statusCode  would be the value declared in the class that extends this exception
         */
         $className = get_called_class();
         $response->status($className::$statusCode, get_class($this->originalException));
     }
     if ($this->callback) {
         $closure = $this->callback->getCallable();
         if (is_array($closure)) {
             $reflection = new \ReflectionMethod($closure[0], $closure[1]);
         } else {
             $reflection = new \ReflectionFunction($closure);
         }
         $response->header("X-Phidias-Exception-Filename", $reflection->getFilename() . ' Line: ' . $reflection->getStartLine());
     }
     if ($message = $this->originalException->getMessage()) {
         $response->header("X-Phidias-Exception-Message", $message);
     }
     return $response;
 }
开发者ID:phidias-sas,项目名称:api,代码行数:25,代码来源:Exception.php

示例3: collect

 /**
  * {@inheritdoc}
  */
 public function collect(Request $request, Response $response, \Exception $exception = null)
 {
     $responseHeaders = $response->headers->all();
     $cookies = array();
     foreach ($response->headers->getCookies() as $cookie) {
         $cookies[] = $this->getCookieHeader($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly());
     }
     if (count($cookies) > 0) {
         $responseHeaders['Set-Cookie'] = $cookies;
     }
     $attributes = array();
     foreach ($request->attributes->all() as $key => $value) {
         if ('_route' === $key && is_object($value)) {
             $attributes['_route'] = $this->varToString($value->getPath());
         } elseif ('_route_params' === $key) {
             foreach ($value as $key => $v) {
                 $attributes['_route_params'][$key] = $this->varToString($v);
             }
         } else {
             $attributes[$key] = $this->varToString($value);
         }
     }
     $content = null;
     try {
         $content = $request->getContent();
     } catch (\LogicException $e) {
         // the user already got the request content as a resource
         $content = false;
     }
     $sessionMetadata = array();
     $sessionAttributes = array();
     $flashes = array();
     if ($request->hasSession()) {
         $session = $request->getSession();
         if ($session->isStarted()) {
             $sessionMetadata['Created'] = date(DATE_RFC822, $session->getMetadataBag()->getCreated());
             $sessionMetadata['Last used'] = date(DATE_RFC822, $session->getMetadataBag()->getLastUsed());
             $sessionMetadata['Lifetime'] = $session->getMetadataBag()->getLifetime();
             $sessionAttributes = $session->all();
             $flashes = $session->getFlashBag()->peekAll();
         }
     }
     $statusCode = $response->getStatusCode();
     $this->data = array('format' => $request->getRequestFormat(), 'content' => $content, 'content_type' => $response->headers->get('Content-Type', 'text/html'), 'status_text' => isset(Response::$statusTexts[$statusCode]) ? Response::$statusTexts[$statusCode] : '', 'status_code' => $statusCode, 'request_query' => $request->query->all(), 'request_request' => $request->request->all(), 'request_headers' => $request->headers->all(), 'request_server' => $request->server->all(), 'request_cookies' => $request->cookies->all(), 'request_attributes' => $attributes, 'response_headers' => $responseHeaders, 'session_metadata' => $sessionMetadata, 'session_attributes' => $sessionAttributes, 'flashes' => $flashes, 'path_info' => $request->getPathInfo(), 'controller' => 'n/a', 'locale' => $request->getLocale());
     if (isset($this->data['request_headers']['php-auth-pw'])) {
         $this->data['request_headers']['php-auth-pw'] = '******';
     }
     if (isset($this->data['request_server']['PHP_AUTH_PW'])) {
         $this->data['request_server']['PHP_AUTH_PW'] = '******';
     }
     if (isset($this->controllers[$request])) {
         $controller = $this->controllers[$request];
         if (is_array($controller)) {
             try {
                 $r = new \ReflectionMethod($controller[0], $controller[1]);
                 $this->data['controller'] = array('class' => is_object($controller[0]) ? get_class($controller[0]) : $controller[0], 'method' => $controller[1], 'file' => $r->getFilename(), 'line' => $r->getStartLine());
             } catch (\ReflectionException $re) {
                 if (is_callable($controller)) {
                     // using __call or  __callStatic
                     $this->data['controller'] = array('class' => is_object($controller[0]) ? get_class($controller[0]) : $controller[0], 'method' => $controller[1], 'file' => 'n/a', 'line' => 'n/a');
                 }
             }
         } elseif ($controller instanceof \Closure) {
             $r = new \ReflectionFunction($controller);
             $this->data['controller'] = array('class' => $r->getName(), 'method' => null, 'file' => $r->getFilename(), 'line' => $r->getStartLine());
         } else {
             $this->data['controller'] = (string) $controller ?: 'n/a';
         }
         unset($this->controllers[$request]);
     }
 }
开发者ID:mesushan,项目名称:FirstRepo,代码行数:74,代码来源:RequestDataCollector.php

示例4: getFunctionAst

 /**
  * Get the AST representation of a given function name, analyzed
  *
  * @param string $name The function name to find the AST for
  *
  * @return \PhpParser\Node\Stmt\Function_|null The function if found
  */
 public function getFunctionAst($name)
 {
     if (!function_exists($name)) {
         return;
     }
     $r = new \ReflectionFunction($name);
     $file = $this->parseFile($r->getFilename());
     $node = $this->findFunction($r->getName(), $file);
     if ($node) {
         $node = $this->analyzer->analyzeFunction($node);
         return $node;
     }
 }
开发者ID:qs9816,项目名称:recki-ct,代码行数:20,代码来源:Jit.php

示例5: 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";
var_dump($func->returnsReference());
echo "--getParameters--\n";
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:025.php


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