Fix PHP 8.1 deprecations
This commit is contained in:
parent
24dcb60373
commit
db1a7218d5
@ -82,7 +82,7 @@ class GlobalFunctionsHelper
|
|||||||
* @param int|null $length
|
* @param int|null $length
|
||||||
* @param string|null $delimiter
|
* @param string|null $delimiter
|
||||||
* @param string|null $enclosure
|
* @param string|null $enclosure
|
||||||
* @return array
|
* @return array|false
|
||||||
*/
|
*/
|
||||||
public function fgetcsv($handle, $length = null, $delimiter = null, $enclosure = null)
|
public function fgetcsv($handle, $length = null, $delimiter = null, $enclosure = null)
|
||||||
{
|
{
|
||||||
|
@ -84,7 +84,7 @@ class RowIterator implements IteratorInterface
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function rewind()
|
public function rewind() : void
|
||||||
{
|
{
|
||||||
$this->rewindAndSkipBom();
|
$this->rewindAndSkipBom();
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ class RowIterator implements IteratorInterface
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function valid()
|
public function valid() : bool
|
||||||
{
|
{
|
||||||
return ($this->filePointer && !$this->hasReachedEndOfFile);
|
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
|
* @throws \Box\Spout\Common\Exception\EncodingConversionException If unable to convert data to UTF-8
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function next()
|
public function next() : void
|
||||||
{
|
{
|
||||||
$this->hasReachedEndOfFile = $this->globalFunctionsHelper->feof($this->filePointer);
|
$this->hasReachedEndOfFile = $this->globalFunctionsHelper->feof($this->filePointer);
|
||||||
|
|
||||||
@ -146,8 +146,8 @@ class RowIterator implements IteratorInterface
|
|||||||
} while ($this->shouldReadNextRow($rowData));
|
} while ($this->shouldReadNextRow($rowData));
|
||||||
|
|
||||||
if ($rowData !== false) {
|
if ($rowData !== false) {
|
||||||
// str_replace will replace NULL values by empty strings
|
// array_map will replace NULL values by empty strings
|
||||||
$rowDataBufferAsArray = \str_replace(null, null, $rowData);
|
$rowDataBufferAsArray = array_map(function ($value) { return (string) $value; }, $rowData);
|
||||||
$this->rowBuffer = $this->entityFactory->createRowFromArray($rowDataBufferAsArray);
|
$this->rowBuffer = $this->entityFactory->createRowFromArray($rowDataBufferAsArray);
|
||||||
$this->numReadRows++;
|
$this->numReadRows++;
|
||||||
} else {
|
} else {
|
||||||
@ -224,7 +224,7 @@ class RowIterator implements IteratorInterface
|
|||||||
*
|
*
|
||||||
* @return Row|null
|
* @return Row|null
|
||||||
*/
|
*/
|
||||||
public function current()
|
public function current() : ?Row
|
||||||
{
|
{
|
||||||
return $this->rowBuffer;
|
return $this->rowBuffer;
|
||||||
}
|
}
|
||||||
@ -235,7 +235,7 @@ class RowIterator implements IteratorInterface
|
|||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function key()
|
public function key() : int
|
||||||
{
|
{
|
||||||
return $this->numReadRows;
|
return $this->numReadRows;
|
||||||
}
|
}
|
||||||
@ -245,7 +245,7 @@ class RowIterator implements IteratorInterface
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function end()
|
public function end() : void
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ use Box\Spout\Reader\IteratorInterface;
|
|||||||
*/
|
*/
|
||||||
class SheetIterator implements IteratorInterface
|
class SheetIterator implements IteratorInterface
|
||||||
{
|
{
|
||||||
/** @var \Box\Spout\Reader\CSV\Sheet The CSV unique "sheet" */
|
/** @var Sheet The CSV unique "sheet" */
|
||||||
protected $sheet;
|
protected $sheet;
|
||||||
|
|
||||||
/** @var bool Whether the unique "sheet" has already been read */
|
/** @var bool Whether the unique "sheet" has already been read */
|
||||||
@ -30,7 +30,7 @@ class SheetIterator implements IteratorInterface
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function rewind()
|
public function rewind() : void
|
||||||
{
|
{
|
||||||
$this->hasReadUniqueSheet = false;
|
$this->hasReadUniqueSheet = false;
|
||||||
}
|
}
|
||||||
@ -41,7 +41,7 @@ class SheetIterator implements IteratorInterface
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function valid()
|
public function valid() : bool
|
||||||
{
|
{
|
||||||
return (!$this->hasReadUniqueSheet);
|
return (!$this->hasReadUniqueSheet);
|
||||||
}
|
}
|
||||||
@ -52,7 +52,7 @@ class SheetIterator implements IteratorInterface
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function next()
|
public function next() : void
|
||||||
{
|
{
|
||||||
$this->hasReadUniqueSheet = true;
|
$this->hasReadUniqueSheet = true;
|
||||||
}
|
}
|
||||||
@ -61,9 +61,9 @@ class SheetIterator implements IteratorInterface
|
|||||||
* Return the current element
|
* Return the current element
|
||||||
* @see http://php.net/manual/en/iterator.current.php
|
* @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;
|
return $this->sheet;
|
||||||
}
|
}
|
||||||
@ -74,7 +74,7 @@ class SheetIterator implements IteratorInterface
|
|||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function key()
|
public function key() : int
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -84,7 +84,7 @@ class SheetIterator implements IteratorInterface
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function end()
|
public function end() : void
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ class RowIterator implements IteratorInterface
|
|||||||
* @throws \Box\Spout\Reader\Exception\IteratorNotRewindableException If the iterator is rewound more than once
|
* @throws \Box\Spout\Reader\Exception\IteratorNotRewindableException If the iterator is rewound more than once
|
||||||
* @return void
|
* @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
|
// 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.
|
// sheet iterator and the row iterator, as XML file cannot be read backwards.
|
||||||
@ -142,7 +142,7 @@ class RowIterator implements IteratorInterface
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function valid()
|
public function valid() : bool
|
||||||
{
|
{
|
||||||
return (!$this->hasReachedEndOfFile);
|
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
|
* @throws \Box\Spout\Common\Exception\IOException If unable to read the sheet data XML
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function next()
|
public function next() : void
|
||||||
{
|
{
|
||||||
if ($this->doesNeedDataForNextRowToBeProcessed()) {
|
if ($this->doesNeedDataForNextRowToBeProcessed()) {
|
||||||
$this->readDataForNextRow();
|
$this->readDataForNextRow();
|
||||||
@ -356,7 +356,7 @@ class RowIterator implements IteratorInterface
|
|||||||
*
|
*
|
||||||
* @return Row
|
* @return Row
|
||||||
*/
|
*/
|
||||||
public function current()
|
public function current() : Row
|
||||||
{
|
{
|
||||||
return $this->rowBuffer;
|
return $this->rowBuffer;
|
||||||
}
|
}
|
||||||
@ -367,7 +367,7 @@ class RowIterator implements IteratorInterface
|
|||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function key()
|
public function key() : int
|
||||||
{
|
{
|
||||||
return $this->lastRowIndexProcessed;
|
return $this->lastRowIndexProcessed;
|
||||||
}
|
}
|
||||||
@ -377,7 +377,7 @@ class RowIterator implements IteratorInterface
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function end()
|
public function end() : void
|
||||||
{
|
{
|
||||||
$this->xmlReader->close();
|
$this->xmlReader->close();
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ class RowIterator implements IteratorInterface
|
|||||||
* @throws \Box\Spout\Common\Exception\IOException If the sheet data XML cannot be read
|
* @throws \Box\Spout\Common\Exception\IOException If the sheet data XML cannot be read
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function rewind()
|
public function rewind() : void
|
||||||
{
|
{
|
||||||
$this->xmlReader->close();
|
$this->xmlReader->close();
|
||||||
|
|
||||||
@ -163,7 +163,7 @@ class RowIterator implements IteratorInterface
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function valid()
|
public function valid() : bool
|
||||||
{
|
{
|
||||||
return (!$this->hasReachedEndOfFile);
|
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
|
* @throws \Box\Spout\Common\Exception\IOException If unable to read the sheet data XML
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function next()
|
public function next() : void
|
||||||
{
|
{
|
||||||
$this->nextRowIndexToBeProcessed++;
|
$this->nextRowIndexToBeProcessed++;
|
||||||
|
|
||||||
@ -374,7 +374,7 @@ class RowIterator implements IteratorInterface
|
|||||||
*
|
*
|
||||||
* @return Row|null
|
* @return Row|null
|
||||||
*/
|
*/
|
||||||
public function current()
|
public function current() : ?Row
|
||||||
{
|
{
|
||||||
$rowToBeProcessed = $this->rowBuffer;
|
$rowToBeProcessed = $this->rowBuffer;
|
||||||
|
|
||||||
@ -399,7 +399,7 @@ class RowIterator implements IteratorInterface
|
|||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function key()
|
public function key() : int
|
||||||
{
|
{
|
||||||
// TODO: This should return $this->nextRowIndexToBeProcessed
|
// TODO: This should return $this->nextRowIndexToBeProcessed
|
||||||
// but to avoid a breaking change, the return value for
|
// but to avoid a breaking change, the return value for
|
||||||
@ -414,7 +414,7 @@ class RowIterator implements IteratorInterface
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function end()
|
public function end() : void
|
||||||
{
|
{
|
||||||
$this->xmlReader->close();
|
$this->xmlReader->close();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user