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


PHP ReflectionClass::getNamespaceName方法代码示例

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


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

示例1: registerPlugins

 /**
  * @param string|mixed $class
  */
 public function registerPlugins($class)
 {
     switch (true) {
         case is_string($class):
             $class = is_string($class) ? new $class() : $class;
         case $class instanceof AbstractHelper:
             $reflector = new \ReflectionClass($class);
             $path = realpath(dirname($reflector->getFileName()));
             $class = array();
             foreach (scandir($path) as $file) {
                 if (strpos($file, '.php') !== FALSE && strpos($file, 'Abstract') === FALSE) {
                     $className = str_replace('.php', '', $file);
                     $class[lcfirst($className)] = $reflector->getNamespaceName() . '\\' . $className;
                     $p = strtolower(preg_replace("/([a-z])([A-Z])/", "\$1_\$2", $className));
                     $class[$p] = $reflector->getNamespaceName() . '\\' . $className;
                 }
             }
             break;
         case is_array($class):
             break;
         default:
             throw new \Exception('Invalid input for $class variable. Type must be string, Zend\\Form\\View\\Helper\\AbstractHelper or array.');
     }
     foreach ($class as $name => $invokableClass) {
         $this->registerPlugin($name, $invokableClass);
     }
     return $this;
 }
开发者ID:athemcms,项目名称:netis,代码行数:31,代码来源:ZendRenderer.php

示例2: qualifiedClass

 protected static function qualifiedClass(\ReflectionClass $class, $type)
 {
     if (substr($type, 0, 1) == '\\') {
         return substr($type, 1);
     }
     $classNamespace = $class->getNamespaceName();
     if (!($uses = self::$namespaceUses[$classNamespace])) {
         $scriptContent = file_get_contents($class->getFileName());
         $scriptContent = substr($scriptContent, strpos($scriptContent, 'namespace ' . $class->getNamespaceName()));
         preg_match_all("/use\\s+([a-z]+(\\\\[a-z]+)*);/i", $scriptContent, $uses);
         if (isset($uses[1])) {
             $uses = $uses[1];
         } else {
             $uses = [];
         }
         $_temp = [];
         foreach ($uses as $use) {
             $parts = explode('\\', $use);
             $className = end($parts);
             $_temp[$className] = implode('\\', array_slice($parts, 0, -1));
         }
         $uses = $_temp;
         self::$namespaceUses[$classNamespace] = $uses;
     }
     if (isset($uses[$type])) {
         $classNamespace = $uses[$type];
     }
     return $classNamespace . '\\' . $type;
 }
开发者ID:mdzzohrabi,项目名称:telegram-sdk,代码行数:29,代码来源:DataTransformer.php

示例3: toObjectValue

 /**
  * {@inheritdoc}
  */
 public function toObjectValue($value, $type, \ReflectionProperty $property, $object)
 {
     $className = null;
     $context = new \ReflectionClass($property->class);
     //try to get the class from use statements in the class file
     if ($className === null) {
         $classContent = file_get_contents($context->getFileName());
         $regExps = ["/use\\s+([\\w\\\\]+{$type});/", "/use\\s+([\\w\\\\]+)\\s+as\\s+{$type}/"];
         foreach ($regExps as $regExp) {
             if ($matchClass = $this->extractClass($regExp, $classContent)) {
                 $className = $matchClass;
                 break;
             }
         }
     }
     //use the same namespace as class container
     if ($className === null && class_exists($context->getNamespaceName() . '\\' . $type)) {
         $className = $context->getNamespaceName() . '\\' . $type;
     }
     //use the type as class
     if (class_exists($type)) {
         $className = $type;
     }
     if (is_array($value) && $className !== null && class_exists($className) && $this->array2Object) {
         $property->setAccessible(true);
         $currentValue = $property->getValue($object);
         if (is_object($currentValue)) {
             $this->array2Object->populate($currentValue, $value);
             return $currentValue;
         } else {
             return $this->array2Object->createObject($className, $value);
         }
     }
     return $value;
 }
开发者ID:rafrsr,项目名称:lib-array2object,代码行数:38,代码来源:ObjectParser.php

示例4: generateRemotingApi

 /**
  * Generate Remote API from a list of controllers
  */
 public function generateRemotingApi()
 {
     $list = array();
     foreach ($this->remotingBundles as $bundle) {
         $bundleRef = new \ReflectionClass($bundle);
         $controllerDir = new Finder();
         $controllerDir->files()->in(dirname($bundleRef->getFileName()) . '/Controller/')->name('/.*Controller\\.php$/');
         foreach ($controllerDir as $controllerFile) {
             /** @var SplFileInfo $controllerFile */
             $controller = $bundleRef->getNamespaceName() . "\\Controller\\" . substr($controllerFile->getFilename(), 0, -4);
             $controllerRef = new \ReflectionClass($controller);
             foreach ($controllerRef->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
                 /** @var $methodDirectAnnotation Direct */
                 $methodDirectAnnotation = $this->annoReader->getMethodAnnotation($method, 'Tpg\\ExtjsBundle\\Annotation\\Direct');
                 if ($methodDirectAnnotation !== null) {
                     $nameSpace = str_replace("\\", ".", $bundleRef->getNamespaceName());
                     $className = str_replace("Controller", "", $controllerRef->getShortName());
                     $methodName = str_replace("Action", "", $method->getName());
                     $list[$nameSpace][$className][] = array('name' => $methodName, 'len' => count($method->getParameters()));
                 }
             }
         }
     }
     return $list;
 }
开发者ID:VAndAl37,项目名称:extjs-bundle,代码行数:28,代码来源:GeneratorService.php

示例5: getNamespace

 /**
  * @return string $classNamespace
  */
 protected function getNamespace() : string
 {
     if (is_null($this->namespace)) {
         $this->namespace = $this->reflection->getNamespaceName();
     }
     return $this->namespace;
 }
开发者ID:geolysis,项目名称:gz3-base,代码行数:10,代码来源:AbstractModule.php

示例6: initialize

 /**
  * @param Controller $controller
  * @param null $entityClassName
  * @return $this
  */
 public function initialize(Controller $controller, $entityClassName = null)
 {
     $entityClassName = explode('\\', $entityClassName);
     $this->entityClassName = $entityClassName[count($entityClassName) - 1];
     $this->reflector = new \ReflectionClass($controller);
     $this->namespace = explode('\\', $this->reflector->getNamespaceName());
     $key = array_search('__CG__', $this->namespace);
     //if the controller come from jms aop bundle
     if ($key) {
         for ($i = $key; $i >= 0; $i--) {
             unset($this->namespace[$i]);
         }
     }
     $this->namespace = array_values($this->namespace);
     $key = array_search('Controller', $this->namespace);
     $lastValue = $this->namespace[count($this->namespace) - 1];
     //May be you have nested controller
     if ('Controller' !== $lastValue) {
         $this->exclude = $lastValue;
     }
     for ($i = $key; $i <= count($this->namespace); $i++) {
         array_pop($this->namespace);
     }
     return $this;
 }
开发者ID:ihsanudin,项目名称:males-bundle,代码行数:30,代码来源:BundleGuesser.php

示例7: bringValueToType

 /**
  * Recursively brings value to type
  * @param $parent
  * @param $type
  * @param $value
  * @param bool $isNullable
  * @param array $restrictions
  * @throws Exception
  * @return mixed
  */
 public static function bringValueToType($parent, $type, $value, $isNullable = false, $restrictions = [])
 {
     if ($isNullable && null === $value || empty($type)) {
         return $value;
     }
     $typeParts = explode("[]", $type);
     $singleType = current($typeParts);
     if (count($typeParts) > 2) {
         throw new Exception(sprintf("In %s type '{$type}' is invalid", get_class($parent)), Exception::INTERNAL_ERROR);
     }
     //for array type
     if (count($typeParts) === 2) {
         if (!is_array($value)) {
             if ($parent instanceof \JsonRpc2\Dto) {
                 throw new Exception(sprintf("In %s value has type %s, but array expected", get_class($parent), gettype($value)), Exception::INTERNAL_ERROR);
             } else {
                 throw new Exception("Value has type %s, but array expected", gettype($value), Exception::INTERNAL_ERROR);
             }
         }
         foreach ($value as $key => $childValue) {
             $value[$key] = self::bringValueToType($parent, $singleType, $childValue, $isNullable);
         }
         return $value;
     }
     $class = new \ReflectionClass($parent);
     if (0 !== strpos($type, "\\") && class_exists($class->getNamespaceName() . "\\" . $type)) {
         $type = $class->getNamespaceName() . "\\" . $type;
     }
     if (class_exists($type)) {
         if (!is_subclass_of($type, '\\JsonRpc2\\Dto')) {
             throw new Exception(sprintf("In %s class '%s' MUST be instance of '\\JsonRpc2\\Dto'", get_class($parent), $type), Exception::INTERNAL_ERROR);
         }
         return new $type($value);
     } else {
         switch ($type) {
             case "string":
                 $value = (string) $value;
                 self::restrictValue($parent, $type, $value, $restrictions);
                 return $value;
                 break;
             case "int":
                 $value = (int) $value;
                 self::restrictValue($parent, $type, $value, $restrictions);
                 return $value;
                 break;
             case "float":
                 $value = (double) $value;
                 self::restrictValue($parent, $type, $value, $restrictions);
                 return $value;
                 break;
             case "array":
                 throw new Exception("Parameter type 'array' is deprecated. Use square brackets with simply types or DTO based classes instead.", Exception::INTERNAL_ERROR);
             case "bool":
                 return (bool) $value;
                 break;
         }
     }
     return $value;
 }
开发者ID:wowkaster,项目名称:yii2-json-rpc-2.0,代码行数:69,代码来源:Helper.php

示例8: getXmlNamespace

 /**
  *
  */
 public function getXmlNamespace()
 {
     $namespace = $this->_parseAnnotation($this->reflection->getDocComment(), 'xmlNamespace');
     if (!$namespace && $this->configuration) {
         $namespace = $this->configuration->getXmlNamespace($this->reflection->getNamespaceName());
     }
     return $namespace;
 }
开发者ID:ddvzwzjm,项目名称:xml-serializer,代码行数:11,代码来源:ClassMetadata.php

示例9: __construct

 /**
  * Initializes a new ClassMetadata instance that will hold the object-relational mapping
  * metadata of the class with the given name.
  *
  * @param string $entityName The name of the entity class the new instance is used for.
  */
 public function __construct($entityName)
 {
     $this->name = $entityName;
     $this->reflClass = new \ReflectionClass($entityName);
     $this->namespace = $this->reflClass->getNamespaceName();
     $this->primaryTable['name'] = $this->reflClass->getShortName();
     $this->rootEntityName = $entityName;
 }
开发者ID:nvdnkpr,项目名称:symfony-demo,代码行数:14,代码来源:ClassMetadata.php

示例10: __construct

 public function __construct(\ReflectionClass $intf)
 {
     $this->intf = $intf;
     $classParser = new PhpParser();
     $uses = array_merge($classParser->parseClass($this->intf), [$this->intf->getNamespaceName()]);
     $this->reader = new AnnotationReader($this->intf);
     $this->converter = new AnnotationConverter($uses);
 }
开发者ID:ritalin,项目名称:omelet,代码行数:8,代码来源:AnnotationConverterAdapter.php

示例11: initialize

 public function initialize()
 {
     $ref = new \ReflectionClass($this);
     $namespace = str_replace(basename($ref->getNamespaceName()), '', $ref->getNamespaceName());
     $this->moduleInstance = $this->getDI()->get($namespace . 'Module');
     $this->modelName = strtolower(basename($ref->name));
     $this->setSource(TH_DB_PREFIX . $this->modelName);
     $this->onInitialize();
 }
开发者ID:skullab,项目名称:thunderhawk,代码行数:9,代码来源:Model.php

示例12:

 static function widget_name()
 {
     $function_name = 'widget_';
     $r = new \ReflectionClass(get_called_class());
     $function_name .= Str::snake(str_replace('Widget', '', $r->getShortName()));
     if ('Larakit\\Widget' != $r->getNamespaceName()) {
         $function_name .= '__' . Str::snake(str_replace(['\\', 'Widget'], '', $r->getNamespaceName()));
     }
     return $function_name;
 }
开发者ID:larakit,项目名称:lk,代码行数:10,代码来源:Widget.php

示例13: generateClassName

 private function generateClassName()
 {
     $shortName = $this->reflection->getShortName();
     $fullName = $this->reflection->getNamespaceName() . "\\{$shortName}Mock";
     $counter = 1;
     while (class_exists($fullName . $counter)) {
         $counter++;
     }
     return ["{$shortName}Mock{$counter}", $fullName . $counter];
 }
开发者ID:bariew,项目名称:yii2-doctest-extension,代码行数:10,代码来源:Mock.php

示例14: getFactory

 /**
  * Creates the factory for this concrete product.
  * If the class does not exists yet, it is generated on the fly.
  * 
  * The factory implements an interface named after the short name of the
  * product class name with the suffix "Factory". The namespace is the
  * same namespace as the product classname.
  * 
  * The concrete factory is not of your concern, that's the trick of
  * factory method. That's why I put a random number after the classname
  * of the concrete factory : do not use that name !
  * 
  * @param string $fqcnProduct
  * 
  * @return object the the new factory
  */
 public function getFactory($fqcnProduct)
 {
     $refl = new \ReflectionClass($fqcnProduct);
     $fmName = 'Concrete' . $refl->getShortName() . 'Factory' . crc32($fqcnProduct);
     $fqcnFM = $refl->getNamespaceName() . '\\' . $fmName;
     if (!class_exists($fqcnFM)) {
         eval($this->generate($refl->getNamespaceName(), $refl->getShortName() . 'Factory', $fmName, $refl->getName()));
     }
     return new $fqcnFM();
 }
开发者ID:trismegiste,项目名称:php-is-magic,代码行数:26,代码来源:Generator.php

示例15: initialize

 public function initialize()
 {
     $ref = new \ReflectionClass($this);
     $namespace = str_replace(basename($ref->getNamespaceName()), '', $ref->getNamespaceName());
     $this->moduleInstance = $this->getDI()->get($namespace . 'Module');
     $this->tag->setTitleSeparator(' - ');
     $this->tag->setTitle('thunderhawk');
     $this->onInitialize();
     $this->onPrepareAssets();
     $this->onPrepareThemeAssets();
 }
开发者ID:skullab,项目名称:thunderhawk,代码行数:11,代码来源:Controller.php


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