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


PHP ReflectionClass::isSubclassOf方法代码示例

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


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

示例1: __construct

 /**
  * @param string $entityName
  */
 public function __construct($entityName)
 {
     $this->entityReflectionClass = new \ReflectionClass($entityName);
     if (!$this->entityReflectionClass->isSubclassOf(AggregateRootInterface::class)) {
         throw new \LogicException(\sprintf('%s not implement %s, only the aggregate roots can have a repository class', $this->entityReflectionClass->name, AggregateRootInterface::class));
     }
 }
开发者ID:cubiche,项目名称:cubiche,代码行数:10,代码来源:Repository.php

示例2: __construct

 /**
  * DocBlockGenerator constructor.
  *
  * @param $className
  */
 public function __construct($className)
 {
     $this->className = $className;
     $this->reflector = new ReflectionClass($className);
     $generatorClass = $this->reflector->isSubclassOf('Controller') ? 'ControllerTagGenerator' : 'OrmTagGenerator';
     $this->tagGenerator = new $generatorClass($className, $this->getExistingTags());
 }
开发者ID:axyr,项目名称:silverstripe-ideannotator,代码行数:12,代码来源:DocBlockGenerator.php

示例3: display

 public function display($url)
 {
     $data = (object) json_decode(file_get_contents('php://input'), true);
     $reflection = new ReflectionClass($data->_type);
     if ($reflection->isSubclassOf('DataSource')) {
         $object = $reflection->newInstance();
         $object->parameters()->{'root-element'} = 'data';
         foreach ($data->_parameters as $key => $value) {
             $object->parameters()->{$key} = $value;
         }
         $result = $object->render(new Register());
         header('content-type: text/xml');
         echo $result->saveXML();
         exit;
     }
     if ($reflection->isSubclassOf('Event')) {
         $object = $reflection->newInstance();
         $object->parameters()->{'root-element'} = 'data';
         foreach ($data->_parameters as $key => $value) {
             $object->parameters()->{$key} = $value;
         }
         $result = $object->trigger(new Register(), (array) $data->_data);
         header('content-type: text/xml');
         echo $result->saveXML();
         exit;
     }
 }
开发者ID:psychoticmeowArchives,项目名称:javascript_api,代码行数:27,代码来源:api.php

示例4: testForm

 public function testForm()
 {
     $this->loadClassFromVfs("Form/TheliaStudioTestModuleConfigForm");
     $reflection = new \ReflectionClass("TheliaStudioTestModule\\Form\\TheliaStudioTestModuleConfigForm");
     // Test mother classes
     $this->assertTrue($reflection->isSubclassOf("TheliaStudioTestModule\\Form\\Base\\TheliaStudioTestModuleConfigForm"));
     $this->assertTrue($reflection->isSubclassOf("Thelia\\Form\\BaseForm"));
 }
开发者ID:Alban-io,项目名称:TheliaStudio,代码行数:8,代码来源:ConfigFormGeneratorTest.php

示例5: process

 /**
  * @see \Symfony\Component\HttpKernel\Bundle::registerCommands
  *
  * @param ContainerBuilder $container
  */
 public function process(ContainerBuilder $container)
 {
     if (!$container->hasParameter('bangpound_console.default_application_id')) {
         return;
     }
     $count = 0;
     $defaultApplicationId = $container->getParameter('bangpound_console.default_application_id');
     // Identify classes of already tagged Command services
     // so this pass does not create additional service definitions
     // for them.
     $classes = array_map(function ($id) use($container) {
         $class = $container->getDefinition($id)->getClass();
         return $container->getParameterBag()->resolveValue($class);
     }, array_keys($container->findTaggedServiceIds('console.command')));
     /** @var BundleInterface $bundle */
     foreach ($this->bundles as $bundle) {
         if (!is_dir($dir = $bundle->getPath() . '/Command')) {
             continue;
         }
         $finder = new Finder();
         $finder->files()->name('*Command.php')->in($dir);
         $prefix = $bundle->getNamespace() . '\\Command';
         /** @var SplFileInfo $file */
         foreach ($finder as $file) {
             $ns = $prefix;
             if ($relativePath = $file->getRelativePath()) {
                 $ns .= '\\' . strtr($relativePath, '/', '\\');
             }
             $class = $ns . '\\' . $file->getBasename('.php');
             // This command is already in the container.
             if (in_array($class, $classes)) {
                 continue;
             }
             $r = new \ReflectionClass($class);
             if ($r->isSubclassOf(self::COMMAND_CLASS) && !$r->isAbstract() && !$r->getConstructor()->getNumberOfRequiredParameters()) {
                 $name = Container::underscore(preg_replace('/Command/', '', $r->getShortName()));
                 $name = strtolower(str_replace('\\', '_', $name));
                 if (!$bundle->getContainerExtension()) {
                     $alias = preg_replace('/Bundle$/', '', $bundle->getName());
                     $alias = Container::underscore($alias);
                 } else {
                     $alias = $bundle->getContainerExtension()->getAlias();
                 }
                 $id = $alias . '.command.' . $name;
                 if ($container->hasDefinition($id)) {
                     $id = sprintf('%s_%d', hash('sha256', $file), ++$count);
                 }
                 $definition = $container->register($id, $r->getName());
                 $definition->addTag('console.command', ['application' => $defaultApplicationId]);
                 if ($r->isSubclassOf('Symfony\\Component\\DependencyInjection\\ContainerAwareInterface')) {
                     $definition->addMethodCall('setContainer', [new Reference('service_container')]);
                 }
             }
         }
     }
 }
开发者ID:bangpound,项目名称:console-bundle,代码行数:61,代码来源:AutoAddConsoleCommandPass.php

示例6: getPossibleActions

 /**
  * Get possible actions from Controller class.
  * Note! Code accelerator (eaccelerator, apc, xcache, etc ) should be disabled to get comment line.
  * Method returns only public methods that ends with "Action" 
  * @param string $controllerName
  * @return array like array(
  * 		array(
  * 			'name' => action name without "Action" postfix
  * 			'comment'=> doc comment
  * 		)
  * )
  */
 public static function getPossibleActions($controllerName)
 {
     $manager = new Backend_Modules_Manager();
     $appCfg = Registry::get('main', 'config');
     $designerConfig = Config::factory(Config::File_Array, $appCfg->get('configs') . 'designer.php');
     $templates = $designerConfig->get('templates');
     $reflector = new ReflectionClass($controllerName);
     if (!$reflector->isSubclassOf('Backend_Controller') && !$reflector->isSubclassOf('Frontend_Controller')) {
         return array();
     }
     $actions = array();
     $methods = $reflector->getMethods(ReflectionMethod::IS_PUBLIC);
     $url = array();
     if ($reflector->isSubclassOf('Backend_Controller')) {
         $url[] = $templates['adminpath'];
         $url[] = $manager->getModuleName($controllerName);
     } elseif ($reflector->isSubclassOf('Frontend_Controller')) {
         if ($appCfg['frontend_router_type'] == 'module') {
             $module = self::_moduleByClass($controllerName);
             if ($module !== false) {
                 $urlcode = Model::factory('Page')->getCodeByModule($module);
                 if ($urlcode !== false) {
                     $url[] = $urlcode;
                 }
             }
         } elseif ($appCfg['frontend_router_type'] == 'path') {
             $paths = explode('_', str_replace(array('Frontend_'), '', $controllerName));
             $pathsCount = count($paths) - 1;
             if ($paths[$pathsCount] === 'Controller') {
                 $paths = array_slice($paths, 0, $pathsCount);
             }
             $url = array_merge($url, $paths);
         } elseif ($appCfg['frontend_router_type'] == 'config') {
             $urlCode = self::_moduleByClass($controllerName);
             if ($urlCode !== false) {
                 $url[] = $urlCode;
             }
         }
     }
     if (!empty($methods)) {
         Request::setDelimiter($templates['urldelimiter']);
         Request::setRoot($templates['wwwroot']);
         foreach ($methods as $method) {
             if (substr($method->name, -6) !== 'Action') {
                 continue;
             }
             $actionName = substr($method->name, 0, -6);
             $paths = $url;
             $paths[] = $actionName;
             $actions[] = array('name' => $actionName, 'code' => $method->name, 'url' => Request::url($paths, false), 'comment' => self::_clearDocSymbols($method->getDocComment()));
         }
         Request::setDelimiter($appCfg['urlDelimiter']);
         Request::setRoot($appCfg['wwwroot']);
     }
     return $actions;
 }
开发者ID:vgrish,项目名称:dvelum,代码行数:68,代码来源:Code.php

示例7: perform

 /**
  * @param BootloadManager $bootloader
  */
 public function perform(BootloadManager $bootloader)
 {
     $grid = $this->tableHelper(['Class:', 'Module:', 'Booted:', 'Location:']);
     foreach ($bootloader->getClasses() as $class) {
         $reflection = new \ReflectionClass($class);
         $booted = $reflection->getConstant('BOOT') || !$reflection->isSubclassOf(Bootloader::class);
         $grid->addRow([$reflection->getName(), $reflection->isSubclassOf(ModuleInterface::class) ? '<info>yes</info>' : 'no', $booted ? 'yes' : '<info>no</info>', $reflection->getFileName()]);
     }
     $grid->render();
 }
开发者ID:vvval,项目名称:spiral,代码行数:13,代码来源:BootloadsCommand.php

示例8: __construct

 /**
  * Creates a new service reflector
  *
  * @param $className string The FQCN of the service class to reflect
  * @throws \Exception If the passed class name isn't a subclass of PartKeepr\Service\Service
  */
 public function __construct($className)
 {
     $this->reflClass = new \ReflectionClass($className);
     if (!$this->reflClass->isSubclassOf("PartKeepr\\Service\\Service")) {
         throw new \Exception(sprintf("%s isn't a subclass of PartKeepr\\Service\\Service, can't reflect", $className));
     }
     $this->className = $className;
     $this->reader = new \Doctrine\Common\Annotations\AnnotationReader();
     $this->registerAnnotationLoaders();
 }
开发者ID:JohnEffland,项目名称:PartKeepr,代码行数:16,代码来源:ServiceReflector.php

示例9: canCreateServiceWithName

 /**
  * @inheritdoc
  */
 public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
 {
     if (class_exists($requestedName)) {
         $reflect = new \ReflectionClass($requestedName);
         if ($reflect->isSubclassOf(AbstractForm::class) || $reflect->isSubclassOf(AbstractFieldset::class)) {
             return true;
         }
     }
     return false;
 }
开发者ID:fagundes,项目名称:zff-base,代码行数:13,代码来源:FormAbstractFactory.php

示例10: getContent

 public static function getContent(sfGeneratorManager $generatorManager, $class, $parameters)
 {
     $data = '';
     // needed to maintain BC with the 1.0 admin generator
     $r = new ReflectionClass($class);
     if (class_exists('sfPropelAdminGenerator') && ('sfPropelAdminGenerator' == $class || $r->isSubclassOf(new ReflectionClass('sfPropelAdminGenerator'))) || class_exists('sfDoctrineAdminGenerator') && ('sfDoctrineAdminGenerator' == $class || $r->isSubclassOf(new ReflectionClass('sfDoctrineAdminGenerator')))) {
         $data .= "require sfConfig::get('sf_symfony_lib_dir').'/plugins/sfCompat10Plugin/config/config.php';\n";
     }
     $data .= $generatorManager->generate($class, $parameters);
     return $data;
 }
开发者ID:ArnaudD,项目名称:RdvZ,代码行数:11,代码来源:sfGeneratorConfigHandler.class.php

示例11: associateModel

 /**
  * Associate model and generate set of model related methods.
  *
  * @param string $name
  * @param string $class
  */
 public function associateModel($name, $class)
 {
     $this->file->addUse($class);
     $this->file->addUse(ValidatesInterface::class);
     $reflection = new \ReflectionClass($class);
     $shortClass = $reflection->getShortName();
     $selection = "{$shortClass}[]";
     if ($reflection->isSubclassOf(Record::class)) {
         $this->file->addUse(Selector::class);
         $selection .= "|Selector";
     } elseif ($reflection->isSubclassOf(Document::class)) {
         $this->file->addUse(Collection::class);
         $selection .= "|Collection";
     }
     /**
      * Create new entity method.
      */
     $create = $this->class->method('create');
     $create->setComment(["Create new {$shortClass}. You must save entity using save method..", "", "@param array|\\Traversable \$fields Initial set of fields.", "@return {$shortClass}"]);
     $create->parameter('fields')->setOptional(true, []);
     $create->setSource(["return {$shortClass}::create(\$fields);"]);
     /**
      * Save entity method.
      */
     $save = $this->class->method('save');
     $save->setComment(["Save {$shortClass} instance.", "", "@param {$shortClass} \${$name}", "@param bool  \$validate", "@param array \$errors Will be populated if save fails.", "@return bool"]);
     $save->parameter($name)->setType($shortClass);
     $save->parameter("validate")->setOptional(true, true);
     $save->parameter("errors")->setOptional(true, null)->setPBR(true);
     $save->setSource(["if (\${$name}->save(\$validate)) {", "    return true;", "}", "", "\$errors = \${$name}->getErrors();", "", "return false;"]);
     /**
      * Delete entity method.
      */
     $delete = $this->class->method('delete');
     $delete->setComment(["Delete {$shortClass}.", "", "@param {$shortClass} \${$name}", "@return bool"]);
     $delete->parameter($name)->setType($shortClass);
     $delete->setSource("return \${$name}->delete();");
     /**
      * Find entity by it's primary key.
      */
     $findPrimary = $this->class->method('findByPK');
     $findPrimary->setComment(["Find {$shortClass} it's primary key.", "", "@param mixed \$primaryKey", "@return {$shortClass}|null"]);
     $findPrimary->parameter("primaryKey");
     $findPrimary->setSource("return {$shortClass}::findByPK(\$primaryKey);");
     /**
      * Find entity using where conditions.
      */
     $find = $this->class->method('find');
     $find->setComment(["Find {$shortClass} using set of where conditions.", "", "@param array \$where", "@return {$selection}"]);
     $find->parameter("where")->setType('array')->setOptional(true, []);
     $find->setSource("return {$shortClass}::find(\$where);");
 }
开发者ID:jwdeitch,项目名称:spiral,代码行数:58,代码来源:ServiceGenerator.php

示例12: testInheritance

 /**
  * @group unit
  */
 public function testInheritance()
 {
     $className = $this->_getExceptionClass();
     $reflection = new \ReflectionClass($className);
     $this->assertTrue($reflection->isSubclassOf('Exception'));
     $this->assertTrue($reflection->implementsInterface('Elastica\\Exception\\ExceptionInterface'));
 }
开发者ID:makeandship,项目名称:wordpress-fantastic-elasticsearch,代码行数:10,代码来源:AbstractExceptionTest.php

示例13: checkComponentClass

 private function checkComponentClass($componentClassName)
 {
     $reflectionClass = new ReflectionClass($componentClassName);
     if (!$reflectionClass->isSubclassOf('BASE_CLASS_Widget')) {
         throw new LogicException('Component is not configurable');
     }
 }
开发者ID:hardikamutech,项目名称:loov,代码行数:7,代码来源:ajax_component_panel.php

示例14: evaluate

 public function evaluate($configFiles)
 {
     $routeDefinitions = $this->parse($configFiles);
     $routes = array();
     $limit = count($this->routes) > 0;
     foreach ($routeDefinitions as $name => $route) {
         // we only load routes defined in the app.yml from
         if ($limit && !in_array($this->getOriginalName($name), $this->routes)) {
             continue;
         }
         $r = new ReflectionClass($route[0]);
         if ($r->isSubclassOf('sfRouteCollection')) {
             $route[1][0]['requirements']['sw_app'] = $this->app;
             $route[1][0]['requirements']['sw_host'] = $this->host;
             $collection_route = $r->newInstanceArgs($route[1]);
             foreach ($collection_route->getRoutes() as $name => $route) {
                 $routes[$this->app . '.' . $name] = new swEncapsulateRoute($route, $this->host, $this->app);
             }
         } else {
             $route[1][2]['sw_app'] = $this->app;
             $route[1][2]['sw_host'] = $this->host;
             $routes[$name] = new swEncapsulateRoute($r->newInstanceArgs($route[1]), $this->host, $this->app);
         }
     }
     return $routes;
 }
开发者ID:robinkanters,项目名称:dnsleergemeenschap,代码行数:26,代码来源:swCrossApplicationRoutingConfigHandler.class.php

示例15: process

 /**
  * {@inheritdoc}
  */
 public function process(ContainerBuilder $container)
 {
     $translationTargets = $container->getParameter('sonata_translation.targets');
     $adminExtensionReferences = $this->getAdminExtensionReferenceByTypes(array_keys($translationTargets));
     foreach ($container->findTaggedServiceIds('sonata.admin') as $id => $attributes) {
         $admin = $container->getDefinition($id);
         $modelClass = $container->getParameterBag()->resolveValue($admin->getArgument(1));
         if (!class_exists($modelClass)) {
             continue;
         }
         $modelClassReflection = new \ReflectionClass($modelClass);
         foreach ($adminExtensionReferences as $type => $reference) {
             foreach ($translationTargets[$type]['implements'] as $interface) {
                 if ($modelClassReflection->implementsInterface($interface)) {
                     $admin->addMethodCall('addExtension', array($reference));
                 }
             }
             foreach ($translationTargets[$type]['instanceof'] as $class) {
                 if ($modelClassReflection->getName() == $class || $modelClassReflection->isSubclassOf($class)) {
                     $admin->addMethodCall('addExtension', array($reference));
                 }
             }
         }
     }
 }
开发者ID:jorrit,项目名称:SonataTranslationBundle,代码行数:28,代码来源:AdminExtensionCompilerPass.php


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