示例#1
0
 public function parseDocblockType($type)
 {
     $types = explode('|', $type);
     $finalTypes = [];
     foreach ($types as $type) {
         $isArray = strpos($type, '[]') !== false;
         $typeWithoutArray = str_replace('[]', '', $type);
         if (\Phint\Context\Variable::isClassType($typeWithoutArray)) {
             $type = $this->getClassName($typeWithoutArray);
             if ($isArray) {
                 $type .= '[]';
             }
         }
         $finalTypes[] = $type;
     }
     return $finalTypes;
 }
示例#2
0
文件: Chain.php 项目: anlutro/phint
 private function updateType(array $types)
 {
     $reflClass = [];
     foreach ($types as $key => $type) {
         $arrayOf = substr($type, -2) == '[]';
         $typeWithoutArray = str_replace('[]', '', $type);
         if (\Phint\Context\Variable::isClassType($typeWithoutArray)) {
             if (!$this->classExists($typeWithoutArray)) {
                 $currentClass = $this->getCurrentReflectionClass();
                 $currentClass = $currentClass ? $currentClass->getName() : null;
                 $this->addClassNotFoundError($typeWithoutArray, $currentClass, $this->currentLink);
                 return false;
             }
             if (!$arrayOf) {
                 $reflClass[] = new ReflectionClass($type);
             }
         }
     }
     $this->currentReflClass = $reflClass;
     $this->currentType = $types;
     return true;
 }