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


PHP ClassReflection::isFinal方法代码示例

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


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

示例1: getCacheCode

 /**
  * Generate code to cache from class reflection.
  * This is a total mess, I know. Just wanted to flesh out the logic.
  *
  * @todo Refactor into a class, clean up logic, DRY it up, maybe move
  *       some of this into Zend\Code
  * @param  ClassReflection $r
  * @return string
  */
 protected static function getCacheCode(ClassReflection $r)
 {
     $useString = '';
     $usesNames = array();
     if (count($uses = $r->getDeclaringFile()->getUses())) {
         foreach ($uses as $use) {
             $usesNames[$use['use']] = $use['as'];
             $useString .= "use {$use['use']}";
             if ($use['as']) {
                 $useString .= " as {$use['as']}";
             }
             $useString .= ";\n";
         }
     }
     $declaration = '';
     if ($r->isAbstract() && !$r->isInterface()) {
         $declaration .= 'abstract ';
     }
     if ($r->isFinal()) {
         $declaration .= 'final ';
     }
     if ($r->isInterface()) {
         $declaration .= 'interface ';
     }
     if (!$r->isInterface()) {
         $declaration .= 'class ';
     }
     $declaration .= $r->getShortName();
     $parentName = false;
     if (($parent = $r->getParentClass()) && $r->getNamespaceName()) {
         $parentName = array_key_exists($parent->getName(), $usesNames) ? $usesNames[$parent->getName()] ?: $parent->getShortName() : (0 === strpos($parent->getName(), $r->getNamespaceName()) ? substr($parent->getName(), strlen($r->getNamespaceName()) + 1) : '\\' . $parent->getName());
     } else {
         if ($parent && !$r->getNamespaceName()) {
             $parentName = '\\' . $parent->getName();
         }
     }
     if ($parentName) {
         $declaration .= " extends {$parentName}";
     }
     $interfaces = array_diff($r->getInterfaceNames(), $parent ? $parent->getInterfaceNames() : array());
     if (count($interfaces)) {
         foreach ($interfaces as $interface) {
             $iReflection = new ClassReflection($interface);
             $interfaces = array_diff($interfaces, $iReflection->getInterfaceNames());
         }
         $declaration .= $r->isInterface() ? ' extends ' : ' implements ';
         $declaration .= implode(', ', array_map(function ($interface) use($usesNames, $r) {
             $iReflection = new ClassReflection($interface);
             return array_key_exists($iReflection->getName(), $usesNames) ? $usesNames[$iReflection->getName()] ?: $iReflection->getShortName() : (0 === strpos($iReflection->getName(), $r->getNamespaceName()) ? substr($iReflection->getName(), strlen($r->getNamespaceName()) + 1) : '\\' . $iReflection->getName());
         }, $interfaces));
     }
     $classContents = $r->getContents(false);
     $classFileDir = dirname($r->getFileName());
     $classContents = trim(str_replace('__DIR__', sprintf("'%s'", $classFileDir), $classContents));
     $return = "\nnamespace " . $r->getNamespaceName() . " {\n" . $useString . $declaration . "\n" . $classContents . "\n}\n";
     return $return;
 }
开发者ID:andreas-serlo,项目名称:athene2,代码行数:66,代码来源:Module.php

示例2: getClassType

 /**
  * Determine the class type (abstract, final, interface, class)
  *
  * @param ClassReflection $reflection
  * @return string
  */
 public function getClassType(ClassReflection $reflection)
 {
     $classType = '';
     if ($reflection->isAbstract() && !$reflection->isInterface()) {
         $classType .= 'abstract ';
     }
     if ($reflection->isFinal()) {
         $classType .= 'final ';
     }
     if ($reflection->isInterface()) {
         $classType .= 'interface ';
     }
     if (!$reflection->isInterface()) {
         $classType .= 'class ';
     }
     return $classType;
 }
开发者ID:simon-barton,项目名称:EdpSuperluminal,代码行数:23,代码来源:ClassTypeService.php

示例3: extractDeclaration

 /**
  * @param ClassReflection $classReflection
  * @return string
  */
 protected function extractDeclaration(ClassReflection $classReflection)
 {
     $declaration = '';
     if ($classReflection->isAbstract() && !$classReflection->isInterface()) {
         $declaration .= 'abstract ';
     }
     if ($classReflection->isFinal()) {
         $declaration .= 'final ';
     }
     if ($classReflection->isInterface()) {
         $declaration .= 'interface ';
     }
     if (!$classReflection->isInterface()) {
         $declaration .= 'class ';
     }
     $declaration .= $classReflection->getShortName();
     return $declaration;
 }
开发者ID:rgabruel,项目名称:refactoring-legacy-code,代码行数:22,代码来源:CacheCodeGenerator.php

示例4: buildClassDecleration

 /**
  * Create the Trait/Interface/Class definition
  *
  * @param Reflection\ClassReflection $class
  * #return string
  */
 protected function buildClassDecleration(Reflection\ClassReflection $class)
 {
     $code = '';
     if ($class->isTrait() === false && $class->isInterface() === false && $class->isAbstract()) {
         $code .= "abstract ";
     }
     if ($class->isFinal()) {
         $code .= "final ";
     }
     if ($class->isInterface()) {
         $code .= "interface ";
     } else {
         if ($class->isTrait()) {
             $code .= "trait ";
         } else {
             $code .= "class ";
         }
     }
     $code .= $class->getShortName();
     return $code;
 }
开发者ID:jdolieslager,项目名称:celeritas,代码行数:27,代码来源:Cacher.php


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