Removed tests for the Zend Framework (#1187)

This commit is contained in:
Yağızhan authored and GitHub committed 2023-04-29 13:46:36 +01:00
1 parent fbb3478ebb
commit 54f4f40f2c
15 files changed
-2333

No files matched your search

-96
View File
@@ -1,96 +0,0 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Exception.php 23775 2011-03-01 17:25:24Z ralph $
*/
/**
* @category Zend
* @package Zend
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Exception extends Exception
{
/**
* @var null|Exception
*/
private $_previous = null;
/**
* Construct the exception
*
* @param string $msg
* @param int $code
* @param Exception $previous
* @return void
*/
public function __construct($msg = '', $code = 0, Exception $previous = null)
{
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
parent::__construct($msg, (int) $code);
$this->_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;
}
}
-329
View File
@@ -1,329 +0,0 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Loader
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Loader.php 23775 2011-03-01 17:25:24Z ralph $
*/
/**
* Static methods for loading classes and files.
*
* @category Zend
* @package Zend_Loader
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Loader
{
/**
* Loads a class from a PHP file. The filename must be formatted
* as "$class.php".
*
* 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 $dirs is null, it will split the class name at underscores to
* generate a path hierarchy (e.g., "Zend_Example_Class" will map
* to "Zend/Example/Class.php").
*
* 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.
*
* @param string $class - The full class name of a Zend component.
* @param string|array $dirs - OPTIONAL Either a path or an array of paths
* to search.
* @return void
* @throws Zend_Exception
*/
public static function loadClass($class, $dirs = null)
{
if (class_exists($class, false) || interface_exists($class, false)) {
return;
}
if ((null !== $dirs) && !is_string($dirs) && !is_array($dirs)) {
require_once 'Zend/Exception.php';
throw new Zend_Exception('Directory argument must be a string or an array');
}
// Autodiscover the path from the class name
// Implementation is PHP namespace-aware, and based on
// Framework Interop Group reference implementation:
// http://groups.google.com/group/php-standards/web/psr-0-final-proposal
$className = ltrim($class, '\\');
$file = '';
$namespace = '';
if ($lastNsPos = strripos($className, '\\')) {
$namespace = substr($className, 0, $lastNsPos);
$className = substr($className, $lastNsPos + 1);
$file = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
}
$file .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
if (!empty($dirs)) {
// use the autodiscovered path
$dirPath = dirname($file);
if (is_string($dirs)) {
$dirs = explode(PATH_SEPARATOR, $dirs);
}
foreach ($dirs as $key => $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:
* <code>
* spl_autoload_register(array('Zend_Loader', 'autoload'));
* </code>
*
* @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 ;
}
}
}
-35
View File
@@ -1,35 +0,0 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Loader
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Exception.php 23775 2011-03-01 17:25:24Z ralph $
*/
/**
* @see Zend_Exception
*/
require_once 'Zend/Exception.php';
/**
* @category Zend
* @package Zend_Loader
* @uses Zend_Exception
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Loader_Exception extends Zend_Exception
{}
-247
View File
@@ -1,247 +0,0 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Reflection
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Class.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Reflection_Property
*/
require_once 'Zend/Reflection/Property.php';
/**
* @see Zend_Reflection_Method
*/
require_once 'Zend/Reflection/Method.php';
/**
* Zend_Reflection_Docblock
*/
require_once 'Zend/Reflection/Docblock.php';
/**
* @category Zend
* @package Zend_Reflection
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Reflection_Class extends ReflectionClass
{
/**
* Return the reflection file of the declaring file.
*
* @return Zend_Reflection_File
*/
public function getDeclaringFile($reflectionClass = 'Zend_Reflection_File')
{
$instance = new $reflectionClass($this->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;
}
}
-294
View File
@@ -1,294 +0,0 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Reflection
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Docblock.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Reflection_Docblock_Tag
*/
require_once 'Zend/Reflection/Docblock/Tag.php';
/**
* @category Zend
* @package Zend_Reflection
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Reflection_Docblock implements Reflector
{
/**
* @var Reflector
*/
protected $_reflector = null;
/**#@+
* @var int
*/
protected $_startLine = null;
protected $_endLine = null;
/**#@-*/
/**
* @var string
*/
protected $_docComment = null;
/**
* @var string
*/
protected $_cleanDocComment = null;
/**
* @var string
*/
protected $_longDescription = null;
/**
* @var string
*/
protected $_shortDescription = null;
/**
* @var array
*/
protected $_tags = array();
/**
* Export reflection
*
* Reqired by the Reflector interface.
*
* @todo What should this do?
* @return void
*/
public static function export()
{
}
/**
* Serialize to string
*
* Required by the Reflector interface
*
* @todo What should this return?
* @return string
*/
public function __toString()
{
$str = "Docblock [ /* Docblock */ ] {".PHP_EOL.PHP_EOL;
$str .= " - Tags [".count($this->_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);
}
}
@@ -1,146 +0,0 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Reflection
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Tag.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/** Zend_Loader */
require_once 'Zend/Loader.php';
/**
* @category Zend
* @package Zend_Reflection
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Reflection_Docblock_Tag implements Reflector
{
/**
* @var array Array of Class names
*/
protected static $_tagClasses = array(
'optional' => '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;
}
}
@@ -1,93 +0,0 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Reflection
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Param.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/** Zend_Reflection_Docblock_Tag */
require_once 'Zend/Reflection/Docblock/Tag.php';
/**
* @category Zend
* @package Zend_Reflection
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Reflection_Docblock_Tag_Param extends Zend_Reflection_Docblock_Tag
{
/**
* @var string
*/
protected $_type = null;
/**
* @var string
*/
protected $_variableName = null;
/**
* Constructor
*
* @param string $tagDocblockLine
*/
public function __construct($tagDocblockLine)
{
$matches = array();
if (!preg_match('#^@(\w+)\s+([\w|\\\]+)(?:\s+(\$\S+))?(?:\s+(.*))?#s', $tagDocblockLine, $matches)) {
require_once 'Zend/Reflection/Exception.php';
throw new Zend_Reflection_Exception('Provided docblock line is does not contain a valid tag');
}
if ($matches[1] != 'param') {
require_once 'Zend/Reflection/Exception.php';
throw new Zend_Reflection_Exception('Provided docblock line is does not contain a valid @param tag');
}
$this->_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;
}
}
@@ -1,72 +0,0 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Reflection
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Return.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/** Zend_Reflection_Docblock_Tag */
require_once 'Zend/Reflection/Docblock/Tag.php';
/**
* @category Zend
* @package Zend_Reflection
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Reflection_Docblock_Tag_Return extends Zend_Reflection_Docblock_Tag
{
/**
* @var string
*/
protected $_type = null;
/**
* Constructor
*
* @param string $tagDocblockLine
* @return void
*/
public function __construct($tagDocblockLine)
{
if (!preg_match('#^@(\w+)\s+([\w|\\\]+)(?:\s+(.*))?#', $tagDocblockLine, $matches)) {
require_once 'Zend/Reflection/Exception.php';
throw new Zend_Reflection_Exception('Provided docblock line is does not contain a valid tag');
}
if ($matches[1] != 'return') {
require_once 'Zend/Reflection/Exception.php';
throw new Zend_Reflection_Exception('Provided docblock line is does not contain a valid @return tag');
}
$this->_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;
}
}
@@ -1,36 +0,0 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Reflection
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Exception
*/
require_once 'Zend/Exception.php';
/**
* @category Zend
* @package Zend_Reflection
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Reflection_Exception extends Zend_Exception
{
}
@@ -1,85 +0,0 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Reflection
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Extension.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Reflection_Class
*/
require_once 'Zend/Reflection/Class.php';
/**
* @see Zend_Reflection_Function
*/
require_once 'Zend/Reflection/Function.php';
/**
* @category Zend
* @package Zend_Reflection
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Reflection_Extension extends ReflectionExtension
{
/**
* Get extension function reflection objects
*
* @param string $reflectionClass Name of reflection class to use
* @return array Array of Zend_Reflection_Function objects
*/
public function getFunctions($reflectionClass = 'Zend_Reflection_Function')
{
$phpReflections = parent::getFunctions();
$zendReflections = array();
while ($phpReflections && ($phpReflection = array_shift($phpReflections))) {
$instance = new $reflectionClass($phpReflection->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;
}
}
-412
View File
@@ -1,412 +0,0 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Reflection
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: File.php 20903 2010-02-04 16:16:47Z matthew $
*/
/**
* @see Zend_Reflection_Class
*/
require_once 'Zend/Reflection/Class.php';
/**
* @see Zend_Reflection_Function
*/
require_once 'Zend/Reflection/Function.php';
/**
* @category Zend
* @package Zend_Reflection
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Reflection_File implements Reflector
{
/**
* @var string
*/
protected $_filepath = null;
/**
* @var string
*/
protected $_docComment = null;
/**
* @var int
*/
protected $_startLine = 1;
/**
* @var int
*/
protected $_endLine = null;
/**
* @var string[]
*/
protected $_requiredFiles = array();
/**
* @var Zend_Reflection_Class[]
*/
protected $_classes = array();
/**
* @var Zend_Reflection_Function[]
*/
protected $_functions = array();
/**
* @var string
*/
protected $_contents = null;
/**
* Constructor
*
* @param string $file
* @return void
*/
public function __construct($file)
{
$fileName = $file;
if (($fileRealpath = realpath($fileName)) === false) {
$fileRealpath = self::findRealpathInIncludePath($file);
}
if (!$fileRealpath || !in_array($fileRealpath, get_included_files())) {
require_once 'Zend/Reflection/Exception.php';
throw new Zend_Reflection_Exception('File ' . $file . ' must be required before it can be reflected');
}
$this->_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;
}
}
}
}
-129
View File
@@ -1,129 +0,0 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Reflection
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Function.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Reflection_Parameter
*/
require_once 'Zend/Reflection/Parameter.php';
/**
* @category Zend
* @package Zend_Reflection
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Reflection_Function extends ReflectionFunction
{
/**
* Get function docblock
*
* @param string $reflectionClass Name of reflection class to use
* @return Zend_Reflection_Docblock
*/
public function getDocblock($reflectionClass = 'Zend_Reflection_Docblock')
{
if ('' == ($comment = $this->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;
}
}
-168
View File
@@ -1,168 +0,0 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Reflection
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Method.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Reflection_Class
*/
require_once 'Zend/Reflection/Class.php';
/**
* @see Zend_Reflection_Docblock
*/
require_once 'Zend/Reflection/Docblock.php';
/**
* @see Zend_Reflection_Parameter
*/
require_once 'Zend/Reflection/Parameter.php';
/**
* @category Zend
* @package Zend_Reflection
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Reflection_Method extends ReflectionMethod
{
/**
* Retrieve method docblock reflection
*
* @return Zend_Reflection_Docblock
* @throws Zend_Reflection_Exception
*/
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 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), '{'), '}');
}
}
@@ -1,123 +0,0 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Reflection
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Parameter.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @category Zend
* @package Zend_Reflection
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Reflection_Parameter extends ReflectionParameter
{
/**
* @var bool
*/
protected $_isFromMethod = false;
/**
* Get declaring class reflection object
*
* @param string $reflectionClass 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 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;
}
}
@@ -1,68 +0,0 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Reflection
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Property.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @todo implement line numbers
* @category Zend
* @package Zend_Reflection
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Reflection_Property extends ReflectionProperty
{
/**
* Get declaring class reflection object
*
* @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 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;
}
}