diff --git a/tests/includes/Zend/Exception.php b/tests/includes/Zend/Exception.php deleted file mode 100644 index e838f519a..000000000 --- a/tests/includes/Zend/Exception.php +++ /dev/null @@ -1,96 +0,0 @@ -_previous = $previous; - } else { - parent::__construct($msg, (int) $code, $previous); - } - } - - /** - * Overloading - * - * For PHP < 5.3.0, provides access to the getPrevious() method. - * - * @param string $method - * @param array $args - * @return mixed - */ - public function __call($method, array $args) - { - if ('getprevious' == strtolower($method)) { - return $this->_getPrevious(); - } - return null; - } - - /** - * String representation of the exception - * - * @return string - */ - public function __toString() - { - if (version_compare(PHP_VERSION, '5.3.0', '<')) { - if (null !== ($e = $this->getPrevious())) { - return $e->__toString() - . "\n\nNext " - . parent::__toString(); - } - } - return parent::__toString(); - } - - /** - * Returns previous Exception - * - * @return Exception|null - */ - protected function _getPrevious() - { - return $this->_previous; - } -} diff --git a/tests/includes/Zend/Loader.php b/tests/includes/Zend/Loader.php deleted file mode 100644 index 9bc083aa6..000000000 --- a/tests/includes/Zend/Loader.php +++ /dev/null @@ -1,329 +0,0 @@ - $dir) { - if ($dir == '.') { - $dirs[$key] = $dirPath; - } else { - $dir = rtrim($dir, '\\/'); - $dirs[$key] = $dir . DIRECTORY_SEPARATOR . $dirPath; - } - } - $file = basename($file); - self::loadFile($file, $dirs, true); - } else { - self::loadFile($file, null, true); - } - - if (!class_exists($class, false) && !interface_exists($class, false)) { - require_once 'Zend/Exception.php'; - throw new Zend_Exception("File \"$file\" does not exist or class \"$class\" was not found in the file"); - } - } - - /** - * Loads a PHP file. This is a wrapper for PHP's include() function. - * - * $filename must be the complete filename, including any - * extension such as ".php". Note that a security check is performed that - * does not permit extended characters in the filename. This method is - * intended for loading Zend Framework files. - * - * If $dirs is a string or an array, it will search the directories - * in the order supplied, and attempt to load the first matching file. - * - * If the file was not found in the $dirs, or if no $dirs were specified, - * it will attempt to load it from PHP's include_path. - * - * If $once is TRUE, it will use include_once() instead of include(). - * - * @param string $filename - * @param string|array $dirs - OPTIONAL either a path or array of paths - * to search. - * @param boolean $once - * @return boolean - * @throws Zend_Exception - */ - public static function loadFile($filename, $dirs = null, $once = false) - { - self::_securityCheck($filename); - - /** - * Search in provided directories, as well as include_path - */ - $incPath = false; - if (!empty($dirs) && (is_array($dirs) || is_string($dirs))) { - if (is_array($dirs)) { - $dirs = implode(PATH_SEPARATOR, $dirs); - } - $incPath = get_include_path(); - set_include_path($dirs . PATH_SEPARATOR . $incPath); - } - - /** - * Try finding for the plain filename in the include_path. - */ - if ($once) { - include_once $filename; - } else { - include $filename; - } - - /** - * If searching in directories, reset include_path - */ - if ($incPath) { - set_include_path($incPath); - } - - return true; - } - - /** - * Returns TRUE if the $filename is readable, or FALSE otherwise. - * This function uses the PHP include_path, where PHP's is_readable() - * does not. - * - * Note from ZF-2900: - * If you use custom error handler, please check whether return value - * from error_reporting() is zero or not. - * At mark of fopen() can not suppress warning if the handler is used. - * - * @param string $filename - * @return boolean - */ - public static function isReadable($filename) - { - if (is_readable($filename)) { - // Return early if the filename is readable without needing the - // include_path - return true; - } - - if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN' - && preg_match('/^[a-z]:/i', $filename) - ) { - // If on windows, and path provided is clearly an absolute path, - // return false immediately - return false; - } - - foreach (self::explodeIncludePath() as $path) { - if ($path == '.') { - if (is_readable($filename)) { - return true; - } - continue; - } - $file = $path . '/' . $filename; - if (is_readable($file)) { - return true; - } - } - return false; - } - - /** - * Explode an include path into an array - * - * If no path provided, uses current include_path. Works around issues that - * occur when the path includes stream schemas. - * - * @param string|null $path - * @return array - */ - public static function explodeIncludePath($path = null) - { - if (null === $path) { - $path = get_include_path(); - } - - if (PATH_SEPARATOR == ':') { - // On *nix systems, include_paths which include paths with a stream - // schema cannot be safely explode'd, so we have to be a bit more - // intelligent in the approach. - $paths = preg_split('#:(?!//)#', $path); - } else { - $paths = explode(PATH_SEPARATOR, $path); - } - return $paths; - } - - /** - * spl_autoload() suitable implementation for supporting class autoloading. - * - * Attach to spl_autoload() using the following: - * - * spl_autoload_register(array('Zend_Loader', 'autoload')); - * - * - * @deprecated Since 1.8.0 - * @param string $class - * @return string|false Class name on success; false on failure - */ - public static function autoload($class) - { - trigger_error(__CLASS__ . '::' . __METHOD__ . ' is deprecated as of 1.8.0 and will be removed with 2.0.0; use Zend_Loader_Autoloader instead', E_USER_NOTICE); - try { - @self::loadClass($class); - return $class; - } catch (Exception $e) { - return false; - } - } - - /** - * Register {@link autoload()} with spl_autoload() - * - * @deprecated Since 1.8.0 - * @param string $class (optional) - * @param boolean $enabled (optional) - * @return void - * @throws Zend_Exception if spl_autoload() is not found - * or if the specified class does not have an autoload() method. - */ - public static function registerAutoload($class = 'Zend_Loader', $enabled = true) - { - trigger_error(__CLASS__ . '::' . __METHOD__ . ' is deprecated as of 1.8.0 and will be removed with 2.0.0; use Zend_Loader_Autoloader instead', E_USER_NOTICE); - require_once 'Zend/Loader/Autoloader.php'; - $autoloader = Zend_Loader_Autoloader::getInstance(); - $autoloader->setFallbackAutoloader(true); - - if ('Zend_Loader' != $class) { - self::loadClass($class); - $methods = get_class_methods($class); - if (!in_array('autoload', (array) $methods)) { - require_once 'Zend/Exception.php'; - throw new Zend_Exception("The class \"$class\" does not have an autoload() method"); - } - - $callback = array($class, 'autoload'); - - if ($enabled) { - $autoloader->pushAutoloader($callback); - } else { - $autoloader->removeAutoloader($callback); - } - } - } - - /** - * Ensure that filename does not contain exploits - * - * @param string $filename - * @return void - * @throws Zend_Exception - */ - protected static function _securityCheck($filename) - { - /** - * Security check - */ - if (preg_match('/[^a-z0-9\\/\\\\_.:-]/i', $filename)) { - require_once 'Zend/Exception.php'; - throw new Zend_Exception('Security check: Illegal character in filename'); - } - } - - /** - * Attempt to include() the file. - * - * include() is not prefixed with the @ operator because if - * the file is loaded and contains a parse error, execution - * will halt silently and this is difficult to debug. - * - * Always set display_errors = Off on production servers! - * - * @param string $filespec - * @param boolean $once - * @return boolean - * @deprecated Since 1.5.0; use loadFile() instead - */ - protected static function _includeFile($filespec, $once = false) - { - if ($once) { - return include_once $filespec; - } else { - return include $filespec ; - } - } -} diff --git a/tests/includes/Zend/Loader/Exception.php b/tests/includes/Zend/Loader/Exception.php deleted file mode 100644 index ee2ba686c..000000000 --- a/tests/includes/Zend/Loader/Exception.php +++ /dev/null @@ -1,35 +0,0 @@ -getFileName()); - if (!$instance instanceof Zend_Reflection_File) { - require_once 'Zend/Reflection/Exception.php'; - throw new Zend_Reflection_Exception('Invalid reflection class specified; must extend Zend_Reflection_File'); - } - return $instance; - } - - /** - * Return the classes Docblock reflection object - * - * @param string $reflectionClass Name of reflection class to use - * @return Zend_Reflection_Docblock - * @throws Zend_Reflection_Exception for missing docblock or invalid reflection class - */ - public function getDocblock($reflectionClass = 'Zend_Reflection_Docblock') - { - if ('' == $this->getDocComment()) { - require_once 'Zend/Reflection/Exception.php'; - throw new Zend_Reflection_Exception($this->getName() . ' does not have a docblock'); - } - - $instance = new $reflectionClass($this); - if (!$instance instanceof Zend_Reflection_Docblock) { - require_once 'Zend/Reflection/Exception.php'; - throw new Zend_Reflection_Exception('Invalid reflection class specified; must extend Zend_Reflection_Docblock'); - } - return $instance; - } - - /** - * Return the start line of the class - * - * @param bool $includeDocComment - * @return int - */ - public function getStartLine($includeDocComment = false) - { - if ($includeDocComment) { - if ($this->getDocComment() != '') { - return $this->getDocblock()->getStartLine(); - } - } - - return parent::getStartLine(); - } - - /** - * Return the contents of the class - * - * @param bool $includeDocblock - * @return string - */ - public function getContents($includeDocblock = true) - { - $filename = $this->getFileName(); - $filelines = file($filename); - $startnum = $this->getStartLine($includeDocblock); - $endnum = $this->getEndLine() - $this->getStartLine(); - - return implode('', array_splice($filelines, $startnum, $endnum, true)); - } - - /** - * Get all reflection objects of implemented interfaces - * - * @param string $reflectionClass Name of reflection class to use - * @return array Array of Zend_Reflection_Class - */ - public function getInterfaces($reflectionClass = 'Zend_Reflection_Class') - { - $phpReflections = parent::getInterfaces(); - $zendReflections = array(); - while ($phpReflections && ($phpReflection = array_shift($phpReflections))) { - $instance = new $reflectionClass($phpReflection->getName()); - if (!$instance instanceof Zend_Reflection_Class) { - require_once 'Zend/Reflection/Exception.php'; - throw new Zend_Reflection_Exception('Invalid reflection class specified; must extend Zend_Reflection_Class'); - } - $zendReflections[] = $instance; - unset($phpReflection); - } - unset($phpReflections); - return $zendReflections; - } - - /** - * Return method reflection by name - * - * @param string $name - * @param string $reflectionClass Reflection class to utilize - * @return Zend_Reflection_Method - */ - public function getMethod($name, $reflectionClass = 'Zend_Reflection_Method') - { - $phpReflection = parent::getMethod($name); - $zendReflection = new $reflectionClass($this->getName(), $phpReflection->getName()); - - if (!$zendReflection instanceof Zend_Reflection_Method) { - require_once 'Zend/Reflection/Exception.php'; - throw new Zend_Reflection_Exception('Invalid reflection class specified; must extend Zend_Reflection_Method'); - } - - unset($phpReflection); - return $zendReflection; - } - - /** - * Get reflection objects of all methods - * - * @param string $filter - * @param string $reflectionClass Reflection class to use for methods - * @return array Array of Zend_Reflection_Method objects - */ - public function getMethods($filter = -1, $reflectionClass = 'Zend_Reflection_Method') - { - $phpReflections = parent::getMethods($filter); - $zendReflections = array(); - while ($phpReflections && ($phpReflection = array_shift($phpReflections))) { - $instance = new $reflectionClass($this->getName(), $phpReflection->getName()); - if (!$instance instanceof Zend_Reflection_Method) { - require_once 'Zend/Reflection/Exception.php'; - throw new Zend_Reflection_Exception('Invalid reflection class specified; must extend Zend_Reflection_Method'); - } - $zendReflections[] = $instance; - unset($phpReflection); - } - unset($phpReflections); - return $zendReflections; - } - - /** - * Get parent reflection class of reflected class - * - * @param string $reflectionClass Name of Reflection class to use - * @return Zend_Reflection_Class - */ - public function getParentClass($reflectionClass = 'Zend_Reflection_Class') - { - $phpReflection = parent::getParentClass(); - if ($phpReflection) { - $zendReflection = new $reflectionClass($phpReflection->getName()); - if (!$zendReflection instanceof Zend_Reflection_Class) { - require_once 'Zend/Reflection/Exception.php'; - throw new Zend_Reflection_Exception('Invalid reflection class specified; must extend Zend_Reflection_Class'); - } - unset($phpReflection); - return $zendReflection; - } else { - return false; - } - } - - /** - * Return reflection property of this class by name - * - * @param string $name - * @param string $reflectionClass Name of reflection class to use - * @return Zend_Reflection_Property - */ - public function getProperty($name, $reflectionClass = 'Zend_Reflection_Property') - { - $phpReflection = parent::getProperty($name); - $zendReflection = new $reflectionClass($this->getName(), $phpReflection->getName()); - if (!$zendReflection instanceof Zend_Reflection_Property) { - require_once 'Zend/Reflection/Exception.php'; - throw new Zend_Reflection_Exception('Invalid reflection class specified; must extend Zend_Reflection_Property'); - } - unset($phpReflection); - return $zendReflection; - } - - /** - * Return reflection properties of this class - * - * @param int $filter - * @param string $reflectionClass Name of reflection class to use - * @return array Array of Zend_Reflection_Property - */ - public function getProperties($filter = -1, $reflectionClass = 'Zend_Reflection_Property') - { - $phpReflections = parent::getProperties($filter); - $zendReflections = array(); - while ($phpReflections && ($phpReflection = array_shift($phpReflections))) { - $instance = new $reflectionClass($this->getName(), $phpReflection->getName()); - if (!$instance instanceof Zend_Reflection_Property) { - require_once 'Zend/Reflection/Exception.php'; - throw new Zend_Reflection_Exception('Invalid reflection class specified; must extend Zend_Reflection_Property'); - } - $zendReflections[] = $instance; - unset($phpReflection); - } - unset($phpReflections); - return $zendReflections; - } -} diff --git a/tests/includes/Zend/Reflection/Docblock.php b/tests/includes/Zend/Reflection/Docblock.php deleted file mode 100755 index fbefdf2bb..000000000 --- a/tests/includes/Zend/Reflection/Docblock.php +++ /dev/null @@ -1,294 +0,0 @@ -_tags)."] {".PHP_EOL; - - foreach($this->_tags AS $tag) { - $str .= " ".$tag; - } - - $str .= " }".PHP_EOL; - $str .= "}".PHP_EOL; - - return $str; - } - - /** - * Constructor - * - * @param Reflector|string $commentOrReflector - */ - public function __construct($commentOrReflector) - { - if ($commentOrReflector instanceof Reflector) { - $this->_reflector = $commentOrReflector; - if (!method_exists($commentOrReflector, 'getDocComment')) { - require_once 'Zend/Reflection/Exception.php'; - throw new Zend_Reflection_Exception('Reflector must contain method "getDocComment"'); - } - $docComment = $commentOrReflector->getDocComment(); - - $lineCount = substr_count($docComment, "\n"); - - $this->_startLine = $this->_reflector->getStartLine() - $lineCount - 1; - $this->_endLine = $this->_reflector->getStartLine() - 1; - - } elseif (is_string($commentOrReflector)) { - $docComment = $commentOrReflector; - } else { - require_once 'Zend/Reflection/Exception.php'; - throw new Zend_Reflection_Exception(get_class($this) . ' must have a (string) DocComment or a Reflector in the constructor'); - } - - if ($docComment == '') { - require_once 'Zend/Reflection/Exception.php'; - throw new Zend_Reflection_Exception('DocComment cannot be empty'); - } - - $this->_docComment = $docComment; - $this->_parse(); - } - - /** - * Retrieve contents of docblock - * - * @return string - */ - public function getContents() - { - return $this->_cleanDocComment; - } - - /** - * Get start line (position) of docblock - * - * @return int - */ - public function getStartLine() - { - return $this->_startLine; - } - - /** - * Get last line (position) of docblock - * - * @return int - */ - public function getEndLine() - { - return $this->_endLine; - } - - /** - * Get docblock short description - * - * @return string - */ - public function getShortDescription() - { - return $this->_shortDescription; - } - - /** - * Get docblock long description - * - * @return string - */ - public function getLongDescription() - { - return $this->_longDescription; - } - - /** - * Does the docblock contain the given annotation tag? - * - * @param string $name - * @return bool - */ - public function hasTag($name) - { - foreach ($this->_tags as $tag) { - if ($tag->getName() == $name) { - return true; - } - } - return false; - } - - /** - * Retrieve the given docblock tag - * - * @param string $name - * @return Zend_Reflection_Docblock_Tag|false - */ - public function getTag($name) - { - foreach ($this->_tags as $tag) { - if ($tag->getName() == $name) { - return $tag; - } - } - - return false; - } - - /** - * Get all docblock annotation tags - * - * @param string $filter - * @return array Array of Zend_Reflection_Docblock_Tag - */ - public function getTags($filter = null) - { - if ($filter === null || !is_string($filter)) { - return $this->_tags; - } - - $returnTags = array(); - foreach ($this->_tags as $tag) { - if ($tag->getName() == $filter) { - $returnTags[] = $tag; - } - } - return $returnTags; - } - - /** - * Parse the docblock - * - * @return void - */ - protected function _parse() - { - $docComment = $this->_docComment; - - // First remove doc block line starters - $docComment = preg_replace('#[ \t]*(?:\/\*\*|\*\/|\*)?[ ]{0,1}(.*)?#', '$1', $docComment); - $docComment = ltrim($docComment, "\r\n"); // @todo should be changed to remove first and last empty line - - $this->_cleanDocComment = $docComment; - - // Next parse out the tags and descriptions - $parsedDocComment = $docComment; - $lineNumber = $firstBlandLineEncountered = 0; - while (($newlinePos = strpos($parsedDocComment, "\n")) !== false) { - $lineNumber++; - $line = substr($parsedDocComment, 0, $newlinePos); - - $matches = array(); - - if ((strpos($line, '@') === 0) && (preg_match('#^(@\w+.*?)(\n)(?:@|\r?\n|$)#s', $parsedDocComment, $matches))) { - $this->_tags[] = Zend_Reflection_Docblock_Tag::factory($matches[1]); - $parsedDocComment = str_replace($matches[1] . $matches[2], '', $parsedDocComment); - } else { - if ($lineNumber < 3 && !$firstBlandLineEncountered) { - $this->_shortDescription .= $line . "\n"; - } else { - $this->_longDescription .= $line . "\n"; - } - - if ($line == '') { - $firstBlandLineEncountered = true; - } - - $parsedDocComment = substr($parsedDocComment, $newlinePos + 1); - } - - } - - $this->_shortDescription = rtrim($this->_shortDescription); - $this->_longDescription = rtrim($this->_longDescription); - } -} diff --git a/tests/includes/Zend/Reflection/Docblock/Tag.php b/tests/includes/Zend/Reflection/Docblock/Tag.php deleted file mode 100755 index c856d72e6..000000000 --- a/tests/includes/Zend/Reflection/Docblock/Tag.php +++ /dev/null @@ -1,146 +0,0 @@ - 'TagOptional', - 'param' => 'Zend_Reflection_Docblock_Tag_Param', - 'return' => 'Zend_Reflection_Docblock_Tag_Return', - ); - - /** - * @var string - */ - protected $_name = null; - - /** - * @var string - */ - protected $_description = null; - - /** - * Factory: Create the appropriate annotation tag object - * - * @param string $tagDocblockLine - * @return Zend_Reflection_Docblock_Tag - */ - public static function factory($tagDocblockLine) - { - $matches = array(); - - if (!preg_match('#^@(\w+)(\s|$)#', $tagDocblockLine, $matches)) { - require_once 'Zend/Reflection/Exception.php'; - throw new Zend_Reflection_Exception('No valid tag name found within provided docblock line.'); - } - - $tagName = $matches[1]; - if (array_key_exists($tagName, self::$_tagClasses)) { - $tagClass = self::$_tagClasses[$tagName]; - if (!class_exists($tagClass)) { - Zend_Loader::loadClass($tagClass); - } - return new $tagClass($tagDocblockLine); - } - return new self($tagDocblockLine); - } - - /** - * Export reflection - * - * Required by Reflector - * - * @todo What should this do? - * @return void - */ - public static function export() - { - } - - /** - * Serialize to string - * - * Required by Reflector - * - * @todo What should this do? - * @return string - */ - public function __toString() - { - $str = "Docblock Tag [ * @".$this->_name." ]".PHP_EOL; - - return $str; - } - - /** - * Constructor - * - * @param string $tagDocblockLine - * @return void - */ - public function __construct($tagDocblockLine) - { - $matches = array(); - - // find the line - if (!preg_match('#^@(\w+)(?:\s+([^\s].*)|$)?#', $tagDocblockLine, $matches)) { - require_once 'Zend/Reflection/Exception.php'; - throw new Zend_Reflection_Exception('Provided docblock line does not contain a valid tag'); - } - - $this->_name = $matches[1]; - if (isset($matches[2]) && $matches[2]) { - $this->_description = $matches[2]; - } - } - - /** - * Get annotation tag name - * - * @return string - */ - public function getName() - { - return $this->_name; - } - - /** - * Get annotation tag description - * - * @return string - */ - public function getDescription() - { - return $this->_description; - } -} diff --git a/tests/includes/Zend/Reflection/Docblock/Tag/Param.php b/tests/includes/Zend/Reflection/Docblock/Tag/Param.php deleted file mode 100755 index 7efdf2a3e..000000000 --- a/tests/includes/Zend/Reflection/Docblock/Tag/Param.php +++ /dev/null @@ -1,93 +0,0 @@ -_name = 'param'; - $this->_type = $matches[2]; - - if (isset($matches[3])) { - $this->_variableName = $matches[3]; - } - - if (isset($matches[4])) { - $this->_description = preg_replace('#\s+#', ' ', $matches[4]); - } - } - - /** - * Get parameter variable type - * - * @return string - */ - public function getType() - { - return $this->_type; - } - - /** - * Get parameter name - * - * @return string - */ - public function getVariableName() - { - return $this->_variableName; - } -} diff --git a/tests/includes/Zend/Reflection/Docblock/Tag/Return.php b/tests/includes/Zend/Reflection/Docblock/Tag/Return.php deleted file mode 100755 index 5fcf40af8..000000000 --- a/tests/includes/Zend/Reflection/Docblock/Tag/Return.php +++ /dev/null @@ -1,72 +0,0 @@ -_name = 'return'; - $this->_type = $matches[2]; - if (isset($matches[3])) { - $this->_description = $matches[3]; - } - } - - /** - * Get return variable type - * - * @return string - */ - public function getType() - { - return $this->_type; - } -} diff --git a/tests/includes/Zend/Reflection/Exception.php b/tests/includes/Zend/Reflection/Exception.php deleted file mode 100755 index d1ad8f02b..000000000 --- a/tests/includes/Zend/Reflection/Exception.php +++ /dev/null @@ -1,36 +0,0 @@ -getName()); - if (!$instance instanceof Zend_Reflection_Function) { - require_once 'Zend/Reflection/Exception.php'; - throw new Zend_Reflection_Exception('Invalid reflection class provided; must extend Zend_Reflection_Function'); - } - $zendReflections[] = $instance; - unset($phpReflection); - } - unset($phpReflections); - return $zendReflections; - } - - /** - * Get extension class reflection objects - * - * @param string $reflectionClass Name of reflection class to use - * @return array Array of Zend_Reflection_Class objects - */ - public function getClasses($reflectionClass = 'Zend_Reflection_Class') - { - $phpReflections = parent::getClasses(); - $zendReflections = array(); - while ($phpReflections && ($phpReflection = array_shift($phpReflections))) { - $instance = new $reflectionClass($phpReflection->getName()); - if (!$instance instanceof Zend_Reflection_Class) { - require_once 'Zend/Reflection/Exception.php'; - throw new Zend_Reflection_Exception('Invalid reflection class provided; must extend Zend_Reflection_Class'); - } - $zendReflections[] = $instance; - unset($phpReflection); - } - unset($phpReflections); - return $zendReflections; - } -} diff --git a/tests/includes/Zend/Reflection/File.php b/tests/includes/Zend/Reflection/File.php deleted file mode 100755 index dd2fef7f9..000000000 --- a/tests/includes/Zend/Reflection/File.php +++ /dev/null @@ -1,412 +0,0 @@ -_fileName = $fileRealpath; - $this->_contents = file_get_contents($this->_fileName); - $this->_reflect(); - } - - /** - * Find realpath of file based on include_path - * - * @param string $fileName - * @return string - */ - public static function findRealpathInIncludePath($fileName) - { - require_once 'Zend/Loader.php'; - $includePaths = Zend_Loader::explodeIncludePath(); - while (count($includePaths) > 0) { - $filePath = array_shift($includePaths) . DIRECTORY_SEPARATOR . $fileName; - - if ( ($foundRealpath = realpath($filePath)) !== false) { - break; - } - } - - return $foundRealpath; - } - - /** - * Export - * - * Required by the Reflector interface. - * - * @todo What should this do? - * @return null - */ - public static function export() - { - return null; - } - - /** - * Return the file name of the reflected file - * - * @return string - */ - public function getFileName() - { - return $this->_fileName; - } - - /** - * Get the start line - Always 1, staying consistent with the Reflection API - * - * @return int - */ - public function getStartLine() - { - return $this->_startLine; - } - - /** - * Get the end line / number of lines - * - * @return int - */ - public function getEndLine() - { - return $this->_endLine; - } - - /** - * Return the doc comment - * - * @return string - */ - public function getDocComment() - { - return $this->_docComment; - } - - /** - * Return the docblock - * - * @param string $reflectionClass Reflection class to use - * @return Zend_Reflection_Docblock - */ - public function getDocblock($reflectionClass = 'Zend_Reflection_Docblock') - { - $instance = new $reflectionClass($this); - if (!$instance instanceof Zend_Reflection_Docblock) { - require_once 'Zend/Reflection/Exception.php'; - throw new Zend_Reflection_Exception('Invalid reflection class specified; must extend Zend_Reflection_Docblock'); - } - return $instance; - } - - /** - * Return the reflection classes of the classes found inside this file - * - * @param string $reflectionClass Name of reflection class to use for instances - * @return array Array of Zend_Reflection_Class instances - */ - public function getClasses($reflectionClass = 'Zend_Reflection_Class') - { - $classes = array(); - foreach ($this->_classes as $class) { - $instance = new $reflectionClass($class); - if (!$instance instanceof Zend_Reflection_Class) { - require_once 'Zend/Reflection/Exception.php'; - throw new Zend_Reflection_Exception('Invalid reflection class provided; must extend Zend_Reflection_Class'); - } - $classes[] = $instance; - } - return $classes; - } - - /** - * Return the reflection functions of the functions found inside this file - * - * @param string $reflectionClass Name of reflection class to use for instances - * @return array Array of Zend_Reflection_Functions - */ - public function getFunctions($reflectionClass = 'Zend_Reflection_Function') - { - $functions = array(); - foreach ($this->_functions as $function) { - $instance = new $reflectionClass($function); - if (!$instance instanceof Zend_Reflection_Function) { - require_once 'Zend/Reflection/Exception.php'; - throw new Zend_Reflection_Exception('Invalid reflection class provided; must extend Zend_Reflection_Function'); - } - $functions[] = $instance; - } - return $functions; - } - - /** - * Retrieve the reflection class of a given class found in this file - * - * @param null|string $name - * @param string $reflectionClass Reflection class to use when creating reflection instance - * @return Zend_Reflection_Class - * @throws Zend_Reflection_Exception for invalid class name or invalid reflection class - */ - public function getClass($name = null, $reflectionClass = 'Zend_Reflection_Class') - { - if ($name === null) { - reset($this->_classes); - $selected = current($this->_classes); - $instance = new $reflectionClass($selected); - if (!$instance instanceof Zend_Reflection_Class) { - require_once 'Zend/Reflection/Exception.php'; - throw new Zend_Reflection_Exception('Invalid reflection class given; must extend Zend_Reflection_Class'); - } - return $instance; - } - - if (in_array($name, $this->_classes)) { - $instance = new $reflectionClass($name); - if (!$instance instanceof Zend_Reflection_Class) { - require_once 'Zend/Reflection/Exception.php'; - throw new Zend_Reflection_Exception('Invalid reflection class given; must extend Zend_Reflection_Class'); - } - return $instance; - } - - require_once 'Zend/Reflection/Exception.php'; - throw new Zend_Reflection_Exception('Class by name ' . $name . ' not found.'); - } - - /** - * Return the full contents of file - * - * @return string - */ - public function getContents() - { - return $this->_contents; - } - - /** - * Serialize to string - * - * Required by the Reflector interface - * - * @todo What should this serialization look like? - * @return string - */ - public function __toString() - { - return ''; - } - - /** - * This method does the work of "reflecting" the file - * - * Uses PHP's tokenizer to perform file reflection. - * - * @return void - */ - protected function _reflect() - { - $contents = $this->_contents; - $tokens = token_get_all($contents); - - $functionTrapped = false; - $classTrapped = false; - $requireTrapped = false; - $openBraces = 0; - - $this->_checkFileDocBlock($tokens); - - foreach ($tokens as $token) { - /* - * Tokens are characters representing symbols or arrays - * representing strings. The keys/values in the arrays are - * - * - 0 => token id, - * - 1 => string, - * - 2 => line number - * - * Token ID's are explained here: - * http://www.php.net/manual/en/tokens.php. - */ - - if (is_array($token)) { - $type = $token[0]; - $value = $token[1]; - $lineNum = $token[2]; - } else { - // It's a symbol - // Maintain the count of open braces - if ($token == '{') { - $openBraces++; - } else if ($token == '}') { - $openBraces--; - } - - continue; - } - - switch ($type) { - // Name of something - case T_STRING: - if ($functionTrapped) { - $this->_functions[] = $value; - $functionTrapped = false; - } elseif ($classTrapped) { - $this->_classes[] = $value; - $classTrapped = false; - } - continue; - - // Required file names are T_CONSTANT_ENCAPSED_STRING - case T_CONSTANT_ENCAPSED_STRING: - if ($requireTrapped) { - $this->_requiredFiles[] = $value ."\n"; - $requireTrapped = false; - } - continue; - - // Functions - case T_FUNCTION: - if ($openBraces == 0) { - $functionTrapped = true; - } - break; - - // Classes - case T_CLASS: - case T_INTERFACE: - $classTrapped = true; - break; - - // All types of requires - case T_REQUIRE: - case T_REQUIRE_ONCE: - case T_INCLUDE: - case T_INCLUDE_ONCE: - $requireTrapped = true; - break; - - // Default case: do nothing - default: - break; - } - } - - $this->_endLine = count(explode("\n", $this->_contents)); - } - - /** - * Validate / check a file level docblock - * - * @param array $tokens Array of tokenizer tokens - * @return void - */ - protected function _checkFileDocBlock($tokens) { - foreach ($tokens as $token) { - $type = $token[0]; - $value = $token[1]; - $lineNum = $token[2]; - if(($type == T_OPEN_TAG) || ($type == T_WHITESPACE)) { - continue; - } elseif ($type == T_DOC_COMMENT) { - $this->_docComment = $value; - $this->_startLine = $lineNum + substr_count($value, "\n") + 1; - return; - } else { - // Only whitespace is allowed before file docblocks - return; - } - } - } -} diff --git a/tests/includes/Zend/Reflection/Function.php b/tests/includes/Zend/Reflection/Function.php deleted file mode 100755 index aab4e75c5..000000000 --- a/tests/includes/Zend/Reflection/Function.php +++ /dev/null @@ -1,129 +0,0 @@ -getDocComment())) { - require_once 'Zend/Reflection/Exception.php'; - throw new Zend_Reflection_Exception($this->getName() . ' does not have a docblock'); - } - $instance = new $reflectionClass($comment); - if (!$instance instanceof Zend_Reflection_Docblock) { - require_once 'Zend/Reflection/Exception.php'; - throw new Zend_Reflection_Exception('Invalid reflection class provided; must extend Zend_Reflection_Docblock'); - } - return $instance; - } - - /** - * Get start line (position) of function - * - * @param bool $includeDocComment - * @return int - */ - public function getStartLine($includeDocComment = false) - { - if ($includeDocComment) { - if ($this->getDocComment() != '') { - return $this->getDocblock()->getStartLine(); - } - } - - return parent::getStartLine(); - } - - /** - * Get contents of function - * - * @param bool $includeDocblock - * @return string - */ - public function getContents($includeDocblock = true) - { - return implode("\n", - array_splice( - file($this->getFileName()), - $this->getStartLine($includeDocblock), - ($this->getEndLine() - $this->getStartLine()), - true - ) - ); - } - - /** - * Get function parameters - * - * @param string $reflectionClass Name of reflection class to use - * @return array Array of Zend_Reflection_Parameter - */ - public function getParameters($reflectionClass = 'Zend_Reflection_Parameter') - { - $phpReflections = parent::getParameters(); - $zendReflections = array(); - while ($phpReflections && ($phpReflection = array_shift($phpReflections))) { - $instance = new $reflectionClass($this->getName(), $phpReflection->getName()); - if (!$instance instanceof Zend_Reflection_Parameter) { - require_once 'Zend/Reflection/Exception.php'; - throw new Zend_Reflection_Exception('Invalid reflection class provided; must extend Zend_Reflection_Parameter'); - } - $zendReflections[] = $instance; - unset($phpReflection); - } - unset($phpReflections); - return $zendReflections; - } - - /** - * Get return type tag - * - * @return Zend_Reflection_Docblock_Tag_Return - */ - public function getReturn() - { - $docblock = $this->getDocblock(); - if (!$docblock->hasTag('return')) { - require_once 'Zend/Reflection/Exception.php'; - throw new Zend_Reflection_Exception('Function does not specify an @return annotation tag; cannot determine return type'); - } - $tag = $docblock->getTag('return'); - $return = Zend_Reflection_Docblock_Tag::factory('@return ' . $tag->getDescription()); - return $return; - } -} diff --git a/tests/includes/Zend/Reflection/Method.php b/tests/includes/Zend/Reflection/Method.php deleted file mode 100755 index c95429f92..000000000 --- a/tests/includes/Zend/Reflection/Method.php +++ /dev/null @@ -1,168 +0,0 @@ -getDocComment()) { - require_once 'Zend/Reflection/Exception.php'; - throw new Zend_Reflection_Exception($this->getName() . ' does not have a docblock'); - } - - $instance = new $reflectionClass($this); - if (!$instance instanceof Zend_Reflection_Docblock) { - require_once 'Zend/Reflection/Exception.php'; - throw new Zend_Reflection_Exception('Invalid reflection class provided; must extend Zend_Reflection_Docblock'); - } - return $instance; - } - - /** - * Get start line (position) of method - * - * @param bool $includeDocComment - * @return int - */ - public function getStartLine($includeDocComment = false) - { - if ($includeDocComment) { - if ($this->getDocComment() != '') { - return $this->getDocblock()->getStartLine(); - } - } - - return parent::getStartLine(); - } - - /** - * Get reflection of declaring class - * - * @param string $reflectionClass Name of reflection class to use - * @return Zend_Reflection_Class - */ - public function getDeclaringClass($reflectionClass = 'Zend_Reflection_Class') - { - $phpReflection = parent::getDeclaringClass(); - $zendReflection = new $reflectionClass($phpReflection->getName()); - if (!$zendReflection instanceof Zend_Reflection_Class) { - require_once 'Zend/Reflection/Exception.php'; - throw new Zend_Reflection_Exception('Invalid reflection class provided; must extend Zend_Reflection_Class'); - } - unset($phpReflection); - return $zendReflection; - } - - /** - * Get all method parameter reflection objects - * - * @param string $reflectionClass Name of reflection class to use - * @return array of Zend_Reflection_Parameter objects - */ - public function getParameters($reflectionClass = 'Zend_Reflection_Parameter') - { - $phpReflections = parent::getParameters(); - $zendReflections = array(); - while ($phpReflections && ($phpReflection = array_shift($phpReflections))) { - $instance = new $reflectionClass(array($this->getDeclaringClass()->getName(), $this->getName()), $phpReflection->getName()); - if (!$instance instanceof Zend_Reflection_Parameter) { - require_once 'Zend/Reflection/Exception.php'; - throw new Zend_Reflection_Exception('Invalid reflection class provided; must extend Zend_Reflection_Parameter'); - } - $zendReflections[] = $instance; - unset($phpReflection); - } - unset($phpReflections); - return $zendReflections; - } - - /** - * Get method contents - * - * @param bool $includeDocblock - * @return string - */ - public function getContents($includeDocblock = true) - { - $fileContents = file($this->getFileName()); - $startNum = $this->getStartLine($includeDocblock); - $endNum = ($this->getEndLine() - $this->getStartLine()); - - return implode("\n", array_splice($fileContents, $startNum, $endNum, true)); - } - - /** - * Get method body - * - * @return string - */ - public function getBody() - { - $lines = array_slice( - file($this->getDeclaringClass()->getFileName(), FILE_IGNORE_NEW_LINES), - $this->getStartLine(), - ($this->getEndLine() - $this->getStartLine()), - true - ); - - $firstLine = array_shift($lines); - - if (trim($firstLine) !== '{') { - array_unshift($lines, $firstLine); - } - - $lastLine = array_pop($lines); - - if (trim($lastLine) !== '}') { - array_push($lines, $lastLine); - } - - // just in case we had code on the bracket lines - return rtrim(ltrim(implode("\n", $lines), '{'), '}'); - } -} diff --git a/tests/includes/Zend/Reflection/Parameter.php b/tests/includes/Zend/Reflection/Parameter.php deleted file mode 100755 index 042c3000d..000000000 --- a/tests/includes/Zend/Reflection/Parameter.php +++ /dev/null @@ -1,123 +0,0 @@ -getName()); - if (!$zendReflection instanceof Zend_Reflection_Class) { - require_once 'Zend/Reflection/Exception.php'; - throw new Zend_Reflection_Exception('Invalid reflection class provided; must extend Zend_Reflection_Class'); - } - unset($phpReflection); - return $zendReflection; - } - - /** - * Get class reflection object - * - * @param string $reflectionClass Reflection class to use - * @return Zend_Reflection_Class - */ - public function getClass($reflectionClass = 'Zend_Reflection_Class') - { - $phpReflection = parent::getClass(); - if($phpReflection == null) { - return null; - } - - $zendReflection = new $reflectionClass($phpReflection->getName()); - if (!$zendReflection instanceof Zend_Reflection_Class) { - require_once 'Zend/Reflection/Exception.php'; - throw new Zend_Reflection_Exception('Invalid reflection class provided; must extend Zend_Reflection_Class'); - } - unset($phpReflection); - return $zendReflection; - } - - /** - * Get declaring function reflection object - * - * @param string $reflectionClass Reflection class to use - * @return Zend_Reflection_Function|Zend_Reflection_Method - */ - public function getDeclaringFunction($reflectionClass = null) - { - $phpReflection = parent::getDeclaringFunction(); - if ($phpReflection instanceof ReflectionMethod) { - $baseClass = 'Zend_Reflection_Method'; - if (null === $reflectionClass) { - $reflectionClass = $baseClass; - } - $zendReflection = new $reflectionClass($this->getDeclaringClass()->getName(), $phpReflection->getName()); - } else { - $baseClass = 'Zend_Reflection_Function'; - if (null === $reflectionClass) { - $reflectionClass = $baseClass; - } - $zendReflection = new $reflectionClass($phpReflection->getName()); - } - if (!$zendReflection instanceof $baseClass) { - require_once 'Zend/Reflection/Exception.php'; - throw new Zend_Reflection_Exception('Invalid reflection class provided; must extend ' . $baseClass); - } - unset($phpReflection); - return $zendReflection; - } - - /** - * Get parameter type - * - * @return string - */ - public function getType() - { - if ($docblock = $this->getDeclaringFunction()->getDocblock()) { - $params = $docblock->getTags('param'); - - if (isset($params[$this->getPosition()])) { - return $params[$this->getPosition()]->getType(); - } - - } - - return null; - } -} diff --git a/tests/includes/Zend/Reflection/Property.php b/tests/includes/Zend/Reflection/Property.php deleted file mode 100755 index 38a774acb..000000000 --- a/tests/includes/Zend/Reflection/Property.php +++ /dev/null @@ -1,68 +0,0 @@ -getName()); - if (!$zendReflection instanceof Zend_Reflection_Class) { - require_once 'Zend/Reflection/Exception.php'; - throw new Zend_Reflection_Exception('Invalid reflection class provided; must extend Zend_Reflection_Class'); - } - unset($phpReflection); - return $zendReflection; - } - - /** - * Get docblock comment - * - * @param string $reflectionClass - * @return Zend_Reflection_Docblock|false False if no docblock defined - */ - public function getDocComment($reflectionClass = 'Zend_Reflection_Docblock') - { - $docblock = parent::getDocComment(); - if (!$docblock) { - return false; - } - - $r = new $reflectionClass($docblock); - if (!$r instanceof Zend_Reflection_Docblock) { - require_once 'Zend/Reflection/Exception.php'; - throw new Zend_Reflection_Exception('Invalid reflection class provided; must extend Zend_Reflection_Docblock'); - } - return $r; - } -}