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

@@ -98,7 +98,7 @@ class CachingStrategyFactory
/**
* Returns the PHP "memory_limit" in Kilobytes
*
* @return float
* @return int
*/
protected function getMemoryLimitInKB()
{
@@ -133,6 +133,9 @@ class CachingStrategyFactory
*/
protected function getMemoryLimitFromIni()
{
return \ini_get('memory_limit');
/** @var string $memoryLimit */
$memoryLimit = \ini_get('memory_limit');
return $memoryLimit;
}
}
@@ -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;
/**
@@ -42,7 +42,7 @@ class FileBasedStrategy implements CachingStrategyInterface
protected $inMemoryTempFilePath;
/**
* @var array Contents of the temporary file that was last read
* @var array<string> Contents of the temporary file that was last read
* @see CachingStrategyFactory::MAX_NUM_STRINGS_PER_TEMP_FILE
*/
protected $inMemoryTempFileContents;
@@ -78,7 +78,9 @@ class FileBasedStrategy implements CachingStrategyInterface
if ($this->tempFilePointer) {
$this->globalFunctionsHelper->fclose($this->tempFilePointer);
}
$this->tempFilePointer = $this->globalFunctionsHelper->fopen($tempFilePath, 'w');
/** @var resource $tempFilePointer */
$tempFilePointer = $this->globalFunctionsHelper->fopen($tempFilePath, 'w');
$this->tempFilePointer = $tempFilePointer;
}
// The shared string retrieval logic expects each cell data to be on one line only
@@ -12,7 +12,7 @@ use Box\Spout\Reader\Exception\SharedStringNotFoundException;
*/
class InMemoryStrategy implements CachingStrategyInterface
{
/** @var \SplFixedArray Array used to cache the shared strings */
/** @var \SplFixedArray<string> Array used to cache the shared strings */
protected $inMemoryCache;
/** @var bool Whether the cache has been closed */
@@ -43,13 +43,13 @@ class SharedStringsManager
/** @var InternalEntityFactory Factory to create entities */
protected $entityFactory;
/** @var HelperFactory $helperFactory Factory to create helpers */
/** @var HelperFactory Factory to create helpers */
protected $helperFactory;
/** @var CachingStrategyFactory Factory to create shared strings caching strategies */
protected $cachingStrategyFactory;
/** @var CachingStrategyInterface The best caching strategy for storing shared strings */
/** @var CachingStrategyInterface|null The best caching strategy for storing shared strings */
protected $cachingStrategy;
/**
@@ -182,6 +182,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);
@@ -54,7 +54,7 @@ class SheetManager
/** @var \Box\Spout\Common\Helper\Escaper\XLSX Used to unescape XML data */
protected $escaper;
/** @var array List of sheets */
/** @var array<Sheet> List of sheets */
protected $sheets;
/** @var int Index of the sheet currently read */
@@ -28,7 +28,7 @@ class StyleManager
/**
* @see https://msdn.microsoft.com/en-us/library/ff529597(v=office.12).aspx
* @var array Mapping between built-in numFmtId and the associated format - for dates only
* @var array<int, string> Mapping between built-in numFmtId and the associated format - for dates only
*/
protected static $builtinNumFmtIdToNumFormatMapping = [
14 => 'm/d/yyyy', // @NOTE: ECMA spec is 'mm-dd-yy'
@@ -57,16 +57,16 @@ class StyleManager
/** @var InternalEntityFactory Factory to create entities */
protected $entityFactory;
/** @var array Array containing the IDs of built-in number formats indicating a date */
/** @var int[]|string[] 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<int,string> Array containing a mapping NUM_FMT_ID => FORMAT_CODE */
protected $customNumberFormats;
/** @var array Array containing a mapping STYLE_ID => [STYLE_ATTRIBUTES] */
/** @var array<mixed> 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 */
/** @var array<int, bool> Cache containing a mapping NUM_FMT_ID => IS_DATE_FORMAT. Used to avoid lots of recalculations */
protected $numFmtIdToIsDateFormatCache = [];
/**
@@ -189,7 +189,7 @@ class StyleManager
}
/**
* @return array The custom number formats
* @return array<int,string> The custom number formats
*/
protected function getCustomNumberFormats()
{
@@ -201,7 +201,7 @@ class StyleManager
}
/**
* @return array The styles attributes
* @return array<mixed> The styles attributes
*/
protected function getStylesAttributes()
{
@@ -213,7 +213,7 @@ class StyleManager
}
/**
* @param array $styleAttributes Array containing the style attributes (2 keys: "applyNumberFormat" and "numFmtId")
* @param array<string, mixed> $styleAttributes Array containing the style attributes (2 keys: "applyNumberFormat" and "numFmtId")
* @return bool Whether the style with the given attributes indicates that the number is a date
*/
protected function doesStyleIndicateDate($styleAttributes)
@@ -33,7 +33,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<string, string> Cache of the already read workbook relationships: [TYPE] => [FILE_NAME] */
private $cachedWorkbookRelationships;
/**
@@ -107,7 +107,7 @@ class WorkbookRelationshipsManager
* It caches the result so that the file is read only once.
*
* @throws \Box\Spout\Common\Exception\IOException If workbook.xml.rels can't be read
* @return array
* @return array<string, string>
*/
private function getWorkbookRelationships()
{