A few more manual code style fixes for phpcs

This commit is contained in:
Adrien Crivelli 2016-12-23 00:08:55 +09:00
parent 8c66afe39a
commit af82e266c0
No known key found for this signature in database
GPG Key ID: B182FD79DC6DE92E
8 changed files with 58 additions and 62 deletions

View File

@ -1945,12 +1945,12 @@ class Engineering
} }
return self::cleanComplex( return self::cleanComplex(
self::COMPLEX( self::COMPLEX(
$parsedComplex['real'], $parsedComplex['real'],
0 - $parsedComplex['imaginary'], 0 - $parsedComplex['imaginary'],
$parsedComplex['suffix'] $parsedComplex['suffix']
) )
); );
} }
/** /**
@ -1976,12 +1976,12 @@ class Engineering
} }
return self::IMCONJUGATE( return self::IMCONJUGATE(
self::COMPLEX( self::COMPLEX(
cos($parsedComplex['real']) * cosh($parsedComplex['imaginary']), cos($parsedComplex['real']) * cosh($parsedComplex['imaginary']),
sin($parsedComplex['real']) * sinh($parsedComplex['imaginary']), sin($parsedComplex['real']) * sinh($parsedComplex['imaginary']),
$parsedComplex['suffix'] $parsedComplex['suffix']
) )
); );
} }
/** /**
@ -2007,10 +2007,10 @@ class Engineering
} }
return self::COMPLEX( return self::COMPLEX(
sin($parsedComplex['real']) * cosh($parsedComplex['imaginary']), sin($parsedComplex['real']) * cosh($parsedComplex['imaginary']),
cos($parsedComplex['real']) * sinh($parsedComplex['imaginary']), cos($parsedComplex['real']) * sinh($parsedComplex['imaginary']),
$parsedComplex['suffix'] $parsedComplex['suffix']
); );
} }
/** /**

View File

@ -22,12 +22,13 @@ class Color
// palette color, color index 0x08 maps to pallete index 0 // palette color, color index 0x08 maps to pallete index 0
return $palette[$color - 8]; return $palette[$color - 8];
} }
// default color table
if ($version == \PhpOffice\PhpSpreadsheet\Reader\Xls::XLS_BIFF8) { // default color table
return Color\BIFF8::lookup($color); if ($version == \PhpOffice\PhpSpreadsheet\Reader\Xls::XLS_BIFF8) {
} return Color\BIFF8::lookup($color);
// BIFF5 }
return Color\BIFF5::lookup($color);
return $color; // BIFF5
return Color\BIFF5::lookup($color);
} }
} }

View File

@ -980,8 +980,7 @@ class Matrix
return $C; return $C;
} }
throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(JAMAError(MatrixDimensionMismatch)); throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(JAMAError(MatrixDimensionMismatch));
break;
case 'array': case 'array':
$B = new self($args[0]); $B = new self($args[0]);
if ($this->n == $B->m) { if ($this->n == $B->m) {
@ -998,9 +997,7 @@ class Matrix
return $C; return $C;
} }
throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(JAMAError(MatrixDimensionMismatch)); throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(JAMAError(MatrixDimensionMismatch));
return $M;
break;
case 'integer': case 'integer':
$C = new self($this->A); $C = new self($this->A);
for ($i = 0; $i < $C->m; ++$i) { for ($i = 0; $i < $C->m; ++$i) {
@ -1010,7 +1007,6 @@ class Matrix
} }
return $C; return $C;
break;
case 'double': case 'double':
$C = new self($this->m, $this->n); $C = new self($this->m, $this->n);
for ($i = 0; $i < $C->m; ++$i) { for ($i = 0; $i < $C->m; ++$i) {
@ -1020,7 +1016,6 @@ class Matrix
} }
return $C; return $C;
break;
case 'float': case 'float':
$C = new self($this->A); $C = new self($this->A);
for ($i = 0; $i < $C->m; ++$i) { for ($i = 0; $i < $C->m; ++$i) {
@ -1030,10 +1025,8 @@ class Matrix
} }
return $C; return $C;
break;
default: default:
throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
break;
} }
} else { } else {
throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION); throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION);

View File

@ -286,7 +286,7 @@ class OLE
public function _readPpsWks($blockId) public function _readPpsWks($blockId)
{ {
$fh = $this->getStream($blockId); $fh = $this->getStream($blockId);
for ($pos = 0; ; $pos += 128) { for ($pos = 0; true; $pos += 128) {
fseek($fh, $pos, SEEK_SET); fseek($fh, $pos, SEEK_SET);
$nameUtf16 = fread($fh, 64); $nameUtf16 = fread($fh, 64);
$nameLength = self::_readInt2($fh); $nameLength = self::_readInt2($fh);

View File

@ -182,8 +182,7 @@ class ZipStreamWrapper
return true; return true;
} }
return false; return false;
break;
case SEEK_CUR: case SEEK_CUR:
if ($offset >= 0) { if ($offset >= 0) {
$this->position += $offset; $this->position += $offset;
@ -191,8 +190,7 @@ class ZipStreamWrapper
return true; return true;
} }
return false; return false;
break;
case SEEK_END: case SEEK_END:
if (strlen($this->data) + $offset >= 0) { if (strlen($this->data) + $offset >= 0) {
$this->position = strlen($this->data) + $offset; $this->position = strlen($this->data) + $offset;
@ -200,8 +198,7 @@ class ZipStreamWrapper
return true; return true;
} }
return false; return false;
break;
default: default:
return false; return false;
} }

View File

@ -1006,23 +1006,24 @@ class Spreadsheet
if ($pIndex > count($this->cellXfCollection) - 1) { if ($pIndex > count($this->cellXfCollection) - 1) {
throw new Exception('CellXf index is out of bounds.'); throw new Exception('CellXf index is out of bounds.');
} }
// first remove the cellXf
array_splice($this->cellXfCollection, $pIndex, 1);
// then update cellXf indexes for cells // first remove the cellXf
foreach ($this->workSheetCollection as $worksheet) { array_splice($this->cellXfCollection, $pIndex, 1);
foreach ($worksheet->getCellCollection(false) as $cellID) {
$cell = $worksheet->getCell($cellID); // then update cellXf indexes for cells
$xfIndex = $cell->getXfIndex(); foreach ($this->workSheetCollection as $worksheet) {
if ($xfIndex > $pIndex) { foreach ($worksheet->getCellCollection(false) as $cellID) {
// decrease xf index by 1 $cell = $worksheet->getCell($cellID);
$cell->setXfIndex($xfIndex - 1); $xfIndex = $cell->getXfIndex();
} elseif ($xfIndex == $pIndex) { if ($xfIndex > $pIndex) {
// set to default xf index 0 // decrease xf index by 1
$cell->setXfIndex(0); $cell->setXfIndex($xfIndex - 1);
} } elseif ($xfIndex == $pIndex) {
// set to default xf index 0
$cell->setXfIndex(0);
} }
} }
}
} }
/** /**

View File

@ -2349,11 +2349,13 @@ class Worksheet implements IComparable
} elseif ($pCellCoordinate == '') { } elseif ($pCellCoordinate == '') {
throw new Exception('Cell coordinate can not be zero-length string.'); throw new Exception('Cell coordinate can not be zero-length string.');
} }
// Check if we already have a comment for this cell.
// If not, create a new comment. // Check if we already have a comment for this cell.
if (isset($this->comments[$pCellCoordinate])) { if (isset($this->comments[$pCellCoordinate])) {
return $this->comments[$pCellCoordinate]; return $this->comments[$pCellCoordinate];
} }
// If not, create a new comment.
$newComment = new Comment(); $newComment = new Comment();
$this->comments[$pCellCoordinate] = $newComment; $this->comments[$pCellCoordinate] = $newComment;

View File

@ -561,10 +561,12 @@ class Parser
// Integer in the range 0..2**16-1 // Integer in the range 0..2**16-1
if ((preg_match("/^\d+$/", $num)) and ($num <= 65535)) { if ((preg_match("/^\d+$/", $num)) and ($num <= 65535)) {
return pack('Cv', $this->ptg['ptgInt'], $num); return pack('Cv', $this->ptg['ptgInt'], $num);
} // A float }
if (BIFFwriter::getByteOrder()) { // if it's Big Endian
$num = strrev($num); // A float
} if (BIFFwriter::getByteOrder()) { // if it's Big Endian
$num = strrev($num);
}
return pack('Cd', $this->ptg['ptgNum'], $num); return pack('Cd', $this->ptg['ptgNum'], $num);
} }