import v2.0.0.0_RC3 | 2012-07-01

https://github.com/lucanos/CommunityID -> http://www.itadmins.net/archives/357
This commit is contained in:
2019-07-17 22:31:04 +02:00
parent 38c146901c
commit 2f397f01f7
2677 changed files with 296182 additions and 45159 deletions

View File

@ -17,7 +17,7 @@
* @subpackage PHP
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Class.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Class.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -53,37 +53,37 @@ require_once 'Zend/CodeGenerator/Php/Docblock.php';
*/
class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
{
/**
* @var Zend_CodeGenerator_Php_Docblock
*/
protected $_docblock = null;
/**
* @var string
*/
protected $_name = null;
/**
* @var bool
*/
protected $_isAbstract = false;
/**
* @var string
*/
protected $_extendedClass = null;
/**
* @var array Array of string names
*/
protected $_implementedInterfaces = array();
/**
* @var array Array of properties
*/
protected $_properties = null;
/**
* @var array Array of methods
*/
@ -98,26 +98,31 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
public static function fromReflection(Zend_Reflection_Class $reflectionClass)
{
$class = new self();
$class->setSourceContent($class->getSourceContent());
$class->setSourceDirty(false);
if ($reflectionClass->getDocComment() != '') {
$class->setDocblock(Zend_CodeGenerator_Php_Docblock::fromReflection($reflectionClass->getDocblock()));
}
$class->setAbstract($reflectionClass->isAbstract());
$class->setName($reflectionClass->getName());
if ($parentClass = $reflectionClass->getParentClass()) {
$class->setExtendedClass($parentClass->getName());
$interfaces = array_diff($parentClass->getInterfaces(), $reflectionClass->getInterfaces());
$interfaces = array_diff($reflectionClass->getInterfaces(), $parentClass->getInterfaces());
} else {
$interfaces = $reflectionClass->getInterfaces();
}
$class->setImplementedInterfaces($interfaces);
$interfaceNames = array();
foreach($interfaces AS $interface) {
$interfaceNames[] = $interface->getName();
}
$class->setImplementedInterfaces($interfaceNames);
$properties = array();
foreach ($reflectionClass->getProperties() as $reflectionProperty) {
if ($reflectionProperty->getDeclaringClass()->getName() == $class->getName()) {
@ -125,7 +130,7 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
}
}
$class->setProperties($properties);
$methods = array();
foreach ($reflectionClass->getMethods() as $reflectionMethod) {
if ($reflectionMethod->getDeclaringClass()->getName() == $class->getName()) {
@ -133,33 +138,33 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
}
}
$class->setMethods($methods);
return $class;
}
/**
* setDocblock() Set the docblock
*
* @param Zend_CodeGenerator_Php_Docblock|array|string $docblock
* @return Zend_CodeGenerator_Php_File
*/
public function setDocblock($docblock)
public function setDocblock($docblock)
{
if (is_string($docblock)) {
$docblock = array('shortDescription' => $docblock);
}
if (is_array($docblock)) {
$docblock = new Zend_CodeGenerator_Php_Docblock($docblock);
} elseif (!$docblock instanceof Zend_CodeGenerator_Php_Docblock) {
require_once 'Zend/CodeGenerator/Php/Exception.php';
throw new Zend_CodeGenerator_Php_Exception('setDocblock() is expecting either a string, array or an instance of Zend_CodeGenerator_Php_Docblock');
}
$this->_docblock = $docblock;
return $this;
}
/**
* getDocblock()
*
@ -169,7 +174,7 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
{
return $this->_docblock;
}
/**
* setName()
*
@ -181,7 +186,7 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
$this->_name = $name;
return $this;
}
/**
* getName()
*
@ -203,7 +208,7 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
$this->_isAbstract = ($isAbstract) ? true : false;
return $this;
}
/**
* isAbstract()
*
@ -213,7 +218,7 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
{
return $this->_isAbstract;
}
/**
* setExtendedClass()
*
@ -225,7 +230,7 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
$this->_extendedClass = $extendedClass;
return $this;
}
/**
* getExtendedClass()
*
@ -235,7 +240,7 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
{
return $this->_extendedClass;
}
/**
* setImplementedInterfaces()
*
@ -247,7 +252,7 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
$this->_implementedInterfaces = $implementedInterfaces;
return $this;
}
/**
* getImplementedInterfaces
*
@ -257,7 +262,7 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
{
return $this->_implementedInterfaces;
}
/**
* setProperties()
*
@ -269,10 +274,10 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
foreach ($properties as $property) {
$this->setProperty($property);
}
return $this;
}
/**
* setProperty()
*
@ -290,16 +295,16 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
require_once 'Zend/CodeGenerator/Php/Exception.php';
throw new Zend_CodeGenerator_Php_Exception('setProperty() expects either an array of property options or an instance of Zend_CodeGenerator_Php_Property');
}
if (isset($this->_properties[$propertyName])) {
require_once 'Zend/CodeGenerator/Php/Exception.php';
throw new Zend_CodeGenerator_Php_Exception('A property by name ' . $propertyName . ' already exists in this class.');
}
$this->_properties->append($property);
$this->_properties[$propertyName] = $property;
return $this;
}
/**
* getProperties()
*
@ -309,7 +314,7 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
{
return $this->_properties;
}
/**
* getProperty()
*
@ -325,7 +330,7 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
}
return false;
}
/**
* hasProperty()
*
@ -336,7 +341,7 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
{
return isset($this->_properties[$propertyName]);
}
/**
* setMethods()
*
@ -350,7 +355,7 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
}
return $this;
}
/**
* setMethod()
*
@ -368,16 +373,16 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
require_once 'Zend/CodeGenerator/Php/Exception.php';
throw new Zend_CodeGenerator_Php_Exception('setMethod() expects either an array of method options or an instance of Zend_CodeGenerator_Php_Method');
}
if (isset($this->_methods[$methodName])) {
require_once 'Zend/CodeGenerator/Php/Exception.php';
throw new Zend_CodeGenerator_Php_Exception('A method by name ' . $methodName . ' already exists in this class.');
}
$this->_methods->append($method);
$this->_methods[$methodName] = $method;
return $this;
}
/**
* getMethods()
*
@ -387,7 +392,7 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
{
return $this->_methods;
}
/**
* getMethod()
*
@ -403,7 +408,7 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
}
return false;
}
/**
* hasMethod()
*
@ -414,7 +419,7 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
{
return isset($this->_methods[$methodName]);
}
/**
* isSourceDirty()
*
@ -425,22 +430,22 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
if (($docblock = $this->getDocblock()) && $docblock->isSourceDirty()) {
return true;
}
foreach ($this->_properties as $property) {
if ($property->isSourceDirty()) {
return true;
}
}
foreach ($this->_methods as $method) {
if ($method->isSourceDirty()) {
return true;
}
}
return parent::isSourceDirty();
}
/**
* generate()
*
@ -451,50 +456,50 @@ class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
if (!$this->isSourceDirty()) {
return $this->getSourceContent();
}
$output = '';
$output = '';
if (null !== ($docblock = $this->getDocblock())) {
$docblock->setIndentation('');
$output .= $docblock->generate();
}
if ($this->isAbstract()) {
$output .= 'abstract ';
}
$output .= 'class ' . $this->getName();
if (null !== ($ec = $this->_extendedClass)) {
$output .= ' extends ' . $ec;
}
$implemented = $this->getImplementedInterfaces();
if (!empty($implemented)) {
$output .= ' implements ' . implode(', ', $implemented);
}
$output .= self::LINE_FEED . '{' . self::LINE_FEED . self::LINE_FEED;
$properties = $this->getProperties();
if (!empty($properties)) {
foreach ($properties as $property) {
$output .= $property->generate() . self::LINE_FEED . self::LINE_FEED;
}
}
$methods = $this->getMethods();
if (!empty($methods)) {
foreach ($methods as $method) {
$output .= $method->generate() . self::LINE_FEED;
}
}
$output .= self::LINE_FEED . '}' . self::LINE_FEED;
return $output;
}
/**
* _init() - is called at construction time
*