예제 #1
0
 /**
  * @param string      $class
  * @param null|string $alias
  * @param bool        $checkClassExists Use FALSE when you want to use a namespace instead of a class
  *
  * @return $this
  * @throws Exception\ClassUse  When the given class does not exists
  */
 public function addUse($class, $alias = null, $checkClassExists = true)
 {
     if ($checkClassExists === true && $this->classFile->isClassDefined("\\{$class}") === false && $this->classFile->isInterfaceDefined("\\{$class}") === false && $this->classFile->isTraitDefined("\\{$class}") === false) {
         throw Exception\ClassUse::classUseNotFound($class);
     }
     $use = new ClassUse($class, $alias);
     $this->append($use);
     return $this;
 }
예제 #2
0
 /**
  * Resolve method name conflict with aliasing the method name
  *
  * @param string $trait  The trait that causing the conflict
  * @param string $method The method of the trait that causing the conflict
  * @param string $alias  The alias for the method
  *
  * @return $this
  * @throws \Aviogram\Common\PHPClass\Exception\ClassTrait   When the trait does not exists
  * @throws \Aviogram\Common\PHPClass\Exception\ClassTrait   When the method is not defined on the trait
  */
 public function resolveConflictAlias($trait, $method, $alias)
 {
     $fullClass = $this->classFile->getFullClassName($trait);
     if (method_exists($fullClass, $method) === false) {
         throw \Aviogram\Common\PHPClass\Exception\ClassTrait::undefinedMethod($trait, $method);
     }
     $this->conflicts[] = "{$trait}::{$method} as {$alias};";
     if ($trait !== $this->name && in_array($trait, $this->secondNames) === false) {
         if ($this->classFile->isTraitDefined($trait) === false) {
             throw \Aviogram\Common\PHPClass\Exception\ClassTrait::traitNotFound($trait);
         }
         $this->secondNames[] = $trait;
     }
     return $this;
 }
예제 #3
0
 /**
  * Combine couple of the same tags with a different name/purpose
  *
  * @param string      $tagName      The name of the tag
  * @param string      $type         The type of the property (See FileClass::PHP_TYPE_*) or use class name
  * @param string      $name         The name of the property
  * @param null|string $description  The description with the property
  *
  * @return DocBlock
  *
  * @throws \Aviogram\Common\PHPClass\Exception\ClassFile    When the type does not exists or the class does not exists
  */
 protected function createVariableTag($tagName, $type, $name, $description = null)
 {
     return $this->internalCreateTag(false, $tagName, $this->classFile->getType($type), "\${$name}", $description);
 }
예제 #4
0
파일: Method.php 프로젝트: aviogram/common
 /**
  *  Checks if the trait is defined or not
  *
  * @param  string $trait
  *
  * @return boolean
  */
 protected function isTraitDefined($trait)
 {
     return $this->classFile->isTraitDefined($trait);
 }