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: Parameter.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Parameter.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -25,6 +25,11 @@
*/
require_once 'Zend/CodeGenerator/Php/Abstract.php';
/**
* @see Zend_CodeGenerator_Php_ParameterDefaultValue
*/
require_once 'Zend/CodeGenerator/Php/Parameter/DefaultValue.php';
/**
* @category Zend
* @package Zend_CodeGenerator
@ -37,22 +42,27 @@ class Zend_CodeGenerator_Php_Parameter extends Zend_CodeGenerator_Php_Abstract
* @var string
*/
protected $_type = null;
/**
* @var string
*/
protected $_name = null;
/**
* @var string
*/
protected $_defaultValue = null;
/**
* @var int
*/
protected $_position = null;
/**
* @var bool
*/
protected $_passedByReference = false;
/**
* fromReflection()
*
@ -61,10 +71,28 @@ class Zend_CodeGenerator_Php_Parameter extends Zend_CodeGenerator_Php_Abstract
*/
public static function fromReflection(Zend_Reflection_Parameter $reflectionParameter)
{
// @todo Research this
return new self();
$param = new Zend_CodeGenerator_Php_Parameter();
$param->setName($reflectionParameter->getName());
if($reflectionParameter->isArray()) {
$param->setType('array');
} else {
$typeClass = $reflectionParameter->getClass();
if($typeClass !== null) {
$param->setType($typeClass->getName());
}
}
$param->setPosition($reflectionParameter->getPosition());
if($reflectionParameter->isOptional()) {
$param->setDefaultValue($reflectionParameter->getDefaultValue());
}
$param->setPassedByReference($reflectionParameter->isPassedByReference());
return $param;
}
/**
* setType()
*
@ -76,7 +104,7 @@ class Zend_CodeGenerator_Php_Parameter extends Zend_CodeGenerator_Php_Abstract
$this->_type = $type;
return $this;
}
/**
* getType()
*
@ -86,7 +114,7 @@ class Zend_CodeGenerator_Php_Parameter extends Zend_CodeGenerator_Php_Abstract
{
return $this->_type;
}
/**
* setName()
*
@ -98,7 +126,7 @@ class Zend_CodeGenerator_Php_Parameter extends Zend_CodeGenerator_Php_Abstract
$this->_name = $name;
return $this;
}
/**
* getName()
*
@ -108,19 +136,34 @@ class Zend_CodeGenerator_Php_Parameter extends Zend_CodeGenerator_Php_Abstract
{
return $this->_name;
}
/**
* setDefaultValue()
* Set the default value of the parameter.
*
* @param string $defaultValue
* Certain variables are difficult to expres
*
* @param null|bool|string|int|float|Zend_CodeGenerator_Php_Parameter_DefaultValue $defaultValue
* @return Zend_CodeGenerator_Php_Parameter
*/
public function setDefaultValue($defaultValue)
{
$this->_defaultValue = $defaultValue;
if($defaultValue === null) {
$this->_defaultValue = new Zend_CodeGenerator_Php_Parameter_DefaultValue("null");
} else if(is_array($defaultValue)) {
$defaultValue = str_replace(array("\r", "\n"), "", var_export($defaultValue, true));
$this->_defaultValue = new Zend_CodeGenerator_Php_Parameter_DefaultValue($defaultValue);
} else if(is_bool($defaultValue)) {
if($defaultValue == true) {
$this->_defaultValue = new Zend_CodeGenerator_Php_Parameter_DefaultValue("true");
} else {
$this->_defaultValue = new Zend_CodeGenerator_Php_Parameter_DefaultValue("false");
}
} else {
$this->_defaultValue = $defaultValue;
}
return $this;
}
/**
* getDefaultValue()
*
@ -130,7 +173,7 @@ class Zend_CodeGenerator_Php_Parameter extends Zend_CodeGenerator_Php_Abstract
{
return $this->_defaultValue;
}
/**
* setPosition()
*
@ -142,7 +185,7 @@ class Zend_CodeGenerator_Php_Parameter extends Zend_CodeGenerator_Php_Abstract
$this->_position = $position;
return $this;
}
/**
* getPosition()
*
@ -152,7 +195,25 @@ class Zend_CodeGenerator_Php_Parameter extends Zend_CodeGenerator_Php_Abstract
{
return $this->_position;
}
/**
* @return bool
*/
public function getPassedByReference()
{
return $this->_passedByReference;
}
/**
* @param bool $passedByReference
* @return Zend_CodeGenerator_Php_Parameter
*/
public function setPassedByReference($passedByReference)
{
$this->_passedByReference = $passedByReference;
return $this;
}
/**
* generate()
*
@ -161,17 +222,23 @@ class Zend_CodeGenerator_Php_Parameter extends Zend_CodeGenerator_Php_Abstract
public function generate()
{
$output = '';
if ($this->_type) {
$output .= $this->_type . ' ';
$output .= $this->_type . ' ';
}
if($this->_passedByReference === true) {
$output .= '&';
}
$output .= '$' . $this->_name;
if ($this->_defaultValue) {
if ($this->_defaultValue !== null) {
$output .= ' = ';
if (is_string($this->_defaultValue)) {
$output .= '\'' . $this->_defaultValue . '\'';
} else if($this->_defaultValue instanceof Zend_CodeGenerator_Php_ParameterDefaultValue) {
$output .= (string)$this->_defaultValue;
} else {
$output .= $this->_defaultValue;
}
@ -179,5 +246,5 @@ class Zend_CodeGenerator_Php_Parameter extends Zend_CodeGenerator_Php_Abstract
return $output;
}
}