diff --git a/src/PhpSpreadsheet/Calculation/Engineering.php b/src/PhpSpreadsheet/Calculation/Engineering.php index 04fa6a1f..50c388c2 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering.php +++ b/src/PhpSpreadsheet/Calculation/Engineering.php @@ -1945,12 +1945,12 @@ class Engineering } return self::cleanComplex( - self::COMPLEX( - $parsedComplex['real'], - 0 - $parsedComplex['imaginary'], - $parsedComplex['suffix'] - ) - ); + self::COMPLEX( + $parsedComplex['real'], + 0 - $parsedComplex['imaginary'], + $parsedComplex['suffix'] + ) + ); } /** @@ -1976,12 +1976,12 @@ class Engineering } return self::IMCONJUGATE( - self::COMPLEX( - cos($parsedComplex['real']) * cosh($parsedComplex['imaginary']), - sin($parsedComplex['real']) * sinh($parsedComplex['imaginary']), - $parsedComplex['suffix'] - ) - ); + self::COMPLEX( + cos($parsedComplex['real']) * cosh($parsedComplex['imaginary']), + sin($parsedComplex['real']) * sinh($parsedComplex['imaginary']), + $parsedComplex['suffix'] + ) + ); } /** @@ -2007,10 +2007,10 @@ class Engineering } return self::COMPLEX( - sin($parsedComplex['real']) * cosh($parsedComplex['imaginary']), - cos($parsedComplex['real']) * sinh($parsedComplex['imaginary']), - $parsedComplex['suffix'] - ); + sin($parsedComplex['real']) * cosh($parsedComplex['imaginary']), + cos($parsedComplex['real']) * sinh($parsedComplex['imaginary']), + $parsedComplex['suffix'] + ); } /** diff --git a/src/PhpSpreadsheet/Reader/Xls/Color.php b/src/PhpSpreadsheet/Reader/Xls/Color.php index bfcfac36..32ea6148 100644 --- a/src/PhpSpreadsheet/Reader/Xls/Color.php +++ b/src/PhpSpreadsheet/Reader/Xls/Color.php @@ -22,12 +22,13 @@ class Color // palette color, color index 0x08 maps to pallete index 0 return $palette[$color - 8]; } - // default color table - if ($version == \PhpOffice\PhpSpreadsheet\Reader\Xls::XLS_BIFF8) { - return Color\BIFF8::lookup($color); - } - // BIFF5 - return Color\BIFF5::lookup($color); - return $color; + + // default color table + if ($version == \PhpOffice\PhpSpreadsheet\Reader\Xls::XLS_BIFF8) { + return Color\BIFF8::lookup($color); + } + + // BIFF5 + return Color\BIFF5::lookup($color); } } diff --git a/src/PhpSpreadsheet/Shared/JAMA/Matrix.php b/src/PhpSpreadsheet/Shared/JAMA/Matrix.php index 21242360..44eca3ea 100644 --- a/src/PhpSpreadsheet/Shared/JAMA/Matrix.php +++ b/src/PhpSpreadsheet/Shared/JAMA/Matrix.php @@ -980,8 +980,7 @@ class Matrix return $C; } - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(JAMAError(MatrixDimensionMismatch)); - break; + throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(JAMAError(MatrixDimensionMismatch)); case 'array': $B = new self($args[0]); if ($this->n == $B->m) { @@ -998,9 +997,7 @@ class Matrix return $C; } - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(JAMAError(MatrixDimensionMismatch)); - return $M; - break; + throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(JAMAError(MatrixDimensionMismatch)); case 'integer': $C = new self($this->A); for ($i = 0; $i < $C->m; ++$i) { @@ -1010,7 +1007,6 @@ class Matrix } return $C; - break; case 'double': $C = new self($this->m, $this->n); for ($i = 0; $i < $C->m; ++$i) { @@ -1020,7 +1016,6 @@ class Matrix } return $C; - break; case 'float': $C = new self($this->A); for ($i = 0; $i < $C->m; ++$i) { @@ -1030,10 +1025,8 @@ class Matrix } return $C; - break; default: throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION); - break; } } else { throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION); diff --git a/src/PhpSpreadsheet/Shared/OLE.php b/src/PhpSpreadsheet/Shared/OLE.php index d81fcf6a..735d23ca 100644 --- a/src/PhpSpreadsheet/Shared/OLE.php +++ b/src/PhpSpreadsheet/Shared/OLE.php @@ -286,7 +286,7 @@ class OLE public function _readPpsWks($blockId) { $fh = $this->getStream($blockId); - for ($pos = 0; ; $pos += 128) { + for ($pos = 0; true; $pos += 128) { fseek($fh, $pos, SEEK_SET); $nameUtf16 = fread($fh, 64); $nameLength = self::_readInt2($fh); diff --git a/src/PhpSpreadsheet/Shared/ZipStreamWrapper.php b/src/PhpSpreadsheet/Shared/ZipStreamWrapper.php index b3ff5903..2c9f6012 100644 --- a/src/PhpSpreadsheet/Shared/ZipStreamWrapper.php +++ b/src/PhpSpreadsheet/Shared/ZipStreamWrapper.php @@ -182,8 +182,7 @@ class ZipStreamWrapper return true; } - return false; - break; + return false; case SEEK_CUR: if ($offset >= 0) { $this->position += $offset; @@ -191,8 +190,7 @@ class ZipStreamWrapper return true; } - return false; - break; + return false; case SEEK_END: if (strlen($this->data) + $offset >= 0) { $this->position = strlen($this->data) + $offset; @@ -200,8 +198,7 @@ class ZipStreamWrapper return true; } - return false; - break; + return false; default: return false; } diff --git a/src/PhpSpreadsheet/Spreadsheet.php b/src/PhpSpreadsheet/Spreadsheet.php index 5d4e155a..22af7c17 100644 --- a/src/PhpSpreadsheet/Spreadsheet.php +++ b/src/PhpSpreadsheet/Spreadsheet.php @@ -1006,23 +1006,24 @@ class Spreadsheet if ($pIndex > count($this->cellXfCollection) - 1) { 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 - foreach ($this->workSheetCollection as $worksheet) { - foreach ($worksheet->getCellCollection(false) as $cellID) { - $cell = $worksheet->getCell($cellID); - $xfIndex = $cell->getXfIndex(); - if ($xfIndex > $pIndex) { - // decrease xf index by 1 - $cell->setXfIndex($xfIndex - 1); - } elseif ($xfIndex == $pIndex) { - // set to default xf index 0 - $cell->setXfIndex(0); - } + // first remove the cellXf + array_splice($this->cellXfCollection, $pIndex, 1); + + // then update cellXf indexes for cells + foreach ($this->workSheetCollection as $worksheet) { + foreach ($worksheet->getCellCollection(false) as $cellID) { + $cell = $worksheet->getCell($cellID); + $xfIndex = $cell->getXfIndex(); + if ($xfIndex > $pIndex) { + // decrease xf index by 1 + $cell->setXfIndex($xfIndex - 1); + } elseif ($xfIndex == $pIndex) { + // set to default xf index 0 + $cell->setXfIndex(0); } } + } } /** diff --git a/src/PhpSpreadsheet/Worksheet.php b/src/PhpSpreadsheet/Worksheet.php index 38d4174d..d0dc781a 100644 --- a/src/PhpSpreadsheet/Worksheet.php +++ b/src/PhpSpreadsheet/Worksheet.php @@ -2349,11 +2349,13 @@ class Worksheet implements IComparable } elseif ($pCellCoordinate == '') { 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. - if (isset($this->comments[$pCellCoordinate])) { - return $this->comments[$pCellCoordinate]; - } + + // Check if we already have a comment for this cell. + if (isset($this->comments[$pCellCoordinate])) { + return $this->comments[$pCellCoordinate]; + } + + // If not, create a new comment. $newComment = new Comment(); $this->comments[$pCellCoordinate] = $newComment; diff --git a/src/PhpSpreadsheet/Writer/Xls/Parser.php b/src/PhpSpreadsheet/Writer/Xls/Parser.php index cec97823..c9f15122 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Parser.php +++ b/src/PhpSpreadsheet/Writer/Xls/Parser.php @@ -561,10 +561,12 @@ class Parser // Integer in the range 0..2**16-1 if ((preg_match("/^\d+$/", $num)) and ($num <= 65535)) { 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); }