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


PHP ReflectionObject::isSubclassOf方法代码示例

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


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

示例1: add

 /**
  * Add new element.
  *
  * @param RenderableInterface $element
  * @return $this
  * @throws ReactorException
  */
 public function add(RenderableInterface $element)
 {
     $reflector = new \ReflectionObject($element);
     $allowed = false;
     foreach ($this->allowed as $class) {
         if ($reflector->isSubclassOf($class) || get_class($element) == $class) {
             $allowed = true;
             break;
         }
     }
     if (!$allowed) {
         $type = get_class($element);
         throw new ReactorException("Elements with type '{$type}' are not allowed.");
     }
     $this->elements[] = $element;
     return $this;
 }
开发者ID:vvval,项目名称:spiral,代码行数:24,代码来源:DeclarationAggregator.php

示例2: isExpectedException

 /**
  * Returns true if the {@link java.lang.reflect.Method Method} definition on
  * the service is specified to throw the exception contained in the
  * InvocationTargetException or false otherwise. NOTE we do not check that the
  * type is serializable here. We assume that it must be otherwise the
  * application would never have been allowed to run.
  *
  * @param MappedMethod serviceIntfMethod the method from the RPC request
  * @param Exception cause the exception that the method threw
  * @return boolean true if the exception's type is in the method's signature
  */
 private static function isExpectedException(MappedMethod $serviceIntfMethod, Exception $cause)
 {
     assert($serviceIntfMethod != null);
     assert($cause != null);
     /*Class[]*/
     $exceptionsThrown = $serviceIntfMethod->getExceptionTypes();
     if (count($exceptionsThrown) <= 0) {
         // The method is not specified to throw any exceptions
         //
         return false;
     }
     $causeType = new ReflectionObject($cause);
     // $cause.getClass();
     foreach ($exceptionsThrown as $exceptionThrown) {
         assert($exceptionThrown != null);
         //$exceptionThrown = new SimpleMappedClass();
         if ($causeType->getFileName() == $exceptionThrown->getReflectionClass()->getFileName() && $causeType->getName() == $exceptionThrown->getReflectionClass()->getName() || $causeType->isSubclassOf($exceptionThrown->getReflectionClass()->getName())) {
             //.isAssignableFrom(causeType)) {
             return true;
         }
     }
     return false;
 }
开发者ID:rrsc,项目名称:freemed,代码行数:34,代码来源:RPC.class.php

示例3: ReflectionObject

<?php

class A
{
}
$ro = new ReflectionObject(new A());
var_dump($ro->isSubclassOf());
var_dump($ro->isSubclassOf('A', 5));
var_dump($ro->isSubclassOf('X'));
开发者ID:badlamer,项目名称:hhvm,代码行数:9,代码来源:ReflectionObject_isSubclassOf_error.php

示例4: ReflectionObject

<?php

class C
{
}
$ro = new ReflectionObject(new C());
echo "\n\nTest bad arguments:\n";
try {
    var_dump($ro->isSubclassOf());
} catch (Exception $e) {
    echo $e->getMessage() . "\n";
}
try {
    var_dump($ro->isSubclassOf('C', 'C'));
} catch (Exception $e) {
    echo $e->getMessage() . "\n";
}
try {
    var_dump($ro->isSubclassOf(null));
} catch (Exception $e) {
    echo $e->getMessage() . "\n";
}
try {
    var_dump($ro->isSubclassOf('ThisClassDoesNotExist'));
} catch (Exception $e) {
    echo $e->getMessage() . "\n";
}
try {
    var_dump($ro->isSubclassOf(2));
} catch (Exception $e) {
    echo $e->getMessage() . "\n";
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:ReflectionObject_isSubclassOf.002.php

示例5: LoadCodeFile

 /**
  * LoadCodeFile() - Loads an extension/plugin into the core.
  *
  * WARNING: This function is PHP5 only. A replacement could be designed for PHP4, requiring a bit of
  * of code magic regarding object reflexion.
  *
  * LoadCodeFile loads any PHP file into PHP via include().
  * It expects an $object variable to be set by the codefile in order to process with further registration.
  * Specifications for the different kind of $objects are available in the development wiki.  
  * -1 return code for "FILE NOT FOUND"
  * -2 return code for "INCORRECT/INEXISTANT OBJECT VARIABLE"
  *   
  * @param $filepath string  Path of the file to include
  */
 function LoadCodeFile($filepath)
 {
     if (defined('BB_DEBUG')) {
         $this->DebugOutput("LoadCodeFile(): Attempting to load '{$filepath}'");
     }
     clearstatcache();
     if (file_exists($filepath)) {
         // Loads the plugin/extension
         include_once $filepath;
         if (!$object) {
             return -2;
         }
         // BAD BAD BAD BAD BAD !
         if (defined('BB_DEBUG')) {
             $this->DebugOutput("LoadCodeFile(): Loaded file '{$filepath}'");
         }
         // Create some reflexion objects in order to check the inheritance of the new $object
         $cmdexts = new ReflectionClass(bbCommandExtension);
         $dataexts = new ReflectionClass(bbDataExtension);
         $reflexion = new ReflectionObject($object);
         // Switch to the appropriate register procedure.
         if ($reflexion->isSubclassOf($cmdexts)) {
             $this->RegisterCommandExtension($object);
         } else {
             if ($reflexion->isSubclassOf($dataexts)) {
                 $this->RegisterDataExtension($object);
             }
         }
     } else {
         return -1;
     }
 }
开发者ID:BackupTheBerlios,项目名称:bblog-svn,代码行数:46,代码来源:bBlog.class.php


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