mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 12:32:08 +02:00
MDL-78262 lib_spout: Update box/spout to address PHP 8.1 deprecation
This commit is contained in:
parent
017a3274fe
commit
a229905760
@ -4,6 +4,13 @@ Description of Spout library import
|
||||
* Only include the src/Spout directory.
|
||||
* Update lib/thirdpartylibs.xml with the latest version.
|
||||
|
||||
2023/05/26
|
||||
----------
|
||||
MDL-78262 lib_spout: Update box/spout to address PHP 8.1 deprecation
|
||||
This change is a direct pull from an upstream fix:
|
||||
https://github.com/openspout/openspout/commit/e75f6f73012b81fd5fee6107d0af9e86c458448e
|
||||
This addresses the deprecation of str_replace() in PHP 8.1.
|
||||
|
||||
2022/11/25
|
||||
----------
|
||||
Imported PHP 8.1 patch from OpenSpout/OpenSpout 4.8.1
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -84,8 +84,7 @@ class RowIterator implements IteratorInterface
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function rewind()
|
||||
public function rewind() : void
|
||||
{
|
||||
$this->rewindAndSkipBom();
|
||||
|
||||
@ -115,8 +114,7 @@ class RowIterator implements IteratorInterface
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function valid()
|
||||
public function valid() : bool
|
||||
{
|
||||
return ($this->filePointer && !$this->hasReachedEndOfFile);
|
||||
}
|
||||
@ -128,8 +126,7 @@ class RowIterator implements IteratorInterface
|
||||
* @throws \Box\Spout\Common\Exception\EncodingConversionException If unable to convert data to UTF-8
|
||||
* @return void
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function next()
|
||||
public function next() : void
|
||||
{
|
||||
$this->hasReachedEndOfFile = $this->globalFunctionsHelper->feof($this->filePointer);
|
||||
|
||||
@ -149,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 {
|
||||
@ -227,8 +224,7 @@ class RowIterator implements IteratorInterface
|
||||
*
|
||||
* @return Row|null
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function current()
|
||||
public function current() : ?Row
|
||||
{
|
||||
return $this->rowBuffer;
|
||||
}
|
||||
@ -239,8 +235,7 @@ class RowIterator implements IteratorInterface
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function key()
|
||||
public function key() : int
|
||||
{
|
||||
return $this->numReadRows;
|
||||
}
|
||||
@ -250,7 +245,7 @@ class RowIterator implements IteratorInterface
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function end()
|
||||
public function end() : void
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
@ -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,8 +30,7 @@ class SheetIterator implements IteratorInterface
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function rewind()
|
||||
public function rewind() : void
|
||||
{
|
||||
$this->hasReadUniqueSheet = false;
|
||||
}
|
||||
@ -42,8 +41,7 @@ class SheetIterator implements IteratorInterface
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function valid()
|
||||
public function valid() : bool
|
||||
{
|
||||
return (!$this->hasReadUniqueSheet);
|
||||
}
|
||||
@ -54,8 +52,7 @@ class SheetIterator implements IteratorInterface
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function next()
|
||||
public function next() : void
|
||||
{
|
||||
$this->hasReadUniqueSheet = true;
|
||||
}
|
||||
@ -64,10 +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
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function current()
|
||||
public function current() : Sheet
|
||||
{
|
||||
return $this->sheet;
|
||||
}
|
||||
@ -78,8 +74,7 @@ class SheetIterator implements IteratorInterface
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function key()
|
||||
public function key() : int
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@ -89,7 +84,7 @@ class SheetIterator implements IteratorInterface
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function end()
|
||||
public function end() : void
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
@ -118,8 +118,7 @@ class RowIterator implements IteratorInterface
|
||||
* @throws \Box\Spout\Reader\Exception\IteratorNotRewindableException If the iterator is rewound more than once
|
||||
* @return void
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
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.
|
||||
@ -143,8 +142,7 @@ class RowIterator implements IteratorInterface
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function valid()
|
||||
public function valid() : bool
|
||||
{
|
||||
return (!$this->hasReachedEndOfFile);
|
||||
}
|
||||
@ -157,8 +155,7 @@ class RowIterator implements IteratorInterface
|
||||
* @throws \Box\Spout\Common\Exception\IOException If unable to read the sheet data XML
|
||||
* @return void
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function next()
|
||||
public function next() : void
|
||||
{
|
||||
if ($this->doesNeedDataForNextRowToBeProcessed()) {
|
||||
$this->readDataForNextRow();
|
||||
@ -359,8 +356,7 @@ class RowIterator implements IteratorInterface
|
||||
*
|
||||
* @return Row
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function current()
|
||||
public function current() : Row
|
||||
{
|
||||
return $this->rowBuffer;
|
||||
}
|
||||
@ -371,8 +367,7 @@ class RowIterator implements IteratorInterface
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function key()
|
||||
public function key() : int
|
||||
{
|
||||
return $this->lastRowIndexProcessed;
|
||||
}
|
||||
@ -382,8 +377,7 @@ class RowIterator implements IteratorInterface
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function end()
|
||||
public function end() : void
|
||||
{
|
||||
$this->xmlReader->close();
|
||||
}
|
||||
|
@ -139,8 +139,7 @@ class RowIterator implements IteratorInterface
|
||||
* @throws \Box\Spout\Common\Exception\IOException If the sheet data XML cannot be read
|
||||
* @return void
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function rewind()
|
||||
public function rewind() : void
|
||||
{
|
||||
$this->xmlReader->close();
|
||||
|
||||
@ -164,8 +163,7 @@ class RowIterator implements IteratorInterface
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function valid()
|
||||
public function valid() : bool
|
||||
{
|
||||
return (!$this->hasReachedEndOfFile);
|
||||
}
|
||||
@ -178,8 +176,7 @@ class RowIterator implements IteratorInterface
|
||||
* @throws \Box\Spout\Common\Exception\IOException If unable to read the sheet data XML
|
||||
* @return void
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function next()
|
||||
public function next() : void
|
||||
{
|
||||
$this->nextRowIndexToBeProcessed++;
|
||||
|
||||
@ -377,8 +374,7 @@ class RowIterator implements IteratorInterface
|
||||
*
|
||||
* @return Row|null
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function current()
|
||||
public function current() : ?Row
|
||||
{
|
||||
$rowToBeProcessed = $this->rowBuffer;
|
||||
|
||||
@ -403,8 +399,7 @@ class RowIterator implements IteratorInterface
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function key()
|
||||
public function key() : int
|
||||
{
|
||||
// TODO: This should return $this->nextRowIndexToBeProcessed
|
||||
// but to avoid a breaking change, the return value for
|
||||
@ -419,8 +414,7 @@ class RowIterator implements IteratorInterface
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function end()
|
||||
public function end() : void
|
||||
{
|
||||
$this->xmlReader->close();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user