PSR2 Fixes

This commit is contained in:
Progi1984 2015-05-17 18:10:35 +02:00
parent 09352e3e80
commit 576effef30
7 changed files with 8379 additions and 8382 deletions

View File

@ -1764,7 +1764,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
// move stream pointer to next record
$this->_pos += 4 + $length;
if (!$this->_verifyPassword('VelvetSweatshop', substr($recordData, 6, 16), substr($recordData, 22, 16), substr($recordData, 38, 16), $this->_md5Ctxt)) {
if (!$this->_verifyPassword('VelvetSweatshop', substr($recordData, 6, 16), substr($recordData, 22, 16), substr($recordData, 38, 16), $this->_md5Ctxt)) {
throw new PHPExcel_Reader_Exception('Decryption password incorrect');
}
@ -1960,19 +1960,19 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
$objFont->setSize($size / 20);
// offset: 2; size: 2; option flags
// bit: 0; mask 0x0001; bold (redundant in BIFF5-BIFF8)
// bit: 1; mask 0x0002; italic
$isItalic = (0x0002 & self::_GetInt2d($recordData, 2)) >> 1;
if ($isItalic) {
$objFont->setItalic(true);
}
// bit: 0; mask 0x0001; bold (redundant in BIFF5-BIFF8)
// bit: 1; mask 0x0002; italic
$isItalic = (0x0002 & self::_GetInt2d($recordData, 2)) >> 1;
if ($isItalic) {
$objFont->setItalic(true);
}
// bit: 2; mask 0x0004; underlined (redundant in BIFF5-BIFF8)
// bit: 3; mask 0x0008; strike
$isStrike = (0x0008 & self::_GetInt2d($recordData, 2)) >> 3;
if ($isStrike) {
$objFont->setStrikethrough(true);
}
// bit: 2; mask 0x0004; underlined (redundant in BIFF5-BIFF8)
// bit: 3; mask 0x0008; strike
$isStrike = (0x0008 & self::_GetInt2d($recordData, 2)) >> 3;
if ($isStrike) {
$objFont->setStrikethrough(true);
}
// offset: 4; size: 2; colour index
$colorIndex = self::_GetInt2d($recordData, 4);
@ -5184,7 +5184,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
break;
case 0x02: // Windows metafile or Macintosh PICT format
case 0x0e: // native format
default;
default:
break;
}
@ -7471,10 +7471,10 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
$value = $mantissa / pow(2, (20 - $exp));
if ($mantissalow1 != 0) {
$value += 1 / pow (2, (21 - $exp));
$value += 1 / pow(2, (21 - $exp));
}
$value += $mantissalow2 / pow (2, (52 - $exp));
$value += $mantissalow2 / pow(2, (52 - $exp));
if ($sign) {
$value *= -1;
}

View File

@ -557,9 +557,9 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
}
break;
case 'boolean':
$type = PHPExcel_Cell_DataType::TYPE_BOOL;
$dataValue = ($allCellDataText == 'TRUE') ? true : false;
break;
$type = PHPExcel_Cell_DataType::TYPE_BOOL;
$dataValue = ($allCellDataText == 'TRUE') ? true : false;
break;
case 'percentage':
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
$dataValue = (float) $cellDataOfficeAttributes['value'];

View File

@ -198,10 +198,14 @@ class PHPExcel_Shared_JAMA_Matrix
case 'integer,integer,integer,integer':
list($i0, $iF, $j0, $jF) = $args;
if (($iF > $i0) && ($this->m >= $iF) && ($i0 >= 0)) {
$m = $iF - $i0; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException);
$m = $iF - $i0;
} else {
throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException);
}
if (($jF > $j0) && ($this->n >= $jF) && ($j0 >= 0)) {
$n = $jF - $j0; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException);
$n = $jF - $j0;
} else {
throw new PHPExcel_Calculation_Exception(self::ArgumentBoundsException);
}
$R = new PHPExcel_Shared_JAMA_Matrix($m+1, $n+1);
for ($i = $i0; $i <= $iF; ++$i) {

View File

@ -17,21 +17,21 @@ date_default_timezone_set('Europe/London');
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../Classes'));
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../Classes'));
// Define path to application tests directory
defined('APPLICATION_TESTS_PATH')
|| define('APPLICATION_TESTS_PATH', realpath(dirname(__FILE__) ));
|| define('APPLICATION_TESTS_PATH', realpath(dirname(__FILE__)));
// Define application environment
defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'ci');
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../Classes'),
'./',
dirname(__FILE__),
get_include_path(),
realpath(APPLICATION_PATH . '/../Classes'),
'./',
dirname(__FILE__),
get_include_path(),
)));
@ -41,9 +41,9 @@ set_include_path(implode(PATH_SEPARATOR, array(
*/
echo "PHPExcel tests beginning\n";
if(extension_loaded('xdebug')) {
echo "Xdebug extension loaded and running\n";
xdebug_enable();
if (extension_loaded('xdebug')) {
echo "Xdebug extension loaded and running\n";
xdebug_enable();
} else {
echo 'Xdebug not found, you should run the following at the command line: echo "zend_extension=/usr/lib64/php/modules/xdebug.so" > /etc/php.d/xdebug.ini' . "\n";
echo 'Xdebug not found, you should run the following at the command line: echo "zend_extension=/usr/lib64/php/modules/xdebug.so" > /etc/php.d/xdebug.ini' . "\n";
}

View File

@ -1,114 +1,115 @@
<?php
class Complex {
class Complex
{
private $realPart = 0;
private $imaginaryPart = 0;
private $suffix = null;
private $realPart = 0;
private $imaginaryPart = 0;
private $suffix = NULL;
public static function _parseComplex($complexNumber)
{
// Test for real number, with no imaginary part
if (is_numeric($complexNumber)) {
return array($complexNumber, 0, null);
}
public static function _parseComplex($complexNumber)
{
// Test for real number, with no imaginary part
if (is_numeric($complexNumber))
return array( $complexNumber, 0, NULL );
// Fix silly human errors
if (strpos($complexNumber, '+-') !== false) {
$complexNumber = str_replace('+-', '-', $complexNumber);
}
if (strpos($complexNumber, '++') !== false) {
$complexNumber = str_replace('++', '+', $complexNumber);
}
if (strpos($complexNumber, '--') !== false) {
$complexNumber = str_replace('--', '-', $complexNumber);
}
// Fix silly human errors
if (strpos($complexNumber,'+-') !== FALSE)
$complexNumber = str_replace('+-','-',$complexNumber);
if (strpos($complexNumber,'++') !== FALSE)
$complexNumber = str_replace('++','+',$complexNumber);
if (strpos($complexNumber,'--') !== FALSE)
$complexNumber = str_replace('--','-',$complexNumber);
// Basic validation of string, to parse out real and imaginary parts, and any suffix
$validComplex = preg_match('/^([\-\+]?(\d+\.?\d*|\d*\.?\d+)([Ee][\-\+]?[0-2]?\d{1,3})?)([\-\+]?(\d+\.?\d*|\d*\.?\d+)([Ee][\-\+]?[0-2]?\d{1,3})?)?(([\-\+]?)([ij]?))$/ui', $complexNumber, $complexParts);
// Basic validation of string, to parse out real and imaginary parts, and any suffix
$validComplex = preg_match('/^([\-\+]?(\d+\.?\d*|\d*\.?\d+)([Ee][\-\+]?[0-2]?\d{1,3})?)([\-\+]?(\d+\.?\d*|\d*\.?\d+)([Ee][\-\+]?[0-2]?\d{1,3})?)?(([\-\+]?)([ij]?))$/ui',$complexNumber,$complexParts);
if (!$validComplex) {
// Neither real nor imaginary part, so test to see if we actually have a suffix
$validComplex = preg_match('/^([\-\+]?)([ij])$/ui', $complexNumber, $complexParts);
if (!$validComplex) {
throw new Exception('COMPLEX: Invalid complex number');
}
// We have a suffix, so set the real to 0, the imaginary to either 1 or -1 (as defined by the sign)
$imaginary = 1;
if ($complexParts[1] === '-') {
$imaginary = 0 - $imaginary;
}
return array(0, $imaginary, $complexParts[2]);
}
if (!$validComplex) {
// Neither real nor imaginary part, so test to see if we actually have a suffix
$validComplex = preg_match('/^([\-\+]?)([ij])$/ui',$complexNumber,$complexParts);
if (!$validComplex) {
throw new Exception('COMPLEX: Invalid complex number');
}
// We have a suffix, so set the real to 0, the imaginary to either 1 or -1 (as defined by the sign)
$imaginary = 1;
if ($complexParts[1] === '-') {
$imaginary = 0 - $imaginary;
}
return array(0, $imaginary, $complexParts[2]);
}
// If we don't have an imaginary part, identify whether it should be +1 or -1...
if (($complexParts[4] === '') && ($complexParts[9] !== '')) {
if ($complexParts[7] !== $complexParts[9]) {
$complexParts[4] = 1;
if ($complexParts[8] === '-') {
$complexParts[4] = -1;
}
// ... or if we have only the real and no imaginary part (in which case our real should be the imaginary)
} else {
$complexParts[4] = $complexParts[1];
$complexParts[1] = 0;
}
}
// If we don't have an imaginary part, identify whether it should be +1 or -1...
if (($complexParts[4] === '') && ($complexParts[9] !== '')) {
if ($complexParts[7] !== $complexParts[9]) {
$complexParts[4] = 1;
if ($complexParts[8] === '-') {
$complexParts[4] = -1;
}
// ... or if we have only the real and no imaginary part (in which case our real should be the imaginary)
} else {
$complexParts[4] = $complexParts[1];
$complexParts[1] = 0;
}
}
// Return real and imaginary parts and suffix as an array, and set a default suffix if user input lazily
return array( $complexParts[1],
$complexParts[4],
!empty($complexParts[9]) ? $complexParts[9] : 'i'
);
} // function _parseComplex()
// Return real and imaginary parts and suffix as an array, and set a default suffix if user input lazily
return array($complexParts[1], $complexParts[4], !empty($complexParts[9]) ? $complexParts[9] : 'i');
} // function _parseComplex()
public function __construct($realPart, $imaginaryPart = null, $suffix = 'i')
{
if ($imaginaryPart === null) {
if (is_array($realPart)) {
// We have an array of (potentially) real and imaginary parts, and any suffix
list ($realPart, $imaginaryPart, $suffix) = array_values($realPart) + array(0.0, 0.0, 'i');
} elseif((is_string($realPart)) || (is_numeric($realPart))) {
// We've been given a string to parse to extract the real and imaginary parts, and any suffix
list ($realPart, $imaginaryPart, $suffix) = self::_parseComplex($realPart);
}
}
public function __construct($realPart, $imaginaryPart = null, $suffix = 'i')
{
if ($imaginaryPart === null) {
if (is_array($realPart)) {
// We have an array of (potentially) real and imaginary parts, and any suffix
list ($realPart, $imaginaryPart, $suffix) = array_values($realPart) + array(0.0, 0.0, 'i');
} elseif((is_string($realPart)) || (is_numeric($realPart))) {
// We've been given a string to parse to extract the real and imaginary parts, and any suffix
list ($realPart, $imaginaryPart, $suffix) = self::_parseComplex($realPart);
}
}
// Set parsed values in our properties
$this->realPart = (float) $realPart;
$this->imaginaryPart = (float) $imaginaryPart;
$this->suffix = strtolower($suffix);
}
// Set parsed values in our properties
$this->realPart = (float) $realPart;
$this->imaginaryPart = (float) $imaginaryPart;
$this->suffix = strtolower($suffix);
}
public function getReal()
{
return $this->realPart;
}
public function getReal()
{
return $this->realPart;
}
public function getImaginary()
{
return $this->imaginaryPart;
}
public function getImaginary()
{
return $this->imaginaryPart;
}
public function getSuffix()
{
return $this->suffix;
}
public function getSuffix()
{
return $this->suffix;
}
public function __toString() {
$str = "";
if ($this->imaginaryPart != 0.0) {
if (abs($this->imaginaryPart) != 1.0) {
$str .= $this->imaginaryPart . $this->suffix;
} else {
$str .= (($this->imaginaryPart < 0.0) ? '-' : ''). $this->suffix;
}
}
if ($this->realPart != 0.0) {
if (($str) && ($this->imaginaryPart > 0.0))
$str = "+" . $str;
$str = $this->realPart . $str;
}
if (!$str)
$str = "0.0";
return $str;
}
public function __toString() {
$str = "";
if ($this->imaginaryPart != 0.0) {
if (abs($this->imaginaryPart) != 1.0) {
$str .= $this->imaginaryPart . $this->suffix;
} else {
$str .= (($this->imaginaryPart < 0.0) ? '-' : ''). $this->suffix;
}
}
if ($this->realPart != 0.0) {
if (($str) && ($this->imaginaryPart > 0.0))
$str = "+" . $str;
$str = $this->realPart . $str;
}
if (!$str)
$str = "0.0";
return $str;
}
}

View File

@ -2,61 +2,54 @@
include_once dirname(__FILE__).'/Complex.php';
class complexAssert {
private $_errorMessage = '';
class complexAssert
{
private $_errorMessage = '';
public function assertComplexEquals($expected, $actual, $delta = 0)
{
if ($expected{0} === '#') {
// Expecting an error, so we do a straight string comparison
if ($expected === $actual) {
return TRUE;
}
$this->_errorMessage = 'Expected Error: ' .
$actual . ' !== ' . $expected;
return FALSE;
}
if ($expected{0} === '#') {
// Expecting an error, so we do a straight string comparison
if ($expected === $actual) {
return true;
}
$this->_errorMessage = 'Expected Error: ' . $actual . ' !== ' . $expected;
return false;
}
$expectedComplex = new Complex($expected);
$actualComplex = new Complex($actual);
if (!is_numeric($actualComplex->getReal()) || !is_numeric($expectedComplex->getReal())) {
if ($actualComplex->getReal() !== $expectedComplex->getReal()) {
$this->_errorMessage = 'Mismatched String: ' .
$actualComplex->getReal() . ' !== ' . $expectedComplex->getReal();
return FALSE;
}
return TRUE;
}
if (!is_numeric($actualComplex->getReal()) || !is_numeric($expectedComplex->getReal())) {
if ($actualComplex->getReal() !== $expectedComplex->getReal()) {
$this->_errorMessage = 'Mismatched String: ' . $actualComplex->getReal() . ' !== ' . $expectedComplex->getReal();
return false;
}
return true;
}
if ($actualComplex->getReal() < ($expectedComplex->getReal() - $delta) ||
$actualComplex->getReal() > ($expectedComplex->getReal() + $delta)) {
$this->_errorMessage = 'Mismatched Real part: ' .
$actualComplex->getReal() . ' != ' . $expectedComplex->getReal();
return FALSE;
$this->_errorMessage = 'Mismatched Real part: ' . $actualComplex->getReal() . ' != ' . $expectedComplex->getReal();
return false;
}
if ($actualComplex->getImaginary() < ($expectedComplex->getImaginary() - $delta) ||
$actualComplex->getImaginary() > ($expectedComplex->getImaginary() + $delta)) {
$this->_errorMessage = 'Mismatched Imaginary part: ' .
$actualComplex->getImaginary() . ' != ' . $expectedComplex->getImaginary();
return FALSE;
$this->_errorMessage = 'Mismatched Imaginary part: ' . $actualComplex->getImaginary() . ' != ' . $expectedComplex->getImaginary();
return false;
}
if ($actualComplex->getSuffix() !== $actualComplex->getSuffix()) {
$this->_errorMessage = 'Mismatched Suffix: ' .
$actualComplex->getSuffix() . ' != ' . $expectedComplex->getSuffix();
return FALSE;
}
$this->_errorMessage = 'Mismatched Suffix: ' . $actualComplex->getSuffix() . ' != ' . $expectedComplex->getSuffix();
return false;
}
return TRUE;
return true;
}
public function getErrorMessage() {
return $this->_errorMessage;
}
public function getErrorMessage()
{
return $this->_errorMessage;
}
}

View File

@ -2,7 +2,6 @@
class testDataFileIterator implements Iterator
{
protected $file;
protected $key = 0;
protected $current;