Add phpstan until level 7

This commit is contained in:
Antoine Lamirault committed 2021-09-18 18:09:14 +02:00
1 parent ab973cab34
commit bfb7c2c68f
114 files changed
+527 -319

No files matched your search

@@ -2,6 +2,7 @@
namespace Box\Spout\Writer\XLSX\Manager\Style;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
/**
@@ -10,7 +11,7 @@ use PHPUnit\Framework\TestCase;
class StyleManagerTest extends TestCase
{
/**
* @return array
* @return array<array>
*/
public function dataProviderForTestShouldApplyStyleOnEmptyCell()
{
@@ -38,6 +39,7 @@ class StyleManagerTest extends TestCase
*/
public function testShouldApplyStyleOnEmptyCell($fillId, $borderId, $expectedResult)
{
/** @var \Box\Spout\Writer\Common\Manager\Style\StyleRegistry&MockObject $styleRegistryMock */
$styleRegistryMock = $this->getMockBuilder(StyleRegistry::class)
->disableOriginalConstructor()
->setMethods(['getFillIdForStyleId', 'getBorderIdForStyleId'])
+3 -3
View File
@@ -15,7 +15,7 @@ class WriterPerfTest extends TestCase
use TestUsingResource;
/**
* @return array
* @return array<array>
*/
public function dataProviderForTestPerfWhenWritingOneMillionRowsXLSX()
{
@@ -102,7 +102,7 @@ class WriterPerfTest extends TestCase
/**
* @param string $filePath
* @return string
* @return int
*/
private function getLasRowNumberForFile($filePath)
{
@@ -135,7 +135,7 @@ class WriterPerfTest extends TestCase
copy($filePath, $tmpFile);
// Get the last 200 characters
$lastCharacters = `tail -c $numCharacters $tmpFile`;
$lastCharacters = shell_exec("tail -c $numCharacters $tmpFile");
// remove the temporary file
unlink($tmpFile);
+1
View File
@@ -120,6 +120,7 @@ class WriterTest extends TestCase
[str_repeat('a', WorksheetManager::MAX_CHARACTERS_PER_CELL + 1)],
];
/* @phpstan-ignore-next-line */
$this->writeToXLSXFile($dataRows, $fileName);
}
@@ -394,10 +394,16 @@ class WriterWithStyleTest extends TestCase
'3 cell xfs present - a default one and two custom ones'
);
$firstCustomId = $styleXfsElements->childNodes->item(1)->getAttribute('fillId');
/** @var \DOMElement $firstItem */
$firstItem = $styleXfsElements->childNodes->item(1);
$firstCustomId = $firstItem->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 $secondItem */
$secondItem = $styleXfsElements->childNodes->item(2);
$secondCustomId = $secondItem->getAttribute('fillId');
$this->assertEquals(2, (int) $secondCustomId, 'The second custom fill id should have the index 2');
}
@@ -468,7 +474,6 @@ class WriterWithStyleTest extends TestCase
$borderParts = $borderNode->childNodes;
$ordering = [];
/** @var \DOMText $part */
foreach ($borderParts as $part) {
if ($part instanceof \DOMElement) {
$ordering[] = $part->nodeName;
@@ -617,6 +622,7 @@ class WriterWithStyleTest extends TestCase
$xmlReader->openFileInZip($resourcePath, 'xl/styles.xml');
$xmlReader->readUntilNodeFound($section);
/** @var \DOMElement $xmlSection */
$xmlSection = $xmlReader->expand();
$xmlReader->close();
@@ -626,7 +632,7 @@ class WriterWithStyleTest extends TestCase
/**
* @param string $fileName
* @return \DOMNode[]
* @return \DOMElement[]
*/
private function getCellElementsFromSheetXmlFile($fileName)
{
@@ -639,7 +645,9 @@ class WriterWithStyleTest extends TestCase
while ($xmlReader->read()) {
if ($xmlReader->isPositionedOnStartingNode('c')) {
$cellElements[] = $xmlReader->expand();
/** @var \DOMElement $element */
$element = $xmlReader->expand();
$cellElements[] = $element;
}
}
@@ -650,19 +658,21 @@ class WriterWithStyleTest extends TestCase
/**
* @param string $expectedValue
* @param \DOMNode $parentElement
* @param \DOMElement $parentElement
* @param string $childTagName
* @param string $attributeName
* @return void
*/
private function assertFirstChildHasAttributeEquals($expectedValue, $parentElement, $childTagName, $attributeName)
{
$this->assertEquals($expectedValue, $parentElement->getElementsByTagName($childTagName)->item(0)->getAttribute($attributeName));
/** @var \DOMElement $child */
$child = $parentElement->getElementsByTagName($childTagName)->item(0);
$this->assertEquals($expectedValue, $child->getAttribute($attributeName));
}
/**
* @param int $expectedNumber
* @param \DOMNode $parentElement
* @param \DOMElement $parentElement
* @param string $message
* @return void
*/
@@ -672,7 +682,7 @@ class WriterWithStyleTest extends TestCase
}
/**
* @param \DOMNode $parentElement
* @param \DOMElement $parentElement
* @param string $childTagName
* @return void
*/