More PSR-2

This commit is contained in:
MarkBaker 2015-05-11 01:31:26 +01:00
parent 1efa7e8533
commit 547d2bd3b2
5 changed files with 888 additions and 896 deletions

View File

@ -99,7 +99,7 @@ class PHPExcel_Calculation_Database
$testConditionCount = 0; $testConditionCount = 0;
foreach ($criteria as $row => $criterion) { foreach ($criteria as $row => $criterion) {
if ($criterion[$key] > '') { if ($criterion[$key] > '') {
$testCondition[] = '[:'.$criteriaName.']'.PHPExcel_Calculation_Functions::_ifCondition($criterion[$key]); $testCondition[] = '[:'.$criteriaName.']'.PHPExcel_Calculation_Functions::ifCondition($criterion[$key]);
$testConditionCount++; $testConditionCount++;
} }
} }

View File

@ -67,7 +67,7 @@ class PHPExcel_Calculation_Functions
* @access private * @access private
* @var string * @var string
*/ */
protected static $compatibilityMode = self::COMPATIBILITY_EXCEL; protected static $compatibilityMode = self::COMPATIBILITY_EXCEL;
/** /**
* Data Type to use when returning date values * Data Type to use when returning date values
@ -75,7 +75,7 @@ class PHPExcel_Calculation_Functions
* @access private * @access private
* @var string * @var string
*/ */
protected static $ReturnDateType = self::RETURNDATE_EXCEL; protected static $returnDateType = self::RETURNDATE_EXCEL;
/** /**
* List of error codes * List of error codes
@ -83,7 +83,7 @@ class PHPExcel_Calculation_Functions
* @access private * @access private
* @var array * @var array
*/ */
protected static $_errorCodes = array( protected static $errorCodes = array(
'null' => '#NULL!', 'null' => '#NULL!',
'divisionbyzero' => '#DIV/0!', 'divisionbyzero' => '#DIV/0!',
'value' => '#VALUE!', 'value' => '#VALUE!',
@ -153,7 +153,7 @@ class PHPExcel_Calculation_Functions
if (($returnDateType == self::RETURNDATE_PHP_NUMERIC) || if (($returnDateType == self::RETURNDATE_PHP_NUMERIC) ||
($returnDateType == self::RETURNDATE_PHP_OBJECT) || ($returnDateType == self::RETURNDATE_PHP_OBJECT) ||
($returnDateType == self::RETURNDATE_EXCEL)) { ($returnDateType == self::RETURNDATE_EXCEL)) {
self::$ReturnDateType = $returnDateType; self::$returnDateType = $returnDateType;
return true; return true;
} }
return false; return false;
@ -173,7 +173,7 @@ class PHPExcel_Calculation_Functions
*/ */
public static function getReturnDateType() public static function getReturnDateType()
{ {
return self::$ReturnDateType; return self::$returnDateType;
} }
@ -199,7 +199,7 @@ class PHPExcel_Calculation_Functions
*/ */
public static function DIV0() public static function DIV0()
{ {
return self::$_errorCodes['divisionbyzero']; return self::$errorCodes['divisionbyzero'];
} }
@ -218,7 +218,7 @@ class PHPExcel_Calculation_Functions
*/ */
public static function NA() public static function NA()
{ {
return self::$_errorCodes['na']; return self::$errorCodes['na'];
} }
@ -233,7 +233,7 @@ class PHPExcel_Calculation_Functions
*/ */
public static function NaN() public static function NaN()
{ {
return self::$_errorCodes['num']; return self::$errorCodes['num'];
} }
@ -248,7 +248,7 @@ class PHPExcel_Calculation_Functions
*/ */
public static function NAME() public static function NAME()
{ {
return self::$_errorCodes['name']; return self::$errorCodes['name'];
} }
@ -263,7 +263,7 @@ class PHPExcel_Calculation_Functions
*/ */
public static function REF() public static function REF()
{ {
return self::$_errorCodes['reference']; return self::$errorCodes['reference'];
} }
@ -278,7 +278,7 @@ class PHPExcel_Calculation_Functions
*/ */
public static function NULL() public static function NULL()
{ {
return self::$_errorCodes['null']; return self::$errorCodes['null'];
} }
@ -293,7 +293,7 @@ class PHPExcel_Calculation_Functions
*/ */
public static function VALUE() public static function VALUE()
{ {
return self::$_errorCodes['value']; return self::$errorCodes['value'];
} }
@ -315,7 +315,7 @@ class PHPExcel_Calculation_Functions
} }
public static function _ifCondition($condition) public static function ifCondition($condition)
{ {
$condition = PHPExcel_Calculation_Functions::flattenSingleValue($condition); $condition = PHPExcel_Calculation_Functions::flattenSingleValue($condition);
if (!isset($condition{0})) { if (!isset($condition{0})) {
@ -350,7 +350,7 @@ class PHPExcel_Calculation_Functions
$value = self::flattenSingleValue($value); $value = self::flattenSingleValue($value);
$i = 1; $i = 1;
foreach (self::$_errorCodes as $errorCode) { foreach (self::$errorCodes as $errorCode) {
if ($value === $errorCode) { if ($value === $errorCode) {
return $i; return $i;
} }
@ -403,7 +403,7 @@ class PHPExcel_Calculation_Functions
if (!is_string($value)) { if (!is_string($value)) {
return false; return false;
} }
return in_array($value, array_values(self::$_errorCodes)); return in_array($value, array_values(self::$errorCodes));
} }

View File

@ -1201,7 +1201,7 @@ class PHPExcel_Calculation_MathTrig
if (empty($sumArgs)) { if (empty($sumArgs)) {
$sumArgs = $aArgs; $sumArgs = $aArgs;
} }
$condition = PHPExcel_Calculation_Functions::_ifCondition($condition); $condition = PHPExcel_Calculation_Functions::ifCondition($condition);
// Loop through arguments // Loop through arguments
foreach ($aArgs as $key => $arg) { foreach ($aArgs as $key => $arg) {
if (!is_numeric($arg)) { if (!is_numeric($arg)) {

View File

@ -91,12 +91,12 @@ class PHPExcel_Calculation_Statistical
* @param q require q>0 * @param q require q>0
* @return 0 if p<=0, q<=0 or p+q>2.55E305 to avoid errors and over/underflow * @return 0 if p<=0, q<=0 or p+q>2.55E305 to avoid errors and over/underflow
*/ */
private static function _beta($p, $q) private static function beta($p, $q)
{ {
if ($p <= 0.0 || $q <= 0.0 || ($p + $q) > LOG_GAMMA_X_MAX_VALUE) { if ($p <= 0.0 || $q <= 0.0 || ($p + $q) > LOG_GAMMA_X_MAX_VALUE) {
return 0.0; return 0.0;
} else { } else {
return exp(self::_logBeta($p, $q)); return exp(self::logBeta($p, $q));
} }
} }
@ -113,7 +113,7 @@ class PHPExcel_Calculation_Statistical
* @param q require q>0 * @param q require q>0
* @return 0 if x<0, p<=0, q<=0 or p+q>2.55E305 and 1 if x>1 to avoid errors and over/underflow * @return 0 if x<0, p<=0, q<=0 or p+q>2.55E305 and 1 if x>1 to avoid errors and over/underflow
*/ */
private static function _incompleteBeta($x, $p, $q) private static function incompleteBeta($x, $p, $q)
{ {
if ($x <= 0.0) { if ($x <= 0.0) {
return 0.0; return 0.0;
@ -122,16 +122,16 @@ class PHPExcel_Calculation_Statistical
} elseif (($p <= 0.0) || ($q <= 0.0) || (($p + $q) > LOG_GAMMA_X_MAX_VALUE)) { } elseif (($p <= 0.0) || ($q <= 0.0) || (($p + $q) > LOG_GAMMA_X_MAX_VALUE)) {
return 0.0; return 0.0;
} }
$beta_gam = exp((0 - self::_logBeta($p, $q)) + $p * log($x) + $q * log(1.0 - $x)); $beta_gam = exp((0 - self::logBeta($p, $q)) + $p * log($x) + $q * log(1.0 - $x));
if ($x < ($p + 1.0) / ($p + $q + 2.0)) { if ($x < ($p + 1.0) / ($p + $q + 2.0)) {
return $beta_gam * self::_betaFraction($x, $p, $q) / $p; return $beta_gam * self::betaFraction($x, $p, $q) / $p;
} else { } else {
return 1.0 - ($beta_gam * self::_betaFraction(1 - $x, $q, $p) / $q); return 1.0 - ($beta_gam * self::betaFraction(1 - $x, $q, $p) / $q);
} }
} }
// Function cache for _logBeta function // Function cache for logBeta function
private static $logBetaCacheP = 0.0; private static $logBetaCacheP = 0.0;
private static $logBetaCacheQ = 0.0; private static $logBetaCacheQ = 0.0;
private static $logBetaCacheResult = 0.0; private static $logBetaCacheResult = 0.0;
@ -144,7 +144,7 @@ class PHPExcel_Calculation_Statistical
* @return 0 if p<=0, q<=0 or p+q>2.55E305 to avoid errors and over/underflow * @return 0 if p<=0, q<=0 or p+q>2.55E305 to avoid errors and over/underflow
* @author Jaco van Kooten * @author Jaco van Kooten
*/ */
private static function _logBeta($p, $q) private static function logBeta($p, $q)
{ {
if ($p != self::$logBetaCacheP || $q != self::$logBetaCacheQ) { if ($p != self::$logBetaCacheP || $q != self::$logBetaCacheQ) {
self::$logBetaCacheP = $p; self::$logBetaCacheP = $p;
@ -152,7 +152,7 @@ class PHPExcel_Calculation_Statistical
if (($p <= 0.0) || ($q <= 0.0) || (($p + $q) > LOG_GAMMA_X_MAX_VALUE)) { if (($p <= 0.0) || ($q <= 0.0) || (($p + $q) > LOG_GAMMA_X_MAX_VALUE)) {
self::$logBetaCacheResult = 0.0; self::$logBetaCacheResult = 0.0;
} else { } else {
self::$logBetaCacheResult = self::_logGamma($p) + self::_logGamma($q) - self::_logGamma($p + $q); self::$logBetaCacheResult = self::logGamma($p) + self::logGamma($q) - self::logGamma($p + $q);
} }
} }
return self::$logBetaCacheResult; return self::$logBetaCacheResult;
@ -164,7 +164,7 @@ class PHPExcel_Calculation_Statistical
* Based on an idea from Numerical Recipes (W.H. Press et al, 1992). * Based on an idea from Numerical Recipes (W.H. Press et al, 1992).
* @author Jaco van Kooten * @author Jaco van Kooten
*/ */
private static function _betaFraction($x, $p, $q) private static function betaFraction($x, $p, $q)
{ {
$c = 1.0; $c = 1.0;
$sum_pq = $p + $q; $sum_pq = $p + $q;
@ -258,7 +258,7 @@ class PHPExcel_Calculation_Statistical
private static $logGammaCacheResult = 0.0; private static $logGammaCacheResult = 0.0;
private static $logGammaCacheX = 0.0; private static $logGammaCacheX = 0.0;
private static function _logGamma($x) private static function logGamma($x)
{ {
// Log Gamma related constants // Log Gamma related constants
static $lg_d1 = -0.5772156649015328605195174; static $lg_d1 = -0.5772156649015328605195174;
@ -435,7 +435,7 @@ class PHPExcel_Calculation_Statistical
// //
// Private implementation of the incomplete Gamma function // Private implementation of the incomplete Gamma function
// //
private static function _incompleteGamma($a, $x) private static function incompleteGamma($a, $x)
{ {
static $max = 32; static $max = 32;
$summer = 0; $summer = 0;
@ -453,7 +453,7 @@ class PHPExcel_Calculation_Statistical
// //
// Private implementation of the Gamma function // Private implementation of the Gamma function
// //
private static function _gamma($data) private static function gamma($data)
{ {
if ($data == 0.0) { if ($data == 0.0) {
return 0; return 0;
@ -872,7 +872,7 @@ class PHPExcel_Calculation_Statistical
if (empty($averageArgs)) { if (empty($averageArgs)) {
$averageArgs = $aArgs; $averageArgs = $aArgs;
} }
$condition = PHPExcel_Calculation_Functions::_ifCondition($condition); $condition = PHPExcel_Calculation_Functions::ifCondition($condition);
// Loop through arguments // Loop through arguments
$aCount = 0; $aCount = 0;
foreach ($aArgs as $key => $arg) { foreach ($aArgs as $key => $arg) {
@ -926,7 +926,7 @@ class PHPExcel_Calculation_Statistical
} }
$value -= $rMin; $value -= $rMin;
$value /= ($rMax - $rMin); $value /= ($rMax - $rMin);
return self::_incompleteBeta($value, $alpha, $beta); return self::incompleteBeta($value, $alpha, $beta);
} }
return PHPExcel_Calculation_Functions::VALUE(); return PHPExcel_Calculation_Functions::VALUE();
} }
@ -1058,7 +1058,7 @@ class PHPExcel_Calculation_Statistical
} }
return PHPExcel_Calculation_Functions::NaN(); return PHPExcel_Calculation_Functions::NaN();
} }
return 1 - (self::_incompleteGamma($degrees/2, $value/2) / self::_gamma($degrees/2)); return 1 - (self::incompleteGamma($degrees/2, $value/2) / self::gamma($degrees/2));
} }
return PHPExcel_Calculation_Functions::VALUE(); return PHPExcel_Calculation_Functions::VALUE();
} }
@ -1294,7 +1294,7 @@ class PHPExcel_Calculation_Statistical
$returnValue = 0; $returnValue = 0;
$aArgs = PHPExcel_Calculation_Functions::flattenArray($aArgs); $aArgs = PHPExcel_Calculation_Functions::flattenArray($aArgs);
$condition = PHPExcel_Calculation_Functions::_ifCondition($condition); $condition = PHPExcel_Calculation_Functions::ifCondition($condition);
// Loop through arguments // Loop through arguments
foreach ($aArgs as $arg) { foreach ($aArgs as $arg) {
if (!is_numeric($arg)) { if (!is_numeric($arg)) {
@ -1649,9 +1649,9 @@ class PHPExcel_Calculation_Statistical
} }
if ((is_numeric($cumulative)) || (is_bool($cumulative))) { if ((is_numeric($cumulative)) || (is_bool($cumulative))) {
if ($cumulative) { if ($cumulative) {
return self::_incompleteGamma($a, $value / $b) / self::_gamma($a); return self::incompleteGamma($a, $value / $b) / self::gamma($a);
} else { } else {
return (1 / (pow($b, $a) * self::_gamma($a))) * pow($value, $a-1) * exp(0-($value / $b)); return (1 / (pow($b, $a) * self::gamma($a))) * pow($value, $a-1) * exp(0-($value / $b));
} }
} }
} }
@ -1737,7 +1737,7 @@ class PHPExcel_Calculation_Statistical
if ($value <= 0) { if ($value <= 0) {
return PHPExcel_Calculation_Functions::NaN(); return PHPExcel_Calculation_Functions::NaN();
} }
return log(self::_gamma($value)); return log(self::gamma($value));
} }
return PHPExcel_Calculation_Functions::VALUE(); return PHPExcel_Calculation_Functions::VALUE();
} }
@ -2286,7 +2286,7 @@ class PHPExcel_Calculation_Statistical
if (empty($sumArgs)) { if (empty($sumArgs)) {
$sumArgs = $aArgs; $sumArgs = $aArgs;
} }
$condition = PHPExcel_Calculation_Functions::_ifCondition($condition); $condition = PHPExcel_Calculation_Functions::ifCondition($condition);
// Loop through arguments // Loop through arguments
foreach ($aArgs as $key => $arg) { foreach ($aArgs as $key => $arg) {
if (!is_numeric($arg)) { if (!is_numeric($arg)) {
@ -2445,7 +2445,7 @@ class PHPExcel_Calculation_Statistical
if (empty($sumArgs)) { if (empty($sumArgs)) {
$sumArgs = $aArgs; $sumArgs = $aArgs;
} }
$condition = PHPExcel_Calculation_Functions::_ifCondition($condition); $condition = PHPExcel_Calculation_Functions::ifCondition($condition);
// Loop through arguments // Loop through arguments
foreach ($aArgs as $key => $arg) { foreach ($aArgs as $key => $arg) {
if (!is_numeric($arg)) { if (!is_numeric($arg)) {

File diff suppressed because it is too large Load Diff