Esempio n. 1
0
    /** @test */
    public function can_parse_return_docblocks()
    {
        $docblock = '/** blah blah */';
        $this->assertEquals(null, DocblockParser::getMethodType($docblock));
        $docblock = '/** @return Foo */';
        $this->assertEquals('Foo', DocblockParser::getMethodType($docblock));
        $docblock = '/**
		* @param Foo $foo
		* @return Bar
		*/';
        $this->assertEquals('Bar', DocblockParser::getMethodType($docblock));
    }
Esempio n. 2
0
 private function getReflectionType($reflector)
 {
     if ($reflector instanceof ReflectionMethod && $reflector->isConstructor()) {
         $className = $reflector->getDeclaringClass()->getName();
         return [$className];
     }
     $docstr = $reflector->getDocComment();
     if (!$docstr) {
         return false;
     }
     if ($reflector instanceof ReflectionMethod) {
         $file = $reflector->getFileName();
         $type = DocblockParser::getMethodType($docstr);
     } elseif ($reflector instanceof ReflectionProperty) {
         $file = $reflector->getDeclaringClass()->getFileName();
         $type = DocblockParser::getPropertyType($docstr);
     } else {
         if (PHINT_DEBUG) {
             var_dump(__METHOD__ . ':' . __LINE__);
             var_dump($reflector);
             throw new \RuntimeException();
         }
         return null;
     }
     if (!$type) {
         return null;
     }
     if ($file == $this->context->getFileName()) {
         $context = $this->context;
     } else {
         $context = $this->getExternalFileContext($file);
     }
     $types = $context->parseDocblockType($type);
     return $types;
 }