Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Code / Reflection / FunctionReflection.php
blob75b7ab8ea703a296dfd8c1292645968b433a1621
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Code\Reflection;
12 use ReflectionFunction;
13 use Zend\Code\Reflection\DocBlock\Tag\ReturnTag;
15 class FunctionReflection extends ReflectionFunction implements ReflectionInterface
17 /**
18 * Get function DocBlock
20 * @throws Exception\InvalidArgumentException
21 * @return DocBlockReflection
23 public function getDocBlock()
25 if ('' == ($comment = $this->getDocComment())) {
26 throw new Exception\InvalidArgumentException(sprintf(
27 '%s does not have a DocBlock',
28 $this->getName()
29 ));
32 $instance = new DocBlockReflection($comment);
34 return $instance;
37 /**
38 * Get start line (position) of function
40 * @param bool $includeDocComment
41 * @return int
43 public function getStartLine($includeDocComment = false)
45 if ($includeDocComment) {
46 if ($this->getDocComment() != '') {
47 return $this->getDocBlock()->getStartLine();
51 return parent::getStartLine();
54 /**
55 * Get contents of function
57 * @param bool $includeDocBlock
58 * @return string
60 public function getContents($includeDocBlock = true)
62 return implode("\n",
63 array_splice(
64 file($this->getFileName()),
65 $this->getStartLine($includeDocBlock),
66 ($this->getEndLine() - $this->getStartLine()),
67 true
72 /**
73 * Get function parameters
75 * @return ParameterReflection[]
77 public function getParameters()
79 $phpReflections = parent::getParameters();
80 $zendReflections = array();
81 while ($phpReflections && ($phpReflection = array_shift($phpReflections))) {
82 $instance = new ParameterReflection($this->getName(), $phpReflection->getName());
83 $zendReflections[] = $instance;
84 unset($phpReflection);
86 unset($phpReflections);
88 return $zendReflections;
91 /**
92 * Get return type tag
94 * @throws Exception\InvalidArgumentException
95 * @return ReturnTag
97 public function getReturn()
99 $docBlock = $this->getDocBlock();
100 if (!$docBlock->hasTag('return')) {
101 throw new Exception\InvalidArgumentException(
102 'Function does not specify an @return annotation tag; cannot determine return type'
106 $tag = $docBlock->getTag('return');
107 return new DocBlockReflection('@return ' . $tag->getDescription());
110 public function toString()
112 return $this->__toString();
116 * Required due to bug in php
118 * @return string
120 public function __toString()
122 return parent::__toString();