Fix PHP 8.1 deprecations

This commit is contained in:
Adrien Loison 2022-01-13 22:37:18 +01:00
parent 24dcb60373
commit db1a7218d5
5 changed files with 29 additions and 29 deletions

View File

@ -82,7 +82,7 @@ class GlobalFunctionsHelper
* @param int|null $length
* @param string|null $delimiter
* @param string|null $enclosure
* @return array
* @return array|false
*/
public function fgetcsv($handle, $length = null, $delimiter = null, $enclosure = null)
{

View File

@ -84,7 +84,7 @@ class RowIterator implements IteratorInterface
*
* @return void
*/
public function rewind()
public function rewind() : void
{
$this->rewindAndSkipBom();
@ -114,7 +114,7 @@ class RowIterator implements IteratorInterface
*
* @return bool
*/
public function valid()
public function valid() : bool
{
return ($this->filePointer && !$this->hasReachedEndOfFile);
}
@ -126,7 +126,7 @@ class RowIterator implements IteratorInterface
* @throws \Box\Spout\Common\Exception\EncodingConversionException If unable to convert data to UTF-8
* @return void
*/
public function next()
public function next() : void
{
$this->hasReachedEndOfFile = $this->globalFunctionsHelper->feof($this->filePointer);
@ -146,8 +146,8 @@ class RowIterator implements IteratorInterface
} while ($this->shouldReadNextRow($rowData));
if ($rowData !== false) {
// str_replace will replace NULL values by empty strings
$rowDataBufferAsArray = \str_replace(null, null, $rowData);
// array_map will replace NULL values by empty strings
$rowDataBufferAsArray = array_map(function ($value) { return (string) $value; }, $rowData);
$this->rowBuffer = $this->entityFactory->createRowFromArray($rowDataBufferAsArray);
$this->numReadRows++;
} else {
@ -224,7 +224,7 @@ class RowIterator implements IteratorInterface
*
* @return Row|null
*/
public function current()
public function current() : ?Row
{
return $this->rowBuffer;
}
@ -235,7 +235,7 @@ class RowIterator implements IteratorInterface
*
* @return int
*/
public function key()
public function key() : int
{
return $this->numReadRows;
}
@ -245,7 +245,7 @@ class RowIterator implements IteratorInterface
*
* @return void
*/
public function end()
public function end() : void
{
// do nothing
}

View File

@ -10,7 +10,7 @@ use Box\Spout\Reader\IteratorInterface;
*/
class SheetIterator implements IteratorInterface
{
/** @var \Box\Spout\Reader\CSV\Sheet The CSV unique "sheet" */
/** @var Sheet The CSV unique "sheet" */
protected $sheet;
/** @var bool Whether the unique "sheet" has already been read */
@ -30,7 +30,7 @@ class SheetIterator implements IteratorInterface
*
* @return void
*/
public function rewind()
public function rewind() : void
{
$this->hasReadUniqueSheet = false;
}
@ -41,7 +41,7 @@ class SheetIterator implements IteratorInterface
*
* @return bool
*/
public function valid()
public function valid() : bool
{
return (!$this->hasReadUniqueSheet);
}
@ -52,7 +52,7 @@ class SheetIterator implements IteratorInterface
*
* @return void
*/
public function next()
public function next() : void
{
$this->hasReadUniqueSheet = true;
}
@ -61,9 +61,9 @@ class SheetIterator implements IteratorInterface
* Return the current element
* @see http://php.net/manual/en/iterator.current.php
*
* @return \Box\Spout\Reader\CSV\Sheet
* @return Sheet
*/
public function current()
public function current() : Sheet
{
return $this->sheet;
}
@ -74,7 +74,7 @@ class SheetIterator implements IteratorInterface
*
* @return int
*/
public function key()
public function key() : int
{
return 1;
}
@ -84,7 +84,7 @@ class SheetIterator implements IteratorInterface
*
* @return void
*/
public function end()
public function end() : void
{
// do nothing
}

View File

@ -118,7 +118,7 @@ class RowIterator implements IteratorInterface
* @throws \Box\Spout\Reader\Exception\IteratorNotRewindableException If the iterator is rewound more than once
* @return void
*/
public function rewind()
public function rewind() : void
{
// Because sheet and row data is located in the file, we can't rewind both the
// sheet iterator and the row iterator, as XML file cannot be read backwards.
@ -142,7 +142,7 @@ class RowIterator implements IteratorInterface
*
* @return bool
*/
public function valid()
public function valid() : bool
{
return (!$this->hasReachedEndOfFile);
}
@ -155,7 +155,7 @@ class RowIterator implements IteratorInterface
* @throws \Box\Spout\Common\Exception\IOException If unable to read the sheet data XML
* @return void
*/
public function next()
public function next() : void
{
if ($this->doesNeedDataForNextRowToBeProcessed()) {
$this->readDataForNextRow();
@ -356,7 +356,7 @@ class RowIterator implements IteratorInterface
*
* @return Row
*/
public function current()
public function current() : Row
{
return $this->rowBuffer;
}
@ -367,7 +367,7 @@ class RowIterator implements IteratorInterface
*
* @return int
*/
public function key()
public function key() : int
{
return $this->lastRowIndexProcessed;
}
@ -377,7 +377,7 @@ class RowIterator implements IteratorInterface
*
* @return void
*/
public function end()
public function end() : void
{
$this->xmlReader->close();
}

View File

@ -139,7 +139,7 @@ class RowIterator implements IteratorInterface
* @throws \Box\Spout\Common\Exception\IOException If the sheet data XML cannot be read
* @return void
*/
public function rewind()
public function rewind() : void
{
$this->xmlReader->close();
@ -163,7 +163,7 @@ class RowIterator implements IteratorInterface
*
* @return bool
*/
public function valid()
public function valid() : bool
{
return (!$this->hasReachedEndOfFile);
}
@ -176,7 +176,7 @@ class RowIterator implements IteratorInterface
* @throws \Box\Spout\Common\Exception\IOException If unable to read the sheet data XML
* @return void
*/
public function next()
public function next() : void
{
$this->nextRowIndexToBeProcessed++;
@ -374,7 +374,7 @@ class RowIterator implements IteratorInterface
*
* @return Row|null
*/
public function current()
public function current() : ?Row
{
$rowToBeProcessed = $this->rowBuffer;
@ -399,7 +399,7 @@ class RowIterator implements IteratorInterface
*
* @return int
*/
public function key()
public function key() : int
{
// TODO: This should return $this->nextRowIndexToBeProcessed
// but to avoid a breaking change, the return value for
@ -414,7 +414,7 @@ class RowIterator implements IteratorInterface
*
* @return void
*/
public function end()
public function end() : void
{
$this->xmlReader->close();
}