Пример #1
0
 /**
  * Checks if "$class instanceof $interface"
  *
  * @param NULL|Class_ $class
  * @param Interface_ $superInterface
  * @return bool
  */
 public static function classImplements(Class_ $class = NULL, Interface_ $superInterface)
 {
     if (NULL === $class) {
         return false;
     }
     foreach ($class->getInterfaces() as $interface) {
         if ($interface === $superInterface) {
             return true;
         }
     }
     return self::classImplements($class->getParent(), $superInterface);
 }
Пример #2
0
 /**
  * @param Class_ $class
  * @param string $methodName
  * @return bool
  */
 private function classHasParentMethod(Class_ $class = NULL, $methodName)
 {
     if (NULL === $class) {
         return false;
     }
     foreach ($class->getMethods() as $method) {
         $classMethodName = $method->getNormalizedName();
         if ($classMethodName === $methodName) {
             return true;
         }
     }
     return self::classHasParentMethod($class->getParent(), $methodName);
 }
Пример #3
0
 /**
  * @param Class_ $parent
  * @return $this
  */
 public function setParent(Class_ $parent)
 {
     if ($parent->getName() !== $this->fqParent) {
         throw new \RuntimeException('Expected class ' . $this->fqParent . ' but got ' . $parent->getName() . ' instead');
     }
     $this->parent = $parent;
     return $this;
 }