PHPStan Level 3

This commit is contained in:
Adrien Crivelli 2021-04-04 22:20:00 +09:00
parent 02f37d4f7e
commit f9532231d2
No known key found for this signature in database
GPG Key ID: 16D79B903B4B5874
90 changed files with 225 additions and 370 deletions

View File

@ -1,8 +1,10 @@
parameters: parameters:
level: 2 level: 3
paths: paths:
- src/ - src/
- tests/ - tests/
parallel:
processTimeout: 300.0
ignoreErrors: ignoreErrors:
- '~^Class GdImage not found\.$~' - '~^Class GdImage not found\.$~'
- '~^Return typehint of method .* has invalid type GdImage\.$~' - '~^Return typehint of method .* has invalid type GdImage\.$~'

View File

@ -5234,10 +5234,8 @@ class Calculation
/** /**
* Get a list of all implemented functions as an array of function objects. * Get a list of all implemented functions as an array of function objects.
*
* @return array of Category
*/ */
public function getFunctions() public function getFunctions(): array
{ {
return self::$phpSpreadsheetFunctions; return self::$phpSpreadsheetFunctions;
} }

View File

@ -57,7 +57,7 @@ abstract class DatabaseAbstract
* the column label in which you specify a condition for the * the column label in which you specify a condition for the
* column. * column.
* *
* @return array of mixed * @return mixed[]
*/ */
protected static function filter(array $database, array $criteria): array protected static function filter(array $database, array $criteria): array
{ {

View File

@ -1395,7 +1395,7 @@ class Engineering
* *
* @see Use the getConversionMultipliers() method in the ConvertUOM class instead * @see Use the getConversionMultipliers() method in the ConvertUOM class instead
* *
* @return array of mixed * @return mixed[]
*/ */
public static function getConversionMultipliers() public static function getConversionMultipliers()
{ {
@ -1412,7 +1412,7 @@ class Engineering
* *
* @see Use the getBinaryConversionMultipliers() method in the ConvertUOM class instead * @see Use the getBinaryConversionMultipliers() method in the ConvertUOM class instead
* *
* @return array of mixed * @return mixed[]
*/ */
public static function getBinaryConversionMultipliers() public static function getBinaryConversionMultipliers()
{ {

View File

@ -38,7 +38,7 @@ class ConvertBinary extends ConvertBase
return '-' . (512 - bindec($value)); return '-' . (512 - bindec($value));
} }
return bindec($value); return (string) bindec($value);
} }
/** /**

View File

@ -85,10 +85,10 @@ class ConvertHex extends ConvertBase
$binX[$i] = ($binX[$i] == '1' ? '0' : '1'); $binX[$i] = ($binX[$i] == '1' ? '0' : '1');
} }
return (bindec($binX) + 1) * -1; return (string) ((bindec($binX) + 1) * -1);
} }
return bindec($binX); return (string) bindec($binX);
} }
/** /**

View File

@ -85,10 +85,10 @@ class ConvertOctal extends ConvertBase
$binX[$i] = ($binX[$i] == '1' ? '0' : '1'); $binX[$i] = ($binX[$i] == '1' ? '0' : '1');
} }
return (bindec($binX) + 1) * -1; return (string) ((bindec($binX) + 1) * -1);
} }
return bindec($binX); return (string) bindec($binX);
} }
/** /**

View File

@ -490,7 +490,7 @@ class ConvertUOM
* getConversionMultipliers * getConversionMultipliers
* Returns an array of the Multiplier prefixes that can be used with Units of Measure in CONVERTUOM(). * Returns an array of the Multiplier prefixes that can be used with Units of Measure in CONVERTUOM().
* *
* @return array of mixed * @return mixed[]
*/ */
public static function getConversionMultipliers() public static function getConversionMultipliers()
{ {
@ -501,7 +501,7 @@ class ConvertUOM
* getBinaryConversionMultipliers * getBinaryConversionMultipliers
* Returns an array of the additional Multiplier prefixes that can be used with Information Units of Measure in CONVERTUOM(). * Returns an array of the additional Multiplier prefixes that can be used with Information Units of Measure in CONVERTUOM().
* *
* @return array of mixed * @return mixed[]
*/ */
public static function getBinaryConversionMultipliers() public static function getBinaryConversionMultipliers()
{ {

View File

@ -90,10 +90,8 @@ class FormulaParser
* Get Token. * Get Token.
* *
* @param int $pId Token id * @param int $pId Token id
*
* @return string
*/ */
public function getToken($pId = 0) public function getToken(int $pId = 0): FormulaToken
{ {
if (isset($this->tokens[$pId])) { if (isset($this->tokens[$pId])) {
return $this->tokens[$pId]; return $this->tokens[$pId];

View File

@ -303,7 +303,7 @@ class Functions
* *
* @param mixed $value Value to check * @param mixed $value Value to check
* *
* @return bool * @return int|string
*/ */
public static function errorType($value = '') public static function errorType($value = '')
{ {

View File

@ -38,7 +38,7 @@ class Offset
* @param mixed $width The width, in number of columns, that you want the returned reference to be. * @param mixed $width The width, in number of columns, that you want the returned reference to be.
* Width must be a positive number. * Width must be a positive number.
* *
* @return array|string An array containing a cell or range of cells, or a string on error * @return array|int|string An array containing a cell or range of cells, or a string on error
*/ */
public static function OFFSET($cellAddress = null, $rows = 0, $columns = 0, $height = null, $width = null, ?Cell $pCell = null) public static function OFFSET($cellAddress = null, $rows = 0, $columns = 0, $height = null, $width = null, ?Cell $pCell = null)
{ {

View File

@ -19,7 +19,7 @@ class Fact
* *
* @param float $factVal Factorial Value * @param float $factVal Factorial Value
* *
* @return int|string Factorial, or a string containing an error * @return float|int|string Factorial, or a string containing an error
*/ */
public static function funcFact($factVal) public static function funcFact($factVal)
{ {

View File

@ -729,7 +729,7 @@ class Statistical
* @param mixed[] $newValues Values of X for which we want to find Y * @param mixed[] $newValues Values of X for which we want to find Y
* @param bool $const a logical value specifying whether to force the intersect to equal 0 * @param bool $const a logical value specifying whether to force the intersect to equal 0
* *
* @return array of float * @return float[]
*/ */
public static function GROWTH($yValues, $xValues = [], $newValues = [], $const = true) public static function GROWTH($yValues, $xValues = [], $newValues = [], $const = true)
{ {
@ -1795,7 +1795,7 @@ class Statistical
* @param mixed[] $newValues Values of X for which we want to find Y * @param mixed[] $newValues Values of X for which we want to find Y
* @param bool $const a logical value specifying whether to force the intersect to equal 0 * @param bool $const a logical value specifying whether to force the intersect to equal 0
* *
* @return array of float * @return float[]
*/ */
public static function TREND($yValues, $xValues = [], $newValues = [], $const = true) public static function TREND($yValues, $xValues = [], $newValues = [], $const = true)
{ {

View File

@ -142,7 +142,7 @@ class Trends
* @param mixed[] $newValues Values of X for which we want to find Y * @param mixed[] $newValues Values of X for which we want to find Y
* @param mixed $const A logical (boolean) value specifying whether to force the intersect to equal 0 or not * @param mixed $const A logical (boolean) value specifying whether to force the intersect to equal 0 or not
* *
* @return array of float * @return float[]
*/ */
public static function GROWTH($yValues, $xValues = [], $newValues = [], $const = true) public static function GROWTH($yValues, $xValues = [], $newValues = [], $const = true)
{ {
@ -399,7 +399,7 @@ class Trends
* @param mixed[] $newValues Values of X for which we want to find Y * @param mixed[] $newValues Values of X for which we want to find Y
* @param mixed $const A logical (boolean) value specifying whether to force the intersect to equal 0 or not * @param mixed $const A logical (boolean) value specifying whether to force the intersect to equal 0 or not
* *
* @return array of float * @return float[]
*/ */
public static function TREND($yValues, $xValues = [], $newValues = [], $const = true) public static function TREND($yValues, $xValues = [], $newValues = [], $const = true)
{ {

View File

@ -78,6 +78,7 @@ class Cell
public function detach(): void public function detach(): void
{ {
// @phpstan-ignore-next-line
$this->parent = null; $this->parent = null;
} }

View File

@ -13,7 +13,7 @@ class Axis extends Properties
/** /**
* Axis Number. * Axis Number.
* *
* @var array of mixed * @var mixed[]
*/ */
private $axisNumber = [ private $axisNumber = [
'format' => self::FORMAT_CODE_GENERAL, 'format' => self::FORMAT_CODE_GENERAL,
@ -23,7 +23,7 @@ class Axis extends Properties
/** /**
* Axis Options. * Axis Options.
* *
* @var array of mixed * @var mixed[]
*/ */
private $axisOptions = [ private $axisOptions = [
'minimum' => null, 'minimum' => null,
@ -41,7 +41,7 @@ class Axis extends Properties
/** /**
* Fill Properties. * Fill Properties.
* *
* @var array of mixed * @var mixed[]
*/ */
private $fillProperties = [ private $fillProperties = [
'type' => self::EXCEL_COLOR_TYPE_ARGB, 'type' => self::EXCEL_COLOR_TYPE_ARGB,
@ -52,7 +52,7 @@ class Axis extends Properties
/** /**
* Line Properties. * Line Properties.
* *
* @var array of mixed * @var mixed[]
*/ */
private $lineProperties = [ private $lineProperties = [
'type' => self::EXCEL_COLOR_TYPE_ARGB, 'type' => self::EXCEL_COLOR_TYPE_ARGB,
@ -63,7 +63,7 @@ class Axis extends Properties
/** /**
* Line Style Properties. * Line Style Properties.
* *
* @var array of mixed * @var mixed[]
*/ */
private $lineStyleProperties = [ private $lineStyleProperties = [
'width' => '9525', 'width' => '9525',
@ -86,7 +86,7 @@ class Axis extends Properties
/** /**
* Shadow Properties. * Shadow Properties.
* *
* @var array of mixed * @var mixed[]
*/ */
private $shadowProperties = [ private $shadowProperties = [
'presets' => self::SHADOW_PRESETS_NOSHADOW, 'presets' => self::SHADOW_PRESETS_NOSHADOW,
@ -111,7 +111,7 @@ class Axis extends Properties
/** /**
* Glow Properties. * Glow Properties.
* *
* @var array of mixed * @var mixed[]
*/ */
private $glowProperties = [ private $glowProperties = [
'size' => null, 'size' => null,
@ -125,7 +125,7 @@ class Axis extends Properties
/** /**
* Soft Edge Properties. * Soft Edge Properties.
* *
* @var array of mixed * @var mixed[]
*/ */
private $softEdges = [ private $softEdges = [
'size' => null, 'size' => null,

View File

@ -75,21 +75,21 @@ class DataSeries
/** /**
* Order of plots in Series. * Order of plots in Series.
* *
* @var array of integer * @var int[]
*/ */
private $plotOrder = []; private $plotOrder = [];
/** /**
* Plot Label. * Plot Label.
* *
* @var array of DataSeriesValues * @var DataSeriesValues[]
*/ */
private $plotLabel = []; private $plotLabel = [];
/** /**
* Plot Category. * Plot Category.
* *
* @var array of DataSeriesValues * @var DataSeriesValues[]
*/ */
private $plotCategory = []; private $plotCategory = [];
@ -103,7 +103,7 @@ class DataSeries
/** /**
* Plot Values. * Plot Values.
* *
* @var array of DataSeriesValues * @var DataSeriesValues[]
*/ */
private $plotValues = []; private $plotValues = [];
@ -231,7 +231,7 @@ class DataSeries
/** /**
* Get Plot Labels. * Get Plot Labels.
* *
* @return array of DataSeriesValues * @return DataSeriesValues[]
*/ */
public function getPlotLabels() public function getPlotLabels()
{ {
@ -243,7 +243,7 @@ class DataSeries
* *
* @param mixed $index * @param mixed $index
* *
* @return DataSeriesValues * @return DataSeriesValues|false
*/ */
public function getPlotLabelByIndex($index) public function getPlotLabelByIndex($index)
{ {
@ -260,7 +260,7 @@ class DataSeries
/** /**
* Get Plot Categories. * Get Plot Categories.
* *
* @return array of DataSeriesValues * @return DataSeriesValues[]
*/ */
public function getPlotCategories() public function getPlotCategories()
{ {
@ -272,7 +272,7 @@ class DataSeries
* *
* @param mixed $index * @param mixed $index
* *
* @return DataSeriesValues * @return DataSeriesValues|false
*/ */
public function getPlotCategoryByIndex($index) public function getPlotCategoryByIndex($index)
{ {
@ -313,7 +313,7 @@ class DataSeries
/** /**
* Get Plot Values. * Get Plot Values.
* *
* @return array of DataSeriesValues * @return DataSeriesValues[]
*/ */
public function getPlotValues() public function getPlotValues()
{ {
@ -325,7 +325,7 @@ class DataSeries
* *
* @param mixed $index * @param mixed $index
* *
* @return DataSeriesValues * @return DataSeriesValues|false
*/ */
public function getPlotValuesByIndex($index) public function getPlotValuesByIndex($index)
{ {

View File

@ -55,7 +55,7 @@ class DataSeriesValues
/** /**
* Data Values. * Data Values.
* *
* @var array of mixed * @var mixed[]
*/ */
private $dataValues = []; private $dataValues = [];
@ -313,7 +313,7 @@ class DataSeriesValues
/** /**
* Get Series Data Values. * Get Series Data Values.
* *
* @return array of mixed * @return mixed[]
*/ */
public function getDataValues() public function getDataValues()
{ {

View File

@ -67,7 +67,7 @@ class PlotArea
/** /**
* Get Plot Series. * Get Plot Series.
* *
* @return array of DataSeries * @return DataSeries[]
*/ */
public function getPlotGroup() public function getPlotGroup()
{ {

View File

@ -19,21 +19,21 @@ class Cells
/** /**
* Parent worksheet. * Parent worksheet.
* *
* @var Worksheet * @var null|Worksheet
*/ */
private $parent; private $parent;
/** /**
* The currently active Cell. * The currently active Cell.
* *
* @var Cell * @var null|Cell
*/ */
private $currentCell; private $currentCell;
/** /**
* Coordinate of the currently active Cell. * Coordinate of the currently active Cell.
* *
* @var string * @var null|string
*/ */
private $currentCoordinate; private $currentCoordinate;

View File

@ -100,7 +100,7 @@ class Properties
/** /**
* Custom Properties. * Custom Properties.
* *
* @var string[] * @var array{value: mixed, type: string}[]
*/ */
private $customProperties = []; private $customProperties = [];

View File

@ -126,7 +126,7 @@ class HashTable
* *
* @param int $pIndex * @param int $pIndex
* *
* @return T * @return null|T
*/ */
public function getByIndex($pIndex) public function getByIndex($pIndex)
{ {
@ -142,7 +142,7 @@ class HashTable
* *
* @param string $pHashCode * @param string $pHashCode
* *
* @return T * @return null|T
*/ */
public function getByHashCode($pHashCode) public function getByHashCode($pHashCode)
{ {

View File

@ -38,7 +38,7 @@ abstract class BaseReader implements IReader
* Restrict which sheets should be loaded? * Restrict which sheets should be loaded?
* This property holds an array of worksheet names to be loaded. If null, then all worksheets will be loaded. * This property holds an array of worksheet names to be loaded. If null, then all worksheets will be loaded.
* *
* @var array of string * @var null|string[]
*/ */
protected $loadSheetsOnly; protected $loadSheetsOnly;

View File

@ -374,7 +374,7 @@ class Xls extends BaseReader
* *
* @var int * @var int
*/ */
private $encryptionStartPos = false; private $encryptionStartPos = 0;
/** /**
* The current RC4 decryption object. * The current RC4 decryption object.
@ -659,7 +659,7 @@ class Xls extends BaseReader
$this->definedname = []; $this->definedname = [];
$this->sst = []; $this->sst = [];
$this->drawingGroupData = ''; $this->drawingGroupData = '';
$this->xfIndex = ''; $this->xfIndex = 0;
$this->mapCellXfIndex = []; $this->mapCellXfIndex = [];
$this->mapCellStyleXfIndex = []; $this->mapCellStyleXfIndex = [];
@ -1296,7 +1296,7 @@ class Xls extends BaseReader
// TODO Provide support for named values // TODO Provide support for named values
} }
} }
$this->data = null; $this->data = '';
return $this->spreadsheet; return $this->spreadsheet;
} }

View File

@ -879,10 +879,11 @@ class Xlsx extends BaseReader
// Loop through contents // Loop through contents
foreach ($commentsFile->commentList->comment as $comment) { foreach ($commentsFile->commentList->comment as $comment) {
$commentModel = $docSheet->getComment((string) $comment['ref']);
if (!empty($comment['authorId'])) { if (!empty($comment['authorId'])) {
$docSheet->getComment((string) $comment['ref'])->setAuthor($authors[(string) $comment['authorId']]); $commentModel->setAuthor($authors[$comment['authorId']]);
} }
$docSheet->getComment((string) $comment['ref'])->setText($this->parseRichText($comment->text)); $commentModel->setText($this->parseRichText($comment->text));
} }
} }

View File

@ -21,16 +21,16 @@ class Theme
/** /**
* Colour Map. * Colour Map.
* *
* @var array of string * @var string[]
*/ */
private $colourMap; private $colourMap;
/** /**
* Create a new Theme. * Create a new Theme.
* *
* @param mixed $themeName * @param string $themeName
* @param mixed $colourSchemeName * @param string $colourSchemeName
* @param mixed $colourMap * @param string[] $colourMap
*/ */
public function __construct($themeName, $colourSchemeName, $colourMap) public function __construct($themeName, $colourSchemeName, $colourMap)
{ {
@ -63,9 +63,9 @@ class Theme
/** /**
* Get colour Map Value by Position. * Get colour Map Value by Position.
* *
* @param mixed $index * @param int $index
* *
* @return string * @return null|string
*/ */
public function getColourByIndex($index) public function getColourByIndex($index)
{ {

View File

@ -118,7 +118,7 @@ class Settings
if (self::$libXmlLoaderOptions === null && defined('LIBXML_DTDLOAD')) { if (self::$libXmlLoaderOptions === null && defined('LIBXML_DTDLOAD')) {
self::setLibXmlLoaderOptions(LIBXML_DTDLOAD | LIBXML_DTDATTR); self::setLibXmlLoaderOptions(LIBXML_DTDLOAD | LIBXML_DTDATTR);
} elseif (self::$libXmlLoaderOptions === null) { } elseif (self::$libXmlLoaderOptions === null) {
self::$libXmlLoaderOptions = true; self::$libXmlLoaderOptions = 0;
} }
return self::$libXmlLoaderOptions; return self::$libXmlLoaderOptions;

View File

@ -255,7 +255,7 @@ class Date
* *
* @param int $dateValue Unix Timestamp * @param int $dateValue Unix Timestamp
* *
* @return float MS Excel serialized date/time value * @return false|float MS Excel serialized date/time value
*/ */
public static function timestampToExcel($dateValue) public static function timestampToExcel($dateValue)
{ {

View File

@ -15,7 +15,7 @@ class Drawing
*/ */
public static function pixelsToEMU($pValue) public static function pixelsToEMU($pValue)
{ {
return round($pValue * 9525); return $pValue * 9525;
} }
/** /**
@ -28,7 +28,7 @@ class Drawing
public static function EMUToPixels($pValue) public static function EMUToPixels($pValue)
{ {
if ($pValue != 0) { if ($pValue != 0) {
return round($pValue / 9525); return (int) round($pValue / 9525);
} }
return 0; return 0;
@ -141,7 +141,7 @@ class Drawing
public static function angleToDegrees($pValue) public static function angleToDegrees($pValue)
{ {
if ($pValue != 0) { if ($pValue != 0) {
return round($pValue / 60000); return (int) round($pValue / 60000);
} }
return 0; return 0;

View File

@ -268,7 +268,7 @@ class Font
$columnWidth = Drawing::pixelsToCellDimension($columnWidth, $defaultFont); $columnWidth = Drawing::pixelsToCellDimension($columnWidth, $defaultFont);
// Return // Return
return round($columnWidth, 6); return (int) round($columnWidth, 6);
} }
/** /**

View File

@ -221,7 +221,7 @@ class LUDecomposition
/** /**
* Count determinants. * Count determinants.
* *
* @return array d matrix deterninat * @return float
*/ */
public function det() public function det()
{ {

View File

@ -147,7 +147,7 @@ class Matrix
* @param int $i Row position * @param int $i Row position
* @param int $j Column position * @param int $j Column position
* *
* @return mixed Element (int/float/double) * @return float|int
*/ */
public function get($i = null, $j = null) public function get($i = null, $j = null)
{ {
@ -323,11 +323,9 @@ class Matrix
* *
* @param int $i Row position * @param int $i Row position
* @param int $j Column position * @param int $j Column position
* @param mixed $c Int/float/double value * @param float|int $c value
*
* @return mixed Element (int/float/double)
*/ */
public function set($i = null, $j = null, $c = null) public function set($i = null, $j = null, $c = null): void
{ {
// Optimized set version just has this // Optimized set version just has this
$this->A[$i][$j] = $c; $this->A[$i][$j] = $c;

View File

@ -9,7 +9,7 @@ class ChainedBlockStream
/** /**
* The OLE container of the file that is being read. * The OLE container of the file that is being read.
* *
* @var OLE * @var null|OLE
*/ */
public $ole; public $ole;
@ -112,7 +112,7 @@ class ChainedBlockStream
* *
* @param int $count maximum number of bytes to read * @param int $count maximum number of bytes to read
* *
* @return string * @return false|string
*/ */
public function stream_read($count) // @codingStandardsIgnoreLine public function stream_read($count) // @codingStandardsIgnoreLine
{ {

View File

@ -188,7 +188,7 @@ class OLERead
* *
* @param int $stream * @param int $stream
* *
* @return string * @return null|string
*/ */
public function getStream($stream) public function getStream($stream)
{ {

View File

@ -2,7 +2,7 @@
namespace PhpOffice\PhpSpreadsheet\Shared\Trend; namespace PhpOffice\PhpSpreadsheet\Shared\Trend;
class BestFit abstract class BestFit
{ {
/** /**
* Indicator flag for a calculation error. * Indicator flag for a calculation error.
@ -96,24 +96,18 @@ class BestFit
* *
* @param float $xValue X-Value * @param float $xValue X-Value
* *
* @return bool Y-Value * @return float Y-Value
*/ */
public function getValueOfYForX($xValue) abstract public function getValueOfYForX($xValue);
{
return false;
}
/** /**
* Return the X-Value for a specified value of Y. * Return the X-Value for a specified value of Y.
* *
* @param float $yValue Y-Value * @param float $yValue Y-Value
* *
* @return bool X-Value * @return float X-Value
*/ */
public function getValueOfXForY($yValue) abstract public function getValueOfXForY($yValue);
{
return false;
}
/** /**
* Return the original set of X-Values. * Return the original set of X-Values.
@ -130,12 +124,9 @@ class BestFit
* *
* @param int $dp Number of places of decimal precision to display * @param int $dp Number of places of decimal precision to display
* *
* @return bool * @return string
*/ */
public function getEquation($dp = 0) abstract public function getEquation($dp = 0);
{
return false;
}
/** /**
* Return the Slope of the line. * Return the Slope of the line.

View File

@ -42,6 +42,7 @@ class PolynomialBestFit extends BestFit
{ {
$retVal = $this->getIntersect(); $retVal = $this->getIntersect();
$slope = $this->getSlope(); $slope = $this->getSlope();
// @phpstan-ignore-next-line
foreach ($slope as $key => $value) { foreach ($slope as $key => $value) {
if ($value != 0.0) { if ($value != 0.0) {
$retVal += $value * $xValue ** ($key + 1); $retVal += $value * $xValue ** ($key + 1);
@ -76,6 +77,7 @@ class PolynomialBestFit extends BestFit
$intersect = $this->getIntersect($dp); $intersect = $this->getIntersect($dp);
$equation = 'Y = ' . $intersect; $equation = 'Y = ' . $intersect;
// @phpstan-ignore-next-line
foreach ($slope as $key => $value) { foreach ($slope as $key => $value) {
if ($value != 0.0) { if ($value != 0.0) {
$equation .= ' + ' . $value . ' * X'; $equation .= ' + ' . $value . ' * X';
@ -93,7 +95,7 @@ class PolynomialBestFit extends BestFit
* *
* @param int $dp Number of places of decimal precision to display * @param int $dp Number of places of decimal precision to display
* *
* @return string * @return float
*/ */
public function getSlope($dp = 0) public function getSlope($dp = 0)
{ {
@ -103,6 +105,7 @@ class PolynomialBestFit extends BestFit
$coefficients[] = round($coefficient, $dp); $coefficients[] = round($coefficient, $dp);
} }
// @phpstan-ignore-next-line
return $coefficients; return $coefficients;
} }

View File

@ -205,7 +205,7 @@ class Xls
* @param int $width Width in pixels * @param int $width Width in pixels
* @param int $height Height in pixels * @param int $height Height in pixels
* *
* @return array * @return null|array
*/ */
public static function oneAnchor2twoAnchor($sheet, $coordinates, $offsetX, $offsetY, $width, $height) public static function oneAnchor2twoAnchor($sheet, $coordinates, $offsetX, $offsetY, $width, $height)
{ {
@ -245,16 +245,16 @@ class Xls
// Bitmap isn't allowed to start or finish in a hidden cell, i.e. a cell // Bitmap isn't allowed to start or finish in a hidden cell, i.e. a cell
// with zero height or width. // with zero height or width.
if (self::sizeCol($sheet, Coordinate::stringFromColumnIndex($col_start)) == 0) { if (self::sizeCol($sheet, Coordinate::stringFromColumnIndex($col_start)) == 0) {
return; return null;
} }
if (self::sizeCol($sheet, Coordinate::stringFromColumnIndex($col_end)) == 0) { if (self::sizeCol($sheet, Coordinate::stringFromColumnIndex($col_end)) == 0) {
return; return null;
} }
if (self::sizeRow($sheet, $row_start + 1) == 0) { if (self::sizeRow($sheet, $row_start + 1) == 0) {
return; return null;
} }
if (self::sizeRow($sheet, $row_end + 1) == 0) { if (self::sizeRow($sheet, $row_end + 1) == 0) {
return; return null;
} }
// Convert the pixel values to the percentage value expected by Excel // Convert the pixel values to the percentage value expected by Excel

View File

@ -69,7 +69,7 @@ class Spreadsheet
/** /**
* Named ranges. * Named ranges.
* *
* @var NamedRange[] * @var DefinedName[]
*/ */
private $definedNames = []; private $definedNames = [];
@ -104,21 +104,21 @@ class Spreadsheet
/** /**
* macrosCode : all macros code as binary data (the vbaProject.bin file, this include form, code, etc.), null if no macro. * macrosCode : all macros code as binary data (the vbaProject.bin file, this include form, code, etc.), null if no macro.
* *
* @var string * @var null|string
*/ */
private $macrosCode; private $macrosCode;
/** /**
* macrosCertificate : if macros are signed, contains binary data vbaProjectSignature.bin file, null if not signed. * macrosCertificate : if macros are signed, contains binary data vbaProjectSignature.bin file, null if not signed.
* *
* @var string * @var null|string
*/ */
private $macrosCertificate; private $macrosCertificate;
/** /**
* ribbonXMLData : null if workbook is'nt Excel 2007 or not contain a customized UI. * ribbonXMLData : null if workbook is'nt Excel 2007 or not contain a customized UI.
* *
* @var null|string * @var null|array{target: string, data: string}
*/ */
private $ribbonXMLData; private $ribbonXMLData;
@ -298,11 +298,9 @@ class Spreadsheet
/** /**
* retrieve ribbon XML Data. * retrieve ribbon XML Data.
* *
* return string|null|array
*
* @param string $what * @param string $what
* *
* @return string * @return null|array|string
*/ */
public function getRibbonXMLData($what = 'all') //we need some constants here... public function getRibbonXMLData($what = 'all') //we need some constants here...
{ {
@ -455,7 +453,7 @@ class Spreadsheet
* *
* @param string $pName Sheet name * @param string $pName Sheet name
* *
* @return Worksheet * @return null|Worksheet
*/ */
public function getSheetByCodeName($pName) public function getSheetByCodeName($pName)
{ {
@ -515,12 +513,10 @@ class Spreadsheet
*/ */
public function disconnectWorksheets(): void public function disconnectWorksheets(): void
{ {
$worksheet = null; foreach ($this->workSheetCollection as $worksheet) {
foreach ($this->workSheetCollection as $k => &$worksheet) {
$worksheet->disconnectCells(); $worksheet->disconnectCells();
$this->workSheetCollection[$k] = null;
}
unset($worksheet); unset($worksheet);
}
$this->workSheetCollection = []; $this->workSheetCollection = [];
} }
@ -876,7 +872,7 @@ class Spreadsheet
/** /**
* Get an array of all Named Ranges. * Get an array of all Named Ranges.
* *
* @return NamedRange[] * @return DefinedName[]
*/ */
public function getNamedRanges(): array public function getNamedRanges(): array
{ {
@ -891,7 +887,7 @@ class Spreadsheet
/** /**
* Get an array of all Named Formulae. * Get an array of all Named Formulae.
* *
* @return NamedFormula[] * @return DefinedName[]
*/ */
public function getNamedFormulae(): array public function getNamedFormulae(): array
{ {
@ -1124,6 +1120,7 @@ class Spreadsheet
*/ */
public function __clone() public function __clone()
{ {
// @phpstan-ignore-next-line
foreach ($this as $key => $val) { foreach ($this as $key => $val) {
if (is_object($val) || (is_array($val))) { if (is_object($val) || (is_array($val))) {
$this->{$key} = unserialize(serialize($val)); $this->{$key} = unserialize(serialize($val));

View File

@ -35,21 +35,21 @@ class Alignment extends Supervisor
/** /**
* Horizontal alignment. * Horizontal alignment.
* *
* @var string * @var null|string
*/ */
protected $horizontal = self::HORIZONTAL_GENERAL; protected $horizontal = self::HORIZONTAL_GENERAL;
/** /**
* Vertical alignment. * Vertical alignment.
* *
* @var string * @var null|string
*/ */
protected $vertical = self::VERTICAL_BOTTOM; protected $vertical = self::VERTICAL_BOTTOM;
/** /**
* Text rotation. * Text rotation.
* *
* @var int * @var null|int
*/ */
protected $textRotation = 0; protected $textRotation = 0;
@ -179,7 +179,7 @@ class Alignment extends Supervisor
/** /**
* Get Horizontal. * Get Horizontal.
* *
* @return string * @return null|string
*/ */
public function getHorizontal() public function getHorizontal()
{ {
@ -216,7 +216,7 @@ class Alignment extends Supervisor
/** /**
* Get Vertical. * Get Vertical.
* *
* @return string * @return null|string
*/ */
public function getVertical() public function getVertical()
{ {
@ -253,7 +253,7 @@ class Alignment extends Supervisor
/** /**
* Get TextRotation. * Get TextRotation.
* *
* @return int * @return null|int
*/ */
public function getTextRotation() public function getTextRotation()
{ {

View File

@ -37,7 +37,7 @@ class Border extends Supervisor
protected $color; protected $color;
/** /**
* @var int * @var null|int
*/ */
public $colorIndex; public $colorIndex;

View File

@ -28,19 +28,19 @@ class Fill extends Supervisor
const FILL_PATTERN_MEDIUMGRAY = 'mediumGray'; const FILL_PATTERN_MEDIUMGRAY = 'mediumGray';
/** /**
* @var int * @var null|int
*/ */
public $startcolorIndex; public $startcolorIndex;
/** /**
* @var int * @var null|int
*/ */
public $endcolorIndex; public $endcolorIndex;
/** /**
* Fill type. * Fill type.
* *
* @var string * @var null|string
*/ */
protected $fillType = self::FILL_NONE; protected $fillType = self::FILL_NONE;
@ -168,7 +168,7 @@ class Fill extends Supervisor
/** /**
* Get Fill Type. * Get Fill Type.
* *
* @return string * @return null|string
*/ */
public function getFillType() public function getFillType()
{ {

View File

@ -14,56 +14,56 @@ class Font extends Supervisor
/** /**
* Font Name. * Font Name.
* *
* @var string * @var null|string
*/ */
protected $name = 'Calibri'; protected $name = 'Calibri';
/** /**
* Font Size. * Font Size.
* *
* @var float * @var null|float
*/ */
protected $size = 11; protected $size = 11;
/** /**
* Bold. * Bold.
* *
* @var bool * @var null|bool
*/ */
protected $bold = false; protected $bold = false;
/** /**
* Italic. * Italic.
* *
* @var bool * @var null|bool
*/ */
protected $italic = false; protected $italic = false;
/** /**
* Superscript. * Superscript.
* *
* @var bool * @var null|bool
*/ */
protected $superscript = false; protected $superscript = false;
/** /**
* Subscript. * Subscript.
* *
* @var bool * @var null|bool
*/ */
protected $subscript = false; protected $subscript = false;
/** /**
* Underline. * Underline.
* *
* @var string * @var null|string
*/ */
protected $underline = self::UNDERLINE_NONE; protected $underline = self::UNDERLINE_NONE;
/** /**
* Strikethrough. * Strikethrough.
* *
* @var bool * @var null|bool
*/ */
protected $strikethrough = false; protected $strikethrough = false;
@ -75,7 +75,7 @@ class Font extends Supervisor
protected $color; protected $color;
/** /**
* @var int * @var null|int
*/ */
public $colorIndex; public $colorIndex;
@ -199,7 +199,7 @@ class Font extends Supervisor
/** /**
* Get Name. * Get Name.
* *
* @return string * @return null|string
*/ */
public function getName() public function getName()
{ {
@ -235,7 +235,7 @@ class Font extends Supervisor
/** /**
* Get Size. * Get Size.
* *
* @return float * @return null|float
*/ */
public function getSize() public function getSize()
{ {
@ -271,7 +271,7 @@ class Font extends Supervisor
/** /**
* Get Bold. * Get Bold.
* *
* @return bool * @return null|bool
*/ */
public function getBold() public function getBold()
{ {
@ -307,7 +307,7 @@ class Font extends Supervisor
/** /**
* Get Italic. * Get Italic.
* *
* @return bool * @return null|bool
*/ */
public function getItalic() public function getItalic()
{ {
@ -343,7 +343,7 @@ class Font extends Supervisor
/** /**
* Get Superscript. * Get Superscript.
* *
* @return bool * @return null|bool
*/ */
public function getSuperscript() public function getSuperscript()
{ {
@ -377,7 +377,7 @@ class Font extends Supervisor
/** /**
* Get Subscript. * Get Subscript.
* *
* @return bool * @return null|bool
*/ */
public function getSubscript() public function getSubscript()
{ {
@ -411,7 +411,7 @@ class Font extends Supervisor
/** /**
* Get Underline. * Get Underline.
* *
* @return string * @return null|string
*/ */
public function getUnderline() public function getUnderline()
{ {
@ -451,7 +451,7 @@ class Font extends Supervisor
/** /**
* Get Strikethrough. * Get Strikethrough.
* *
* @return bool * @return null|bool
*/ */
public function getStrikethrough() public function getStrikethrough()
{ {

View File

@ -64,14 +64,14 @@ class NumberFormat extends Supervisor
/** /**
* Format Code. * Format Code.
* *
* @var string * @var null|string
*/ */
protected $formatCode = self::FORMAT_GENERAL; protected $formatCode = self::FORMAT_GENERAL;
/** /**
* Built-in format Code. * Built-in format Code.
* *
* @var string * @var false|int
*/ */
protected $builtInFormatCode = 0; protected $builtInFormatCode = 0;
@ -150,7 +150,7 @@ class NumberFormat extends Supervisor
/** /**
* Get Format Code. * Get Format Code.
* *
* @return string * @return null|string
*/ */
public function getFormatCode() public function getFormatCode()
{ {
@ -190,7 +190,7 @@ class NumberFormat extends Supervisor
/** /**
* Get Built-In Format Code. * Get Built-In Format Code.
* *
* @return int * @return false|int
*/ */
public function getBuiltInFormatCode() public function getBuiltInFormatCode()
{ {

View File

@ -14,7 +14,7 @@ class AutoFilter
/** /**
* Autofilter Worksheet. * Autofilter Worksheet.
* *
* @var Worksheet * @var null|Worksheet
*/ */
private $workSheet; private $workSheet;
@ -47,7 +47,7 @@ class AutoFilter
/** /**
* Get AutoFilter Parent Worksheet. * Get AutoFilter Parent Worksheet.
* *
* @return Worksheet * @return null|Worksheet
*/ */
public function getParent() public function getParent()
{ {
@ -791,10 +791,10 @@ class AutoFilter
if ($ruleOperator === AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT) { if ($ruleOperator === AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT) {
$ruleValue = floor($ruleValue * ($dataRowCount / 100)); $ruleValue = floor($ruleValue * ($dataRowCount / 100));
} }
if ($ruleValue < 1) { if (!is_array($ruleValue) && $ruleValue < 1) {
$ruleValue = 1; $ruleValue = 1;
} }
if ($ruleValue > 500) { if (!is_array($ruleValue) && $ruleValue > 500) {
$ruleValue = 500; $ruleValue = 500;
} }

View File

@ -49,7 +49,7 @@ class Column
/** /**
* Autofilter. * Autofilter.
* *
* @var AutoFilter * @var null|AutoFilter
*/ */
private $parent; private $parent;
@ -77,14 +77,14 @@ class Column
/** /**
* Autofilter Column Rules. * Autofilter Column Rules.
* *
* @var array of Column\Rule * @var Column\Rule[]
*/ */
private $ruleset = []; private $ruleset = [];
/** /**
* Autofilter Column Dynamic Attributes. * Autofilter Column Dynamic Attributes.
* *
* @var array of mixed * @var mixed[]
*/ */
private $attributes = []; private $attributes = [];
@ -133,7 +133,7 @@ class Column
/** /**
* Get this Column's AutoFilter Parent. * Get this Column's AutoFilter Parent.
* *
* @return AutoFilter * @return null|AutoFilter
*/ */
public function getParent() public function getParent()
{ {
@ -256,7 +256,7 @@ class Column
* *
* @param string $pName Attribute Name * @param string $pName Attribute Name
* *
* @return string * @return null|string
*/ */
public function getAttribute($pName) public function getAttribute($pName)
{ {

View File

@ -217,7 +217,7 @@ class Rule
/** /**
* Autofilter Rule Value. * Autofilter Rule Value.
* *
* @var string * @var string|string[]
*/ */
private $value = ''; private $value = '';
@ -276,7 +276,7 @@ class Rule
/** /**
* Get AutoFilter Rule Value. * Get AutoFilter Rule Value.
* *
* @return string * @return string|string[]
*/ */
public function getValue() public function getValue()
{ {

View File

@ -39,7 +39,7 @@ class BaseDrawing implements IComparable
/** /**
* Worksheet. * Worksheet.
* *
* @var Worksheet * @var null|Worksheet
*/ */
protected $worksheet; protected $worksheet;
@ -190,7 +190,7 @@ class BaseDrawing implements IComparable
/** /**
* Get Worksheet. * Get Worksheet.
* *
* @return Worksheet * @return null|Worksheet
*/ */
public function getWorksheet() public function getWorksheet()
{ {
@ -330,7 +330,7 @@ class BaseDrawing implements IComparable
// Resize proportional? // Resize proportional?
if ($this->resizeProportional && $pValue != 0) { if ($this->resizeProportional && $pValue != 0) {
$ratio = $this->height / ($this->width != 0 ? $this->width : 1); $ratio = $this->height / ($this->width != 0 ? $this->width : 1);
$this->height = round($ratio * $pValue); $this->height = (int) round($ratio * $pValue);
} }
// Set width // Set width
@ -361,7 +361,7 @@ class BaseDrawing implements IComparable
// Resize proportional? // Resize proportional?
if ($this->resizeProportional && $pValue != 0) { if ($this->resizeProportional && $pValue != 0) {
$ratio = $this->width / ($this->height != 0 ? $this->height : 1); $ratio = $this->width / ($this->height != 0 ? $this->height : 1);
$this->width = round($ratio * $pValue); $this->width = (int) round($ratio * $pValue);
} }
// Set height // Set height
@ -392,10 +392,10 @@ class BaseDrawing implements IComparable
$yratio = $height / ($this->height != 0 ? $this->height : 1); $yratio = $height / ($this->height != 0 ? $this->height : 1);
if ($this->resizeProportional && !($width == 0 || $height == 0)) { if ($this->resizeProportional && !($width == 0 || $height == 0)) {
if (($xratio * $this->height) < $height) { if (($xratio * $this->height) < $height) {
$this->height = ceil($xratio * $this->height); $this->height = (int) ceil($xratio * $this->height);
$this->width = $width; $this->width = $width;
} else { } else {
$this->width = ceil($yratio * $this->width); $this->width = (int) ceil($yratio * $this->width);
$this->height = $height; $this->height = $height;
} }
} else { } else {

View File

@ -25,6 +25,7 @@ abstract class CellIterator implements Iterator
*/ */
public function __destruct() public function __destruct()
{ {
// @phpstan-ignore-next-line
$this->worksheet = null; $this->worksheet = null;
} }

View File

@ -36,6 +36,7 @@ class Column
*/ */
public function __destruct() public function __destruct()
{ {
// @phpstan-ignore-next-line
$this->parent = null; $this->parent = null;
} }

View File

@ -18,7 +18,7 @@ class ColumnCellIterator extends CellIterator
/** /**
* Column index. * Column index.
* *
* @var string * @var int
*/ */
private $columnIndex; private $columnIndex;

View File

@ -57,6 +57,7 @@ class ColumnIterator implements Iterator
*/ */
public function __destruct() public function __destruct()
{ {
// @phpstan-ignore-next-line
$this->worksheet = null; $this->worksheet = null;
} }

View File

@ -52,7 +52,7 @@ class Shadow implements IComparable
/** /**
* Shadow alignment. * Shadow alignment.
* *
* @var int * @var string
*/ */
private $alignment; private $alignment;
@ -184,7 +184,7 @@ class Shadow implements IComparable
/** /**
* Get Shadow alignment. * Get Shadow alignment.
* *
* @return int * @return string
*/ */
public function getAlignment() public function getAlignment()
{ {
@ -194,7 +194,7 @@ class Shadow implements IComparable
/** /**
* Set Shadow alignment. * Set Shadow alignment.
* *
* @param int $pValue * @param string $pValue
* *
* @return $this * @return $this
*/ */

View File

@ -29,14 +29,6 @@ class Iterator implements \Iterator
$this->subject = $subject; $this->subject = $subject;
} }
/**
* Destructor.
*/
public function __destruct()
{
$this->subject = null;
}
/** /**
* Rewind iterator. * Rewind iterator.
*/ */

View File

@ -52,7 +52,6 @@ class MemoryDrawing extends BaseDrawing
public function __construct() public function __construct()
{ {
// Initialise values // Initialise values
$this->imageResource = null;
$this->renderingFunction = self::RENDERING_DEFAULT; $this->renderingFunction = self::RENDERING_DEFAULT;
$this->mimeType = self::MIMETYPE_DEFAULT; $this->mimeType = self::MIMETYPE_DEFAULT;
$this->uniqueName = md5(mt_rand(0, 9999) . time() . mt_rand(0, 9999)); $this->uniqueName = md5(mt_rand(0, 9999) . time() . mt_rand(0, 9999));

View File

@ -238,7 +238,7 @@ class PageSetup
/** /**
* Print area. * Print area.
* *
* @var string * @var null|string
*/ */
private $printArea; private $printArea;

View File

@ -36,6 +36,7 @@ class Row
*/ */
public function __destruct() public function __destruct()
{ {
// @phpstan-ignore-next-line
$this->worksheet = null; $this->worksheet = null;
} }

View File

@ -50,14 +50,6 @@ class RowIterator implements Iterator
$this->resetStart($startRow); $this->resetStart($startRow);
} }
/**
* Destructor.
*/
public function __destruct()
{
$this->subject = null;
}
/** /**
* (Re)Set the start row and the current row pointer. * (Re)Set the start row and the current row pointer.
* *

View File

@ -105,7 +105,7 @@ class Worksheet implements IComparable
* *
* @var ArrayObject<Chart> * @var ArrayObject<Chart>
*/ */
private $chartCollection = []; private $chartCollection;
/** /**
* Worksheet title. * Worksheet title.
@ -278,9 +278,9 @@ class Worksheet implements IComparable
/** /**
* Cached highest column. * Cached highest column.
* *
* @var string * @var int
*/ */
private $cachedHighestColumn = 'A'; private $cachedHighestColumn = 1;
/** /**
* Cached highest row. * Cached highest row.
@ -313,7 +313,7 @@ class Worksheet implements IComparable
/** /**
* Tab color. * Tab color.
* *
* @var Color * @var null|Color
*/ */
private $tabColor; private $tabColor;
@ -383,9 +383,11 @@ class Worksheet implements IComparable
{ {
if ($this->cellCollection !== null) { if ($this->cellCollection !== null) {
$this->cellCollection->unsetWorksheetCells(); $this->cellCollection->unsetWorksheetCells();
// @phpstan-ignore-next-line
$this->cellCollection = null; $this->cellCollection = null;
} }
// detach ourself from the workbook, so that it can then delete this worksheet successfully // detach ourself from the workbook, so that it can then delete this worksheet successfully
// @phpstan-ignore-next-line
$this->parent = null; $this->parent = null;
} }
@ -1039,7 +1041,7 @@ class Worksheet implements IComparable
public function getHighestColumn($row = null) public function getHighestColumn($row = null)
{ {
if ($row == null) { if ($row == null) {
return $this->cachedHighestColumn; return Coordinate::stringFromColumnIndex($this->cachedHighestColumn);
} }
return $this->getHighestDataColumn($row); return $this->getHighestDataColumn($row);
@ -1252,11 +1254,12 @@ class Worksheet implements IComparable
// Coordinates // Coordinates
$aCoordinates = Coordinate::coordinateFromString($pCoordinate); $aCoordinates = Coordinate::coordinateFromString($pCoordinate);
if (Coordinate::columnIndexFromString($this->cachedHighestColumn) < Coordinate::columnIndexFromString($aCoordinates[0])) { $aIndexes = Coordinate::indexesFromString($pCoordinate);
$this->cachedHighestColumn = $aCoordinates[0]; if ($this->cachedHighestColumn < $aIndexes[0]) {
$this->cachedHighestColumn = $aIndexes[0];
} }
if ($aCoordinates[1] > $this->cachedHighestRow) { if ($aIndexes[1] > $this->cachedHighestRow) {
$this->cachedHighestRow = $aCoordinates[1]; $this->cachedHighestRow = $aIndexes[1];
} }
// Cell needs appropriate xfIndex from dimensions records // Cell needs appropriate xfIndex from dimensions records
@ -1377,8 +1380,9 @@ class Worksheet implements IComparable
} }
$this->columnDimensions[$pColumn] = new ColumnDimension($pColumn); $this->columnDimensions[$pColumn] = new ColumnDimension($pColumn);
if (Coordinate::columnIndexFromString($this->cachedHighestColumn) < Coordinate::columnIndexFromString($pColumn)) { $columnIndex = Coordinate::columnIndexFromString($pColumn);
$this->cachedHighestColumn = $pColumn; if ($this->cachedHighestColumn < $columnIndex) {
$this->cachedHighestColumn = $columnIndex;
} }
} }
@ -1987,7 +1991,7 @@ class Worksheet implements IComparable
/** /**
* Get the default position of the right bottom pane. * Get the default position of the right bottom pane.
* *
* @return int * @return null|string
*/ */
public function getTopLeftCell() public function getTopLeftCell()
{ {
@ -2677,9 +2681,9 @@ class Worksheet implements IComparable
// Cache values // Cache values
if ($highestColumn < 1) { if ($highestColumn < 1) {
$this->cachedHighestColumn = 'A'; $this->cachedHighestColumn = 1;
} else { } else {
$this->cachedHighestColumn = Coordinate::stringFromColumnIndex($highestColumn); $this->cachedHighestColumn = $highestColumn;
} }
$this->cachedHighestRow = $highestRow; $this->cachedHighestRow = $highestRow;
@ -2905,7 +2909,6 @@ class Worksheet implements IComparable
public function resetTabColor() public function resetTabColor()
{ {
$this->tabColor = null; $this->tabColor = null;
$this->tabColor = null;
return $this; return $this;
} }
@ -2935,6 +2938,7 @@ class Worksheet implements IComparable
*/ */
public function __clone() public function __clone()
{ {
// @phpstan-ignore-next-line
foreach ($this as $key => $val) { foreach ($this as $key => $val) {
if ($key == 'parent') { if ($key == 'parent') {
continue; continue;

View File

@ -37,7 +37,7 @@ class Html extends BaseWriter
/** /**
* Sheet index to write. * Sheet index to write.
* *
* @var int * @var null|int
*/ */
private $sheetIndex = 0; private $sheetIndex = 0;
@ -735,7 +735,7 @@ class Html extends BaseWriter
if ($chartCoordinates['cell'] == $coordinates) { if ($chartCoordinates['cell'] == $coordinates) {
$chartFileName = File::sysGetTempDir() . '/' . uniqid('', true) . '.png'; $chartFileName = File::sysGetTempDir() . '/' . uniqid('', true) . '.png';
if (!$chart->render($chartFileName)) { if (!$chart->render($chartFileName)) {
return; return '';
} }
$html .= PHP_EOL; $html .= PHP_EOL;

View File

@ -165,7 +165,7 @@ abstract class Pdf extends Html
/** /**
* Set Paper Size. * Set Paper Size.
* *
* @param string $pValue Paper size see PageSetup::PAPERSIZE_* * @param int $pValue Paper size see PageSetup::PAPERSIZE_*
* *
* @return self * @return self
*/ */

View File

@ -81,14 +81,14 @@ class Xls extends BaseWriter
/** /**
* Basic OLE object summary information. * Basic OLE object summary information.
* *
* @var array * @var string
*/ */
private $summaryInformation; private $summaryInformation;
/** /**
* Extended OLE object document summary information. * Extended OLE object document summary information.
* *
* @var array * @var string
*/ */
private $documentSummaryInformation; private $documentSummaryInformation;
@ -727,6 +727,7 @@ class Xls extends BaseWriter
} elseif ($dataProp['type']['data'] == 0x1E) { // null-terminated string prepended by dword string length } elseif ($dataProp['type']['data'] == 0x1E) { // null-terminated string prepended by dword string length
// Null-terminated string // Null-terminated string
$dataProp['data']['data'] .= chr(0); $dataProp['data']['data'] .= chr(0);
// @phpstan-ignore-next-line
++$dataProp['data']['length']; ++$dataProp['data']['length'];
// Complete the string with null string for being a %4 // Complete the string with null string for being a %4
$dataProp['data']['length'] = $dataProp['data']['length'] + ((4 - $dataProp['data']['length'] % 4) == 4 ? 0 : (4 - $dataProp['data']['length'] % 4)); $dataProp['data']['length'] = $dataProp['data']['length'] + ((4 - $dataProp['data']['length'] % 4) == 4 ? 0 : (4 - $dataProp['data']['length'] % 4));
@ -744,6 +745,7 @@ class Xls extends BaseWriter
} else { } else {
$dataSection_Content .= $dataProp['data']['data']; $dataSection_Content .= $dataProp['data']['data'];
// @phpstan-ignore-next-line
$dataSection_Content_Offset += 4 + $dataProp['data']['length']; $dataSection_Content_Offset += 4 + $dataProp['data']['length'];
} }
} }

View File

@ -49,7 +49,7 @@ class BIFFwriter
/** /**
* The string containing the data of the BIFF stream. * The string containing the data of the BIFF stream.
* *
* @var string * @var null|string
*/ */
public $_data; public $_data;

View File

@ -119,7 +119,7 @@ class Font
/** /**
* Map of BIFF2-BIFF8 codes for underline styles. * Map of BIFF2-BIFF8 codes for underline styles.
* *
* @var array of int * @var int[]
*/ */
private static $mapUnderline = [ private static $mapUnderline = [
\PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_NONE => 0x00, \PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_NONE => 0x00,

View File

@ -95,7 +95,7 @@ class Worksheet extends BIFFwriter
/** /**
* Whether to use outline. * Whether to use outline.
* *
* @var int * @var bool
*/ */
private $outlineOn; private $outlineOn;
@ -244,10 +244,10 @@ class Worksheet extends BIFFwriter
$this->printHeaders = 0; $this->printHeaders = 0;
$this->outlineStyle = 0; $this->outlineStyle = false;
$this->outlineBelow = 1; $this->outlineBelow = true;
$this->outlineRight = 1; $this->outlineRight = true;
$this->outlineOn = 1; $this->outlineOn = true;
$this->fontHashIndex = []; $this->fontHashIndex = [];
@ -594,15 +594,13 @@ class Worksheet extends BIFFwriter
} }
/** /**
* Retrieves data from memory in one chunk, or from disk in $buffer * Retrieves data from memory in one chunk, or from disk
* sized chunks. * sized chunks.
* *
* @return string The data * @return string The data
*/ */
public function getData() public function getData()
{ {
$buffer = 4096;
// Return data stored in memory // Return data stored in memory
if (isset($this->_data)) { if (isset($this->_data)) {
$tmp = $this->_data; $tmp = $this->_data;
@ -612,7 +610,7 @@ class Worksheet extends BIFFwriter
} }
// No data to return // No data to return
return false; return '';
} }
/** /**
@ -640,11 +638,6 @@ class Worksheet extends BIFFwriter
$this->outlineBelow = $symbols_below; $this->outlineBelow = $symbols_below;
$this->outlineRight = $symbols_right; $this->outlineRight = $symbols_right;
$this->outlineStyle = $auto_style; $this->outlineStyle = $auto_style;
// Ensure this is a boolean vale for Window2
if ($this->outlineOn) {
$this->outlineOn = 1;
}
} }
/** /**
@ -926,20 +919,14 @@ class Worksheet extends BIFFwriter
* The hyperlink can be to a http, ftp, mail, internal sheet (not yet), or external * The hyperlink can be to a http, ftp, mail, internal sheet (not yet), or external
* directory url. * directory url.
* *
* Returns 0 : normal termination
* -2 : row or column out of range
* -3 : long string truncated to 255 chars
*
* @param int $row Row * @param int $row Row
* @param int $col Column * @param int $col Column
* @param string $url URL string * @param string $url URL string
*
* @return int
*/ */
private function writeUrl($row, $col, $url) private function writeUrl($row, $col, $url): void
{ {
// Add start row and col to arg list // Add start row and col to arg list
return $this->writeUrlRange($row, $col, $row, $col, $url); $this->writeUrlRange($row, $col, $row, $col, $url);
} }
/** /**
@ -954,21 +941,19 @@ class Worksheet extends BIFFwriter
* @param int $col2 End column * @param int $col2 End column
* @param string $url URL string * @param string $url URL string
* *
* @return int
*
* @see writeUrl() * @see writeUrl()
*/ */
public function writeUrlRange($row1, $col1, $row2, $col2, $url) private function writeUrlRange($row1, $col1, $row2, $col2, $url): void
{ {
// Check for internal/external sheet links or default to web link // Check for internal/external sheet links or default to web link
if (preg_match('[^internal:]', $url)) { if (preg_match('[^internal:]', $url)) {
return $this->writeUrlInternal($row1, $col1, $row2, $col2, $url); $this->writeUrlInternal($row1, $col1, $row2, $col2, $url);
} }
if (preg_match('[^external:]', $url)) { if (preg_match('[^external:]', $url)) {
return $this->writeUrlExternal($row1, $col1, $row2, $col2, $url); $this->writeUrlExternal($row1, $col1, $row2, $col2, $url);
} }
return $this->writeUrlWeb($row1, $col1, $row2, $col2, $url); $this->writeUrlWeb($row1, $col1, $row2, $col2, $url);
} }
/** /**
@ -982,14 +967,11 @@ class Worksheet extends BIFFwriter
* @param int $col2 End column * @param int $col2 End column
* @param string $url URL string * @param string $url URL string
* *
* @return int
*
* @see writeUrl() * @see writeUrl()
*/ */
public function writeUrlWeb($row1, $col1, $row2, $col2, $url) public function writeUrlWeb($row1, $col1, $row2, $col2, $url): void
{ {
$record = 0x01B8; // Record identifier $record = 0x01B8; // Record identifier
$length = 0x00000; // Bytes to follow
// Pack the undocumented parts of the hyperlink stream // Pack the undocumented parts of the hyperlink stream
$unknown1 = pack('H*', 'D0C9EA79F9BACE118C8200AA004BA90B02000000'); $unknown1 = pack('H*', 'D0C9EA79F9BACE118C8200AA004BA90B02000000');
@ -1014,8 +996,6 @@ class Worksheet extends BIFFwriter
// Write the packed data // Write the packed data
$this->append($header . $data . $unknown1 . $options . $unknown2 . $url_len . $url); $this->append($header . $data . $unknown1 . $options . $unknown2 . $url_len . $url);
return 0;
} }
/** /**
@ -1027,14 +1007,11 @@ class Worksheet extends BIFFwriter
* @param int $col2 End column * @param int $col2 End column
* @param string $url URL string * @param string $url URL string
* *
* @return int
*
* @see writeUrl() * @see writeUrl()
*/ */
public function writeUrlInternal($row1, $col1, $row2, $col2, $url) private function writeUrlInternal($row1, $col1, $row2, $col2, $url): void
{ {
$record = 0x01B8; // Record identifier $record = 0x01B8; // Record identifier
$length = 0x00000; // Bytes to follow
// Strip URL type // Strip URL type
$url = preg_replace('/^internal:/', '', $url); $url = preg_replace('/^internal:/', '', $url);
@ -1063,8 +1040,6 @@ class Worksheet extends BIFFwriter
// Write the packed data // Write the packed data
$this->append($header . $data . $unknown1 . $options . $url_len . $url); $this->append($header . $data . $unknown1 . $options . $url_len . $url);
return 0;
} }
/** /**
@ -1080,16 +1055,14 @@ class Worksheet extends BIFFwriter
* @param int $col2 End column * @param int $col2 End column
* @param string $url URL string * @param string $url URL string
* *
* @return int
*
* @see writeUrl() * @see writeUrl()
*/ */
public function writeUrlExternal($row1, $col1, $row2, $col2, $url) private function writeUrlExternal($row1, $col1, $row2, $col2, $url): void
{ {
// Network drives are different. We will handle them separately // Network drives are different. We will handle them separately
// MS/Novell network drives and shares start with \\ // MS/Novell network drives and shares start with \\
if (preg_match('[^external:\\\\]', $url)) { if (preg_match('[^external:\\\\]', $url)) {
return; //($this->writeUrlExternal_net($row1, $col1, $row2, $col2, $url, $str, $format)); return;
} }
$record = 0x01B8; // Record identifier $record = 0x01B8; // Record identifier
@ -1165,8 +1138,6 @@ class Worksheet extends BIFFwriter
// Write the packed data // Write the packed data
$this->append($header . $data); $this->append($header . $data);
return 0;
} }
/** /**

View File

@ -362,7 +362,7 @@ class Xf
/** /**
* Map of BIFF2-BIFF8 codes for border styles. * Map of BIFF2-BIFF8 codes for border styles.
* *
* @var array of int * @var int[]
*/ */
private static $mapBorderStyles = [ private static $mapBorderStyles = [
Border::BORDER_NONE => 0x00, Border::BORDER_NONE => 0x00,
@ -396,7 +396,7 @@ class Xf
/** /**
* Map of BIFF2-BIFF8 codes for fill types. * Map of BIFF2-BIFF8 codes for fill types.
* *
* @var array of int * @var int[]
*/ */
private static $mapFillTypes = [ private static $mapFillTypes = [
Fill::FILL_NONE => 0x00, Fill::FILL_NONE => 0x00,
@ -437,7 +437,7 @@ class Xf
/** /**
* Map of BIFF2-BIFF8 codes for horizontal alignment. * Map of BIFF2-BIFF8 codes for horizontal alignment.
* *
* @var array of int * @var int[]
*/ */
private static $mapHAlignments = [ private static $mapHAlignments = [
Alignment::HORIZONTAL_GENERAL => 0, Alignment::HORIZONTAL_GENERAL => 0,
@ -464,7 +464,7 @@ class Xf
/** /**
* Map of BIFF2-BIFF8 codes for vertical alignment. * Map of BIFF2-BIFF8 codes for vertical alignment.
* *
* @var array of int * @var int[]
*/ */
private static $mapVAlignments = [ private static $mapVAlignments = [
Alignment::VERTICAL_TOP => 0, Alignment::VERTICAL_TOP => 0,

View File

@ -200,12 +200,19 @@ class Xlsx extends BaseWriter
$this->writerPartWorksheet = new Worksheet($this); $this->writerPartWorksheet = new Worksheet($this);
// Set HashTable variables // Set HashTable variables
// @phpstan-ignore-next-line
$this->bordersHashTable = new HashTable(); $this->bordersHashTable = new HashTable();
// @phpstan-ignore-next-line
$this->drawingHashTable = new HashTable(); $this->drawingHashTable = new HashTable();
// @phpstan-ignore-next-line
$this->fillHashTable = new HashTable(); $this->fillHashTable = new HashTable();
// @phpstan-ignore-next-line
$this->fontHashTable = new HashTable(); $this->fontHashTable = new HashTable();
// @phpstan-ignore-next-line
$this->numFmtHashTable = new HashTable(); $this->numFmtHashTable = new HashTable();
// @phpstan-ignore-next-line
$this->styleHashTable = new HashTable(); $this->styleHashTable = new HashTable();
// @phpstan-ignore-next-line
$this->stylesConditionalHashTable = new HashTable(); $this->stylesConditionalHashTable = new HashTable();
} }

View File

@ -170,13 +170,13 @@ class DocProps extends WriterPart
/** /**
* Write docProps/custom.xml to XML format. * Write docProps/custom.xml to XML format.
* *
* @return string XML Output * @return null|string XML Output
*/ */
public function writeDocPropsCustom(Spreadsheet $spreadsheet) public function writeDocPropsCustom(Spreadsheet $spreadsheet)
{ {
$customPropertyList = $spreadsheet->getProperties()->getCustomProperties(); $customPropertyList = $spreadsheet->getProperties()->getCustomProperties();
if (empty($customPropertyList)) { if (empty($customPropertyList)) {
return; return null;
} }
// Create XML writer // Create XML writer

View File

@ -10,7 +10,7 @@ class Theme extends WriterPart
/** /**
* Map of Major fonts to write. * Map of Major fonts to write.
* *
* @var array of string * @var string[]
*/ */
private static $majorFonts = [ private static $majorFonts = [
'Jpan' => ' Pゴシック', 'Jpan' => ' Pゴシック',
@ -48,7 +48,7 @@ class Theme extends WriterPart
/** /**
* Map of Minor fonts to write. * Map of Minor fonts to write.
* *
* @var array of string * @var string[]
*/ */
private static $minorFonts = [ private static $minorFonts = [
'Jpan' => ' Pゴシック', 'Jpan' => ' Pゴシック',
@ -86,7 +86,7 @@ class Theme extends WriterPart
/** /**
* Map of core colours. * Map of core colours.
* *
* @var array of string * @var string[]
*/ */
private static $colourScheme = [ private static $colourScheme = [
'dk2' => '1F497D', 'dk2' => '1F497D',

View File

@ -22,11 +22,6 @@ class ImConjugateTest extends TestCase
$this->complexAssert = new ComplexAssert(); $this->complexAssert = new ComplexAssert();
} }
protected function tearDown(): void
{
$this->complexAssert = null;
}
/** /**
* @dataProvider providerIMCONJUGATE * @dataProvider providerIMCONJUGATE
* *

View File

@ -22,11 +22,6 @@ class ImCosTest extends TestCase
$this->complexAssert = new ComplexAssert(); $this->complexAssert = new ComplexAssert();
} }
protected function tearDown(): void
{
$this->complexAssert = null;
}
/** /**
* @dataProvider providerIMCOS * @dataProvider providerIMCOS
* *

View File

@ -22,11 +22,6 @@ class ImCoshTest extends TestCase
$this->complexAssert = new ComplexAssert(); $this->complexAssert = new ComplexAssert();
} }
protected function tearDown(): void
{
$this->complexAssert = null;
}
/** /**
* @dataProvider providerIMCOSH * @dataProvider providerIMCOSH
* *

View File

@ -22,11 +22,6 @@ class ImCotTest extends TestCase
$this->complexAssert = new ComplexAssert(); $this->complexAssert = new ComplexAssert();
} }
protected function tearDown(): void
{
$this->complexAssert = null;
}
/** /**
* @dataProvider providerIMCOT * @dataProvider providerIMCOT
* *

View File

@ -22,11 +22,6 @@ class ImCscTest extends TestCase
$this->complexAssert = new ComplexAssert(); $this->complexAssert = new ComplexAssert();
} }
protected function tearDown(): void
{
$this->complexAssert = null;
}
/** /**
* @dataProvider providerIMCSC * @dataProvider providerIMCSC
* *

View File

@ -22,11 +22,6 @@ class ImCschTest extends TestCase
$this->complexAssert = new ComplexAssert(); $this->complexAssert = new ComplexAssert();
} }
protected function tearDown(): void
{
$this->complexAssert = null;
}
/** /**
* @dataProvider providerIMCSCH * @dataProvider providerIMCSCH
* *

View File

@ -22,11 +22,6 @@ class ImDivTest extends TestCase
$this->complexAssert = new ComplexAssert(); $this->complexAssert = new ComplexAssert();
} }
protected function tearDown(): void
{
$this->complexAssert = null;
}
/** /**
* @dataProvider providerIMDIV * @dataProvider providerIMDIV
* *

View File

@ -22,11 +22,6 @@ class ImExpTest extends TestCase
$this->complexAssert = new ComplexAssert(); $this->complexAssert = new ComplexAssert();
} }
protected function tearDown(): void
{
$this->complexAssert = null;
}
/** /**
* @dataProvider providerIMEXP * @dataProvider providerIMEXP
* *

View File

@ -22,11 +22,6 @@ class ImLnTest extends TestCase
$this->complexAssert = new ComplexAssert(); $this->complexAssert = new ComplexAssert();
} }
protected function tearDown(): void
{
$this->complexAssert = null;
}
/** /**
* @dataProvider providerIMLN * @dataProvider providerIMLN
* *

View File

@ -22,11 +22,6 @@ class ImLog10Test extends TestCase
$this->complexAssert = new ComplexAssert(); $this->complexAssert = new ComplexAssert();
} }
protected function tearDown(): void
{
$this->complexAssert = null;
}
/** /**
* @dataProvider providerIMLOG10 * @dataProvider providerIMLOG10
* *

View File

@ -22,11 +22,6 @@ class ImLog2Test extends TestCase
$this->complexAssert = new ComplexAssert(); $this->complexAssert = new ComplexAssert();
} }
protected function tearDown(): void
{
$this->complexAssert = null;
}
/** /**
* @dataProvider providerIMLOG2 * @dataProvider providerIMLOG2
* *

View File

@ -22,11 +22,6 @@ class ImPowerTest extends TestCase
$this->complexAssert = new ComplexAssert(); $this->complexAssert = new ComplexAssert();
} }
protected function tearDown(): void
{
$this->complexAssert = null;
}
/** /**
* @dataProvider providerIMPOWER * @dataProvider providerIMPOWER
* *

View File

@ -22,11 +22,6 @@ class ImProductTest extends TestCase
$this->complexAssert = new ComplexAssert(); $this->complexAssert = new ComplexAssert();
} }
protected function tearDown(): void
{
$this->complexAssert = null;
}
/** /**
* @dataProvider providerIMPRODUCT * @dataProvider providerIMPRODUCT
* *

View File

@ -22,11 +22,6 @@ class ImSecTest extends TestCase
$this->complexAssert = new ComplexAssert(); $this->complexAssert = new ComplexAssert();
} }
protected function tearDown(): void
{
$this->complexAssert = null;
}
/** /**
* @dataProvider providerIMSEC * @dataProvider providerIMSEC
* *

View File

@ -22,11 +22,6 @@ class ImSechTest extends TestCase
$this->complexAssert = new ComplexAssert(); $this->complexAssert = new ComplexAssert();
} }
protected function tearDown(): void
{
$this->complexAssert = null;
}
/** /**
* @dataProvider providerIMSECH * @dataProvider providerIMSECH
* *

View File

@ -22,11 +22,6 @@ class ImSinTest extends TestCase
$this->complexAssert = new ComplexAssert(); $this->complexAssert = new ComplexAssert();
} }
protected function tearDown(): void
{
$this->complexAssert = null;
}
/** /**
* @dataProvider providerIMSIN * @dataProvider providerIMSIN
* *

View File

@ -22,11 +22,6 @@ class ImSinhTest extends TestCase
$this->complexAssert = new ComplexAssert(); $this->complexAssert = new ComplexAssert();
} }
protected function tearDown(): void
{
$this->complexAssert = null;
}
/** /**
* @dataProvider providerIMSINH * @dataProvider providerIMSINH
* *

View File

@ -22,11 +22,6 @@ class ImSqrtTest extends TestCase
$this->complexAssert = new ComplexAssert(); $this->complexAssert = new ComplexAssert();
} }
protected function tearDown(): void
{
$this->complexAssert = null;
}
/** /**
* @dataProvider providerIMSQRT * @dataProvider providerIMSQRT
* *

View File

@ -22,11 +22,6 @@ class ImSubTest extends TestCase
$this->complexAssert = new ComplexAssert(); $this->complexAssert = new ComplexAssert();
} }
protected function tearDown(): void
{
$this->complexAssert = null;
}
/** /**
* @dataProvider providerIMSUB * @dataProvider providerIMSUB
* *

View File

@ -22,11 +22,6 @@ class ImSumTest extends TestCase
$this->complexAssert = new ComplexAssert(); $this->complexAssert = new ComplexAssert();
} }
protected function tearDown(): void
{
$this->complexAssert = null;
}
/** /**
* @dataProvider providerIMSUM * @dataProvider providerIMSUM
* *

View File

@ -22,11 +22,6 @@ class ImTanTest extends TestCase
$this->complexAssert = new ComplexAssert(); $this->complexAssert = new ComplexAssert();
} }
protected function tearDown(): void
{
$this->complexAssert = null;
}
/** /**
* @dataProvider providerIMTAN * @dataProvider providerIMTAN
* *

View File

@ -8,7 +8,7 @@ use PHPUnit\Framework\TestCase;
class SettingsTest extends TestCase class SettingsTest extends TestCase
{ {
/** /**
* @var string * @var bool
*/ */
protected $prevValue; protected $prevValue;