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


PHP ClassType::isAbstract方法代码示例

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


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

示例1: getPresenterClass

 /**
  * Generates and checks presenter class name.
  *
  * @param  string presenter name
  * @return string  class name
  * @throws Application\InvalidPresenterException
  */
 public function getPresenterClass(&$name)
 {
     if (isset($this->cache[$name])) {
         return $this->cache[$name];
     }
     if (!is_string($name) || !Nette\Utils\Strings::match($name, '#^[a-zA-Z\\x7f-\\xff][a-zA-Z0-9\\x7f-\\xff:]*\\z#')) {
         throw new Application\InvalidPresenterException("Presenter name must be alphanumeric string, '{$name}' is invalid.");
     }
     $classes = $this->formatPresenterClasses($name);
     if (!$classes) {
         throw new Application\InvalidPresenterException("Cannot load presenter '{$name}', no applicable mapping found.");
     }
     $class = $this->findValidClass($classes);
     if (!$class) {
         throw new Application\InvalidPresenterException("Cannot load presenter '{$name}', none of following classes were found: " . implode(', ', $classes));
     }
     $reflection = new Nette\Reflection\ClassType($class);
     $class = $reflection->getName();
     if (!$reflection->implementsInterface('Nette\\Application\\IPresenter')) {
         throw new Application\InvalidPresenterException("Cannot load presenter '{$name}', class '{$class}' is not Nette\\Application\\IPresenter implementor.");
     }
     if ($reflection->isAbstract()) {
         throw new Application\InvalidPresenterException("Cannot load presenter '{$name}', class '{$class}' is abstract.");
     }
     return $this->cache[$name] = $class;
 }
开发者ID:librette,项目名称:presenter-factory,代码行数:33,代码来源:PresenterFactory.php

示例2: getPresenterClass

 /**
  * Generates and checks presenter class name.
  * @param  string  presenter name
  * @return string  class name
  * @throws InvalidPresenterException
  */
 public function getPresenterClass(&$name)
 {
     if (isset($this->cache[$name])) {
         list($class, $name) = $this->cache[$name];
         return $class;
     }
     if (!is_string($name) || !Nette\Utils\Strings::match($name, '#^[a-zA-Z\\x7f-\\xff][a-zA-Z0-9\\x7f-\\xff:]*\\z#')) {
         throw new InvalidPresenterException("Presenter name must be alphanumeric string, '{$name}' is invalid.");
     }
     $class = $this->formatPresenterClass($name);
     if (!class_exists($class)) {
         // internal autoloading
         $file = $this->formatPresenterFile($name);
         if (is_file($file) && is_readable($file)) {
             Nette\Utils\LimitedScope::load($file, TRUE);
         }
         if (!class_exists($class)) {
             throw new InvalidPresenterException("Cannot load presenter '{$name}', class '{$class}' was not found in '{$file}'.");
         }
     }
     $reflection = new Nette\Reflection\ClassType($class);
     $class = $reflection->getName();
     if (!$reflection->implementsInterface('Nette\\Application\\IPresenter')) {
         throw new InvalidPresenterException("Cannot load presenter '{$name}', class '{$class}' is not Nette\\Application\\IPresenter implementor.");
     }
     if ($reflection->isAbstract()) {
         throw new InvalidPresenterException("Cannot load presenter '{$name}', class '{$class}' is abstract.");
     }
     // canonicalize presenter name
     $realName = $this->unformatPresenterClass($class);
     if ($name !== $realName) {
         if ($this->caseSensitive) {
             throw new InvalidPresenterException("Cannot load presenter '{$name}', case mismatch. Real name is '{$realName}'.");
         } else {
             $this->cache[$name] = array($class, $realName);
             $name = $realName;
         }
     } else {
         $this->cache[$name] = array($class, $realName);
     }
     return $class;
 }
开发者ID:genextwebs,项目名称:dropbox-sample,代码行数:48,代码来源:PresenterFactory.php

示例3: loadDefinitions

 private function loadDefinitions(ContainerBuilder $builder)
 {
     $classes = $this->robotLoader->getIndexedClasses();
     $markerInterface = new ClassType(IServiceMarker::class);
     foreach ($classes as $key => $val) {
         if (Strings::endsWith($key, 'Service')) {
             $reflection = new ClassType($key);
             $serviceName = '_auto.' . str_replace("\\", "_", $key);
             if (!$reflection->isAbstract() && $reflection->isSubclassOf($markerInterface)) {
                 $builder->addDefinition($serviceName)->setClass($key);
             }
         }
     }
 }
开发者ID:dtforce,项目名称:nette-inject,代码行数:14,代码来源:InjectionCompilerExtension.php

示例4: getAnnotatedProperties

 /**
  * Parse class and returns names and target classes of annotated properties
  * @param $className
  * @return mixed
  * @throws RestException
  */
 public function getAnnotatedProperties($className)
 {
     if (!isset($this->classProperties[$className])) {
         $this->classProperties[$className] = array();
         $ref = new ClassType($className);
         if ($ref->isAbstract() or $ref->isInterface()) {
             throw new RestException("Class can not be either abstract nor interface");
         }
         $ann = $ref->getAnnotations();
         $parents = class_parents($className);
         $parents[$className] = $className;
         if ($className != DataHash::class and (!$parents or !in_array(DataHash::class, $parents))) {
             throw RestException::notInheritedForm($className, DataHash::class);
         }
         $this->parseProperties($ref, $ann, 'property');
         $this->parseProperties($ref, $ann, 'property-read');
     }
     return $this->classProperties[$className];
 }
开发者ID:pipaslot,项目名称:rest,代码行数:25,代码来源:ResultMapper.php

示例5: findByInterfaces

 /**
  * @param array $dirs
  * @param array $interfaces
  * @return array
  */
 private function findByInterfaces(array $dirs, array $interfaces)
 {
     $loader = $this->createLoader();
     $loader->addDirectory($dirs);
     $loader->rebuild();
     $loader->register();
     $classes = [];
     foreach (array_keys($loader->getIndexedClasses()) as $class) {
         // Skip not existing class
         if (!class_exists($class, TRUE)) {
             continue;
         }
         // Detect by reflection
         $ct = new ClassType($class);
         // Skip abstract
         if ($ct->isAbstract()) {
             continue;
         }
         // Does class implement one of given interface
         foreach ($interfaces as $interface) {
             if ($ct->implementsInterface($interface)) {
                 $classes[] = $ct->getName();
             }
         }
     }
     return $classes;
 }
开发者ID:minetro,项目名称:service-autoloader,代码行数:32,代码来源:ServiceAutoloadExtension.php


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