PHPStan Level 3
This commit is contained in:
parent
64a09a748d
commit
91554e7d8e
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -267,4 +267,4 @@ jobs:
|
|||||||
run: composer install --no-progress --prefer-dist --optimize-autoloader
|
run: composer install --no-progress --prefer-dist --optimize-autoloader
|
||||||
|
|
||||||
- name: Static Analysis using PHPStan
|
- name: Static Analysis using PHPStan
|
||||||
run: phpstan analyse --no-progress src tests
|
run: ./vendor/bin/phpstan analyse -c phpstan.neon --no-progress
|
||||||
|
9
phpstan.neon
Normal file
9
phpstan.neon
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
parameters:
|
||||||
|
level: 3
|
||||||
|
paths:
|
||||||
|
- src
|
||||||
|
- tests
|
||||||
|
excludePaths:
|
||||||
|
# Exclude these files that are OK
|
||||||
|
- src/Spout/Reader/Common/Creator/ReaderEntityFactory.php
|
||||||
|
- src/Spout/Writer/Common/Creator/WriterEntityFactory.php
|
@ -9,7 +9,7 @@ namespace Box\Spout\Common\Helper;
|
|||||||
class CellTypeHelper
|
class CellTypeHelper
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param $value
|
* @param mixed|null $value
|
||||||
* @return bool Whether the given value is considered "empty"
|
* @return bool Whether the given value is considered "empty"
|
||||||
*/
|
*/
|
||||||
public static function isEmpty($value)
|
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
|
* @return bool Whether the given value is a non empty string
|
||||||
*/
|
*/
|
||||||
public static function isNonEmptyString($value)
|
public static function isNonEmptyString($value)
|
||||||
@ -30,7 +30,7 @@ class CellTypeHelper
|
|||||||
* Returns whether the given value is numeric.
|
* Returns whether the given value is numeric.
|
||||||
* A numeric value is from type "integer" or "double" ("float" is not returned by gettype).
|
* 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
|
* @return bool Whether the given value is numeric
|
||||||
*/
|
*/
|
||||||
public static function isNumeric($value)
|
public static function isNumeric($value)
|
||||||
@ -44,7 +44,7 @@ class CellTypeHelper
|
|||||||
* Returns whether the given value is boolean.
|
* Returns whether the given value is boolean.
|
||||||
* "true"/"false" and 0/1 are not booleans.
|
* "true"/"false" and 0/1 are not booleans.
|
||||||
*
|
*
|
||||||
* @param $value
|
* @param mixed $value
|
||||||
* @return bool Whether the given value is boolean
|
* @return bool Whether the given value is boolean
|
||||||
*/
|
*/
|
||||||
public static function isBoolean($value)
|
public static function isBoolean($value)
|
||||||
@ -55,7 +55,7 @@ class CellTypeHelper
|
|||||||
/**
|
/**
|
||||||
* Returns whether the given value is a DateTime or DateInterval object.
|
* 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
|
* @return bool Whether the given value is a DateTime or DateInterval object
|
||||||
*/
|
*/
|
||||||
public static function isDateTimeOrDateInterval($value)
|
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.
|
* @see https://wiki.php.net/rfc/locale_independent_float_to_string for the changed behavior in PHP8.
|
||||||
*
|
*
|
||||||
* @param int|float $numericValue
|
* @param int|float $numericValue
|
||||||
* @return string
|
* @return int|float|string
|
||||||
*/
|
*/
|
||||||
public function formatNumericValue($numericValue)
|
public function formatNumericValue($numericValue)
|
||||||
{
|
{
|
||||||
|
@ -105,7 +105,7 @@ class InternalEntityFactory implements InternalEntityFactoryInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $xmlReader
|
* @param XMLReader $xmlReader
|
||||||
* @return XMLProcessor
|
* @return XMLProcessor
|
||||||
*/
|
*/
|
||||||
private function createXMLProcessor($xmlReader)
|
private function createXMLProcessor($xmlReader)
|
||||||
|
@ -64,7 +64,7 @@ class CellValueFormatter
|
|||||||
* Returns the (unescaped) correctly marshalled, cell value associated to the given XML node.
|
* 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
|
* @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
|
* @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
|
* @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.
|
* Returns the cell String value.
|
||||||
*
|
*
|
||||||
* @param \DOMNode $node
|
* @param \DOMElement $node
|
||||||
* @return string The value associated with the cell
|
* @return string The value associated with the cell
|
||||||
*/
|
*/
|
||||||
protected function formatStringCellValue($node)
|
protected function formatStringCellValue($node)
|
||||||
@ -115,7 +115,7 @@ class CellValueFormatter
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $pNode
|
* @param \DOMNode $pNode
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function extractTextValueFromNode($pNode)
|
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
|
* @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
|
* @return string The corresponding whitespace value
|
||||||
*/
|
*/
|
||||||
private function transformWhitespaceNode($node)
|
private function transformWhitespaceNode($node)
|
||||||
@ -173,7 +173,7 @@ class CellValueFormatter
|
|||||||
/**
|
/**
|
||||||
* Returns the cell Numeric value from the given node.
|
* Returns the cell Numeric value from the given node.
|
||||||
*
|
*
|
||||||
* @param \DOMNode $node
|
* @param \DOMElement $node
|
||||||
* @return int|float The value associated with the cell
|
* @return int|float The value associated with the cell
|
||||||
*/
|
*/
|
||||||
protected function formatFloatCellValue($node)
|
protected function formatFloatCellValue($node)
|
||||||
@ -190,7 +190,7 @@ class CellValueFormatter
|
|||||||
/**
|
/**
|
||||||
* Returns the cell Boolean value from the given node.
|
* Returns the cell Boolean value from the given node.
|
||||||
*
|
*
|
||||||
* @param \DOMNode $node
|
* @param \DOMElement $node
|
||||||
* @return bool The value associated with the cell
|
* @return bool The value associated with the cell
|
||||||
*/
|
*/
|
||||||
protected function formatBooleanCellValue($node)
|
protected function formatBooleanCellValue($node)
|
||||||
@ -203,7 +203,7 @@ class CellValueFormatter
|
|||||||
/**
|
/**
|
||||||
* Returns the cell Date value from the given node.
|
* 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
|
* @throws InvalidValueException If the value is not a valid date
|
||||||
* @return \DateTime|string The value associated with the cell
|
* @return \DateTime|string The value associated with the cell
|
||||||
*/
|
*/
|
||||||
@ -234,7 +234,7 @@ class CellValueFormatter
|
|||||||
/**
|
/**
|
||||||
* Returns the cell Time value from the given node.
|
* 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
|
* @throws InvalidValueException If the value is not a valid time
|
||||||
* @return \DateInterval|string The value associated with the cell
|
* @return \DateInterval|string The value associated with the cell
|
||||||
*/
|
*/
|
||||||
@ -265,7 +265,7 @@ class CellValueFormatter
|
|||||||
/**
|
/**
|
||||||
* Returns the cell Currency value from the given node.
|
* 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")
|
* @return string The value associated with the cell (e.g. "100 USD" or "9.99 EUR")
|
||||||
*/
|
*/
|
||||||
protected function formatCurrencyCellValue($node)
|
protected function formatCurrencyCellValue($node)
|
||||||
@ -279,7 +279,7 @@ class CellValueFormatter
|
|||||||
/**
|
/**
|
||||||
* Returns the cell Percentage value from the given node.
|
* Returns the cell Percentage value from the given node.
|
||||||
*
|
*
|
||||||
* @param \DOMNode $node
|
* @param \DOMElement $node
|
||||||
* @return int|float The value associated with the cell
|
* @return int|float The value associated with the cell
|
||||||
*/
|
*/
|
||||||
protected function formatPercentageCellValue($node)
|
protected function formatPercentageCellValue($node)
|
||||||
|
@ -56,7 +56,7 @@ class RowIterator implements IteratorInterface
|
|||||||
/** @var Row The currently processed row */
|
/** @var Row The currently processed row */
|
||||||
protected $currentlyProcessedRow;
|
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;
|
protected $rowBuffer;
|
||||||
|
|
||||||
/** @var bool Indicates whether all rows have been read */
|
/** @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) */
|
/** @var int Row index to be processed next (one-based) */
|
||||||
protected $nextRowIndexToBeProcessed = 1;
|
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;
|
protected $lastProcessedCell;
|
||||||
|
|
||||||
/** @var int Number of times the last processed row should be repeated */
|
/** @var int Number of times the last processed row should be repeated */
|
||||||
@ -225,6 +225,7 @@ class RowIterator implements IteratorInterface
|
|||||||
$currentNumColumnsRepeated = $this->getNumColumnsRepeatedForCurrentNode($xmlReader);
|
$currentNumColumnsRepeated = $this->getNumColumnsRepeatedForCurrentNode($xmlReader);
|
||||||
|
|
||||||
// NOTE: expand() will automatically decode all XML entities of the child nodes
|
// NOTE: expand() will automatically decode all XML entities of the child nodes
|
||||||
|
/** @var \DOMElement $node */
|
||||||
$node = $xmlReader->expand();
|
$node = $xmlReader->expand();
|
||||||
$currentCell = $this->getCell($node);
|
$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.
|
* 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
|
* @return Cell The cell set with the associated with the cell
|
||||||
*/
|
*/
|
||||||
protected function getCell($node)
|
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).
|
* row data yet (as we still need to apply the "num-columns-repeated" attribute).
|
||||||
*
|
*
|
||||||
* @param Row $currentRow
|
* @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
|
* @return bool Whether the row is empty
|
||||||
*/
|
*/
|
||||||
protected function isEmptyRow($currentRow, $lastReadCell)
|
protected function isEmptyRow($currentRow, $lastReadCell)
|
||||||
|
@ -108,6 +108,7 @@ class SheetIterator implements IteratorInterface
|
|||||||
$sheetsVisibility = [];
|
$sheetsVisibility = [];
|
||||||
|
|
||||||
$this->xmlReader->readUntilNodeFound(self::XML_NODE_AUTOMATIC_STYLES);
|
$this->xmlReader->readUntilNodeFound(self::XML_NODE_AUTOMATIC_STYLES);
|
||||||
|
/** @var \DOMElement $automaticStylesNode */
|
||||||
$automaticStylesNode = $this->xmlReader->expand();
|
$automaticStylesNode = $this->xmlReader->expand();
|
||||||
|
|
||||||
$tableStyleNodes = $automaticStylesNode->getElementsByTagNameNS(self::XML_STYLE_NAMESPACE, self::XML_NODE_STYLE_TABLE_PROPERTIES);
|
$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.
|
* Closes the reader. To be used after reading the file.
|
||||||
*
|
*
|
||||||
* @return ReaderAbstract
|
* @return void
|
||||||
*/
|
*/
|
||||||
abstract protected function closeReader();
|
abstract protected function closeReader();
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ class InternalEntityFactory implements InternalEntityFactoryInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $xmlReader
|
* @param XMLReader $xmlReader
|
||||||
* @return XMLProcessor
|
* @return XMLProcessor
|
||||||
*/
|
*/
|
||||||
public function createXMLProcessor($xmlReader)
|
public function createXMLProcessor($xmlReader)
|
||||||
|
@ -66,7 +66,7 @@ class CellValueFormatter
|
|||||||
/**
|
/**
|
||||||
* Returns the (unescaped) correctly marshalled, cell value associated to the given XML node.
|
* 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
|
* @throws InvalidValueException If the value is not valid
|
||||||
* @return string|int|float|bool|\DateTime The value associated with the cell
|
* @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
|
* 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
|
* @return string The value associated with the cell
|
||||||
*/
|
*/
|
||||||
protected function getVNodeValue($node)
|
protected function getVNodeValue($node)
|
||||||
@ -117,7 +117,7 @@ class CellValueFormatter
|
|||||||
/**
|
/**
|
||||||
* Returns the cell String value where string is inline.
|
* Returns the cell String value where string is inline.
|
||||||
*
|
*
|
||||||
* @param \DOMNode $node
|
* @param \DOMElement $node
|
||||||
* @return string The value associated with the cell
|
* @return string The value associated with the cell
|
||||||
*/
|
*/
|
||||||
protected function formatInlineStringCellValue($node)
|
protected function formatInlineStringCellValue($node)
|
||||||
|
@ -32,7 +32,7 @@ class FileBasedStrategy implements CachingStrategyInterface
|
|||||||
*/
|
*/
|
||||||
protected $maxNumStringsPerTempFile;
|
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;
|
protected $tempFilePointer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -179,6 +179,7 @@ class SharedStringsManager
|
|||||||
$sharedStringValue = '';
|
$sharedStringValue = '';
|
||||||
|
|
||||||
// NOTE: expand() will automatically decode all XML entities of the child nodes
|
// NOTE: expand() will automatically decode all XML entities of the child nodes
|
||||||
|
/** @var \DOMElement $siNode */
|
||||||
$siNode = $xmlReader->expand();
|
$siNode = $xmlReader->expand();
|
||||||
$textNodes = $siNode->getElementsByTagName(self::XML_NODE_T);
|
$textNodes = $siNode->getElementsByTagName(self::XML_NODE_T);
|
||||||
|
|
||||||
|
@ -276,6 +276,7 @@ class RowIterator implements IteratorInterface
|
|||||||
$currentColumnIndex = $this->getColumnIndex($xmlReader);
|
$currentColumnIndex = $this->getColumnIndex($xmlReader);
|
||||||
|
|
||||||
// NOTE: expand() will automatically decode all XML entities of the child nodes
|
// NOTE: expand() will automatically decode all XML entities of the child nodes
|
||||||
|
/** @var \DOMElement $node */
|
||||||
$node = $xmlReader->expand();
|
$node = $xmlReader->expand();
|
||||||
$cell = $this->getCell($node);
|
$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.
|
* 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
|
* @return Cell The cell set with the associated with the cell
|
||||||
*/
|
*/
|
||||||
protected function getCell($node)
|
protected function getCell($node)
|
||||||
|
@ -11,7 +11,7 @@ class Worksheet
|
|||||||
/** @var string Path to the XML file that will contain the sheet data */
|
/** @var string Path to the XML file that will contain the sheet data */
|
||||||
private $filePath;
|
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;
|
private $filePointer;
|
||||||
|
|
||||||
/** @var Sheet The "external" sheet */
|
/** @var Sheet The "external" sheet */
|
||||||
|
@ -30,7 +30,7 @@ class HelperFactory extends \Box\Spout\Common\Creator\HelperFactory
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $entityFactory
|
* @param InternalEntityFactory $entityFactory
|
||||||
* @return ZipHelper
|
* @return ZipHelper
|
||||||
*/
|
*/
|
||||||
private function createZipHelper($entityFactory)
|
private function createZipHelper($entityFactory)
|
||||||
|
@ -86,7 +86,7 @@ class WorksheetManager implements WorksheetManagerInterface
|
|||||||
* Returns the table XML root node as string.
|
* Returns the table XML root node as string.
|
||||||
*
|
*
|
||||||
* @param Worksheet $worksheet
|
* @param Worksheet $worksheet
|
||||||
* @return string <table> node as string
|
* @return string "<table>" node as string
|
||||||
*/
|
*/
|
||||||
public function getTableElementStartAsString(Worksheet $worksheet)
|
public function getTableElementStartAsString(Worksheet $worksheet)
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Box\Spout\Writer\XLSX\Manager\Style;
|
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\Color;
|
||||||
use Box\Spout\Common\Entity\Style\Style;
|
use Box\Spout\Common\Entity\Style\Style;
|
||||||
use Box\Spout\Writer\XLSX\Helper\BorderHelper;
|
use Box\Spout\Writer\XLSX\Helper\BorderHelper;
|
||||||
@ -186,7 +187,7 @@ EOD;
|
|||||||
$content .= '<border><left/><right/><top/><bottom/></border>';
|
$content .= '<border><left/><right/><top/><bottom/></border>';
|
||||||
|
|
||||||
foreach ($registeredBorders as $styleId) {
|
foreach ($registeredBorders as $styleId) {
|
||||||
/** @var \Box\Spout\Common\Entity\Style\Style $style */
|
/** @var Style $style */
|
||||||
$style = $this->styleRegistry->getStyleFromStyleId($styleId);
|
$style = $this->styleRegistry->getStyleFromStyleId($styleId);
|
||||||
$border = $style->getBorder();
|
$border = $style->getBorder();
|
||||||
$content .= '<border>';
|
$content .= '<border>';
|
||||||
@ -196,7 +197,7 @@ EOD;
|
|||||||
|
|
||||||
foreach ($sortOrder as $partName) {
|
foreach ($sortOrder as $partName) {
|
||||||
if ($border->hasPart($partName)) {
|
if ($border->hasPart($partName)) {
|
||||||
/** @var $part \Box\Spout\Common\Entity\Style\BorderPart */
|
/** @var BorderPart $part */
|
||||||
$part = $border->getPart($partName);
|
$part = $border->getPart($partName);
|
||||||
$content .= BorderHelper::serializeBorderPart($part);
|
$content .= BorderHelper::serializeBorderPart($part);
|
||||||
}
|
}
|
||||||
|
@ -240,6 +240,7 @@ EOD;
|
|||||||
} elseif ($cell->isBoolean()) {
|
} elseif ($cell->isBoolean()) {
|
||||||
$cellXML .= ' t="b"><v>' . (int) ($cell->getValue()) . '</v></c>';
|
$cellXML .= ' t="b"><v>' . (int) ($cell->getValue()) . '</v></c>';
|
||||||
} elseif ($cell->isNumeric()) {
|
} elseif ($cell->isNumeric()) {
|
||||||
|
var_dump($cell);
|
||||||
$cellXML .= '><v>' . $this->stringHelper->formatNumericValue($cell->getValue()) . '</v></c>';
|
$cellXML .= '><v>' . $this->stringHelper->formatNumericValue($cell->getValue()) . '</v></c>';
|
||||||
} elseif ($cell->isError() && is_string($cell->getValueEvenIfError())) {
|
} elseif ($cell->isError() && is_string($cell->getValueEvenIfError())) {
|
||||||
// only writes the error value if it's a string
|
// only writes the error value if it's a string
|
||||||
|
@ -7,7 +7,7 @@ use Box\Spout\Common\Entity\Style\Style;
|
|||||||
class RowTest extends \PHPUnit\Framework\TestCase
|
class RowTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @return \PHPUnit_Framework_MockObject_MockObject|Style
|
* @return \PHPUnit\Framework\MockObject\MockObject|Style
|
||||||
*/
|
*/
|
||||||
private function getStyleMock()
|
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()
|
private function getCellMock()
|
||||||
{
|
{
|
||||||
|
@ -113,7 +113,7 @@ class BorderTest extends TestCase
|
|||||||
$border->addPart($borderPart);
|
$border->addPart($borderPart);
|
||||||
$this->assertCount(1, $border->getParts());
|
$this->assertCount(1, $border->getParts());
|
||||||
|
|
||||||
/** @var $part BorderPart */
|
/** @var BorderPart $part */
|
||||||
$part = $border->getParts()[$allowedName];
|
$part = $border->getParts()[$allowedName];
|
||||||
|
|
||||||
$this->assertEquals($allowedStyle, $part->getStyle());
|
$this->assertEquals($allowedStyle, $part->getStyle());
|
||||||
|
@ -68,15 +68,15 @@ class EncodingHelperTest extends TestCase
|
|||||||
$this->expectException(EncodingConversionException::class);
|
$this->expectException(EncodingConversionException::class);
|
||||||
|
|
||||||
$helperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\GlobalFunctionsHelper')
|
$helperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\GlobalFunctionsHelper')
|
||||||
->setMethods(['iconv', 'mb_convert_encoding'])
|
->onlyMethods(['iconv', 'mb_convert_encoding'])
|
||||||
->getMock();
|
->getMock();
|
||||||
$helperStub->method('iconv')->willReturn(false);
|
$helperStub->method('iconv')->willReturn(false);
|
||||||
$helperStub->method('mb_convert_encoding')->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')
|
$encodingHelperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\EncodingHelper')
|
||||||
->setConstructorArgs([$helperStub])
|
->setConstructorArgs([$helperStub])
|
||||||
->setMethods(['canUseIconv', 'canUseMbString'])
|
->onlyMethods(['canUseIconv', 'canUseMbString'])
|
||||||
->getMock();
|
->getMock();
|
||||||
$encodingHelperStub->method('canUseIconv')->willReturn($shouldUseIconv);
|
$encodingHelperStub->method('canUseIconv')->willReturn($shouldUseIconv);
|
||||||
$encodingHelperStub->method('canUseMbString')->willReturn(true);
|
$encodingHelperStub->method('canUseMbString')->willReturn(true);
|
||||||
@ -91,10 +91,10 @@ class EncodingHelperTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->expectException(EncodingConversionException::class);
|
$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')
|
$encodingHelperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\EncodingHelper')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->setMethods(['canUseIconv', 'canUseMbString'])
|
->onlyMethods(['canUseIconv', 'canUseMbString'])
|
||||||
->getMock();
|
->getMock();
|
||||||
$encodingHelperStub->method('canUseIconv')->willReturn(false);
|
$encodingHelperStub->method('canUseIconv')->willReturn(false);
|
||||||
$encodingHelperStub->method('canUseMbString')->willReturn(false);
|
$encodingHelperStub->method('canUseMbString')->willReturn(false);
|
||||||
@ -110,10 +110,10 @@ class EncodingHelperTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testAttemptConversionToUTF8ShouldReturnReencodedString($shouldUseIconv)
|
public function testAttemptConversionToUTF8ShouldReturnReencodedString($shouldUseIconv)
|
||||||
{
|
{
|
||||||
/** @var EncodingHelper $encodingHelperStub */
|
/** @var EncodingHelper|\PHPUnit\Framework\MockObject\MockObject $encodingHelperStub */
|
||||||
$encodingHelperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\EncodingHelper')
|
$encodingHelperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\EncodingHelper')
|
||||||
->setConstructorArgs([new GlobalFunctionsHelper()])
|
->setConstructorArgs([new GlobalFunctionsHelper()])
|
||||||
->setMethods(['canUseIconv', 'canUseMbString'])
|
->onlyMethods(['canUseIconv', 'canUseMbString'])
|
||||||
->getMock();
|
->getMock();
|
||||||
$encodingHelperStub->method('canUseIconv')->willReturn($shouldUseIconv);
|
$encodingHelperStub->method('canUseIconv')->willReturn($shouldUseIconv);
|
||||||
$encodingHelperStub->method('canUseMbString')->willReturn(true);
|
$encodingHelperStub->method('canUseMbString')->willReturn(true);
|
||||||
@ -129,10 +129,10 @@ class EncodingHelperTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testAttemptConversionToUTF8ShouldBeNoopWhenTargetIsUTF8()
|
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')
|
$encodingHelperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\EncodingHelper')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->setMethods(['canUseIconv'])
|
->onlyMethods(['canUseIconv'])
|
||||||
->getMock();
|
->getMock();
|
||||||
$encodingHelperStub->expects($this->never())->method('canUseIconv');
|
$encodingHelperStub->expects($this->never())->method('canUseIconv');
|
||||||
|
|
||||||
@ -151,15 +151,15 @@ class EncodingHelperTest extends TestCase
|
|||||||
$this->expectException(EncodingConversionException::class);
|
$this->expectException(EncodingConversionException::class);
|
||||||
|
|
||||||
$helperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\GlobalFunctionsHelper')
|
$helperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\GlobalFunctionsHelper')
|
||||||
->setMethods(['iconv', 'mb_convert_encoding'])
|
->onlyMethods(['iconv', 'mb_convert_encoding'])
|
||||||
->getMock();
|
->getMock();
|
||||||
$helperStub->method('iconv')->willReturn(false);
|
$helperStub->method('iconv')->willReturn(false);
|
||||||
$helperStub->method('mb_convert_encoding')->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')
|
$encodingHelperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\EncodingHelper')
|
||||||
->setConstructorArgs([$helperStub])
|
->setConstructorArgs([$helperStub])
|
||||||
->setMethods(['canUseIconv', 'canUseMbString'])
|
->onlyMethods(['canUseIconv', 'canUseMbString'])
|
||||||
->getMock();
|
->getMock();
|
||||||
$encodingHelperStub->method('canUseIconv')->willReturn($shouldUseIconv);
|
$encodingHelperStub->method('canUseIconv')->willReturn($shouldUseIconv);
|
||||||
$encodingHelperStub->method('canUseMbString')->willReturn(true);
|
$encodingHelperStub->method('canUseMbString')->willReturn(true);
|
||||||
@ -174,10 +174,10 @@ class EncodingHelperTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->expectException(EncodingConversionException::class);
|
$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')
|
$encodingHelperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\EncodingHelper')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->setMethods(['canUseIconv', 'canUseMbString'])
|
->onlyMethods(['canUseIconv', 'canUseMbString'])
|
||||||
->getMock();
|
->getMock();
|
||||||
$encodingHelperStub->method('canUseIconv')->willReturn(false);
|
$encodingHelperStub->method('canUseIconv')->willReturn(false);
|
||||||
$encodingHelperStub->method('canUseMbString')->willReturn(false);
|
$encodingHelperStub->method('canUseMbString')->willReturn(false);
|
||||||
@ -193,10 +193,10 @@ class EncodingHelperTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testAttemptConversionFromUTF8ShouldReturnReencodedString($shouldUseIconv)
|
public function testAttemptConversionFromUTF8ShouldReturnReencodedString($shouldUseIconv)
|
||||||
{
|
{
|
||||||
/** @var EncodingHelper $encodingHelperStub */
|
/** @var EncodingHelper|\PHPUnit\Framework\MockObject\MockObject $encodingHelperStub */
|
||||||
$encodingHelperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\EncodingHelper')
|
$encodingHelperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\EncodingHelper')
|
||||||
->setConstructorArgs([new GlobalFunctionsHelper()])
|
->setConstructorArgs([new GlobalFunctionsHelper()])
|
||||||
->setMethods(['canUseIconv', 'canUseMbString'])
|
->onlyMethods(['canUseIconv', 'canUseMbString'])
|
||||||
->getMock();
|
->getMock();
|
||||||
$encodingHelperStub->method('canUseIconv')->willReturn($shouldUseIconv);
|
$encodingHelperStub->method('canUseIconv')->willReturn($shouldUseIconv);
|
||||||
$encodingHelperStub->method('canUseMbString')->willReturn(true);
|
$encodingHelperStub->method('canUseMbString')->willReturn(true);
|
||||||
@ -212,10 +212,10 @@ class EncodingHelperTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testAttemptConversionFromUTF8ShouldBeNoopWhenTargetIsUTF8()
|
public function testAttemptConversionFromUTF8ShouldBeNoopWhenTargetIsUTF8()
|
||||||
{
|
{
|
||||||
/** @var EncodingHelper $encodingHelperStub */
|
/** @var EncodingHelper|\PHPUnit\Framework\MockObject\MockObject $encodingHelperStub */
|
||||||
$encodingHelperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\EncodingHelper')
|
$encodingHelperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\EncodingHelper')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->setMethods(['canUseIconv'])
|
->onlyMethods(['canUseIconv'])
|
||||||
->getMock();
|
->getMock();
|
||||||
$encodingHelperStub->expects($this->never())->method('canUseIconv');
|
$encodingHelperStub->expects($this->never())->method('canUseIconv');
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ use PHPUnit\Framework\TestCase;
|
|||||||
*/
|
*/
|
||||||
class FileSystemHelperTest extends TestCase
|
class FileSystemHelperTest extends TestCase
|
||||||
{
|
{
|
||||||
/** @var \Box\Spout\Writer\XLSX\Helper\FileSystemHelper */
|
/** @var FileSystemHelper */
|
||||||
protected $fileSystemHelper;
|
protected $fileSystemHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,9 +47,9 @@ class ReaderTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->expectException(IOException::class);
|
$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')
|
$helperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\GlobalFunctionsHelper')
|
||||||
->setMethods(['is_readable'])
|
->onlyMethods(['is_readable'])
|
||||||
->getMock();
|
->getMock();
|
||||||
$helperStub->method('is_readable')->willReturn(false);
|
$helperStub->method('is_readable')->willReturn(false);
|
||||||
|
|
||||||
@ -66,9 +66,9 @@ class ReaderTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->expectException(IOException::class);
|
$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')
|
$helperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\GlobalFunctionsHelper')
|
||||||
->setMethods(['fopen'])
|
->onlyMethods(['fopen'])
|
||||||
->getMock();
|
->getMock();
|
||||||
$helperStub->method('fopen')->willReturn(false);
|
$helperStub->method('fopen')->willReturn(false);
|
||||||
|
|
||||||
@ -304,9 +304,9 @@ class ReaderTest extends TestCase
|
|||||||
$allRows = [];
|
$allRows = [];
|
||||||
$resourcePath = $this->getResourcePath($fileName);
|
$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')
|
$helperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\GlobalFunctionsHelper')
|
||||||
->setMethods(['function_exists'])
|
->onlyMethods(['function_exists'])
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
$returnValueMap = [
|
$returnValueMap = [
|
||||||
|
@ -36,11 +36,11 @@ class CachingStrategyFactoryTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCreateBestCachingStrategy($sharedStringsUniqueCount, $memoryLimitInKB, $expectedStrategyClassName)
|
public function testCreateBestCachingStrategy($sharedStringsUniqueCount, $memoryLimitInKB, $expectedStrategyClassName)
|
||||||
{
|
{
|
||||||
/** @var CachingStrategyFactory|\PHPUnit_Framework_MockObject_MockObject $factoryStub */
|
/** @var CachingStrategyFactory|\PHPUnit\Framework\MockObject\MockObject $factoryStub */
|
||||||
$factoryStub = $this
|
$factoryStub = $this
|
||||||
->getMockBuilder('\Box\Spout\Reader\XLSX\Manager\SharedStringsCaching\CachingStrategyFactory')
|
->getMockBuilder('\Box\Spout\Reader\XLSX\Manager\SharedStringsCaching\CachingStrategyFactory')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->setMethods(['getMemoryLimitInKB'])
|
->onlyMethods(['getMemoryLimitInKB'])
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
$factoryStub->method('getMemoryLimitInKB')->willReturn($memoryLimitInKB);
|
$factoryStub->method('getMemoryLimitInKB')->willReturn($memoryLimitInKB);
|
||||||
@ -84,11 +84,11 @@ class CachingStrategyFactoryTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetMemoryLimitInKB($memoryLimitFormatted, $expectedMemoryLimitInKB)
|
public function testGetMemoryLimitInKB($memoryLimitFormatted, $expectedMemoryLimitInKB)
|
||||||
{
|
{
|
||||||
/** @var CachingStrategyFactory|\PHPUnit_Framework_MockObject_MockObject $factoryStub */
|
/** @var CachingStrategyFactory|\PHPUnit\Framework\MockObject\MockObject $factoryStub */
|
||||||
$factoryStub = $this
|
$factoryStub = $this
|
||||||
->getMockBuilder('\Box\Spout\Reader\XLSX\Manager\SharedStringsCaching\CachingStrategyFactory')
|
->getMockBuilder('\Box\Spout\Reader\XLSX\Manager\SharedStringsCaching\CachingStrategyFactory')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->setMethods(['getMemoryLimitFromIni'])
|
->onlyMethods(['getMemoryLimitFromIni'])
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
$factoryStub->method('getMemoryLimitFromIni')->willReturn($memoryLimitFormatted);
|
$factoryStub->method('getMemoryLimitFromIni')->willReturn($memoryLimitFormatted);
|
||||||
|
@ -19,7 +19,7 @@ class SharedStringsManagerTest extends TestCase
|
|||||||
{
|
{
|
||||||
use TestUsingResource;
|
use TestUsingResource;
|
||||||
|
|
||||||
/** @var SharedStringsManager */
|
/** @var SharedStringsManager|null */
|
||||||
private $sharedStringsManager;
|
private $sharedStringsManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,10 +21,10 @@ class StyleManagerTest extends TestCase
|
|||||||
$workbookRelationshipsManager = $this->createMock(WorkbookRelationshipsManager::class);
|
$workbookRelationshipsManager = $this->createMock(WorkbookRelationshipsManager::class);
|
||||||
$workbookRelationshipsManager->method('hasStylesXMLFile')->willReturn(true);
|
$workbookRelationshipsManager->method('hasStylesXMLFile')->willReturn(true);
|
||||||
|
|
||||||
/** @var StyleManager $styleManager */
|
/** @var StyleManager|\PHPUnit\Framework\MockObject\MockObject $styleManager */
|
||||||
$styleManager = $this->getMockBuilder('\Box\Spout\Reader\XLSX\Manager\StyleManager')
|
$styleManager = $this->getMockBuilder('\Box\Spout\Reader\XLSX\Manager\StyleManager')
|
||||||
->setConstructorArgs(['/path/to/file.xlsx', $workbookRelationshipsManager, $entityFactory])
|
->setConstructorArgs(['/path/to/file.xlsx', $workbookRelationshipsManager, $entityFactory])
|
||||||
->setMethods(['getCustomNumberFormats', 'getStylesAttributes'])
|
->onlyMethods(['getCustomNumberFormats', 'getStylesAttributes'])
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
$styleManager->method('getStylesAttributes')->willReturn($styleAttributes);
|
$styleManager->method('getStylesAttributes')->willReturn($styleAttributes);
|
||||||
|
@ -95,7 +95,6 @@ class ReflectionHelper
|
|||||||
*
|
*
|
||||||
* @param object $object
|
* @param object $object
|
||||||
* @param string $methodName
|
* @param string $methodName
|
||||||
* @param *mixed|null $params
|
|
||||||
*
|
*
|
||||||
* @return mixed|null
|
* @return mixed|null
|
||||||
*/
|
*/
|
||||||
|
@ -348,6 +348,7 @@ class WriterTest extends TestCase
|
|||||||
$fileName = 'test_add_row_should_use_number_columns_repeated.ods';
|
$fileName = 'test_add_row_should_use_number_columns_repeated.ods';
|
||||||
$this->writeToODSFile($this->createRowsFromValues([$dataRow]), $fileName);
|
$this->writeToODSFile($this->createRowsFromValues([$dataRow]), $fileName);
|
||||||
|
|
||||||
|
/** @var \DOMElement $sheetXmlNode */
|
||||||
$sheetXmlNode = $this->getSheetXmlNode($fileName, 1);
|
$sheetXmlNode = $this->getSheetXmlNode($fileName, 1);
|
||||||
$tableCellNodes = $sheetXmlNode->getElementsByTagName('table-cell');
|
$tableCellNodes = $sheetXmlNode->getElementsByTagName('table-cell');
|
||||||
|
|
||||||
|
@ -88,6 +88,7 @@ class WriterWithStyleTest extends TestCase
|
|||||||
$this->assertCount(3, $cellStyleElements, 'There should be 3 separate cell styles, including the default one.');
|
$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
|
// Second font should contain data from the first created style
|
||||||
|
/** @var \DOMElement $customFont1Element */
|
||||||
$customFont1Element = $cellStyleElements[1];
|
$customFont1Element = $cellStyleElements[1];
|
||||||
$this->assertFirstChildHasAttributeEquals('bold', $customFont1Element, 'text-properties', 'fo:font-weight');
|
$this->assertFirstChildHasAttributeEquals('bold', $customFont1Element, 'text-properties', 'fo:font-weight');
|
||||||
$this->assertFirstChildHasAttributeEquals('italic', $customFont1Element, 'text-properties', 'fo:font-style');
|
$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');
|
$this->assertFirstChildHasAttributeEquals('solid', $customFont1Element, 'text-properties', 'style:text-line-through-style');
|
||||||
|
|
||||||
// Third font should contain data from the second created style
|
// Third font should contain data from the second created style
|
||||||
|
/** @var \DOMElement $customFont2Element */
|
||||||
$customFont2Element = $cellStyleElements[2];
|
$customFont2Element = $cellStyleElements[2];
|
||||||
$this->assertFirstChildHasAttributeEquals('15pt', $customFont2Element, 'text-properties', 'fo:font-size');
|
$this->assertFirstChildHasAttributeEquals('15pt', $customFont2Element, 'text-properties', 'fo:font-size');
|
||||||
$this->assertFirstChildHasAttributeEquals('#' . Color::RED, $customFont2Element, 'text-properties', 'fo:color');
|
$this->assertFirstChildHasAttributeEquals('#' . Color::RED, $customFont2Element, 'text-properties', 'fo:color');
|
||||||
@ -397,7 +399,7 @@ class WriterWithStyleTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $fileName
|
* @param string $fileName
|
||||||
* @return \DOMNode[]
|
* @return \DOMElement[]
|
||||||
*/
|
*/
|
||||||
private function getCellElementsFromContentXmlFile($fileName)
|
private function getCellElementsFromContentXmlFile($fileName)
|
||||||
{
|
{
|
||||||
@ -410,7 +412,9 @@ class WriterWithStyleTest extends TestCase
|
|||||||
|
|
||||||
while ($xmlReader->read()) {
|
while ($xmlReader->read()) {
|
||||||
if ($xmlReader->isPositionedOnStartingNode('table:table-cell') && $xmlReader->getAttribute('office:value-type') !== null) {
|
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
|
* @param string $fileName
|
||||||
* @return \DOMNode[]
|
* @return \DOMElement[]
|
||||||
*/
|
*/
|
||||||
private function getCellStyleElementsFromContentXmlFile($fileName)
|
private function getCellStyleElementsFromContentXmlFile($fileName)
|
||||||
{
|
{
|
||||||
@ -434,7 +438,9 @@ class WriterWithStyleTest extends TestCase
|
|||||||
|
|
||||||
while ($xmlReader->read()) {
|
while ($xmlReader->read()) {
|
||||||
if ($xmlReader->isPositionedOnStartingNode('style:style') && $xmlReader->getAttribute('style:family') === 'table-cell') {
|
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 $fileName
|
||||||
* @param string $section
|
* @param string $section
|
||||||
* @return \DomNode
|
* @return \DOMElement
|
||||||
*/
|
*/
|
||||||
private function getXmlSectionFromStylesXmlFile($fileName, $section)
|
private function getXmlSectionFromStylesXmlFile($fileName, $section)
|
||||||
{
|
{
|
||||||
@ -456,12 +462,15 @@ class WriterWithStyleTest extends TestCase
|
|||||||
$xmlReader->openFileInZip($resourcePath, 'styles.xml');
|
$xmlReader->openFileInZip($resourcePath, 'styles.xml');
|
||||||
$xmlReader->readUntilNodeFound($section);
|
$xmlReader->readUntilNodeFound($section);
|
||||||
|
|
||||||
return $xmlReader->expand();
|
/** @var \DOMElement $element */
|
||||||
|
$element = $xmlReader->expand();
|
||||||
|
|
||||||
|
return $element;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $expectedValue
|
* @param string $expectedValue
|
||||||
* @param \DOMNode $parentElement
|
* @param \DOMElement $parentElement
|
||||||
* @param string $childTagName
|
* @param string $childTagName
|
||||||
* @param string $attributeName
|
* @param string $attributeName
|
||||||
* @return void
|
* @return void
|
||||||
|
@ -40,7 +40,7 @@ class StyleManagerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$styleRegistryMock = $this->getMockBuilder(StyleRegistry::class)
|
$styleRegistryMock = $this->getMockBuilder(StyleRegistry::class)
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->setMethods(['getFillIdForStyleId', 'getBorderIdForStyleId'])
|
->onlyMethods(['getFillIdForStyleId', 'getBorderIdForStyleId'])
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
$styleRegistryMock
|
$styleRegistryMock
|
||||||
|
@ -102,7 +102,7 @@ class WriterPerfTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $filePath
|
* @param string $filePath
|
||||||
* @return string
|
* @return int
|
||||||
*/
|
*/
|
||||||
private function getLasRowNumberForFile($filePath)
|
private function getLasRowNumberForFile($filePath)
|
||||||
{
|
{
|
||||||
|
@ -92,6 +92,7 @@ class WriterWithStyleTest extends TestCase
|
|||||||
$this->assertEquals(3, $fontElements->length, 'There should be 3 associated "font" elements, including the default one.');
|
$this->assertEquals(3, $fontElements->length, 'There should be 3 associated "font" elements, including the default one.');
|
||||||
|
|
||||||
// First font should be the default one
|
// First font should be the default one
|
||||||
|
/** @var \DOMElement $defaultFontElement */
|
||||||
$defaultFontElement = $fontElements->item(0);
|
$defaultFontElement = $fontElements->item(0);
|
||||||
$this->assertChildrenNumEquals(3, $defaultFontElement, 'The default font should only have 3 properties.');
|
$this->assertChildrenNumEquals(3, $defaultFontElement, 'The default font should only have 3 properties.');
|
||||||
$this->assertFirstChildHasAttributeEquals((string) OptionsManager::DEFAULT_FONT_SIZE, $defaultFontElement, 'sz', 'val');
|
$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');
|
$this->assertFirstChildHasAttributeEquals(OptionsManager::DEFAULT_FONT_NAME, $defaultFontElement, 'name', 'val');
|
||||||
|
|
||||||
// Second font should contain data from the first created style
|
// Second font should contain data from the first created style
|
||||||
|
/** @var \DOMElement $secondFontElement */
|
||||||
$secondFontElement = $fontElements->item(1);
|
$secondFontElement = $fontElements->item(1);
|
||||||
$this->assertChildrenNumEquals(7, $secondFontElement, 'The font should only have 7 properties (4 custom styles + 3 default styles).');
|
$this->assertChildrenNumEquals(7, $secondFontElement, 'The font should only have 7 properties (4 custom styles + 3 default styles).');
|
||||||
$this->assertChildExists($secondFontElement, 'b');
|
$this->assertChildExists($secondFontElement, 'b');
|
||||||
@ -110,6 +112,7 @@ class WriterWithStyleTest extends TestCase
|
|||||||
$this->assertFirstChildHasAttributeEquals(OptionsManager::DEFAULT_FONT_NAME, $secondFontElement, 'name', 'val');
|
$this->assertFirstChildHasAttributeEquals(OptionsManager::DEFAULT_FONT_NAME, $secondFontElement, 'name', 'val');
|
||||||
|
|
||||||
// Third font should contain data from the second created style
|
// Third font should contain data from the second created style
|
||||||
|
/** @var \DOMElement $thirdFontElement */
|
||||||
$thirdFontElement = $fontElements->item(2);
|
$thirdFontElement = $fontElements->item(2);
|
||||||
$this->assertChildrenNumEquals(3, $thirdFontElement, 'The font should only have 3 properties.');
|
$this->assertChildrenNumEquals(3, $thirdFontElement, 'The font should only have 3 properties.');
|
||||||
$this->assertFirstChildHasAttributeEquals('15', $thirdFontElement, 'sz', 'val');
|
$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'
|
'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');
|
$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');
|
$this->assertEquals(2, (int) $secondCustomId, 'The second custom fill id should have the index 2');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -607,7 +614,7 @@ class WriterWithStyleTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* @param string $fileName
|
* @param string $fileName
|
||||||
* @param string $section
|
* @param string $section
|
||||||
* @return \DomElement
|
* @return \DOMElement
|
||||||
*/
|
*/
|
||||||
private function getXmlSectionFromStylesXmlFile($fileName, $section)
|
private function getXmlSectionFromStylesXmlFile($fileName, $section)
|
||||||
{
|
{
|
||||||
@ -617,6 +624,7 @@ class WriterWithStyleTest extends TestCase
|
|||||||
$xmlReader->openFileInZip($resourcePath, 'xl/styles.xml');
|
$xmlReader->openFileInZip($resourcePath, 'xl/styles.xml');
|
||||||
$xmlReader->readUntilNodeFound($section);
|
$xmlReader->readUntilNodeFound($section);
|
||||||
|
|
||||||
|
/** @var \DOMElement $xmlSection */
|
||||||
$xmlSection = $xmlReader->expand();
|
$xmlSection = $xmlReader->expand();
|
||||||
|
|
||||||
$xmlReader->close();
|
$xmlReader->close();
|
||||||
@ -626,7 +634,7 @@ class WriterWithStyleTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $fileName
|
* @param string $fileName
|
||||||
* @return \DOMNode[]
|
* @return \DOMElement[]
|
||||||
*/
|
*/
|
||||||
private function getCellElementsFromSheetXmlFile($fileName)
|
private function getCellElementsFromSheetXmlFile($fileName)
|
||||||
{
|
{
|
||||||
@ -639,7 +647,9 @@ class WriterWithStyleTest extends TestCase
|
|||||||
|
|
||||||
while ($xmlReader->read()) {
|
while ($xmlReader->read()) {
|
||||||
if ($xmlReader->isPositionedOnStartingNode('c')) {
|
if ($xmlReader->isPositionedOnStartingNode('c')) {
|
||||||
$cellElements[] = $xmlReader->expand();
|
/** @var \DOMElement $cellElement */
|
||||||
|
$cellElement = $xmlReader->expand();
|
||||||
|
$cellElements[] = $cellElement;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -650,7 +660,7 @@ class WriterWithStyleTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $expectedValue
|
* @param string $expectedValue
|
||||||
* @param \DOMNode $parentElement
|
* @param \DOMElement $parentElement
|
||||||
* @param string $childTagName
|
* @param string $childTagName
|
||||||
* @param string $attributeName
|
* @param string $attributeName
|
||||||
* @return void
|
* @return void
|
||||||
@ -662,7 +672,7 @@ class WriterWithStyleTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $expectedNumber
|
* @param int $expectedNumber
|
||||||
* @param \DOMNode $parentElement
|
* @param \DOMElement $parentElement
|
||||||
* @param string $message
|
* @param string $message
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@ -672,7 +682,7 @@ class WriterWithStyleTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \DOMNode $parentElement
|
* @param \DOMElement $parentElement
|
||||||
* @param string $childTagName
|
* @param string $childTagName
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user