PHPStan Level 3
This commit is contained in:
1 parent
64a09a748d
commit
e95e0eeefd
34 files changed
+122
-88
No files matched your search
@@ -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,7 +55,7 @@ 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)
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -105,7 +105,7 @@ class InternalEntityFactory implements InternalEntityFactoryInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $xmlReader
|
||||
* @param XMLReader $xmlReader
|
||||
* @return XMLProcessor
|
||||
*/
|
||||
private function createXMLProcessor($xmlReader)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 */
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@ class InternalEntityFactory implements InternalEntityFactoryInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $xmlReader
|
||||
* @param XMLReader $xmlReader
|
||||
* @return XMLProcessor
|
||||
*/
|
||||
public function createXMLProcessor($xmlReader)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -30,7 +30,7 @@ class HelperFactory extends \Box\Spout\Common\Creator\HelperFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $entityFactory
|
||||
* @param InternalEntityFactory $entityFactory
|
||||
* @return ZipHelper
|
||||
*/
|
||||
private function createZipHelper($entityFactory)
|
||||
|
||||
@@ -86,7 +86,7 @@ class WorksheetManager implements WorksheetManagerInterface
|
||||
* Returns the table XML root node as string.
|
||||
*
|
||||
* @param Worksheet $worksheet
|
||||
* @return string <table> node as string
|
||||
* @return string "<table>" node as string
|
||||
*/
|
||||
public function getTableElementStartAsString(Worksheet $worksheet)
|
||||
{
|
||||
|
||||
@@ -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 .= '<border><left/><right/><top/><bottom/></border>';
|
||||
|
||||
foreach ($registeredBorders as $styleId) {
|
||||
/** @var \Box\Spout\Common\Entity\Style\Style $style */
|
||||
/** @var Style $style */
|
||||
$style = $this->styleRegistry->getStyleFromStyleId($styleId);
|
||||
$border = $style->getBorder();
|
||||
$content .= '<border>';
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -240,6 +240,7 @@ EOD;
|
||||
} elseif ($cell->isBoolean()) {
|
||||
$cellXML .= ' t="b"><v>' . (int) ($cell->getValue()) . '</v></c>';
|
||||
} elseif ($cell->isNumeric()) {
|
||||
var_dump($cell);
|
||||
$cellXML .= '><v>' . $this->stringHelper->formatNumericValue($cell->getValue()) . '</v></c>';
|
||||
} elseif ($cell->isError() && is_string($cell->getValueEvenIfError())) {
|
||||
// only writes the error value if it's a string
|
||||
|
||||
Reference in new issue
Block a user