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


PHP ReflectionClass::getName方法代码示例

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


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

示例1: createClassBody

 protected function createClassBody($class, $type)
 {
     if (!class_exists($class)) {
         throw new \InvalidArgumentException(sprintf('Class %s does not exist', $class));
     }
     if (substr($class, -4) !== 'Base') {
         throw new \InvalidArgumentException('The class must end in `Base`');
     }
     $refClass = new \ReflectionClass($class);
     $namespace = $refClass->getNamespaceName();
     $baseClassName = $namespace ? substr($refClass->getName(), strlen($namespace) + 1) : $refClass->getName();
     $destinationClassName = substr($baseClassName, 0, -4);
     $layerableMethods = array();
     $fileLines = file($refClass->getFileName());
     foreach ($refClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
         if (strpos($method->getDocComment(), '@Stratum\\Layerable')) {
             $methodBody = implode(PHP_EOL, array_slice($fileLines, $method->getStartLine() - 1, $method->getEndLine() - $method->getStartLine() + 1));
             $layerableMethods[] = array('head' => substr($methodBody, 0, strpos($methodBody, '{')), 'name' => $method->getName(), 'arguments' => implode(', ', array_map(function ($parameter) {
                 return '$' . $parameter->getName();
             }, $method->getParameters())));
         }
     }
     if (!in_array($type, array('class', 'layer', 'wrapper'))) {
         throw new \InvalidArgumentException('Invalid type of class. Allowed values are `class`, `layer` and `wrapper`.');
     }
     ob_start();
     include_once __DIR__ . '/../templates/' . $type . '.php';
     $output = ob_get_clean();
     return $output;
 }
开发者ID:siriusphp,项目名称:stratum,代码行数:30,代码来源:ClassMaker.php

示例2: from

 /**
  * @param  \ReflectionClass|string
  * @return self
  */
 public static function from($from)
 {
     $from = new \ReflectionClass($from instanceof \ReflectionClass ? $from->getName() : $from);
     if (PHP_VERSION_ID >= 70000 && $from->isAnonymous()) {
         $class = new static('anonymous');
     } else {
         $class = new static($from->getShortName(), new PhpNamespace($from->getNamespaceName()));
     }
     $class->type = $from->isInterface() ? 'interface' : (PHP_VERSION_ID >= 50400 && $from->isTrait() ? 'trait' : 'class');
     $class->final = $from->isFinal() && $class->type === 'class';
     $class->abstract = $from->isAbstract() && $class->type === 'class';
     $class->implements = $from->getInterfaceNames();
     $class->documents = $from->getDocComment() ? array(preg_replace('#^\\s*\\* ?#m', '', trim($from->getDocComment(), "/* \r\n\t"))) : array();
     if ($from->getParentClass()) {
         $class->extends = $from->getParentClass()->getName();
         $class->implements = array_diff($class->implements, $from->getParentClass()->getInterfaceNames());
     }
     foreach ($from->getProperties() as $prop) {
         if ($prop->getDeclaringClass()->getName() === $from->getName()) {
             $class->properties[$prop->getName()] = Property::from($prop);
         }
     }
     foreach ($from->getMethods() as $method) {
         if ($method->getDeclaringClass()->getName() === $from->getName()) {
             $class->methods[$method->getName()] = Method::from($method)->setNamespace($class->namespace);
         }
     }
     return $class;
 }
开发者ID:luminousinfoways,项目名称:pccfoas,代码行数:33,代码来源:ClassType.php

示例3: getRestServices

 /**
  * Helper method to get all REST services.
  *
  * @todo Build a cache for this!
  *
  * @return  array
  */
 protected function getRestServices()
 {
     /**
      * Lambda function to get all service classes that exists in application.
      *
      * @param   string  $file
      *
      * @return  null|\stdClass
      */
     $iterator = function ($file) {
         // Specify service class name with namespace
         $className = '\\App\\Services\\' . str_replace('.php', '', basename($file));
         // Get reflection about controller class
         $reflectionClass = new \ReflectionClass($className);
         if (!$reflectionClass->isAbstract() && $reflectionClass->implementsInterface('\\App\\Services\\Interfaces\\Rest')) {
             $bits = explode('\\', $reflectionClass->getName());
             // Create output
             $output = new \stdClass();
             $output->class = $reflectionClass->getName();
             $output->name = 'service.' . end($bits);
             return $output;
         }
         return null;
     };
     return array_filter(array_map($iterator, glob($this->app->getRootDir() . 'src/App/Services/*.php')));
 }
开发者ID:tarlepp,项目名称:silex-backend,代码行数:33,代码来源:Loader.php

示例4: getInstance

 /**
  *
  * @param InjectorInterface $injector
  * @return mixed
  */
 protected function getInstance(InjectorInterface $injector)
 {
     $name = $this->aliasClassReflection->getName();
     $nameValueMap = $this->getNameValueMap();
     $definitionArray = $this->getDefinitionArray();
     return $injector->create($name, $nameValueMap, $definitionArray);
 }
开发者ID:northborndesign,项目名称:northborndesign.tundra.injectors,代码行数:12,代码来源:AliasDefinition.php

示例5: getInjectionProperties

 public function getInjectionProperties(\ReflectionClass $class)
 {
     $injections = array();
     $properties = $class->getProperties();
     /* @var $prop \ReflectionProperty */
     foreach ($properties as $prop) {
         preg_match("/@Inject(.*?)[\\*\\@]/si", $prop->getDocComment(), $m);
         if (count($m) > 0) {
             $dep = trim(str_replace(array('(', ')', '"'), '', $m[1]));
             if (strpos($dep, ',') !== false) {
                 throw new AnnotationException("Commatas are not allowed for class property inject annotations! " . $class->getName() . '#' . $prop->name);
             }
             if (strlen($dep) > 0) {
                 $injections[$prop->getName()] = array('class' => trim($dep));
                 continue;
             }
             preg_match("/@var\\s(.*?)[\\*\\@\\s]/si", $prop->getDocComment(), $ma);
             if (count($ma) > 0) {
                 $injections[$prop->getName()] = array('class' => trim($ma[1]));
                 continue;
             }
             throw new AnnotationException("If no @var annotation is provided, you have to specify the value or class for the property with the inject annotation! " . $class->getName() . '#' . $prop->name);
         }
     }
     return $injections;
 }
开发者ID:johnarben2468,项目名称:sampleffuf-core,代码行数:26,代码来源:MetadataResolver.php

示例6: loadMetadataFromFile

 /**
  * {@inheritdoc}
  */
 public function loadMetadataFromFile(\ReflectionClass $class, $path)
 {
     $classMetadata = new ClassMetadata($class->getName());
     $use = libxml_use_internal_errors(true);
     $dom = new \DOMDocument('1.0');
     $dom->load($path);
     if (!$dom->schemaValidate(__DIR__ . '/../../../schema/mapping.xsd')) {
         $message = array_reduce(libxml_get_errors(), function ($foo, $error) {
             return $error->message;
         });
         throw new \InvalidArgumentException(sprintf('Could not validate XML mapping at "%s": %s', $path, $message));
     }
     libxml_use_internal_errors($use);
     $xpath = new \DOMXpath($dom);
     $xpath->registerNamespace('psict', self::XML_NAMESPACE);
     foreach ($xpath->query('//psict:class') as $classEl) {
         $classAttr = $classEl->getAttribute('name');
         if ($classAttr !== $class->getName()) {
             throw new \InvalidArgumentException(sprintf('Expected class name to be "%s" but it is mapped as "%s"', $class->getName(), $classAttr));
         }
         foreach ($xpath->query('./psict:field', $classEl) as $fieldEl) {
             $shared = $this->extractOptionSet($xpath, $fieldEl, 'shared-options');
             $form = $this->extractOptionSet($xpath, $fieldEl, 'form-options');
             $view = $this->extractOptionSet($xpath, $fieldEl, 'view-options');
             $storage = $this->extractOptionSet($xpath, $fieldEl, 'storage-options');
             $propertyMetadata = new PropertyMetadata($class->getName(), $fieldEl->getAttribute('name'), $fieldEl->getAttribute('type'), $fieldEl->getAttribute('role'), $fieldEl->getAttribute('group'), ['shared' => $shared, 'form' => $form, 'view' => $view, 'storage' => $storage]);
             $classMetadata->addPropertyMetadata($propertyMetadata);
         }
     }
     return $classMetadata;
 }
开发者ID:symfony-cmf,项目名称:content-type,代码行数:34,代码来源:XmlDriver.php

示例7: configureRoute

 protected function configureRoute(\Symfony\Component\Routing\Route $route, \ReflectionClass $class, \ReflectionMethod $method, $annot)
 {
     // defines the controller
     $route->setDefault('_controller', $class->getName() . '::' . $method->getName());
     // verify the other callbacks
     $options = $annot->getOptions();
     foreach ($options as $prop => &$values) {
         if (!in_array($prop, array('_after_middlewares', '_before_middlewares', '_converters'))) {
             continue;
         }
         if (empty($values)) {
             continue;
         }
         foreach ($values as &$value) {
             if (is_string($value) && $class->hasMethod($value)) {
                 // call static method from class
                 $value = array($class->getName(), $value);
             }
         }
         unset($value);
         // clear reference
     }
     unset($values);
     $route->setOptions($options);
 }
开发者ID:brodaproject,项目名称:broda,代码行数:25,代码来源:AnnotationClassLoader.php

示例8: loadMetadataForClass

 public function loadMetadataForClass(\ReflectionClass $class)
 {
     $classMetadata = new ClassMetadata($class->getName());
     foreach ($class->getProperties() as $reflectionProperty) {
         foreach ($this->reader->getPropertyAnnotations($reflectionProperty) as $fieldAnnot) {
             $propertyMetadata = new PropertyMetadata($class->getName(), $reflectionProperty->getName());
             if ($fieldAnnot instanceof BRIDGE\Entity) {
                 /**
                  * @var BRIDGE\Entity $fieldAnnot
                  */
                 $propertyMetadata->targetObject = $fieldAnnot->targetEntity;
                 $propertyMetadata->targetManager = $fieldAnnot->entityManager;
                 $propertyMetadata->type = 'dbal';
                 $classMetadata->addPropertyMetadata($propertyMetadata);
             }
             if ($fieldAnnot instanceof BRIDGE\Document) {
                 /**
                  * @var BRIDGE\Document $fieldAnnot
                  */
                 $propertyMetadata->targetObject = $fieldAnnot->targetDocument;
                 $propertyMetadata->targetManager = $fieldAnnot->documentManager;
                 $propertyMetadata->type = 'odm';
                 $classMetadata->addPropertyMetadata($propertyMetadata);
             }
         }
     }
     return $classMetadata;
 }
开发者ID:netvlies,项目名称:doctrinebridgebundle,代码行数:28,代码来源:AnnotationDriver.php

示例9: expandClassName

 /**
  * Expands class name into full name.
  * @param  string
  * @return string  full name
  * @throws Nette\InvalidArgumentException
  */
 public static function expandClassName($name, \ReflectionClass $rc)
 {
     if (empty($name)) {
         throw new Nette\InvalidArgumentException('Class name must not be empty.');
     } elseif ($name === 'self') {
         return $rc->getName();
     } elseif ($name[0] === '\\') {
         // fully qualified name
         return ltrim($name, '\\');
     }
     $uses =& self::$cache[$rc->getName()];
     if ($uses === NULL) {
         self::$cache = self::parseUseStatemenets(file_get_contents($rc->getFileName()), $rc->getName()) + self::$cache;
         $uses =& self::$cache[$rc->getName()];
     }
     $parts = explode('\\', $name, 2);
     if (isset($uses[$parts[0]])) {
         $parts[0] = $uses[$parts[0]];
         return implode('\\', $parts);
     } elseif ($rc->inNamespace()) {
         return $rc->getNamespaceName() . '\\' . $name;
     } else {
         return $name;
     }
 }
开发者ID:vladimirslevercz,项目名称:alena,代码行数:31,代码来源:PhpReflection.php

示例10: getParentClass

 /**
  * @return \ReflectionClass
  */
 public function getParentClass()
 {
     if (defined('HHVM_VERSION')) {
         return new ReflectionClass($this->reflectionClass->getName());
     }
     return $this->reflectionClass;
 }
开发者ID:crashuxx,项目名称:phproxy,代码行数:10,代码来源:ProxyClassImpl.php

示例11: __construct

 /**
  * Initializes a new ClassMetadata instance that will hold the object-document mapping
  * metadata of the class with the given name.
  *
  * @param string $documentName The name of the document class the new instance is used for.
  */
 public function __construct($documentName)
 {
     parent::__construct($documentName);
     $this->reflClass = new \ReflectionClass($documentName);
     $this->name = $this->reflClass->getName();
     $this->namespace = $this->reflClass->getNamespaceName();
 }
开发者ID:hlubek,项目名称:couchdb-odm,代码行数:13,代码来源:ClassMetadata.php

示例12: __invoke

 /**
  * @param \ReflectionClass $class
  *
  * @return \ReflectionClass[]
  */
 public function __invoke(\ReflectionClass $class)
 {
     if ($parentClass = $class->getParentClass()) {
         return array_merge([$class->getName() => $class], $this->__invoke($parentClass));
     }
     return [$class->getName() => $class];
 }
开发者ID:ocramius,项目名称:finalizer,代码行数:12,代码来源:InheritanceClasses.php

示例13: loadResourceControllerModule

 /**
  * Carrega os recursos controllers dos modulos da aplicacao.
  * @param $pathController
  * @param $module
  * @param string $parentClass - indica qual é a classe parent da classe, para saber se é um controller
  * @return mixed|string
  */
 public function loadResourceControllerModule($parentClass = "Zend\\Mvc\\Controller\\AbstractActionController")
 {
     $resourcesController = array();
     foreach ($this->getModulesSystem() as $module) {
         $pathDefaultControllersModule = './module/' . $module . '/src/' . $module . '/Controller/';
         foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($pathDefaultControllersModule)) as $filename) {
             if ($filename->isDir()) {
                 continue;
             }
             //criar um metodo para acomodar este tratamento
             $pathController = str_replace('./module/' . $module . '/src/', '', $filename);
             $pathController = str_replace('.php', '', $pathController);
             $pathController = "\\" . str_replace('/', "\\", $pathController);
             if ($pathController != "\\" . $module . "\\Controller\\AbstractController") {
                 $oReflectionClass = new \ReflectionClass($pathController);
                 if (is_subclass_of($oReflectionClass->getName(), $parentClass) || is_subclass_of($oReflectionClass->getName(), "Base\\Controller\\AbstractController")) {
                     $actions = $this->loadResourceActionsController($oReflectionClass);
                     if (!empty($actions)) {
                         $resourcesController[$module][$oReflectionClass->getName()] = $actions;
                     }
                 }
             }
         }
     }
     return $resourcesController;
 }
开发者ID:ericoautocad,项目名称:module-security-zf2,代码行数:33,代码来源:RecursoSistema.php

示例14: discriminateClass

 private function discriminateClass(\ReflectionClass $class, array $data)
 {
     $properties = $class->getDefaultProperties();
     if (!empty($properties["modelDiscriminatorMap"])) {
         $discriminator = $properties["modelDiscriminatorMap"];
         if (empty($discriminator["discriminatorField"])) {
             throw new ModelException("Cannot use the discriminator map for '{$class->getName()}'. No discriminator field was configured.");
         }
         $field = $discriminator["discriminatorField"];
         if (empty($data[$field])) {
             throw new ModelException("The discriminator field '{$field}' for '{$class->getName()}' was not found in the data set.");
         }
         $baseNamespace = !empty($discriminator["subclassNamespace"]) ? $discriminator["subclassNamespace"] : $class->getNamespaceName();
         $classNameSuffix = !empty($discriminator["subclassSuffix"]) ? $discriminator["subclassSuffix"] : "";
         $map = !empty($discriminator["map"]) ? $discriminator["map"] : [];
         // generate the class name
         $value = $data[$field];
         if (empty($map[$value])) {
             throw new ModelException("The discriminator value '{$value}' was not registered in the map");
         }
         $className = $map[$value] !== true ? $map[$value] : $this->toStudlyCaps($value);
         // if this is not a valid class, try it with the base namespace
         if (!class_exists($className)) {
             $className = $baseNamespace . "\\" . $className;
             if (!class_exists($className)) {
                 $className .= $classNameSuffix;
             }
         }
         // create the reflection object. This will throw an exception if the class does not exist, as is expected.
         $class = new \ReflectionClass($className);
     }
     return $class;
 }
开发者ID:downsider,项目名称:clay,代码行数:33,代码来源:ClassDiscriminatorTrait.php

示例15: map

 /**
  * @param $serviceId
  * @param $class
  * @param $method
  */
 public function map($serviceId, $class, $method)
 {
     $class = new \ReflectionClass($class);
     $method = $class->getMethod($method);
     $annotations = [];
     $annotations[] = $this->reader->getMethodAnnotation($method, self::REGISTER_ANNOTATION_CLASS);
     $annotations[] = $this->reader->getMethodAnnotation($method, self::SUBSCRIBE_ANNOTATION_CLASS);
     $securityAnnotation = $this->reader->getMethodAnnotation($method, self::SECURITY_ANNOTATION_CLASS);
     /* @var $annotation Register */
     foreach ($annotations as $annotation) {
         if ($annotation) {
             /* @var $workerAnnotation Register  */
             $workerAnnotation = isset($this->workerAnnotationsClasses[$class->getName()]) ? $this->workerAnnotationsClasses[$class->getName()] : null;
             if ($workerAnnotation) {
                 $worker = $workerAnnotation->getName();
             } else {
                 $worker = $annotation->getWorker() ?: "default";
             }
             $mapping = new URIClassMapping($serviceId, $method, $annotation);
             if (isset($this->mappings[$worker][$annotation->getName()])) {
                 $uri = $annotation->getName();
                 $className = $this->mappings[$worker][$annotation->getName()]->getMethod()->class;
                 throw new Exception("The URI '{$uri}' has already been registered in '{$className}' for the worker '{$worker}'");
             }
             //Set security Annotation
             $mapping->setSecurityAnnotation($securityAnnotation);
             $this->mappings[$worker][$annotation->getName()] = $mapping;
         }
     }
 }
开发者ID:trajedy,项目名称:ThruwayBundle,代码行数:35,代码来源:ResourceMapper.php


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