Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

Fix incompatible return types for PHP 8.1 #874

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/Spout/Reader/ODS/SheetIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function __construct($filePath, $optionsManager, $escaper, $settingsHelpe
* @throws \Box\Spout\Common\Exception\IOException If unable to open the XML file containing sheets' data
* @return void
*/
public function rewind()
public function rewind() : void
{
$this->xmlReader->close();

Expand All @@ -103,7 +103,7 @@ public function rewind()
*
* @return array Associative array [STYLE_NAME] => [IS_SHEET_VISIBLE]
*/
private function readSheetsVisibility()
private function readSheetsVisibility() : array
{
$sheetsVisibility = [];

Expand Down Expand Up @@ -132,7 +132,7 @@ private function readSheetsVisibility()
*
* @return bool
*/
public function valid()
public function valid() : bool
{
return $this->hasFoundSheet;
}
Expand All @@ -143,7 +143,7 @@ public function valid()
*
* @return void
*/
public function next()
public function next() : void
{
$this->hasFoundSheet = $this->xmlReader->readUntilNodeFound(self::XML_NODE_TABLE);

Expand All @@ -156,9 +156,9 @@ public function next()
* Return the current element
* @see http://php.net/manual/en/iterator.current.php
*
* @return \Box\Spout\Reader\ODS\Sheet
* @return Sheet
*/
public function current()
public function current() : Sheet
{
$escapedSheetName = $this->xmlReader->getAttribute(self::XML_ATTRIBUTE_TABLE_NAME);
$sheetName = $this->escaper->unescape($escapedSheetName);
Expand Down Expand Up @@ -186,7 +186,7 @@ public function current()
* @param string|null $activeSheetName Name of the sheet that was defined as active or NULL if none defined
* @return bool Whether the current sheet was defined as the active one
*/
private function isSheetActive($sheetName, $sheetIndex, $activeSheetName)
private function isSheetActive($sheetName, $sheetIndex, $activeSheetName) : bool
{
// The given sheet is active if its name matches the defined active sheet's name
// or if no information about the active sheet was found, it defaults to the first sheet.
Expand All @@ -202,7 +202,7 @@ private function isSheetActive($sheetName, $sheetIndex, $activeSheetName)
* @param string $sheetStyleName Name of the sheet style
* @return bool Whether the current sheet is visible
*/
private function isSheetVisible($sheetStyleName)
private function isSheetVisible($sheetStyleName) : bool
{
return isset($this->sheetsVisibility[$sheetStyleName]) ?
$this->sheetsVisibility[$sheetStyleName] :
Expand All @@ -215,7 +215,7 @@ private function isSheetVisible($sheetStyleName)
*
* @return int
*/
public function key()
public function key() : int
{
return $this->currentSheetIndex + 1;
}
Expand All @@ -225,7 +225,7 @@ public function key()
*
* @return void
*/
public function end()
public function end() : void
{
$this->xmlReader->close();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Spout/Reader/Wrapper/XMLReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ protected function fileExistsWithinZip($zipStreamURI)
* @throws \Box\Spout\Reader\Exception\XMLProcessingException If an error/warning occurred
* @return bool TRUE on success or FALSE on failure
*/
public function read()
public function read() : bool
{
$this->useXMLInternalErrors();

Expand Down Expand Up @@ -119,7 +119,7 @@ public function readUntilNodeFound($nodeName)
* @throws \Box\Spout\Reader\Exception\XMLProcessingException If an error/warning occurred
* @return bool TRUE on success or FALSE on failure
*/
public function next($localName = null)
public function next($localName = null) : bool
{
$this->useXMLInternalErrors();

Expand Down
14 changes: 7 additions & 7 deletions src/Spout/Reader/XLSX/SheetIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __construct($sheetManager)
*
* @return void
*/
public function rewind()
public function rewind() : void
{
$this->currentSheetIndex = 0;
}
Expand All @@ -49,7 +49,7 @@ public function rewind()
*
* @return bool
*/
public function valid()
public function valid() : bool
{
return ($this->currentSheetIndex < \count($this->sheets));
}
Expand All @@ -60,7 +60,7 @@ public function valid()
*
* @return void
*/
public function next()
public function next() : void
{
// Using isset here because it is way faster than array_key_exists...
if (isset($this->sheets[$this->currentSheetIndex])) {
Expand All @@ -75,9 +75,9 @@ public function next()
* Return the current element
* @see http://php.net/manual/en/iterator.current.php
*
* @return \Box\Spout\Reader\XLSX\Sheet
* @return Sheet
*/
public function current()
public function current() : Sheet
{
return $this->sheets[$this->currentSheetIndex];
}
Expand All @@ -88,7 +88,7 @@ public function current()
*
* @return int
*/
public function key()
public function key() : int
{
return $this->currentSheetIndex + 1;
}
Expand All @@ -98,7 +98,7 @@ public function key()
*
* @return void
*/
public function end()
public function end() : void
{
// make sure we are not leaking memory in case the iteration stopped before the end
foreach ($this->sheets as $sheet) {
Expand Down