PSR2 Fixes

This commit is contained in:
Progi1984 2015-05-17 12:11:56 +02:00
parent 9140e3da2e
commit 6b1764f771
6 changed files with 274 additions and 214 deletions

View File

@ -886,9 +886,13 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
// Check for numeric values
if (is_numeric($value) && $cellDataType != 's') {
if ($value == (int)$value) $value = (int)$value;
elseif ($value == (float)$value) $value = (float)$value;
elseif ($value == (double)$value) $value = (double)$value;
if ($value == (int)$value) {
$value = (int)$value;
} elseif ($value == (float)$value) {
$value = (float)$value;
} elseif ($value == (double)$value) {
$value = (double)$value;
}
}
// Rich text?
@ -921,14 +925,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
if (!$this->_readDataOnly && $xmlSheet && $xmlSheet->conditionalFormatting) {
foreach ($xmlSheet->conditionalFormatting as $conditional) {
foreach ($conditional->cfRule as $cfRule) {
if (
(
(string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_NONE ||
(string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_CELLIS ||
(string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT ||
(string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_EXPRESSION
) && isset($dxfs[intval($cfRule["dxfId"])])
) {
if (((string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_NONE || (string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_CELLIS || (string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT || (string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_EXPRESSION) && isset($dxfs[intval($cfRule["dxfId"])])) {
$conditionals[(string) $conditional["sqref"]][intval($cfRule["priority"])] = $cfRule;
}
}
@ -1284,8 +1281,9 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
// Loop through contents
foreach ($commentsFile->commentList->comment as $comment) {
if (!empty($comment['authorId']))
if (!empty($comment['authorId'])) {
$docSheet->getComment((string)$comment['ref'])->setAuthor($authors[(string)$comment['authorId']]);
}
$docSheet->getComment((string)$comment['ref'])->setText($this->_parseRichText($comment->text));
}
}
@ -1588,9 +1586,8 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
// check for repeating columns, e g. 'A:A' or 'A:D'
if (preg_match('/!?([A-Z]+)\:([A-Z]+)$/', $range, $matches)) {
$docSheet->getPageSetup()->setColumnsToRepeatAtLeft(array($matches[1], $matches[2]));
}
} elseif (preg_match('/!?(\d+)\:(\d+)$/', $range, $matches)) {
// check for repeating rows, e.g. '1:1' or '1:5'
elseif (preg_match('/!?(\d+)\:(\d+)$/', $range, $matches)) {
$docSheet->getPageSetup()->setRowsToRepeatAtTop(array($matches[1], $matches[2]));
}
}

View File

@ -112,25 +112,63 @@ class PHPExcel_Reader_Excel5_Escher
$fbt = PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos + 2);
switch ($fbt) {
case self::DGGCONTAINER: $this->_readDggContainer(); break;
case self::DGG: $this->_readDgg(); break;
case self::BSTORECONTAINER: $this->_readBstoreContainer(); break;
case self::BSE: $this->_readBSE(); break;
case self::BLIPJPEG: $this->_readBlipJPEG(); break;
case self::BLIPPNG: $this->_readBlipPNG(); break;
case self::OPT: $this->_readOPT(); break;
case self::TERTIARYOPT: $this->_readTertiaryOPT(); break;
case self::SPLITMENUCOLORS: $this->_readSplitMenuColors(); break;
case self::DGCONTAINER: $this->_readDgContainer(); break;
case self::DG: $this->_readDg(); break;
case self::SPGRCONTAINER: $this->_readSpgrContainer(); break;
case self::SPCONTAINER: $this->_readSpContainer(); break;
case self::SPGR: $this->_readSpgr(); break;
case self::SP: $this->_readSp(); break;
case self::CLIENTTEXTBOX: $this->_readClientTextbox(); break;
case self::CLIENTANCHOR: $this->_readClientAnchor(); break;
case self::CLIENTDATA: $this->_readClientData(); break;
default: $this->_readDefault(); break;
case self::DGGCONTAINER:
$this->_readDggContainer();
break;
case self::DGG:
$this->_readDgg();
break;
case self::BSTORECONTAINER:
$this->_readBstoreContainer();
break;
case self::BSE:
$this->_readBSE();
break;
case self::BLIPJPEG:
$this->_readBlipJPEG();
break;
case self::BLIPPNG:
$this->_readBlipPNG();
break;
case self::OPT:
$this->_readOPT();
break;
case self::TERTIARYOPT:
$this->_readTertiaryOPT();
break;
case self::SPLITMENUCOLORS:
$this->_readSplitMenuColors();
break;
case self::DGCONTAINER:
$this->_readDgContainer();
break;
case self::DG:
$this->_readDg();
break;
case self::SPGRCONTAINER:
$this->_readSpgrContainer();
break;
case self::SPCONTAINER:
$this->_readSpContainer();
break;
case self::SPGR:
$this->_readSpgr();
break;
case self::SP:
$this->_readSp();
break;
case self::CLIENTTEXTBOX:
$this->_readClientTextbox();
break;
case self::CLIENTANCHOR:
$this->_readClientAnchor();
break;
case self::CLIENTDATA:
$this->_readClientData();
break;
default:
$this->_readDefault();
break;
}
}
@ -598,8 +636,8 @@ class PHPExcel_Reader_Excel5_Escher
* @param string $data Binary data
* @param int $n Number of properties
*/
private function _readOfficeArtRGFOPTE($data, $n) {
private function _readOfficeArtRGFOPTE($data, $n)
{
$splicedComplexData = substr($data, 6 * $n);
// loop through property-value pairs
@ -636,5 +674,4 @@ class PHPExcel_Reader_Excel5_Escher
$this->_object->setOPT($opidOpid, $value);
}
}
}

View File

@ -41,7 +41,6 @@ class PHPExcel_Reader_Excel5_MD5
private $c;
private $d;
/**
* MD5 stream constructor
*/
@ -50,7 +49,6 @@ class PHPExcel_Reader_Excel5_MD5
$this->reset();
}
/**
* Reset the MD5 stream context
*/
@ -62,7 +60,6 @@ class PHPExcel_Reader_Excel5_MD5
$this->d = 0x10325476;
}
/**
* Get MD5 stream context
*
@ -82,7 +79,6 @@ class PHPExcel_Reader_Excel5_MD5
return $s;
}
/**
* Add data to context
*
@ -180,31 +176,26 @@ class PHPExcel_Reader_Excel5_MD5
$this->d = ($this->d + $D) & 0xffffffff;
}
private static function F($X, $Y, $Z)
{
return (($X & $Y) | ((~ $X) & $Z)); // X AND Y OR NOT X AND Z
}
private static function G($X, $Y, $Z)
{
return (($X & $Z) | ($Y & (~ $Z))); // X AND Z OR Y AND NOT Z
}
private static function H($X, $Y, $Z)
{
return ($X ^ $Y ^ $Z); // X XOR Y XOR Z
}
private static function I($X, $Y, $Z)
{
return ($Y ^ ($X | (~ $Z))) ; // Y XOR (X OR NOT Z)
}
private static function step($func, &$A, $B, $C, $D, $M, $s, $t)
{
$A = ($A + call_user_func($func, $B, $C, $D) + $M + $t) & 0xffffffff;
@ -212,7 +203,6 @@ class PHPExcel_Reader_Excel5_MD5
$A = ($B + $A) & 0xffffffff;
}
private static function rotate($decimal, $bits)
{
$binary = str_pad(decbin($decimal), 32, "0", STR_PAD_LEFT);

View File

@ -92,16 +92,16 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
// Count delimiters in file
$delimiterCount = substr_count($data, ';');
if ($delimiterCount < 1) {
return FALSE;
return false;
}
// Analyze first line looking for ID; signature
$lines = explode("\n", $data);
if (substr($lines[0],0,4) != 'ID;P') {
return FALSE;
return false;
}
return TRUE;
return true;
}
/**
@ -154,7 +154,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
// loop through one row (line) at a time in the file
$rowIndex = 0;
while (($rowData = fgets($fileHandle)) !== FALSE) {
while (($rowData = fgets($fileHandle)) !== false) {
$columnIndex = 0;
// convert SYLK encoded $rowData to UTF-8
@ -243,7 +243,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
$column = $row = '';
// loop through one row (line) at a time in the file
while (($rowData = fgets($fileHandle)) !== FALSE) {
while (($rowData = fgets($fileHandle)) !== false) {
// convert SYLK encoded $rowData to UTF-8
$rowData = PHPExcel_Shared_String::SYLKtoUTF8($rowData);
@ -258,27 +258,37 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
$formatArray = array();
foreach ($rowData as $rowDatum) {
switch ($rowDatum{0}) {
case 'P' : $formatArray['numberformat']['code'] = str_replace($fromFormats, $toFormats,substr($rowDatum,1));
case 'P':
$formatArray['numberformat']['code'] = str_replace($fromFormats, $toFormats, substr($rowDatum, 1));
break;
case 'E':
case 'F' : $formatArray['font']['name'] = substr($rowDatum,1);
case 'F':
$formatArray['font']['name'] = substr($rowDatum, 1);
break;
case 'L' : $formatArray['font']['size'] = substr($rowDatum,1);
case 'L':
$formatArray['font']['size'] = substr($rowDatum, 1);
break;
case 'S' : $styleSettings = substr($rowDatum,1);
case 'S':
$styleSettings = substr($rowDatum,1);
for ($i=0;$i<strlen($styleSettings);++$i) {
switch ($styleSettings{$i}) {
case 'I' : $formatArray['font']['italic'] = true;
case 'I':
$formatArray['font']['italic'] = true;
break;
case 'D' : $formatArray['font']['bold'] = true;
case 'D':
$formatArray['font']['bold'] = true;
break;
case 'T' : $formatArray['borders']['top']['style'] = PHPExcel_Style_Border::BORDER_THIN;
case 'T':
$formatArray['borders']['top']['style'] = PHPExcel_Style_Border::BORDER_THIN;
break;
case 'B' : $formatArray['borders']['bottom']['style'] = PHPExcel_Style_Border::BORDER_THIN;
case 'B':
$formatArray['borders']['bottom']['style'] = PHPExcel_Style_Border::BORDER_THIN;
break;
case 'L' : $formatArray['borders']['left']['style'] = PHPExcel_Style_Border::BORDER_THIN;
case 'L':
$formatArray['borders']['left']['style'] = PHPExcel_Style_Border::BORDER_THIN;
break;
case 'R' : $formatArray['borders']['right']['style'] = PHPExcel_Style_Border::BORDER_THIN;
case 'R':
$formatArray['borders']['right']['style'] = PHPExcel_Style_Border::BORDER_THIN;
break;
}
}
@ -293,14 +303,18 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
foreach ($rowData as $rowDatum) {
switch ($rowDatum{0}) {
case 'C':
case 'X' : $column = substr($rowDatum,1);
case 'X':
$column = substr($rowDatum, 1);
break;
case 'R':
case 'Y' : $row = substr($rowDatum,1);
case 'Y':
$row = substr($rowDatum, 1);
break;
case 'K' : $cellData = substr($rowDatum,1);
case 'K':
$cellData = substr($rowDatum, 1);
break;
case 'E' : $cellDataFormula = '='.substr($rowDatum,1);
case 'E':
$cellDataFormula = '='.substr($rowDatum, 1);
// Convert R1C1 style references to A1 style references (but only when not quoted)
$temp = explode('"', $cellDataFormula);
$key = false;
@ -317,14 +331,22 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
foreach ($cellReferences as $cellReference) {
$rowReference = $cellReference[2][0];
// Empty R reference is the current row
if ($rowReference == '') $rowReference = $row;
if ($rowReference == '') {
$rowReference = $row;
}
// Bracketed R references are relative to the current row
if ($rowReference{0} == '[') $rowReference = $row + trim($rowReference,'[]');
if ($rowReference{0} == '[') {
$rowReference = $row + trim($rowReference, '[]');
}
$columnReference = $cellReference[4][0];
// Empty C reference is the current column
if ($columnReference == '') $columnReference = $column;
if ($columnReference == '') {
$columnReference = $column;
}
// Bracketed C references are relative to the current column
if ($columnReference{0} == '[') $columnReference = $column + trim($columnReference,'[]');
if ($columnReference{0} == '[') {
$columnReference = $column + trim($columnReference,'[]');
}
$A1CellReference = PHPExcel_Cell::stringFromColumnIndex($columnReference-1).$rowReference;
$value = substr_replace($value, $A1CellReference, $cellReference[0][1], strlen($cellReference[0][0]));
@ -354,29 +376,40 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
foreach ($rowData as $rowDatum) {
switch ($rowDatum{0}) {
case 'C':
case 'X' : $column = substr($rowDatum,1);
case 'X':
$column = substr($rowDatum, 1);
break;
case 'R':
case 'Y' : $row = substr($rowDatum,1);
case 'Y':
$row = substr($rowDatum, 1);
break;
case 'P' : $formatStyle = $rowDatum;
case 'P':
$formatStyle = $rowDatum;
break;
case 'W' : list($startCol, $endCol, $columnWidth) = explode(' ',substr($rowDatum,1));
case 'W':
list($startCol, $endCol, $columnWidth) = explode(' ', substr($rowDatum, 1));
break;
case 'S' : $styleSettings = substr($rowDatum,1);
case 'S':
$styleSettings = substr($rowDatum,1);
for ($i=0;$i<strlen($styleSettings);++$i) {
switch ($styleSettings{$i}) {
case 'I' : $styleData['font']['italic'] = true;
case 'I':
$styleData['font']['italic'] = true;
break;
case 'D' : $styleData['font']['bold'] = true;
case 'D':
$styleData['font']['bold'] = true;
break;
case 'T' : $styleData['borders']['top']['style'] = PHPExcel_Style_Border::BORDER_THIN;
case 'T':
$styleData['borders']['top']['style'] = PHPExcel_Style_Border::BORDER_THIN;
break;
case 'B' : $styleData['borders']['bottom']['style'] = PHPExcel_Style_Border::BORDER_THIN;
case 'B':
$styleData['borders']['bottom']['style'] = PHPExcel_Style_Border::BORDER_THIN;
break;
case 'L' : $styleData['borders']['left']['style'] = PHPExcel_Style_Border::BORDER_THIN;
case 'L':
$styleData['borders']['left']['style'] = PHPExcel_Style_Border::BORDER_THIN;
break;
case 'R' : $styleData['borders']['right']['style'] = PHPExcel_Style_Border::BORDER_THIN;
case 'R':
$styleData['borders']['right']['style'] = PHPExcel_Style_Border::BORDER_THIN;
break;
}
}
@ -410,10 +443,12 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
foreach ($rowData as $rowDatum) {
switch ($rowDatum{0}) {
case 'C':
case 'X' : $column = substr($rowDatum,1);
case 'X':
$column = substr($rowDatum,1);
break;
case 'R':
case 'Y' : $row = substr($rowDatum,1);
case 'Y':
$row = substr($rowDatum,1);
break;
}
}
@ -432,7 +467,8 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
*
* @return int
*/
public function getSheetIndex() {
public function getSheetIndex()
{
return $this->_sheetIndex;
}
@ -442,9 +478,9 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
* @param int $pValue Sheet index
* @return PHPExcel_Reader_SYLK
*/
public function setSheetIndex($pValue = 0) {
public function setSheetIndex($pValue = 0)
{
$this->_sheetIndex = $pValue;
return $this;
}
}