diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 6d46b92..e163f80 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -1,6 +1,6 @@
name: Spout CI
-on: push
+on: [push, pull_request]
jobs:
tests-on-php-latest:
@@ -8,7 +8,7 @@ jobs:
matrix:
operating-system: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.operating-system }}
- name: Tests - PHP 8.0 on ${{ matrix.operating-system }}
+ name: Tests - PHP 8.1 on ${{ matrix.operating-system }}
env:
extensions: zip, xmlreader, dom
cache-key: cache-matrix-v1 # can be any string, change to clear the extension cache.
@@ -20,7 +20,7 @@ jobs:
id: extcache
uses: shivammathur/cache-extensions@v1
with:
- php-version: '8.0'
+ php-version: '8.1'
extensions: ${{ env.extensions }}
key: ${{ env.cache-key }}
@@ -34,7 +34,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
- php-version: '8.0'
+ php-version: '8.1'
extensions: ${{ env.extensions }}
- name: Get composer cache directory
@@ -59,7 +59,7 @@ jobs:
tests-on-older-php:
strategy:
matrix:
- php-versions: ['7.3', '7.4']
+ php-versions: ['7.3', '7.4', '8.0']
runs-on: ubuntu-latest
name: Tests - PHP ${{ matrix.php-versions }}
env:
@@ -123,7 +123,7 @@ jobs:
id: extcache
uses: shivammathur/cache-extensions@v1
with:
- php-version: '7.4'
+ php-version: '8.1'
extensions: ${{ env.extensions }}
key: ${{ env.cache-key }}
@@ -137,7 +137,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
- php-version: '7.4'
+ php-version: '8.1'
extensions: ${{ env.extensions }}
- name: Get composer cache directory
@@ -182,7 +182,7 @@ jobs:
id: extcache
uses: shivammathur/cache-extensions@v1
with:
- php-version: '8.0'
+ php-version: '8.1'
extensions: ${{ env.extensions }}
key: ${{ env.cache-key }}
@@ -196,7 +196,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
- php-version: '8.0'
+ php-version: '8.1'
extensions: ${{ env.extensions }}
- name: Get composer cache directory
@@ -232,7 +232,7 @@ jobs:
id: extcache
uses: shivammathur/cache-extensions@v1
with:
- php-version: '8.0'
+ php-version: '8.1'
extensions: ${{ env.extensions }}
key: ${{ env.cache-key }}
@@ -246,7 +246,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
- php-version: '8.0'
+ php-version: '8.1'
extensions: ${{ env.extensions }}
tools: phpstan
@@ -267,4 +267,4 @@ jobs:
run: composer install --no-progress --prefer-dist --optimize-autoloader
- name: Static Analysis using PHPStan
- run: phpstan analyse --no-progress src tests
+ run: ./vendor/bin/phpstan analyse -c phpstan.neon --no-progress
diff --git a/phpstan.neon b/phpstan.neon
new file mode 100644
index 0000000..772c5cc
--- /dev/null
+++ b/phpstan.neon
@@ -0,0 +1,9 @@
+parameters:
+ level: 4
+ paths:
+ - src
+ - tests
+ excludePaths:
+ # Exclude these files that are OK
+ - src/Spout/Reader/Common/Creator/ReaderEntityFactory.php
+ - src/Spout/Writer/Common/Creator/WriterEntityFactory.php
diff --git a/phpunit.xml b/phpunit.xml
index 4e410e2..8ddc54c 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -1,38 +1,36 @@
+ xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
+ bootstrap="tests/bootstrap.php"
+ colors="true"
+ convertErrorsToExceptions="false"
+ convertWarningsToExceptions="false"
+ defaultTestSuite="unit-tests"
+ verbose="false">
-
-
-
+
+
+
-
+
+
+ tests/
+
+
-
- tests/
-
+
+
+ perf-tests
+
+
-
-
-
-
- perf-tests
-
-
-
-
-
- src/
-
- src/Spout/Autoloader
-
-
-
+
+
+ src/
+
+
+ src/Spout/Autoloader
+
+
diff --git a/src/Spout/Common/Entity/Style/Style.php b/src/Spout/Common/Entity/Style/Style.php
index b5f38f9..0af1450 100644
--- a/src/Spout/Common/Entity/Style/Style.php
+++ b/src/Spout/Common/Entity/Style/Style.php
@@ -66,7 +66,7 @@ class Style
/** @var bool Whether the wrap text property was set */
private $hasSetWrapText = false;
- /** @var Border */
+ /** @var Border|null */
private $border;
/** @var bool Whether border properties should be applied */
@@ -78,7 +78,7 @@ class Style
/** @var bool */
private $hasSetBackgroundColor = false;
- /** @var string Format */
+ /** @var string|null Format */
private $format;
/** @var bool */
@@ -110,7 +110,7 @@ class Style
}
/**
- * @return Border
+ * @return Border|null
*/
public function getBorder()
{
@@ -467,7 +467,7 @@ class Style
}
/**
- * @return string
+ * @return string|null
*/
public function getFormat()
{
diff --git a/src/Spout/Common/Helper/CellTypeHelper.php b/src/Spout/Common/Helper/CellTypeHelper.php
index 97d2e8d..6f567c4 100644
--- a/src/Spout/Common/Helper/CellTypeHelper.php
+++ b/src/Spout/Common/Helper/CellTypeHelper.php
@@ -9,7 +9,7 @@ namespace Box\Spout\Common\Helper;
class CellTypeHelper
{
/**
- * @param $value
+ * @param mixed|null $value
* @return bool Whether the given value is considered "empty"
*/
public static function isEmpty($value)
@@ -18,7 +18,7 @@ class CellTypeHelper
}
/**
- * @param $value
+ * @param mixed $value
* @return bool Whether the given value is a non empty string
*/
public static function isNonEmptyString($value)
@@ -30,7 +30,7 @@ class CellTypeHelper
* Returns whether the given value is numeric.
* A numeric value is from type "integer" or "double" ("float" is not returned by gettype).
*
- * @param $value
+ * @param mixed $value
* @return bool Whether the given value is numeric
*/
public static function isNumeric($value)
@@ -44,7 +44,7 @@ class CellTypeHelper
* Returns whether the given value is boolean.
* "true"/"false" and 0/1 are not booleans.
*
- * @param $value
+ * @param mixed $value
* @return bool Whether the given value is boolean
*/
public static function isBoolean($value)
@@ -55,13 +55,13 @@ class CellTypeHelper
/**
* Returns whether the given value is a DateTime or DateInterval object.
*
- * @param $value
+ * @param mixed $value
* @return bool Whether the given value is a DateTime or DateInterval object
*/
public static function isDateTimeOrDateInterval($value)
{
return (
- $value instanceof \DateTime ||
+ $value instanceof \DateTimeInterface ||
$value instanceof \DateInterval
);
}
diff --git a/src/Spout/Common/Helper/GlobalFunctionsHelper.php b/src/Spout/Common/Helper/GlobalFunctionsHelper.php
index 5deb8d9..8c2d34c 100644
--- a/src/Spout/Common/Helper/GlobalFunctionsHelper.php
+++ b/src/Spout/Common/Helper/GlobalFunctionsHelper.php
@@ -82,7 +82,7 @@ class GlobalFunctionsHelper
* @param int|null $length
* @param string|null $delimiter
* @param string|null $enclosure
- * @return array
+ * @return array|false
*/
public function fgetcsv($handle, $length = null, $delimiter = null, $enclosure = null)
{
@@ -103,7 +103,7 @@ class GlobalFunctionsHelper
* @param array $fields
* @param string|null $delimiter
* @param string|null $enclosure
- * @return int
+ * @return int|false
*/
public function fputcsv($handle, array $fields, $delimiter = null, $enclosure = null)
{
@@ -243,10 +243,10 @@ class GlobalFunctionsHelper
* @see basename()
*
* @param string $path
- * @param string|null $suffix
+ * @param string $suffix
* @return string
*/
- public function basename($path, $suffix = null)
+ public function basename($path, $suffix = '')
{
return \basename($path, $suffix);
}
diff --git a/src/Spout/Common/Helper/StringHelper.php b/src/Spout/Common/Helper/StringHelper.php
index 6256b1e..340d65c 100644
--- a/src/Spout/Common/Helper/StringHelper.php
+++ b/src/Spout/Common/Helper/StringHelper.php
@@ -88,7 +88,7 @@ class StringHelper
* @see https://wiki.php.net/rfc/locale_independent_float_to_string for the changed behavior in PHP8.
*
* @param int|float $numericValue
- * @return string
+ * @return int|float|string
*/
public function formatNumericValue($numericValue)
{
diff --git a/src/Spout/Reader/CSV/Reader.php b/src/Spout/Reader/CSV/Reader.php
index ca61ef2..2597067 100644
--- a/src/Spout/Reader/CSV/Reader.php
+++ b/src/Spout/Reader/CSV/Reader.php
@@ -3,6 +3,9 @@
namespace Box\Spout\Reader\CSV;
use Box\Spout\Common\Exception\IOException;
+use Box\Spout\Common\Helper\GlobalFunctionsHelper;
+use Box\Spout\Common\Manager\OptionsManagerInterface;
+use Box\Spout\Reader\Common\Creator\InternalEntityFactoryInterface;
use Box\Spout\Reader\Common\Entity\Options;
use Box\Spout\Reader\CSV\Creator\InternalEntityFactory;
use Box\Spout\Reader\ReaderAbstract;
@@ -22,6 +25,23 @@ class Reader extends ReaderAbstract
/** @var string Original value for the "auto_detect_line_endings" INI value */
protected $originalAutoDetectLineEndings;
+ /** @var bool Whether the code is running with PHP >= 8.1 */
+ private $isRunningAtLeastPhp81;
+
+ /**
+ * @param OptionsManagerInterface $optionsManager
+ * @param GlobalFunctionsHelper $globalFunctionsHelper
+ * @param InternalEntityFactoryInterface $entityFactory
+ */
+ public function __construct(
+ OptionsManagerInterface $optionsManager,
+ GlobalFunctionsHelper $globalFunctionsHelper,
+ InternalEntityFactoryInterface $entityFactory
+ ) {
+ parent::__construct($optionsManager, $globalFunctionsHelper, $entityFactory);
+ $this->isRunningAtLeastPhp81 = \version_compare(PHP_VERSION, '8.1.0') >= 0;
+ }
+
/**
* Sets the field delimiter for the CSV.
* Needs to be called before opening the reader.
@@ -84,8 +104,11 @@ class Reader extends ReaderAbstract
*/
protected function openReader($filePath)
{
- $this->originalAutoDetectLineEndings = \ini_get('auto_detect_line_endings');
- \ini_set('auto_detect_line_endings', '1');
+ // "auto_detect_line_endings" is deprecated in PHP 8.1
+ if (!$this->isRunningAtLeastPhp81) {
+ $this->originalAutoDetectLineEndings = \ini_get('auto_detect_line_endings');
+ \ini_set('auto_detect_line_endings', '1');
+ }
$this->filePointer = $this->globalFunctionsHelper->fopen($filePath, 'r');
if (!$this->filePointer) {
@@ -119,10 +142,13 @@ class Reader extends ReaderAbstract
*/
protected function closeReader()
{
- if ($this->filePointer) {
+ if (is_resource($this->filePointer)) {
$this->globalFunctionsHelper->fclose($this->filePointer);
}
- \ini_set('auto_detect_line_endings', $this->originalAutoDetectLineEndings);
+ // "auto_detect_line_endings" is deprecated in PHP 8.1
+ if (!$this->isRunningAtLeastPhp81) {
+ \ini_set('auto_detect_line_endings', $this->originalAutoDetectLineEndings);
+ }
}
}
diff --git a/src/Spout/Reader/CSV/RowIterator.php b/src/Spout/Reader/CSV/RowIterator.php
index 1312d9c..dfa2688 100644
--- a/src/Spout/Reader/CSV/RowIterator.php
+++ b/src/Spout/Reader/CSV/RowIterator.php
@@ -21,7 +21,7 @@ class RowIterator implements IteratorInterface
*/
public const MAX_READ_BYTES_PER_LINE = 0;
- /** @var resource Pointer to the CSV file to read */
+ /** @var resource|null Pointer to the CSV file to read */
protected $filePointer;
/** @var int Number of read rows */
@@ -84,7 +84,7 @@ class RowIterator implements IteratorInterface
*
* @return void
*/
- public function rewind()
+ public function rewind() : void
{
$this->rewindAndSkipBom();
@@ -114,7 +114,7 @@ class RowIterator implements IteratorInterface
*
* @return bool
*/
- public function valid()
+ public function valid() : bool
{
return ($this->filePointer && !$this->hasReachedEndOfFile);
}
@@ -126,7 +126,7 @@ class RowIterator implements IteratorInterface
* @throws \Box\Spout\Common\Exception\EncodingConversionException If unable to convert data to UTF-8
* @return void
*/
- public function next()
+ public function next() : void
{
$this->hasReachedEndOfFile = $this->globalFunctionsHelper->feof($this->filePointer);
@@ -146,8 +146,8 @@ class RowIterator implements IteratorInterface
} while ($this->shouldReadNextRow($rowData));
if ($rowData !== false) {
- // str_replace will replace NULL values by empty strings
- $rowDataBufferAsArray = \str_replace(null, null, $rowData);
+ // array_map will replace NULL values by empty strings
+ $rowDataBufferAsArray = array_map(function ($value) { return (string) $value; }, $rowData);
$this->rowBuffer = $this->entityFactory->createRowFromArray($rowDataBufferAsArray);
$this->numReadRows++;
} else {
@@ -224,7 +224,7 @@ class RowIterator implements IteratorInterface
*
* @return Row|null
*/
- public function current()
+ public function current() : ?Row
{
return $this->rowBuffer;
}
@@ -235,7 +235,7 @@ class RowIterator implements IteratorInterface
*
* @return int
*/
- public function key()
+ public function key() : int
{
return $this->numReadRows;
}
@@ -245,7 +245,7 @@ class RowIterator implements IteratorInterface
*
* @return void
*/
- public function end()
+ public function end() : void
{
// do nothing
}
diff --git a/src/Spout/Reader/CSV/SheetIterator.php b/src/Spout/Reader/CSV/SheetIterator.php
index 69eb58a..84c3c80 100644
--- a/src/Spout/Reader/CSV/SheetIterator.php
+++ b/src/Spout/Reader/CSV/SheetIterator.php
@@ -10,7 +10,7 @@ use Box\Spout\Reader\IteratorInterface;
*/
class SheetIterator implements IteratorInterface
{
- /** @var \Box\Spout\Reader\CSV\Sheet The CSV unique "sheet" */
+ /** @var Sheet The CSV unique "sheet" */
protected $sheet;
/** @var bool Whether the unique "sheet" has already been read */
@@ -30,7 +30,7 @@ class SheetIterator implements IteratorInterface
*
* @return void
*/
- public function rewind()
+ public function rewind() : void
{
$this->hasReadUniqueSheet = false;
}
@@ -41,7 +41,7 @@ class SheetIterator implements IteratorInterface
*
* @return bool
*/
- public function valid()
+ public function valid() : bool
{
return (!$this->hasReadUniqueSheet);
}
@@ -52,7 +52,7 @@ class SheetIterator implements IteratorInterface
*
* @return void
*/
- public function next()
+ public function next() : void
{
$this->hasReadUniqueSheet = true;
}
@@ -61,9 +61,9 @@ class SheetIterator implements IteratorInterface
* Return the current element
* @see http://php.net/manual/en/iterator.current.php
*
- * @return \Box\Spout\Reader\CSV\Sheet
+ * @return Sheet
*/
- public function current()
+ public function current() : Sheet
{
return $this->sheet;
}
@@ -74,7 +74,7 @@ class SheetIterator implements IteratorInterface
*
* @return int
*/
- public function key()
+ public function key() : int
{
return 1;
}
@@ -84,7 +84,7 @@ class SheetIterator implements IteratorInterface
*
* @return void
*/
- public function end()
+ public function end() : void
{
// do nothing
}
diff --git a/src/Spout/Reader/Common/Creator/ReaderFactory.php b/src/Spout/Reader/Common/Creator/ReaderFactory.php
index 6b10175..09ca422 100644
--- a/src/Spout/Reader/Common/Creator/ReaderFactory.php
+++ b/src/Spout/Reader/Common/Creator/ReaderFactory.php
@@ -45,7 +45,7 @@ class ReaderFactory
/**
* This creates an instance of the appropriate reader, given the type of the file to be read
*
- * @param string $readerType Type of the reader to instantiate
+ * @param string $readerType Type of the reader to instantiate
* @throws \Box\Spout\Common\Exception\UnsupportedTypeException
* @return ReaderInterface
*/
diff --git a/src/Spout/Reader/ODS/Creator/InternalEntityFactory.php b/src/Spout/Reader/ODS/Creator/InternalEntityFactory.php
index cb06ce2..a9d96d6 100644
--- a/src/Spout/Reader/ODS/Creator/InternalEntityFactory.php
+++ b/src/Spout/Reader/ODS/Creator/InternalEntityFactory.php
@@ -105,7 +105,7 @@ class InternalEntityFactory implements InternalEntityFactoryInterface
}
/**
- * @param $xmlReader
+ * @param XMLReader $xmlReader
* @return XMLProcessor
*/
private function createXMLProcessor($xmlReader)
diff --git a/src/Spout/Reader/ODS/Helper/CellValueFormatter.php b/src/Spout/Reader/ODS/Helper/CellValueFormatter.php
index 77bd3c2..b69dcd6 100644
--- a/src/Spout/Reader/ODS/Helper/CellValueFormatter.php
+++ b/src/Spout/Reader/ODS/Helper/CellValueFormatter.php
@@ -64,7 +64,7 @@ class CellValueFormatter
* Returns the (unescaped) correctly marshalled, cell value associated to the given XML node.
* @see http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#refTable13
*
- * @param \DOMNode $node
+ * @param \DOMElement $node
* @throws InvalidValueException If the node value is not valid
* @return string|int|float|bool|\DateTime|\DateInterval The value associated with the cell, empty string if cell's type is void/undefined
*/
@@ -96,7 +96,7 @@ class CellValueFormatter
/**
* Returns the cell String value.
*
- * @param \DOMNode $node
+ * @param \DOMElement $node
* @return string The value associated with the cell
*/
protected function formatStringCellValue($node)
@@ -115,7 +115,7 @@ class CellValueFormatter
}
/**
- * @param $pNode
+ * @param \DOMNode $pNode
* @return string
*/
private function extractTextValueFromNode($pNode)
@@ -159,7 +159,7 @@ class CellValueFormatter
*
* @see https://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1415200_253892949
*
- * @param \DOMNode $node The XML node representing a whitespace
+ * @param \DOMElement $node The XML node representing a whitespace
* @return string The corresponding whitespace value
*/
private function transformWhitespaceNode($node)
@@ -173,7 +173,7 @@ class CellValueFormatter
/**
* Returns the cell Numeric value from the given node.
*
- * @param \DOMNode $node
+ * @param \DOMElement $node
* @return int|float The value associated with the cell
*/
protected function formatFloatCellValue($node)
@@ -190,7 +190,7 @@ class CellValueFormatter
/**
* Returns the cell Boolean value from the given node.
*
- * @param \DOMNode $node
+ * @param \DOMElement $node
* @return bool The value associated with the cell
*/
protected function formatBooleanCellValue($node)
@@ -203,7 +203,7 @@ class CellValueFormatter
/**
* Returns the cell Date value from the given node.
*
- * @param \DOMNode $node
+ * @param \DOMElement $node
* @throws InvalidValueException If the value is not a valid date
* @return \DateTime|string The value associated with the cell
*/
@@ -234,7 +234,7 @@ class CellValueFormatter
/**
* Returns the cell Time value from the given node.
*
- * @param \DOMNode $node
+ * @param \DOMElement $node
* @throws InvalidValueException If the value is not a valid time
* @return \DateInterval|string The value associated with the cell
*/
@@ -265,7 +265,7 @@ class CellValueFormatter
/**
* Returns the cell Currency value from the given node.
*
- * @param \DOMNode $node
+ * @param \DOMElement $node
* @return string The value associated with the cell (e.g. "100 USD" or "9.99 EUR")
*/
protected function formatCurrencyCellValue($node)
@@ -279,7 +279,7 @@ class CellValueFormatter
/**
* Returns the cell Percentage value from the given node.
*
- * @param \DOMNode $node
+ * @param \DOMElement $node
* @return int|float The value associated with the cell
*/
protected function formatPercentageCellValue($node)
diff --git a/src/Spout/Reader/ODS/Reader.php b/src/Spout/Reader/ODS/Reader.php
index d07dbb4..00a39bd 100644
--- a/src/Spout/Reader/ODS/Reader.php
+++ b/src/Spout/Reader/ODS/Reader.php
@@ -69,7 +69,7 @@ class Reader extends ReaderAbstract
*/
protected function closeReader()
{
- if ($this->zip) {
+ if ($this->zip !== null) {
$this->zip->close();
}
}
diff --git a/src/Spout/Reader/ODS/RowIterator.php b/src/Spout/Reader/ODS/RowIterator.php
index b804376..f9a0733 100644
--- a/src/Spout/Reader/ODS/RowIterator.php
+++ b/src/Spout/Reader/ODS/RowIterator.php
@@ -56,7 +56,7 @@ class RowIterator implements IteratorInterface
/** @var Row The currently processed row */
protected $currentlyProcessedRow;
- /** @var Row Buffer used to store the current row, while checking if there are more rows to read */
+ /** @var Row|null Buffer used to store the current row, while checking if there are more rows to read */
protected $rowBuffer;
/** @var bool Indicates whether all rows have been read */
@@ -68,7 +68,7 @@ class RowIterator implements IteratorInterface
/** @var int Row index to be processed next (one-based) */
protected $nextRowIndexToBeProcessed = 1;
- /** @var Cell Last processed cell (because when reading cell at column N+1, cell N is processed) */
+ /** @var Cell|null Last processed cell (because when reading cell at column N+1, cell N is processed) */
protected $lastProcessedCell;
/** @var int Number of times the last processed row should be repeated */
@@ -118,7 +118,7 @@ class RowIterator implements IteratorInterface
* @throws \Box\Spout\Reader\Exception\IteratorNotRewindableException If the iterator is rewound more than once
* @return void
*/
- public function rewind()
+ public function rewind() : void
{
// Because sheet and row data is located in the file, we can't rewind both the
// sheet iterator and the row iterator, as XML file cannot be read backwards.
@@ -142,7 +142,7 @@ class RowIterator implements IteratorInterface
*
* @return bool
*/
- public function valid()
+ public function valid() : bool
{
return (!$this->hasReachedEndOfFile);
}
@@ -155,7 +155,7 @@ class RowIterator implements IteratorInterface
* @throws \Box\Spout\Common\Exception\IOException If unable to read the sheet data XML
* @return void
*/
- public function next()
+ public function next() : void
{
if ($this->doesNeedDataForNextRowToBeProcessed()) {
$this->readDataForNextRow();
@@ -225,6 +225,7 @@ class RowIterator implements IteratorInterface
$currentNumColumnsRepeated = $this->getNumColumnsRepeatedForCurrentNode($xmlReader);
// NOTE: expand() will automatically decode all XML entities of the child nodes
+ /** @var \DOMElement $node */
$node = $xmlReader->expand();
$currentCell = $this->getCell($node);
@@ -316,7 +317,7 @@ class RowIterator implements IteratorInterface
/**
* Returns the cell with (unescaped) correctly marshalled, cell value associated to the given XML node.
*
- * @param \DOMNode $node
+ * @param \DOMElement $node
* @return Cell The cell set with the associated with the cell
*/
protected function getCell($node)
@@ -339,7 +340,7 @@ class RowIterator implements IteratorInterface
* row data yet (as we still need to apply the "num-columns-repeated" attribute).
*
* @param Row $currentRow
- * @param Cell $lastReadCell The last read cell
+ * @param Cell|null $lastReadCell The last read cell
* @return bool Whether the row is empty
*/
protected function isEmptyRow($currentRow, $lastReadCell)
@@ -356,7 +357,7 @@ class RowIterator implements IteratorInterface
*
* @return Row
*/
- public function current()
+ public function current() : Row
{
return $this->rowBuffer;
}
@@ -367,7 +368,7 @@ class RowIterator implements IteratorInterface
*
* @return int
*/
- public function key()
+ public function key() : int
{
return $this->lastRowIndexProcessed;
}
@@ -377,7 +378,7 @@ class RowIterator implements IteratorInterface
*
* @return void
*/
- public function end()
+ public function end() : void
{
$this->xmlReader->close();
}
diff --git a/src/Spout/Reader/ODS/SheetIterator.php b/src/Spout/Reader/ODS/SheetIterator.php
index c396d79..b2cb8b8 100644
--- a/src/Spout/Reader/ODS/SheetIterator.php
+++ b/src/Spout/Reader/ODS/SheetIterator.php
@@ -108,6 +108,7 @@ class SheetIterator implements IteratorInterface
$sheetsVisibility = [];
$this->xmlReader->readUntilNodeFound(self::XML_NODE_AUTOMATIC_STYLES);
+ /** @var \DOMElement $automaticStylesNode */
$automaticStylesNode = $this->xmlReader->expand();
$tableStyleNodes = $automaticStylesNode->getElementsByTagNameNS(self::XML_STYLE_NAMESPACE, self::XML_NODE_STYLE_TABLE_PROPERTIES);
diff --git a/src/Spout/Reader/ReaderAbstract.php b/src/Spout/Reader/ReaderAbstract.php
index 39b333d..0c469a1 100644
--- a/src/Spout/Reader/ReaderAbstract.php
+++ b/src/Spout/Reader/ReaderAbstract.php
@@ -53,7 +53,7 @@ abstract class ReaderAbstract implements ReaderInterface
/**
* Closes the reader. To be used after reading the file.
*
- * @return ReaderAbstract
+ * @return void
*/
abstract protected function closeReader();
@@ -233,7 +233,7 @@ abstract class ReaderAbstract implements ReaderInterface
$this->closeReader();
$sheetIterator = $this->getConcreteSheetIterator();
- if ($sheetIterator) {
+ if ($sheetIterator !== null) {
$sheetIterator->end();
}
diff --git a/src/Spout/Reader/XLSX/Creator/InternalEntityFactory.php b/src/Spout/Reader/XLSX/Creator/InternalEntityFactory.php
index 4dc2dc7..d5ab4c9 100644
--- a/src/Spout/Reader/XLSX/Creator/InternalEntityFactory.php
+++ b/src/Spout/Reader/XLSX/Creator/InternalEntityFactory.php
@@ -152,7 +152,7 @@ class InternalEntityFactory implements InternalEntityFactoryInterface
}
/**
- * @param $xmlReader
+ * @param XMLReader $xmlReader
* @return XMLProcessor
*/
public function createXMLProcessor($xmlReader)
diff --git a/src/Spout/Reader/XLSX/Creator/ManagerFactory.php b/src/Spout/Reader/XLSX/Creator/ManagerFactory.php
index d23a53f..e69d429 100644
--- a/src/Spout/Reader/XLSX/Creator/ManagerFactory.php
+++ b/src/Spout/Reader/XLSX/Creator/ManagerFactory.php
@@ -21,7 +21,7 @@ class ManagerFactory
/** @var CachingStrategyFactory */
private $cachingStrategyFactory;
- /** @var WorkbookRelationshipsManager */
+ /** @var WorkbookRelationshipsManager|null */
private $cachedWorkbookRelationshipsManager;
/**
diff --git a/src/Spout/Reader/XLSX/Helper/CellValueFormatter.php b/src/Spout/Reader/XLSX/Helper/CellValueFormatter.php
index 5fcd794..cf4c383 100644
--- a/src/Spout/Reader/XLSX/Helper/CellValueFormatter.php
+++ b/src/Spout/Reader/XLSX/Helper/CellValueFormatter.php
@@ -66,7 +66,7 @@ class CellValueFormatter
/**
* Returns the (unescaped) correctly marshalled, cell value associated to the given XML node.
*
- * @param \DOMNode $node
+ * @param \DOMElement $node
* @throws InvalidValueException If the value is not valid
* @return string|int|float|bool|\DateTime The value associated with the cell
*/
@@ -102,7 +102,7 @@ class CellValueFormatter
/**
* Returns the cell's string value from a node's nested value node
*
- * @param \DOMNode $node
+ * @param \DOMElement $node
* @return string The value associated with the cell
*/
protected function getVNodeValue($node)
@@ -117,7 +117,7 @@ class CellValueFormatter
/**
* Returns the cell String value where string is inline.
*
- * @param \DOMNode $node
+ * @param \DOMElement $node
* @return string The value associated with the cell
*/
protected function formatInlineStringCellValue($node)
diff --git a/src/Spout/Reader/XLSX/Manager/SharedStringsCaching/CachingStrategyFactory.php b/src/Spout/Reader/XLSX/Manager/SharedStringsCaching/CachingStrategyFactory.php
index 9afec2f..c36b911 100644
--- a/src/Spout/Reader/XLSX/Manager/SharedStringsCaching/CachingStrategyFactory.php
+++ b/src/Spout/Reader/XLSX/Manager/SharedStringsCaching/CachingStrategyFactory.php
@@ -84,7 +84,7 @@ class CachingStrategyFactory
$memoryAvailable = $this->getMemoryLimitInKB();
- if ($memoryAvailable === -1) {
+ if ((int) $memoryAvailable === -1) {
// if cannot get memory limit or if memory limit set as unlimited, don't trust and play safe
$isInMemoryStrategyUsageSafe = ($sharedStringsUniqueCount < self::MAX_NUM_STRINGS_PER_TEMP_FILE);
} else {
diff --git a/src/Spout/Reader/XLSX/Manager/SharedStringsCaching/FileBasedStrategy.php b/src/Spout/Reader/XLSX/Manager/SharedStringsCaching/FileBasedStrategy.php
index 60e69b0..9a4142b 100644
--- a/src/Spout/Reader/XLSX/Manager/SharedStringsCaching/FileBasedStrategy.php
+++ b/src/Spout/Reader/XLSX/Manager/SharedStringsCaching/FileBasedStrategy.php
@@ -32,7 +32,7 @@ class FileBasedStrategy implements CachingStrategyInterface
*/
protected $maxNumStringsPerTempFile;
- /** @var resource Pointer to the last temp file a shared string was written to */
+ /** @var resource|null Pointer to the last temp file a shared string was written to */
protected $tempFilePointer;
/**
diff --git a/src/Spout/Reader/XLSX/Manager/SharedStringsManager.php b/src/Spout/Reader/XLSX/Manager/SharedStringsManager.php
index 46cbe6d..fcf2a2b 100644
--- a/src/Spout/Reader/XLSX/Manager/SharedStringsManager.php
+++ b/src/Spout/Reader/XLSX/Manager/SharedStringsManager.php
@@ -179,6 +179,7 @@ class SharedStringsManager
$sharedStringValue = '';
// NOTE: expand() will automatically decode all XML entities of the child nodes
+ /** @var \DOMElement $siNode */
$siNode = $xmlReader->expand();
$textNodes = $siNode->getElementsByTagName(self::XML_NODE_T);
@@ -241,7 +242,7 @@ class SharedStringsManager
*/
public function cleanup()
{
- if ($this->cachingStrategy) {
+ if ($this->cachingStrategy !== null) {
$this->cachingStrategy->clearCache();
}
}
diff --git a/src/Spout/Reader/XLSX/Manager/StyleManager.php b/src/Spout/Reader/XLSX/Manager/StyleManager.php
index 71eeead..6435f7c 100644
--- a/src/Spout/Reader/XLSX/Manager/StyleManager.php
+++ b/src/Spout/Reader/XLSX/Manager/StyleManager.php
@@ -60,10 +60,10 @@ class StyleManager
/** @var array Array containing the IDs of built-in number formats indicating a date */
protected $builtinNumFmtIdIndicatingDates;
- /** @var array Array containing a mapping NUM_FMT_ID => FORMAT_CODE */
+ /** @var array|null Array containing a mapping NUM_FMT_ID => FORMAT_CODE */
protected $customNumberFormats;
- /** @var array Array containing a mapping STYLE_ID => [STYLE_ATTRIBUTES] */
+ /** @var array|null Array containing a mapping STYLE_ID => [STYLE_ATTRIBUTES] */
protected $stylesAttributes;
/** @var array Cache containing a mapping NUM_FMT_ID => IS_DATE_FORMAT. Used to avoid lots of recalculations */
diff --git a/src/Spout/Reader/XLSX/Manager/WorkbookRelationshipsManager.php b/src/Spout/Reader/XLSX/Manager/WorkbookRelationshipsManager.php
index 7199f50..e022b34 100644
--- a/src/Spout/Reader/XLSX/Manager/WorkbookRelationshipsManager.php
+++ b/src/Spout/Reader/XLSX/Manager/WorkbookRelationshipsManager.php
@@ -34,7 +34,7 @@ class WorkbookRelationshipsManager
/** @var InternalEntityFactory Factory to create entities */
private $entityFactory;
- /** @var array Cache of the already read workbook relationships: [TYPE] => [FILE_NAME] */
+ /** @var array|null Cache of the already read workbook relationships: [TYPE] => [FILE_NAME] */
private $cachedWorkbookRelationships;
/**
diff --git a/src/Spout/Reader/XLSX/Reader.php b/src/Spout/Reader/XLSX/Reader.php
index 689f6e2..a031bb7 100644
--- a/src/Spout/Reader/XLSX/Reader.php
+++ b/src/Spout/Reader/XLSX/Reader.php
@@ -119,11 +119,11 @@ class Reader extends ReaderAbstract
*/
protected function closeReader()
{
- if ($this->zip) {
+ if ($this->zip !== null) {
$this->zip->close();
}
- if ($this->sharedStringsManager) {
+ if ($this->sharedStringsManager !== null) {
$this->sharedStringsManager->cleanup();
}
}
diff --git a/src/Spout/Reader/XLSX/RowIterator.php b/src/Spout/Reader/XLSX/RowIterator.php
index e9cafdd..fcb2b88 100644
--- a/src/Spout/Reader/XLSX/RowIterator.php
+++ b/src/Spout/Reader/XLSX/RowIterator.php
@@ -139,7 +139,7 @@ class RowIterator implements IteratorInterface
* @throws \Box\Spout\Common\Exception\IOException If the sheet data XML cannot be read
* @return void
*/
- public function rewind()
+ public function rewind() : void
{
$this->xmlReader->close();
@@ -163,7 +163,7 @@ class RowIterator implements IteratorInterface
*
* @return bool
*/
- public function valid()
+ public function valid() : bool
{
return (!$this->hasReachedEndOfFile);
}
@@ -176,7 +176,7 @@ class RowIterator implements IteratorInterface
* @throws \Box\Spout\Common\Exception\IOException If unable to read the sheet data XML
* @return void
*/
- public function next()
+ public function next() : void
{
$this->nextRowIndexToBeProcessed++;
@@ -276,6 +276,7 @@ class RowIterator implements IteratorInterface
$currentColumnIndex = $this->getColumnIndex($xmlReader);
// NOTE: expand() will automatically decode all XML entities of the child nodes
+ /** @var \DOMElement $node */
$node = $xmlReader->expand();
$cell = $this->getCell($node);
@@ -352,7 +353,7 @@ class RowIterator implements IteratorInterface
/**
* Returns the cell with (unescaped) correctly marshalled, cell value associated to the given XML node.
*
- * @param \DOMNode $node
+ * @param \DOMElement $node
* @return Cell The cell set with the associated with the cell
*/
protected function getCell($node)
@@ -374,7 +375,7 @@ class RowIterator implements IteratorInterface
*
* @return Row|null
*/
- public function current()
+ public function current() : ?Row
{
$rowToBeProcessed = $this->rowBuffer;
@@ -399,7 +400,7 @@ class RowIterator implements IteratorInterface
*
* @return int
*/
- public function key()
+ public function key() : int
{
// TODO: This should return $this->nextRowIndexToBeProcessed
// but to avoid a breaking change, the return value for
@@ -414,7 +415,7 @@ class RowIterator implements IteratorInterface
*
* @return void
*/
- public function end()
+ public function end() : void
{
$this->xmlReader->close();
}
diff --git a/src/Spout/Writer/Common/Entity/Worksheet.php b/src/Spout/Writer/Common/Entity/Worksheet.php
index 74c4976..1e496f0 100644
--- a/src/Spout/Writer/Common/Entity/Worksheet.php
+++ b/src/Spout/Writer/Common/Entity/Worksheet.php
@@ -11,7 +11,7 @@ class Worksheet
/** @var string Path to the XML file that will contain the sheet data */
private $filePath;
- /** @var resource Pointer to the sheet data file (e.g. xl/worksheets/sheet1.xml) */
+ /** @var resource|null Pointer to the sheet data file (e.g. xl/worksheets/sheet1.xml) */
private $filePointer;
/** @var Sheet The "external" sheet */
diff --git a/src/Spout/Writer/Common/Manager/Style/StyleMerger.php b/src/Spout/Writer/Common/Manager/Style/StyleMerger.php
index 806c8d5..cdc45d5 100644
--- a/src/Spout/Writer/Common/Manager/Style/StyleMerger.php
+++ b/src/Spout/Writer/Common/Manager/Style/StyleMerger.php
@@ -88,10 +88,10 @@ class StyleMerger
if (!$style->hasSetCellAlignment() && $baseStyle->shouldApplyCellAlignment()) {
$styleToUpdate->setCellAlignment($baseStyle->getCellAlignment());
}
- if (!$style->getBorder() && $baseStyle->shouldApplyBorder()) {
+ if ($style->getBorder() === null && $baseStyle->shouldApplyBorder()) {
$styleToUpdate->setBorder($baseStyle->getBorder());
}
- if (!$style->getFormat() && $baseStyle->shouldApplyFormat()) {
+ if ($style->getFormat() === null && $baseStyle->shouldApplyFormat()) {
$styleToUpdate->setFormat($baseStyle->getFormat());
}
if (!$style->shouldApplyBackgroundColor() && $baseStyle->shouldApplyBackgroundColor()) {
diff --git a/src/Spout/Writer/Common/Manager/WorkbookManagerAbstract.php b/src/Spout/Writer/Common/Manager/WorkbookManagerAbstract.php
index 653778c..9b25e15 100644
--- a/src/Spout/Writer/Common/Manager/WorkbookManagerAbstract.php
+++ b/src/Spout/Writer/Common/Manager/WorkbookManagerAbstract.php
@@ -23,7 +23,7 @@ use Box\Spout\Writer\Exception\WriterException;
*/
abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
{
- /** @var Workbook The workbook to manage */
+ /** @var Workbook|null The workbook to manage */
protected $workbook;
/** @var OptionsManagerInterface */
@@ -92,7 +92,7 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
abstract protected function getWorksheetFilePath(Sheet $sheet);
/**
- * @return Workbook
+ * @return Workbook|null
*/
public function getWorkbook()
{
diff --git a/src/Spout/Writer/Common/Manager/WorkbookManagerInterface.php b/src/Spout/Writer/Common/Manager/WorkbookManagerInterface.php
index aed304a..526163d 100644
--- a/src/Spout/Writer/Common/Manager/WorkbookManagerInterface.php
+++ b/src/Spout/Writer/Common/Manager/WorkbookManagerInterface.php
@@ -17,7 +17,7 @@ use Box\Spout\Writer\Exception\WriterException;
interface WorkbookManagerInterface
{
/**
- * @return Workbook
+ * @return Workbook|null
*/
public function getWorkbook();
diff --git a/src/Spout/Writer/ODS/Creator/HelperFactory.php b/src/Spout/Writer/ODS/Creator/HelperFactory.php
index e6aa645..cdc5a6a 100644
--- a/src/Spout/Writer/ODS/Creator/HelperFactory.php
+++ b/src/Spout/Writer/ODS/Creator/HelperFactory.php
@@ -30,7 +30,7 @@ class HelperFactory extends \Box\Spout\Common\Creator\HelperFactory
}
/**
- * @param $entityFactory
+ * @param InternalEntityFactory $entityFactory
* @return ZipHelper
*/
private function createZipHelper($entityFactory)
diff --git a/src/Spout/Writer/ODS/Manager/WorksheetManager.php b/src/Spout/Writer/ODS/Manager/WorksheetManager.php
index 3b8da63..345d1fb 100644
--- a/src/Spout/Writer/ODS/Manager/WorksheetManager.php
+++ b/src/Spout/Writer/ODS/Manager/WorksheetManager.php
@@ -86,7 +86,7 @@ class WorksheetManager implements WorksheetManagerInterface
* Returns the table XML root node as string.
*
* @param Worksheet $worksheet
- * @return string
node as string
+ * @return string "" node as string
*/
public function getTableElementStartAsString(Worksheet $worksheet)
{
diff --git a/src/Spout/Writer/WriterAbstract.php b/src/Spout/Writer/WriterAbstract.php
index 36a583f..fa43c97 100644
--- a/src/Spout/Writer/WriterAbstract.php
+++ b/src/Spout/Writer/WriterAbstract.php
@@ -169,7 +169,7 @@ abstract class WriterAbstract implements WriterInterface
*/
protected function throwIfFilePointerIsNotAvailable()
{
- if (!$this->filePointer) {
+ if (!is_resource($this->filePointer)) {
throw new IOException('File pointer has not be opened');
}
}
diff --git a/src/Spout/Writer/WriterMultiSheetsAbstract.php b/src/Spout/Writer/WriterMultiSheetsAbstract.php
index 8170b67..18b40bd 100644
--- a/src/Spout/Writer/WriterMultiSheetsAbstract.php
+++ b/src/Spout/Writer/WriterMultiSheetsAbstract.php
@@ -9,7 +9,6 @@ use Box\Spout\Common\Manager\OptionsManagerInterface;
use Box\Spout\Writer\Common\Creator\ManagerFactoryInterface;
use Box\Spout\Writer\Common\Entity\Options;
use Box\Spout\Writer\Common\Entity\Sheet;
-use Box\Spout\Writer\Common\Entity\Worksheet;
use Box\Spout\Writer\Common\Manager\WorkbookManagerInterface;
use Box\Spout\Writer\Exception\SheetNotFoundException;
use Box\Spout\Writer\Exception\WriterAlreadyOpenedException;
@@ -25,7 +24,7 @@ abstract class WriterMultiSheetsAbstract extends WriterAbstract
/** @var ManagerFactoryInterface */
private $managerFactory;
- /** @var WorkbookManagerInterface */
+ /** @var WorkbookManagerInterface|null */
private $workbookManager;
/**
@@ -66,7 +65,7 @@ abstract class WriterMultiSheetsAbstract extends WriterAbstract
*/
protected function openWriter()
{
- if (!$this->workbookManager) {
+ if ($this->workbookManager === null) {
$this->workbookManager = $this->managerFactory->createWorkbookManager($this->optionsManager);
$this->workbookManager->addNewSheetAndMakeItCurrent();
}
@@ -85,7 +84,6 @@ abstract class WriterMultiSheetsAbstract extends WriterAbstract
$externalSheets = [];
$worksheets = $this->workbookManager->getWorksheets();
- /** @var Worksheet $worksheet */
foreach ($worksheets as $worksheet) {
$externalSheets[] = $worksheet->getExternalSheet();
}
@@ -143,7 +141,7 @@ abstract class WriterMultiSheetsAbstract extends WriterAbstract
*/
protected function throwIfWorkbookIsNotAvailable()
{
- if (!$this->workbookManager->getWorkbook()) {
+ if ($this->workbookManager->getWorkbook() === null) {
throw new WriterNotOpenedException('The writer must be opened before performing this action.');
}
}
@@ -162,7 +160,7 @@ abstract class WriterMultiSheetsAbstract extends WriterAbstract
*/
protected function closeWriter()
{
- if ($this->workbookManager) {
+ if ($this->workbookManager !== null) {
$this->workbookManager->close($this->filePointer);
}
}
diff --git a/src/Spout/Writer/XLSX/Creator/ManagerFactory.php b/src/Spout/Writer/XLSX/Creator/ManagerFactory.php
index aa3bcd5..5865268 100644
--- a/src/Spout/Writer/XLSX/Creator/ManagerFactory.php
+++ b/src/Spout/Writer/XLSX/Creator/ManagerFactory.php
@@ -91,8 +91,7 @@ class ManagerFactory implements ManagerFactoryInterface
$styleMerger,
$sharedStringsManager,
$stringsEscaper,
- $stringsHelper,
- $this->entityFactory
+ $stringsHelper
);
}
diff --git a/src/Spout/Writer/XLSX/Manager/SharedStringsManager.php b/src/Spout/Writer/XLSX/Manager/SharedStringsManager.php
index da21f7b..9a82cff 100644
--- a/src/Spout/Writer/XLSX/Manager/SharedStringsManager.php
+++ b/src/Spout/Writer/XLSX/Manager/SharedStringsManager.php
@@ -59,7 +59,7 @@ EOD;
*/
protected function throwIfSharedStringsFilePointerIsNotAvailable()
{
- if (!$this->sharedStringsFilePointer) {
+ if (!is_resource($this->sharedStringsFilePointer)) {
throw new IOException('Unable to open shared strings file for writing.');
}
}
diff --git a/src/Spout/Writer/XLSX/Manager/Style/StyleManager.php b/src/Spout/Writer/XLSX/Manager/Style/StyleManager.php
index f0ca9d9..4a72b2f 100644
--- a/src/Spout/Writer/XLSX/Manager/Style/StyleManager.php
+++ b/src/Spout/Writer/XLSX/Manager/Style/StyleManager.php
@@ -2,6 +2,7 @@
namespace Box\Spout\Writer\XLSX\Manager\Style;
+use Box\Spout\Common\Entity\Style\BorderPart;
use Box\Spout\Common\Entity\Style\Color;
use Box\Spout\Common\Entity\Style\Style;
use Box\Spout\Writer\XLSX\Helper\BorderHelper;
@@ -186,7 +187,7 @@ EOD;
$content .= '';
foreach ($registeredBorders as $styleId) {
- /** @var \Box\Spout\Common\Entity\Style\Style $style */
+ /** @var Style $style */
$style = $this->styleRegistry->getStyleFromStyleId($styleId);
$border = $style->getBorder();
$content .= '';
@@ -196,7 +197,7 @@ EOD;
foreach ($sortOrder as $partName) {
if ($border->hasPart($partName)) {
- /** @var $part \Box\Spout\Common\Entity\Style\BorderPart */
+ /** @var BorderPart $part */
$part = $border->getPart($partName);
$content .= BorderHelper::serializeBorderPart($part);
}
diff --git a/src/Spout/Writer/XLSX/Manager/WorksheetManager.php b/src/Spout/Writer/XLSX/Manager/WorksheetManager.php
index 96688e2..18464b7 100644
--- a/src/Spout/Writer/XLSX/Manager/WorksheetManager.php
+++ b/src/Spout/Writer/XLSX/Manager/WorksheetManager.php
@@ -10,7 +10,6 @@ use Box\Spout\Common\Exception\IOException;
use Box\Spout\Common\Helper\Escaper\XLSX as XLSXEscaper;
use Box\Spout\Common\Helper\StringHelper;
use Box\Spout\Common\Manager\OptionsManagerInterface;
-use Box\Spout\Writer\Common\Creator\InternalEntityFactory;
use Box\Spout\Writer\Common\Entity\Options;
use Box\Spout\Writer\Common\Entity\Worksheet;
use Box\Spout\Writer\Common\Helper\CellHelper;
@@ -60,9 +59,6 @@ EOD;
/** @var StringHelper String helper */
private $stringHelper;
- /** @var InternalEntityFactory Factory to create entities */
- private $entityFactory;
-
/**
* WorksheetManager constructor.
*
@@ -73,7 +69,6 @@ EOD;
* @param SharedStringsManager $sharedStringsManager
* @param XLSXEscaper $stringsEscaper
* @param StringHelper $stringHelper
- * @param InternalEntityFactory $entityFactory
*/
public function __construct(
OptionsManagerInterface $optionsManager,
@@ -82,8 +77,7 @@ EOD;
StyleMerger $styleMerger,
SharedStringsManager $sharedStringsManager,
XLSXEscaper $stringsEscaper,
- StringHelper $stringHelper,
- InternalEntityFactory $entityFactory
+ StringHelper $stringHelper
) {
$this->shouldUseInlineStrings = $optionsManager->getOption(Options::SHOULD_USE_INLINE_STRINGS);
$this->rowManager = $rowManager;
@@ -92,7 +86,6 @@ EOD;
$this->sharedStringsManager = $sharedStringsManager;
$this->stringsEscaper = $stringsEscaper;
$this->stringHelper = $stringHelper;
- $this->entityFactory = $entityFactory;
}
/**
diff --git a/tests/Spout/Common/Entity/RowTest.php b/tests/Spout/Common/Entity/RowTest.php
index 9aa12f6..bc58499 100644
--- a/tests/Spout/Common/Entity/RowTest.php
+++ b/tests/Spout/Common/Entity/RowTest.php
@@ -7,7 +7,7 @@ use Box\Spout\Common\Entity\Style\Style;
class RowTest extends \PHPUnit\Framework\TestCase
{
/**
- * @return \PHPUnit_Framework_MockObject_MockObject|Style
+ * @return \PHPUnit\Framework\MockObject\MockObject|Style
*/
private function getStyleMock()
{
@@ -15,7 +15,7 @@ class RowTest extends \PHPUnit\Framework\TestCase
}
/**
- * @return \PHPUnit_Framework_MockObject_MockObject|Cell
+ * @return \PHPUnit\Framework\MockObject\MockObject|Cell
*/
private function getCellMock()
{
diff --git a/tests/Spout/Common/Entity/Style/BorderTest.php b/tests/Spout/Common/Entity/Style/BorderTest.php
index fa1e7ef..bb89af7 100644
--- a/tests/Spout/Common/Entity/Style/BorderTest.php
+++ b/tests/Spout/Common/Entity/Style/BorderTest.php
@@ -113,7 +113,7 @@ class BorderTest extends TestCase
$border->addPart($borderPart);
$this->assertCount(1, $border->getParts());
- /** @var $part BorderPart */
+ /** @var BorderPart $part */
$part = $border->getParts()[$allowedName];
$this->assertEquals($allowedStyle, $part->getStyle());
diff --git a/tests/Spout/Common/Helper/EncodingHelperTest.php b/tests/Spout/Common/Helper/EncodingHelperTest.php
index 8d3c158..ad4dd91 100644
--- a/tests/Spout/Common/Helper/EncodingHelperTest.php
+++ b/tests/Spout/Common/Helper/EncodingHelperTest.php
@@ -68,15 +68,15 @@ class EncodingHelperTest extends TestCase
$this->expectException(EncodingConversionException::class);
$helperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\GlobalFunctionsHelper')
- ->setMethods(['iconv', 'mb_convert_encoding'])
+ ->onlyMethods(['iconv', 'mb_convert_encoding'])
->getMock();
$helperStub->method('iconv')->willReturn(false);
$helperStub->method('mb_convert_encoding')->willReturn(false);
- /** @var EncodingHelper $encodingHelperStub */
+ /** @var EncodingHelper|\PHPUnit\Framework\MockObject\MockObject|\PHPUnit\Framework\MockObject\MockObject $encodingHelperStub */
$encodingHelperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\EncodingHelper')
->setConstructorArgs([$helperStub])
- ->setMethods(['canUseIconv', 'canUseMbString'])
+ ->onlyMethods(['canUseIconv', 'canUseMbString'])
->getMock();
$encodingHelperStub->method('canUseIconv')->willReturn($shouldUseIconv);
$encodingHelperStub->method('canUseMbString')->willReturn(true);
@@ -91,10 +91,10 @@ class EncodingHelperTest extends TestCase
{
$this->expectException(EncodingConversionException::class);
- /** @var EncodingHelper $encodingHelperStub */
+ /** @var EncodingHelper|\PHPUnit\Framework\MockObject\MockObject|\PHPUnit\Framework\MockObject\MockObject $encodingHelperStub */
$encodingHelperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\EncodingHelper')
->disableOriginalConstructor()
- ->setMethods(['canUseIconv', 'canUseMbString'])
+ ->onlyMethods(['canUseIconv', 'canUseMbString'])
->getMock();
$encodingHelperStub->method('canUseIconv')->willReturn(false);
$encodingHelperStub->method('canUseMbString')->willReturn(false);
@@ -110,10 +110,10 @@ class EncodingHelperTest extends TestCase
*/
public function testAttemptConversionToUTF8ShouldReturnReencodedString($shouldUseIconv)
{
- /** @var EncodingHelper $encodingHelperStub */
+ /** @var EncodingHelper|\PHPUnit\Framework\MockObject\MockObject $encodingHelperStub */
$encodingHelperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\EncodingHelper')
->setConstructorArgs([new GlobalFunctionsHelper()])
- ->setMethods(['canUseIconv', 'canUseMbString'])
+ ->onlyMethods(['canUseIconv', 'canUseMbString'])
->getMock();
$encodingHelperStub->method('canUseIconv')->willReturn($shouldUseIconv);
$encodingHelperStub->method('canUseMbString')->willReturn(true);
@@ -129,10 +129,10 @@ class EncodingHelperTest extends TestCase
*/
public function testAttemptConversionToUTF8ShouldBeNoopWhenTargetIsUTF8()
{
- /** @var EncodingHelper $encodingHelperStub */
+ /** @var EncodingHelper|\PHPUnit\Framework\MockObject\MockObject|\PHPUnit\Framework\MockObject\MockObject $encodingHelperStub */
$encodingHelperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\EncodingHelper')
->disableOriginalConstructor()
- ->setMethods(['canUseIconv'])
+ ->onlyMethods(['canUseIconv'])
->getMock();
$encodingHelperStub->expects($this->never())->method('canUseIconv');
@@ -151,15 +151,15 @@ class EncodingHelperTest extends TestCase
$this->expectException(EncodingConversionException::class);
$helperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\GlobalFunctionsHelper')
- ->setMethods(['iconv', 'mb_convert_encoding'])
+ ->onlyMethods(['iconv', 'mb_convert_encoding'])
->getMock();
$helperStub->method('iconv')->willReturn(false);
$helperStub->method('mb_convert_encoding')->willReturn(false);
- /** @var EncodingHelper $encodingHelperStub */
+ /** @var EncodingHelper|\PHPUnit\Framework\MockObject\MockObject|\PHPUnit\Framework\MockObject\MockObject $encodingHelperStub */
$encodingHelperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\EncodingHelper')
->setConstructorArgs([$helperStub])
- ->setMethods(['canUseIconv', 'canUseMbString'])
+ ->onlyMethods(['canUseIconv', 'canUseMbString'])
->getMock();
$encodingHelperStub->method('canUseIconv')->willReturn($shouldUseIconv);
$encodingHelperStub->method('canUseMbString')->willReturn(true);
@@ -174,10 +174,10 @@ class EncodingHelperTest extends TestCase
{
$this->expectException(EncodingConversionException::class);
- /** @var EncodingHelper $encodingHelperStub */
+ /** @var EncodingHelper|\PHPUnit\Framework\MockObject\MockObject|\PHPUnit\Framework\MockObject\MockObject $encodingHelperStub */
$encodingHelperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\EncodingHelper')
->disableOriginalConstructor()
- ->setMethods(['canUseIconv', 'canUseMbString'])
+ ->onlyMethods(['canUseIconv', 'canUseMbString'])
->getMock();
$encodingHelperStub->method('canUseIconv')->willReturn(false);
$encodingHelperStub->method('canUseMbString')->willReturn(false);
@@ -193,10 +193,10 @@ class EncodingHelperTest extends TestCase
*/
public function testAttemptConversionFromUTF8ShouldReturnReencodedString($shouldUseIconv)
{
- /** @var EncodingHelper $encodingHelperStub */
+ /** @var EncodingHelper|\PHPUnit\Framework\MockObject\MockObject $encodingHelperStub */
$encodingHelperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\EncodingHelper')
->setConstructorArgs([new GlobalFunctionsHelper()])
- ->setMethods(['canUseIconv', 'canUseMbString'])
+ ->onlyMethods(['canUseIconv', 'canUseMbString'])
->getMock();
$encodingHelperStub->method('canUseIconv')->willReturn($shouldUseIconv);
$encodingHelperStub->method('canUseMbString')->willReturn(true);
@@ -212,10 +212,10 @@ class EncodingHelperTest extends TestCase
*/
public function testAttemptConversionFromUTF8ShouldBeNoopWhenTargetIsUTF8()
{
- /** @var EncodingHelper $encodingHelperStub */
+ /** @var EncodingHelper|\PHPUnit\Framework\MockObject\MockObject $encodingHelperStub */
$encodingHelperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\EncodingHelper')
->disableOriginalConstructor()
- ->setMethods(['canUseIconv'])
+ ->onlyMethods(['canUseIconv'])
->getMock();
$encodingHelperStub->expects($this->never())->method('canUseIconv');
diff --git a/tests/Spout/Common/Helper/FileSystemHelperTest.php b/tests/Spout/Common/Helper/FileSystemHelperTest.php
index 7eb0183..0eb314e 100644
--- a/tests/Spout/Common/Helper/FileSystemHelperTest.php
+++ b/tests/Spout/Common/Helper/FileSystemHelperTest.php
@@ -10,7 +10,7 @@ use PHPUnit\Framework\TestCase;
*/
class FileSystemHelperTest extends TestCase
{
- /** @var \Box\Spout\Writer\XLSX\Helper\FileSystemHelper */
+ /** @var FileSystemHelper */
protected $fileSystemHelper;
/**
diff --git a/tests/Spout/Reader/CSV/ReaderTest.php b/tests/Spout/Reader/CSV/ReaderTest.php
index 1d092f0..78f1d42 100644
--- a/tests/Spout/Reader/CSV/ReaderTest.php
+++ b/tests/Spout/Reader/CSV/ReaderTest.php
@@ -47,9 +47,9 @@ class ReaderTest extends TestCase
{
$this->expectException(IOException::class);
- /** @var \Box\Spout\Common\Helper\GlobalFunctionsHelper|\PHPUnit_Framework_MockObject_MockObject $helperStub */
+ /** @var \Box\Spout\Common\Helper\GlobalFunctionsHelper|\PHPUnit\Framework\MockObject\MockObject $helperStub */
$helperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\GlobalFunctionsHelper')
- ->setMethods(['is_readable'])
+ ->onlyMethods(['is_readable'])
->getMock();
$helperStub->method('is_readable')->willReturn(false);
@@ -66,9 +66,9 @@ class ReaderTest extends TestCase
{
$this->expectException(IOException::class);
- /** @var \Box\Spout\Common\Helper\GlobalFunctionsHelper|\PHPUnit_Framework_MockObject_MockObject $helperStub */
+ /** @var \Box\Spout\Common\Helper\GlobalFunctionsHelper|\PHPUnit\Framework\MockObject\MockObject $helperStub */
$helperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\GlobalFunctionsHelper')
- ->setMethods(['fopen'])
+ ->onlyMethods(['fopen'])
->getMock();
$helperStub->method('fopen')->willReturn(false);
@@ -304,9 +304,9 @@ class ReaderTest extends TestCase
$allRows = [];
$resourcePath = $this->getResourcePath($fileName);
- /** @var \Box\Spout\Common\Helper\GlobalFunctionsHelper|\PHPUnit_Framework_MockObject_MockObject $helperStub */
+ /** @var \Box\Spout\Common\Helper\GlobalFunctionsHelper|\PHPUnit\Framework\MockObject\MockObject $helperStub */
$helperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\GlobalFunctionsHelper')
- ->setMethods(['function_exists'])
+ ->onlyMethods(['function_exists'])
->getMock();
$returnValueMap = [
diff --git a/tests/Spout/Reader/XLSX/Helper/CellValueFormatterTest.php b/tests/Spout/Reader/XLSX/Helper/CellValueFormatterTest.php
index f981a63..db51f9b 100644
--- a/tests/Spout/Reader/XLSX/Helper/CellValueFormatterTest.php
+++ b/tests/Spout/Reader/XLSX/Helper/CellValueFormatterTest.php
@@ -79,7 +79,7 @@ class CellValueFormatterTest extends TestCase
->method('getAttribute')
->will($this->returnValueMap([
[CellValueFormatter::XML_ATTRIBUTE_TYPE, CellValueFormatter::CELL_TYPE_NUMERIC],
- [CellValueFormatter::XML_ATTRIBUTE_STYLE_ID, 123],
+ [CellValueFormatter::XML_ATTRIBUTE_STYLE_ID, '123'],
]));
$nodeMock
@@ -88,7 +88,7 @@ class CellValueFormatterTest extends TestCase
->with(CellValueFormatter::XML_NODE_VALUE)
->will($this->returnValue($nodeListMock));
- /** @var StyleManager|\PHPUnit_Framework_MockObject_MockObject $styleManagerMock */
+ /** @var StyleManager|\PHPUnit\Framework\MockObject\MockObject $styleManagerMock */
$styleManagerMock = $this->createMock(StyleManager::class);
$styleManagerMock
@@ -149,7 +149,7 @@ class CellValueFormatterTest extends TestCase
*/
public function testFormatNumericCellValueWithNumbers($value, $expectedFormattedValue, $expectedType)
{
- /** @var StyleManager|\PHPUnit_Framework_MockObject_MockObject $styleManagerMock */
+ /** @var StyleManager|\PHPUnit\Framework\MockObject\MockObject $styleManagerMock */
$styleManagerMock = $this->createMock(StyleManager::class);
$styleManagerMock
->expects($this->once())
diff --git a/tests/Spout/Reader/XLSX/Manager/SharedStringsCaching/CachingStrategyFactoryTest.php b/tests/Spout/Reader/XLSX/Manager/SharedStringsCaching/CachingStrategyFactoryTest.php
index 6216b40..5b75cbd 100644
--- a/tests/Spout/Reader/XLSX/Manager/SharedStringsCaching/CachingStrategyFactoryTest.php
+++ b/tests/Spout/Reader/XLSX/Manager/SharedStringsCaching/CachingStrategyFactoryTest.php
@@ -36,11 +36,11 @@ class CachingStrategyFactoryTest extends TestCase
*/
public function testCreateBestCachingStrategy($sharedStringsUniqueCount, $memoryLimitInKB, $expectedStrategyClassName)
{
- /** @var CachingStrategyFactory|\PHPUnit_Framework_MockObject_MockObject $factoryStub */
+ /** @var CachingStrategyFactory|\PHPUnit\Framework\MockObject\MockObject $factoryStub */
$factoryStub = $this
->getMockBuilder('\Box\Spout\Reader\XLSX\Manager\SharedStringsCaching\CachingStrategyFactory')
->disableOriginalConstructor()
- ->setMethods(['getMemoryLimitInKB'])
+ ->onlyMethods(['getMemoryLimitInKB'])
->getMock();
$factoryStub->method('getMemoryLimitInKB')->willReturn($memoryLimitInKB);
@@ -84,11 +84,11 @@ class CachingStrategyFactoryTest extends TestCase
*/
public function testGetMemoryLimitInKB($memoryLimitFormatted, $expectedMemoryLimitInKB)
{
- /** @var CachingStrategyFactory|\PHPUnit_Framework_MockObject_MockObject $factoryStub */
+ /** @var CachingStrategyFactory|\PHPUnit\Framework\MockObject\MockObject $factoryStub */
$factoryStub = $this
->getMockBuilder('\Box\Spout\Reader\XLSX\Manager\SharedStringsCaching\CachingStrategyFactory')
->disableOriginalConstructor()
- ->setMethods(['getMemoryLimitFromIni'])
+ ->onlyMethods(['getMemoryLimitFromIni'])
->getMock();
$factoryStub->method('getMemoryLimitFromIni')->willReturn($memoryLimitFormatted);
diff --git a/tests/Spout/Reader/XLSX/Manager/SharedStringsManagerTest.php b/tests/Spout/Reader/XLSX/Manager/SharedStringsManagerTest.php
index f344b35..4c3e512 100644
--- a/tests/Spout/Reader/XLSX/Manager/SharedStringsManagerTest.php
+++ b/tests/Spout/Reader/XLSX/Manager/SharedStringsManagerTest.php
@@ -19,7 +19,7 @@ class SharedStringsManagerTest extends TestCase
{
use TestUsingResource;
- /** @var SharedStringsManager */
+ /** @var SharedStringsManager|null */
private $sharedStringsManager;
/**
diff --git a/tests/Spout/Reader/XLSX/Manager/StyleManagerTest.php b/tests/Spout/Reader/XLSX/Manager/StyleManagerTest.php
index 794f4bc..7a98f0e 100644
--- a/tests/Spout/Reader/XLSX/Manager/StyleManagerTest.php
+++ b/tests/Spout/Reader/XLSX/Manager/StyleManagerTest.php
@@ -21,10 +21,10 @@ class StyleManagerTest extends TestCase
$workbookRelationshipsManager = $this->createMock(WorkbookRelationshipsManager::class);
$workbookRelationshipsManager->method('hasStylesXMLFile')->willReturn(true);
- /** @var StyleManager $styleManager */
+ /** @var StyleManager|\PHPUnit\Framework\MockObject\MockObject $styleManager */
$styleManager = $this->getMockBuilder('\Box\Spout\Reader\XLSX\Manager\StyleManager')
->setConstructorArgs(['/path/to/file.xlsx', $workbookRelationshipsManager, $entityFactory])
- ->setMethods(['getCustomNumberFormats', 'getStylesAttributes'])
+ ->onlyMethods(['getCustomNumberFormats', 'getStylesAttributes'])
->getMock();
$styleManager->method('getStylesAttributes')->willReturn($styleAttributes);
diff --git a/tests/Spout/ReflectionHelper.php b/tests/Spout/ReflectionHelper.php
index d958df0..e046046 100644
--- a/tests/Spout/ReflectionHelper.php
+++ b/tests/Spout/ReflectionHelper.php
@@ -95,7 +95,6 @@ class ReflectionHelper
*
* @param object $object
* @param string $methodName
- * @param *mixed|null $params
*
* @return mixed|null
*/
diff --git a/tests/Spout/Writer/CSV/WriterTest.php b/tests/Spout/Writer/CSV/WriterTest.php
index deb3f22..ccf5181 100644
--- a/tests/Spout/Writer/CSV/WriterTest.php
+++ b/tests/Spout/Writer/CSV/WriterTest.php
@@ -193,7 +193,7 @@ class WriterTest extends TestCase
* @param string $fieldDelimiter
* @param string $fieldEnclosure
* @param bool $shouldAddBOM
- * @return string|null
+ * @return string
*/
private function writeToCsvFileAndReturnWrittenContent($allRows, $fileName, $fieldDelimiter = ',', $fieldEnclosure = '"', $shouldAddBOM = true)
{
diff --git a/tests/Spout/Writer/ODS/WriterTest.php b/tests/Spout/Writer/ODS/WriterTest.php
index dc86f7c..1d1ff44 100644
--- a/tests/Spout/Writer/ODS/WriterTest.php
+++ b/tests/Spout/Writer/ODS/WriterTest.php
@@ -348,6 +348,7 @@ class WriterTest extends TestCase
$fileName = 'test_add_row_should_use_number_columns_repeated.ods';
$this->writeToODSFile($this->createRowsFromValues([$dataRow]), $fileName);
+ /** @var \DOMElement $sheetXmlNode */
$sheetXmlNode = $this->getSheetXmlNode($fileName, 1);
$tableCellNodes = $sheetXmlNode->getElementsByTagName('table-cell');
diff --git a/tests/Spout/Writer/ODS/WriterWithStyleTest.php b/tests/Spout/Writer/ODS/WriterWithStyleTest.php
index 75177da..3c7a6fd 100644
--- a/tests/Spout/Writer/ODS/WriterWithStyleTest.php
+++ b/tests/Spout/Writer/ODS/WriterWithStyleTest.php
@@ -88,6 +88,7 @@ class WriterWithStyleTest extends TestCase
$this->assertCount(3, $cellStyleElements, 'There should be 3 separate cell styles, including the default one.');
// Second font should contain data from the first created style
+ /** @var \DOMElement $customFont1Element */
$customFont1Element = $cellStyleElements[1];
$this->assertFirstChildHasAttributeEquals('bold', $customFont1Element, 'text-properties', 'fo:font-weight');
$this->assertFirstChildHasAttributeEquals('italic', $customFont1Element, 'text-properties', 'fo:font-style');
@@ -95,6 +96,7 @@ class WriterWithStyleTest extends TestCase
$this->assertFirstChildHasAttributeEquals('solid', $customFont1Element, 'text-properties', 'style:text-line-through-style');
// Third font should contain data from the second created style
+ /** @var \DOMElement $customFont2Element */
$customFont2Element = $cellStyleElements[2];
$this->assertFirstChildHasAttributeEquals('15pt', $customFont2Element, 'text-properties', 'fo:font-size');
$this->assertFirstChildHasAttributeEquals('#' . Color::RED, $customFont2Element, 'text-properties', 'fo:color');
@@ -397,7 +399,7 @@ class WriterWithStyleTest extends TestCase
/**
* @param string $fileName
- * @return \DOMNode[]
+ * @return \DOMElement[]
*/
private function getCellElementsFromContentXmlFile($fileName)
{
@@ -410,7 +412,9 @@ class WriterWithStyleTest extends TestCase
while ($xmlReader->read()) {
if ($xmlReader->isPositionedOnStartingNode('table:table-cell') && $xmlReader->getAttribute('office:value-type') !== null) {
- $cellElements[] = $xmlReader->expand();
+ /** @var \DOMElement $cellElement */
+ $cellElement = $xmlReader->expand();
+ $cellElements[] = $cellElement;
}
}
@@ -421,7 +425,7 @@ class WriterWithStyleTest extends TestCase
/**
* @param string $fileName
- * @return \DOMNode[]
+ * @return \DOMElement[]
*/
private function getCellStyleElementsFromContentXmlFile($fileName)
{
@@ -434,7 +438,9 @@ class WriterWithStyleTest extends TestCase
while ($xmlReader->read()) {
if ($xmlReader->isPositionedOnStartingNode('style:style') && $xmlReader->getAttribute('style:family') === 'table-cell') {
- $cellStyleElements[] = $xmlReader->expand();
+ /** @var \DOMElement $cellStyleElement */
+ $cellStyleElement = $xmlReader->expand();
+ $cellStyleElements[] = $cellStyleElement;
}
}
@@ -446,7 +452,7 @@ class WriterWithStyleTest extends TestCase
/**
* @param string $fileName
* @param string $section
- * @return \DomNode
+ * @return \DOMElement
*/
private function getXmlSectionFromStylesXmlFile($fileName, $section)
{
@@ -456,12 +462,15 @@ class WriterWithStyleTest extends TestCase
$xmlReader->openFileInZip($resourcePath, 'styles.xml');
$xmlReader->readUntilNodeFound($section);
- return $xmlReader->expand();
+ /** @var \DOMElement $element */
+ $element = $xmlReader->expand();
+
+ return $element;
}
/**
* @param string $expectedValue
- * @param \DOMNode $parentElement
+ * @param \DOMElement $parentElement
* @param string $childTagName
* @param string $attributeName
* @return void
diff --git a/tests/Spout/Writer/XLSX/Manager/Style/StyleManagerTest.php b/tests/Spout/Writer/XLSX/Manager/Style/StyleManagerTest.php
index 3bb0f42..1c21cc3 100644
--- a/tests/Spout/Writer/XLSX/Manager/Style/StyleManagerTest.php
+++ b/tests/Spout/Writer/XLSX/Manager/Style/StyleManagerTest.php
@@ -40,7 +40,7 @@ class StyleManagerTest extends TestCase
{
$styleRegistryMock = $this->getMockBuilder(StyleRegistry::class)
->disableOriginalConstructor()
- ->setMethods(['getFillIdForStyleId', 'getBorderIdForStyleId'])
+ ->onlyMethods(['getFillIdForStyleId', 'getBorderIdForStyleId'])
->getMock();
$styleRegistryMock
diff --git a/tests/Spout/Writer/XLSX/WriterPerfTest.php b/tests/Spout/Writer/XLSX/WriterPerfTest.php
index 66ff337..a0f6e90 100644
--- a/tests/Spout/Writer/XLSX/WriterPerfTest.php
+++ b/tests/Spout/Writer/XLSX/WriterPerfTest.php
@@ -102,7 +102,7 @@ class WriterPerfTest extends TestCase
/**
* @param string $filePath
- * @return string
+ * @return int
*/
private function getLasRowNumberForFile($filePath)
{
diff --git a/tests/Spout/Writer/XLSX/WriterWithStyleTest.php b/tests/Spout/Writer/XLSX/WriterWithStyleTest.php
index 2571df4..57859b6 100644
--- a/tests/Spout/Writer/XLSX/WriterWithStyleTest.php
+++ b/tests/Spout/Writer/XLSX/WriterWithStyleTest.php
@@ -92,6 +92,7 @@ class WriterWithStyleTest extends TestCase
$this->assertEquals(3, $fontElements->length, 'There should be 3 associated "font" elements, including the default one.');
// First font should be the default one
+ /** @var \DOMElement $defaultFontElement */
$defaultFontElement = $fontElements->item(0);
$this->assertChildrenNumEquals(3, $defaultFontElement, 'The default font should only have 3 properties.');
$this->assertFirstChildHasAttributeEquals((string) OptionsManager::DEFAULT_FONT_SIZE, $defaultFontElement, 'sz', 'val');
@@ -99,6 +100,7 @@ class WriterWithStyleTest extends TestCase
$this->assertFirstChildHasAttributeEquals(OptionsManager::DEFAULT_FONT_NAME, $defaultFontElement, 'name', 'val');
// Second font should contain data from the first created style
+ /** @var \DOMElement $secondFontElement */
$secondFontElement = $fontElements->item(1);
$this->assertChildrenNumEquals(7, $secondFontElement, 'The font should only have 7 properties (4 custom styles + 3 default styles).');
$this->assertChildExists($secondFontElement, 'b');
@@ -110,6 +112,7 @@ class WriterWithStyleTest extends TestCase
$this->assertFirstChildHasAttributeEquals(OptionsManager::DEFAULT_FONT_NAME, $secondFontElement, 'name', 'val');
// Third font should contain data from the second created style
+ /** @var \DOMElement $thirdFontElement */
$thirdFontElement = $fontElements->item(2);
$this->assertChildrenNumEquals(3, $thirdFontElement, 'The font should only have 3 properties.');
$this->assertFirstChildHasAttributeEquals('15', $thirdFontElement, 'sz', 'val');
@@ -394,10 +397,14 @@ class WriterWithStyleTest extends TestCase
'3 cell xfs present - a default one and two custom ones'
);
- $firstCustomId = $styleXfsElements->childNodes->item(1)->getAttribute('fillId');
+ /** @var \DOMElement $styleXfsElementChild1 */
+ $styleXfsElementChild1 = $styleXfsElements->childNodes->item(1);
+ $firstCustomId = $styleXfsElementChild1->getAttribute('fillId');
$this->assertEquals(2, (int) $firstCustomId, 'The first custom fill id should have the index 2');
- $secondCustomId = $styleXfsElements->childNodes->item(2)->getAttribute('fillId');
+ /** @var \DOMElement $styleXfsElementChild2 */
+ $styleXfsElementChild2 = $styleXfsElements->childNodes->item(2);
+ $secondCustomId = $styleXfsElementChild2->getAttribute('fillId');
$this->assertEquals(2, (int) $secondCustomId, 'The second custom fill id should have the index 2');
}
@@ -468,7 +475,6 @@ class WriterWithStyleTest extends TestCase
$borderParts = $borderNode->childNodes;
$ordering = [];
- /** @var \DOMText $part */
foreach ($borderParts as $part) {
if ($part instanceof \DOMElement) {
$ordering[] = $part->nodeName;
@@ -607,7 +613,7 @@ class WriterWithStyleTest extends TestCase
/**
* @param string $fileName
* @param string $section
- * @return \DomElement
+ * @return \DOMElement
*/
private function getXmlSectionFromStylesXmlFile($fileName, $section)
{
@@ -617,6 +623,7 @@ class WriterWithStyleTest extends TestCase
$xmlReader->openFileInZip($resourcePath, 'xl/styles.xml');
$xmlReader->readUntilNodeFound($section);
+ /** @var \DOMElement $xmlSection */
$xmlSection = $xmlReader->expand();
$xmlReader->close();
@@ -626,7 +633,7 @@ class WriterWithStyleTest extends TestCase
/**
* @param string $fileName
- * @return \DOMNode[]
+ * @return \DOMElement[]
*/
private function getCellElementsFromSheetXmlFile($fileName)
{
@@ -639,7 +646,9 @@ class WriterWithStyleTest extends TestCase
while ($xmlReader->read()) {
if ($xmlReader->isPositionedOnStartingNode('c')) {
- $cellElements[] = $xmlReader->expand();
+ /** @var \DOMElement $cellElement */
+ $cellElement = $xmlReader->expand();
+ $cellElements[] = $cellElement;
}
}
@@ -650,7 +659,7 @@ class WriterWithStyleTest extends TestCase
/**
* @param string $expectedValue
- * @param \DOMNode $parentElement
+ * @param \DOMElement $parentElement
* @param string $childTagName
* @param string $attributeName
* @return void
@@ -662,7 +671,7 @@ class WriterWithStyleTest extends TestCase
/**
* @param int $expectedNumber
- * @param \DOMNode $parentElement
+ * @param \DOMElement $parentElement
* @param string $message
* @return void
*/
@@ -672,7 +681,7 @@ class WriterWithStyleTest extends TestCase
}
/**
- * @param \DOMNode $parentElement
+ * @param \DOMElement $parentElement
* @param string $childTagName
* @return void
*/