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


PHP ReflectionFunction::getNamespaceName方法代码示例

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


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

示例1: import

 public function import(\ReflectionFunction $function)
 {
     $this->name = $function->name;
     $this->function = $function->getShortName();
     $this->namespace = $function->getNamespaceName();
     $this->_importFromReflection($function);
 }
开发者ID:bzick,项目名称:koda,代码行数:7,代码来源:FunctionInfo.php

示例2: onWildcardEvent

 public function onWildcardEvent()
 {
     $name = $this->events->firing();
     $time = microtime(true);
     // Get the arguments passed to the event
     $params = $this->prepareParams(func_get_args());
     // Find all listeners for the current event
     foreach ($this->events->getListeners($name) as $i => $listener) {
         // Check if it's an object + method name
         if (is_array($listener) && count($listener) > 1 && is_object($listener[0])) {
             list($class, $method) = $listener;
             // Skip this class itself
             if ($class instanceof static) {
                 continue;
             }
             // Format the listener to readable format
             $listener = get_class($class) . '@' . $method;
             // Handle closures
         } elseif ($listener instanceof \Closure) {
             $reflector = new \ReflectionFunction($listener);
             // Skip our own listeners
             if ($reflector->getNamespaceName() == 'Barryvdh\\Debugbar') {
                 continue;
             }
             // Format the closure to a readable format
             $filename = ltrim(str_replace(base_path(), '', $reflector->getFileName()), '/');
             $listener = $reflector->getName() . ' (' . $filename . ':' . $reflector->getStartLine() . '-' . $reflector->getEndLine() . ')';
         } else {
             // Not sure if this is possible, but to prevent edge cases
             $listener = $this->formatVar($listener);
         }
         $params['listeners.' . $i] = $listener;
     }
     $this->addMeasure($name, $time, $time, $params);
 }
开发者ID:sethathay,项目名称:PPBakery,代码行数:35,代码来源:EventCollector.php

示例3: hash

 /**
  * Hash anything, return the unique identity.
  *
  * @param $object
  * @return string
  */
 protected function hash($object)
 {
     array_walk_recursive($object, function (&$item) {
         if ($item instanceof \Closure) {
             $reflection = new \ReflectionFunction($item);
             $item = serialize($reflection->getClosureScopeClass()) . $reflection->getNumberOfParameters() . $reflection->getNamespaceName() . $reflection->getStartLine() . $reflection->getEndLine();
         }
     });
     return md5(serialize($object));
 }
开发者ID:sandeeprajoria,项目名称:Housekeeper,代码行数:16,代码来源:AbstractCacheManager.php

示例4: hash

 /**
  * Hash anything (except PDO connection stuff, for now).
  *
  * @param mixed $object
  * @return string
  */
 public static function hash($object)
 {
     $object = is_array($object) ? $object : [$object];
     array_walk_recursive($object, function ($item) {
         if ($item instanceof \Closure) {
             $reflection = new \ReflectionFunction($item);
             // Unique and fast.
             $item = serialize($reflection->getClosureScopeClass()) . $reflection->getNumberOfParameters() . $reflection->getNamespaceName() . $reflection->getStartLine() . $reflection->getEndLine();
         }
     });
     return md5(serialize($object));
 }
开发者ID:aaronjan,项目名称:housekeeper,代码行数:18,代码来源:SmartHasher.php

示例5: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $term = $input->getArgument('search_term');
     $listeners = $this->get('event.dispatcher')->getListeners();
     $events = array();
     foreach ($listeners as $eventName => $handlers) {
         foreach ($handlers as $order => $listener) {
             if (is_array($listener)) {
                 list($object, $methodName) = $listener;
                 $priority = 0;
                 $object = get_class($object);
                 // get the priority
                 $objectEvents = $object::getSubscribedEvents();
                 $eventMethods = $objectEvents[$eventName];
                 if (is_array($eventMethods)) {
                     foreach ($eventMethods as $eventMethod) {
                         if ($eventMethod[0] == $methodName) {
                             $priority = isset($eventMethod[1]) ? $eventMethod[1] : 0;
                         }
                     }
                 }
             } else {
                 $reflection = new \ReflectionFunction($listener);
                 $file = new \Message\Cog\Filesystem\File($reflection->getFileName());
                 $object = $reflection->getNamespaceName() . '\\' . $file->getFilenameWithoutExtension();
                 $methodName = 'Closure (L:' . $reflection->getStartLine() . ' - L:' . $reflection->getEndLine() . ')';
                 $priority = '';
             }
             // look for the search term
             if ($term && strpos(strtolower($object), strtolower($term)) === false && strpos(strtolower($methodName), strtolower($term)) === false && strpos(strtolower($eventName), strtolower($term)) === false) {
                 continue;
             }
             $events[] = array($object, $methodName, $eventName, $priority, $order);
         }
     }
     // Sort events by event name, then by order of execution.
     uasort($events, function ($a, $b) {
         if ($a[2] == $b[2]) {
             if ($a[4] == $b[4]) {
                 return 0;
             }
             return $a[4] < $b[4] ? -1 : 1;
         }
         return $a[2] < $b[2] ? -1 : 1;
     });
     $output->writeln('<info>Found ' . count($events) . ' registered event listeners.</info>');
     $table = $this->_getTable($output)->setHeaders(array('Class', 'Method', 'Event', 'Priority'));
     foreach ($events as $event) {
         $table->addRow(array($event[0], $event[1], $event[2], $event[3]));
     }
     $table->render($output);
 }
开发者ID:mothership-ec,项目名称:cog,代码行数:52,代码来源:EventList.php

示例6: 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

示例7: function

<?php

namespace foo;

$a = function () {
};
$r = new \ReflectionFunction($a);
var_dump($r->inNamespace());
var_dump($r->getNamespaceName());
var_dump($r->getName());
开发者ID:badlamer,项目名称:hhvm,代码行数:10,代码来源:ns_closure.php

示例8: foo

<?php

namespace A\B;

function foo()
{
}
$function = new \ReflectionFunction('sort');
var_dump($function->inNamespace());
var_dump($function->getName());
var_dump($function->getNamespaceName());
var_dump($function->getShortName());
$function = new \ReflectionFunction('A\\B\\foo');
var_dump($function->inNamespace());
var_dump($function->getName());
var_dump($function->getNamespaceName());
var_dump($function->getShortName());
开发者ID:badlamer,项目名称:hhvm,代码行数:17,代码来源:ReflectionFunction_getNamespaceName.php

示例9: implode

             $param .= '$' . $rp->getName();
             if ($rp->isOptional() && $rm->isUserDefined()) {
                 $param .= '=' . json_encode($rp->getDefaultValue());
             }
             $params[] = $param;
         }
         $info['type'] = '(' . implode(', ', $params) . ')';
         fwrite($fp, implode("\t", array($rm->getName(), $filename, $rm->getStartLine() . ';"', '')) . $build($info) . PHP_EOL);
     }
 }
 unset($it);
 // functions
 $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());
开发者ID:DQNEO,项目名称:prestissimo,代码行数:31,代码来源:bootstrap.php

示例10: analyseClosure

 /**
  * Analyses a closure.
  *
  * @param Model $model
  *   The closure we want to analyse.
  *
  * @return string
  *   The generated markup.
  */
 public function analyseClosure(Model $model)
 {
     $ref = new \ReflectionFunction($model->getData());
     $result = array();
     // Adding comments from the file.
     $methodclass = new ThroughMethods($this->storage);
     $result['comments'] = $methodclass->prettifyComment($ref->getDocComment());
     // Adding the sourcecode
     $highlight = $ref->getStartLine() - 1;
     $from = $highlight - 3;
     $to = $ref->getEndLine() - 1;
     $file = $ref->getFileName();
     $result['source'] = $this->storage->readSourcecode($file, $highlight, $from, $to);
     // Adding the place where it was declared.
     $result['declared in'] = $ref->getFileName() . "\n";
     $result['declared in'] .= 'in line ' . $ref->getStartLine();
     // Adding the namespace, but only if we have one.
     $namespace = $ref->getNamespaceName();
     if (!empty($namespace)) {
         $result['namespace'] = $namespace;
     }
     // Adding the parameters.
     $parameters = $ref->getParameters();
     $paramList = '';
     foreach ($parameters as $parameter) {
         preg_match('/(.*)(?= \\[ )/', $parameter, $key);
         $parameter = str_replace($key[0], '', $parameter);
         $result[$key[0]] = trim($parameter, ' []');
         $paramList .= trim($result[$key[0]]) . ', ';
     }
     $paramList = str_replace(array('&lt;required&gt; ', '&lt;optional&gt; '), '', $this->storage->encodeString($paramList));
     // Remove the ',' after the last char.
     $paramList = '<small>' . trim($paramList, ', ') . '</small>';
     $model->setType($model->getAdditional() . ' closure')->setAdditional('. . .')->setConnector2($model->getConnector2() . '(' . $paramList . ')')->setDomid($this->generateDomIdFromObject($model->getData()))->addParameter('data', $result)->initCallback('Iterate\\ThroughMethodAnalysis');
     return $this->storage->render->renderExpandableChild($model);
 }
开发者ID:brainworxx,项目名称:krexx,代码行数:45,代码来源:Routing.php

示例11: execute

 /**
  * {@inheritdoc}
  *
  * @throws \LogicException
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $verbose = OutputInterface::VERBOSITY_VERBOSE === $output->getVerbosity();
     $invoke = $input->getOption('invoke');
     $sm = $this->getServiceManager()->get('ServiceManager');
     $registeredServices = $sm->getRegisteredServicesReal();
     $lines = array();
     $pad = array('id' => 0, 'type' => strlen('Instance  '), 'class' => strlen('Class name|type|alias'));
     $serviceTypeToColumnName = array('invokableClasses' => 'Invokable', 'factories' => 'Factory', 'aliases' => 'Alias', 'instances' => 'Instance');
     foreach ($registeredServices as $type => $services) {
         foreach ($services as $key => $service) {
             $lines[$key]['type'] = $serviceTypeToColumnName[$type];
             if (strlen($key) > $pad['id']) {
                 $pad['id'] = strlen($key);
             }
             if (is_object($service)) {
                 // As of PHP 5.4 you can rely on Closure being a Closure: php.net/manual/en/class.closure.php
                 if ($service instanceof \Closure) {
                     $r = new \ReflectionFunction($service);
                     if ($ns = $r->getNamespaceName()) {
                         $filename = basename($r->getFileName(), '.php');
                         $lines[$key]['class'] = $ns . '\\' . $filename . '\\{closure}';
                     } else {
                         $lines[$key]['class'] = 'Closure in ' . $r->getFileName();
                     }
                 } else {
                     $r = new \ReflectionObject($service);
                     $lines[$key]['class'] = $r->getName();
                 }
             } elseif (is_array($service)) {
                 $lines[$key]['class'] = 'Array';
             } elseif (is_string($service) && $type != 'aliases') {
                 $r = new \ReflectionClass($service);
                 $lines[$key]['class'] = $r->getName();
             } else {
                 // Alias
                 $lines[$key]['class'] = $service;
             }
             $len = strlen($lines[$key]['class']);
             if ('aliases' == $type) {
                 $len += 10;
                 // add the "alias for " prefix
             }
             if ($len > $pad['class']) {
                 $pad['class'] = $len;
             }
         }
     }
     ksort($lines);
     $output->write(sprintf('<comment>%s</comment> <comment>%s</comment> <comment>%s</comment>', str_pad('Service Id', $pad['id']), str_pad('Type', $pad['type']), str_pad('Class Name|Type|Alias', $pad['class'])));
     $output->writeln($invoke ? '  <comment>Invokation Status [result]</comment>' : '');
     foreach ($lines as $id => $line) {
         $output->write(sprintf('<info>%s</info> ', str_pad($id, $pad['id'])));
         $output->write(sprintf('%s ', str_pad($line['type'], $pad['type'])));
         if ('Alias' == $line['type']) {
             $output->write(sprintf('<comment>alias for</comment> <info>%s </info>', str_pad($line['class'], $pad['class'] - 10)));
         } else {
             $output->write(sprintf('%s ', str_pad($line['class'], $pad['class'])));
         }
         if ($invoke) {
             try {
                 $service = $sm->get($id);
                 $output->write(sprintf(' <info>OK</info> [%s]', is_object($service) ? get_class($service) : gettype($service)));
             } catch (\Exception $e) {
                 $output->write(' <error>FAIL</error> [' . $e->getMessage() . ']');
             }
         }
         $output->writeln('');
     }
 }
开发者ID:code-ph0y,项目名称:framework,代码行数:75,代码来源:ServiceManagerDebugCommand.php


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