Ejemplo n.º 1
0
 /**
  * Extract the list of returned values
  *
  * @param ReflectedMethod $method
  * @param string $content
  * @return $this
  */
 private function extractReturns(ReflectedMethod $method, $content)
 {
     if (preg_match_all('!([\\s;]return\\s|^return\\s)!', $content, $matches)) {
         foreach ($matches[1] as $m) {
             $method->pushReturn($m);
         }
     }
     return $this;
 }
Ejemplo n.º 2
0
 /**
  * Extract the list of returned values
  *
  * @param ReflectedMethod $method
  * @return $this
  */
 private function extractReturns(ReflectedMethod $method, $n, TokenCollection $tokens)
 {
     $resolver = new TypeResolver();
     // PHP 7
     // we cannot use specific token. The ":" delimiter is a T_STRING token
     $following = $this->searcher->getUnder(array('{', ';'), $n, $tokens);
     if (preg_match('!:(.*)!', $following, $matches)) {
         $type = trim($matches[1]);
         if (empty($type)) {
             return $this;
         }
         $return = new ReflectedReturn($type, ReflectedReturn::VALUE_UNKNOW, ReflectedReturn::STRICT_TYPE_HINT);
         $method->pushReturn($return);
         return $this;
     }
     // array of available values based on code
     if (preg_match_all('!([\\s;]return\\s|^return\\s+)(.*?);!', $method->getContent(), $matches)) {
         foreach ($matches[2] as $m) {
             $value = trim($m, ";\t\n\r\v");
             $return = new ReflectedReturn($resolver->resolve($m), $value, ReflectedReturn::ESTIMATED_TYPE_HINT);
             $method->pushReturn($return);
         }
     }
     return $this;
 }