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


PHP ReflectionClass::getParentClass方法代码示例

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


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

示例1: generateRoute

 /**
  * Add all the routes in the router in parameter
  * @param $router Router
  */
 public function generateRoute(Router $router)
 {
     foreach ($this->classes as $class) {
         $classMethods = get_class_methods($this->namespace . $class . 'Controller');
         $rc = new \ReflectionClass($this->namespace . $class . 'Controller');
         $parent = $rc->getParentClass();
         $parent = get_class_methods($parent->name);
         $className = $this->namespace . $class . 'Controller';
         foreach ($classMethods as $methodName) {
             if (in_array($methodName, $parent) || $methodName == 'index') {
                 continue;
             } else {
                 foreach (Router::getSupportedHttpMethods() as $httpMethod) {
                     if (strstr($methodName, $httpMethod)) {
                         continue 2;
                     }
                     if (in_array($methodName . $httpMethod, $classMethods)) {
                         $router->add('/' . strtolower($class) . '/' . $methodName, new $className(), $methodName . $httpMethod, $httpMethod);
                         unset($classMethods[$methodName . $httpMethod]);
                     }
                 }
                 $router->add('/' . strtolower($class) . '/' . $methodName, new $className(), $methodName);
             }
         }
         $router->add('/' . strtolower($class), new $className(), 'index');
     }
 }
开发者ID:kazuohirai,项目名称:awayfromswag,代码行数:31,代码来源:ClassRouting.php

示例2: writeMethods

function writeMethods(ReflectionClass $class, $fp)
{
    if ($class->getParentClass()) {
        writeMethods($class->getParentClass(), $fp);
    }
    foreach ($class->getMethods() as $method) {
        if (!$method->isPublic() || $method->getName() === '__construct' || substr($method->getName(), 0, 3) === 'set' || substr($method->getName(), 0, 3) === 'add') {
            continue;
        }
        $return = '';
        $description = '';
        foreach (explode("\n", $method->getDocComment()) as $line) {
            $line = ltrim(trim(trim(trim($line), '*')), '/');
            if (strpos($line, '@return') === 0) {
                $return = trim(substr($line, 7));
                $return = preg_replace_callback('~[A-Z][a-zA-Z]+~', function ($match) {
                    if ($match[0] === '\\DateTime' || $match[0] === 'DateTime') {
                        return $match[0];
                    }
                    return '[' . $match[0] . '](#' . strtolower($match[0]) . ')';
                }, $return);
                $return = str_replace('|', '|', $return);
            } elseif (strpos($line, '@') !== 0 && !empty($line)) {
                $description = $line;
            }
        }
        $parameters = [];
        foreach ($method->getParameters() as $parameter) {
            $parameters[] = $parameter->getName();
        }
        fwrite($fp, '| ' . $method->getName() . " | {$return} | " . implode(', ', $parameters) . "  | {$description} |\n");
    }
}
开发者ID:shopapicz,项目名称:client,代码行数:33,代码来源:docs.php

示例3: getParentClass

 /**
  * @return bool|\PHPStan\Reflection\ClassReflection
  */
 public function getParentClass()
 {
     if ($this->reflection->getParentClass() === false) {
         return false;
     }
     return $this->broker->getClass($this->reflection->getParentClass()->getName());
 }
开发者ID:phpstan,项目名称:phpstan,代码行数:10,代码来源:ClassReflection.php

示例4: getContexts

 /**
  * Get a hierarchy of contexts for the given class as an array
  *
  * @param string $class
  * @return array
  */
 private function getContexts($class)
 {
     if ($class == Wires_Locator_Interface::GLOBAL_CONTEXT) {
         return array($class);
     }
     $ref = new ReflectionClass($class);
     $contexts = array($class);
     // collect interfaces
     if (is_array($ref->getInterfaceNames())) {
         foreach ($ref->getInterfaceNames() as $interface) {
             $contexts[] = $interface;
         }
     }
     // add parent class
     if ($ref->getParentClass()) {
         $parent_contexts = $this->getContexts($ref->getParentClass()->getName());
         foreach ($parent_contexts as $pc) {
             if ($pc != Wires_Locator_Interface::GLOBAL_CONTEXT && !in_array($pc, $contexts)) {
                 $contexts[] = $pc;
             }
         }
     }
     $contexts[] = Wires_Locator_Interface::GLOBAL_CONTEXT;
     return $contexts;
 }
开发者ID:spiralout,项目名称:Wires,代码行数:31,代码来源:Injector.php

示例5: create_controller

 public function create_controller($request)
 {
     $loaded = false;
     foreach ($this->context->load_paths() as $path) {
         if (list($controller_file, $controller_class) = $this->load_controller($request->parameter('controller'), $path)) {
             $loaded = true;
             break;
         }
     }
     if ($loaded === false) {
         throw new Exception('Cannot load controller `' . $request->parameter('controller') . '`, searched in `' . join(', ', $this->context->load_paths()) . '`');
     }
     // load ApplicationController if any.
     foreach ($this->context->load_paths() as $load_path) {
         if (file_exists($load_path . 'app/controllers/application.php')) {
             require $load_path . 'app/controllers/application.php';
             if (class_exists('ApplicationController')) {
                 break;
             }
         }
     }
     require $controller_file;
     if (false === class_exists($controller_class)) {
         throw new Exception('Expected `' . $controller_file . '` to define `' . $controller_class . '`');
     }
     $rclass = new ReflectionClass($controller_class);
     if (false === ($rclass->getParentClass() || $rclass->getParentClass() == 'ApplicationController' || $rclass->getParentClass() == 'ActionController')) {
         throw new Exception('Expected `' . $controller_class . '` to extend ApplicationController(recommended) or ActionControler');
     }
     // XXX: the $path
     $this->context->logger()->debug(str_replace($path, '${' . $this->context->config()->application_name() . '}/', $controller_file) . ' --> ' . $controller_class);
     return $rclass->newInstance($this->context);
 }
开发者ID:BackupTheBerlios,项目名称:medick-svn,代码行数:33,代码来源:Router.php

示例6: load

 /**
  * Loads from annotations from a directory.
  *
  * @param string $path A directory path
  * @param string $type The resource type
  *
  * @return EventsMap A event map
  *
  * @throws \InvalidArgumentException When annotations can't be parsed
  */
 public function load($path, $type = null)
 {
     $dir = $this->locator->locate($path);
     $map = new EventsMap();
     $map->addResource(new DirectoryResource($dir, '/Event\\.php$/'));
     $files = iterator_to_array(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir), \RecursiveIteratorIterator::LEAVES_ONLY));
     usort($files, function (\SplFileInfo $a, \SplFileInfo $b) {
         return (string) $a > (string) $b ? 1 : -1;
     });
     foreach ($files as $file) {
         if (!$file->isFile() || 'Event.php' !== substr($file->getFilename(), -9)) {
             continue;
         }
         if ($class = $this->findClass($file)) {
             $refl = new \ReflectionClass($class);
             if ($refl->isAbstract()) {
                 continue;
             }
             if (!$refl->getParentClass() || $refl->getParentClass()->getName() != 'Symfony\\Component\\EventDispatcher\\Event') {
                 continue;
             }
             $map->merge($this->loader->load($class, $type));
         }
     }
     return $map;
 }
开发者ID:intaro,项目名称:rule-engine-bundle,代码行数:36,代码来源:AnnotationDirectoryLoader.php

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

示例8: extractProperties

 /**
  *
  * Recursive properties extraction. Returns properties of the $reflectedClass and parents.
  *
  * @param \ReflectionClass $reflectedClass
  * @param int $filter
  * @return \ReflectionProperty[]
  */
 private function extractProperties(\ReflectionClass $reflectedClass, $filter)
 {
     $result = $reflectedClass->getProperties($filter);
     if ($reflectedClass->getParentClass()) {
         $result = array_merge($result, $this->extractProperties($reflectedClass->getParentClass(), $filter));
     }
     return $result;
 }
开发者ID:raphhh,项目名称:trex,代码行数:16,代码来源:ClassReflection.php

示例9: getTraitNames

 private function getTraitNames(\ReflectionClass $class) : array
 {
     $traitNames = $class->getTraitNames();
     while ($class->getParentClass() !== false) {
         $traitNames = array_values(array_unique(array_merge($traitNames, $class->getParentClass()->getTraitNames())));
         $class = $class->getParentClass();
     }
     return $traitNames;
 }
开发者ID:phpstan,项目名称:phpstan-nette,代码行数:9,代码来源:SmartObjectPropertiesClassReflectionExtension.php

示例10: injectTestCaseHierarchy

 protected function injectTestCaseHierarchy(AbstractTestCase $testCase)
 {
     $rc = new \ReflectionClass($testCase);
     while ($rc->getParentClass()) {
         $class = $rc->getParentClass()->getName();
         $testCase->getDi()->instanceManager()->addSharedInstance($testCase, $class);
         $rc = new \ReflectionClass($class);
     }
 }
开发者ID:magium,项目名称:magium,代码行数:9,代码来源:Initializer.php

示例11: getClassParents

 /**
  * @param \ReflectionClass $class
  * @return \ReflectionClass[]
  */
 public function getClassParents(\ReflectionClass $class)
 {
     if ($class->getParentClass()) {
         $parents = $this->getClassParents($class->getParentClass());
         $p = array($class->getParentClass());
         return array_merge($p, $parents);
     } else {
         return array();
     }
 }
开发者ID:activelamp,项目名称:taxonomy,代码行数:14,代码来源:MetadataFactory.php

示例12: traitsUsedRecursive

 protected function traitsUsedRecursive($class, $traitNames = [])
 {
     if (!$class instanceof ReflectionClass) {
         $class = new ReflectionClass($class);
     }
     $traitNames = array_merge($traitNames, $class->getTraitNames());
     if ($class->getParentClass() != false) {
         return array_merge($traitNames, $this->traitsUsedRecursive($class->getParentClass()));
     }
     return $traitNames;
 }
开发者ID:webfox,项目名称:silverstripe-helpers,代码行数:11,代码来源:ExtraPageFieldsExtension.php

示例13: getClassProperties

 /**
  * Method that extract all the properties of a class
  * @param string $class
  * @return array
  */
 public static function getClassProperties($class)
 {
     $properties = [];
     Logger::log('Extracting annotations properties from class ' . $class);
     $selfReflector = new \ReflectionClass($class);
     if (false !== $selfReflector->getParentClass()) {
         $properties = self::getClassProperties($selfReflector->getParentClass()->getName());
     }
     $properties = array_merge($properties, self::extractProperties($selfReflector));
     return $properties;
 }
开发者ID:c15k0,项目名称:psfs,代码行数:16,代码来源:InjectorHelper.php

示例14: addDependency

 protected function addDependency(array &$loadPaths, \ReflectionClass $dep)
 {
     if ($dep->getFileName() !== false) {
         $loadPaths[$dep->getName()] = $dep->getFileName();
     }
     if ($dep->getParentClass() instanceof \ReflectionClass) {
         $this->addDependency($loadPaths, $dep->getParentClass());
     }
     foreach ($dep->getInterfaces() as $interface) {
         $this->addDependency($loadPaths, $interface);
     }
 }
开发者ID:MrDoni98,项目名称:Genisys,代码行数:12,代码来源:RakLibServer.php

示例15: _getClassProperties

 /**
  * @param \ReflectionClass $class
  *
  * @return array
  */
 private function _getClassProperties(\ReflectionClass $class)
 {
     $props = [];
     if ($class->getParentClass()) {
         $props = $this->_getClassProperties($class->getParentClass());
     }
     foreach ($class->getProperties() as $property) {
         if (!in_array($property->getName(), $props)) {
             $props[] = $property->getName();
         }
     }
     return $props;
 }
开发者ID:ddvzwzjm,项目名称:xml-serializer,代码行数:18,代码来源:ClassMetadata.php


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