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

+11 -9
View File
@@ -6,11 +6,13 @@ use Box\Spout\Common\Creator\HelperFactory;
use Box\Spout\Common\Exception\IOException;
use Box\Spout\Common\Helper\EncodingHelper;
use Box\Spout\Common\Helper\GlobalFunctionsHelper;
use Box\Spout\Common\Manager\OptionsManagerInterface;
use Box\Spout\Reader\CSV\Creator\InternalEntityFactory;
use Box\Spout\Reader\CSV\Manager\OptionsManager;
use Box\Spout\Reader\Exception\ReaderNotOpenedException;
use Box\Spout\Reader\ReaderInterface;
use Box\Spout\TestUsingResource;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
/**
@@ -47,7 +49,7 @@ 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&MockObject $helperStub */
$helperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\GlobalFunctionsHelper')
->setMethods(['is_readable'])
->getMock();
@@ -66,7 +68,7 @@ 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&MockObject $helperStub */
$helperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\GlobalFunctionsHelper')
->setMethods(['fopen'])
->getMock();
@@ -159,7 +161,7 @@ class ReaderTest extends TestCase
}
/**
* @return array
* @return array<array>
*/
public function dataProviderForTestReadShouldReadEmptyFile()
{
@@ -241,7 +243,7 @@ class ReaderTest extends TestCase
}
/**
* @return array
* @return array<array>
*/
public function dataProviderForTestReadShouldSkipBom()
{
@@ -274,7 +276,7 @@ class ReaderTest extends TestCase
}
/**
* @return array
* @return array<array>
*/
public function dataProviderForTestReadShouldSupportNonUTF8FilesWithoutBOMs()
{
@@ -302,7 +304,7 @@ 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&MockObject $helperStub */
$helperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\GlobalFunctionsHelper')
->setMethods(['function_exists'])
->getMock();
@@ -475,8 +477,8 @@ class ReaderTest extends TestCase
}
/**
* @param \Box\Spout\Common\Helper\GlobalFunctionsHelper|null $optionsManager
* @param \Box\Spout\Common\Manager\OptionsManagerInterface|null $globalFunctionsHelper
* @param OptionsManagerInterface|null $optionsManager
* @param GlobalFunctionsHelper|null $globalFunctionsHelper
* @return ReaderInterface
*/
private function createCSVReader($optionsManager = null, $globalFunctionsHelper = null)
@@ -494,7 +496,7 @@ class ReaderTest extends TestCase
* @param string $fieldEnclosure
* @param string $encoding
* @param bool $shouldPreserveEmptyRows
* @return array All the read rows the given file
* @return array<array> All the read rows the given file
*/
private function getAllRowsForFile(
$fileName,
+2 -1
View File
@@ -3,6 +3,7 @@
namespace Box\Spout\Reader\CSV;
use Box\Spout\Reader\Common\Creator\ReaderEntityFactory;
use Box\Spout\Reader\SheetInterface;
use Box\Spout\TestUsingResource;
use PHPUnit\Framework\TestCase;
@@ -27,7 +28,7 @@ class SheetTest extends TestCase
/**
* @param string $fileName
* @return Sheet
* @return SheetInterface
*/
private function openFileAndReturnSheet($fileName)
{
+16 -6
View File
@@ -14,22 +14,25 @@ class SpoutTestStream
const PATH_TO_CSV_RESOURCES = 'tests/resources/csv/';
const CSV_EXTENSION = '.csv';
/** @var int $position */
/** @var int */
private $position;
/** @var resource $fileHandle */
/** @var resource */
private $fileHandle;
/**
* @param string $path
* @param int $flag
* @return array
* @return array<mixed>
*/
public function url_stat($path, $flag)
{
$filePath = $this->getFilePathFromStreamPath($path);
return stat($filePath);
/** @var array<mixed> $stat */
$stat = stat($filePath);
return $stat;
}
/**
@@ -56,7 +59,11 @@ class SpoutTestStream
// the path is like "spout://csv_name" so the actual file name correspond the name of the host.
$filePath = $this->getFilePathFromStreamPath($path);
$this->fileHandle = fopen($filePath, $mode);
/** @var resource $fileHandle */
$fileHandle = fopen($filePath, $mode);
$this->fileHandle = $fileHandle;
return true;
}
@@ -69,7 +76,10 @@ class SpoutTestStream
{
$this->position += $numBytes;
return fread($this->fileHandle, $numBytes);
/** @var string $read */
$read = fread($this->fileHandle, $numBytes);
return $read;
}
/**