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

Deprecated warnings for incompatible return types in PHP 8.1 #846

@fabacino

Description

@fabacino

Since PHP 8.1 most methods of internal classes require a compatible return type when overriding them (see Return Type Compatibility with Internal Classes).

This results in deprecated warnings for the following classes:

  • Box\Spout\Reader\CSV\RowIterator
  • Box\Spout\Reader\CSV\SheetIterator
  • Box\Spout\Reader\ODS\RowIterator
  • Box\Spout\Reader\ODS\SheetIterator
  • Box\Spout\Reader\Wrapper\XMLReader
  • Box\Spout\Reader\XLSX\RowIterator
  • Box\Spout\Reader\XLSX\SheetIterator

Sample output for Box\Spout\Reader\CSV\RowIterator:

❯ vendor/bin/phpunit | grep -i "deprecated: return type" | grep -i 'csv\\rowiterator'

Deprecated: Return type of Box\Spout\Reader\CSV\RowIterator::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in src/Spout/Reader/CSV/RowIterator.php on line 227
Deprecated: Return type of Box\Spout\Reader\CSV\RowIterator::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in src/Spout/Reader/CSV/RowIterator.php on line 129
Deprecated: Return type of Box\Spout\Reader\CSV\RowIterator::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in src/Spout/Reader/CSV/RowIterator.php on line 238
Deprecated: Return type of Box\Spout\Reader\CSV\RowIterator::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in src/Spout/Reader/CSV/RowIterator.php on line 117
Deprecated: Return type of Box\Spout\Reader\CSV\RowIterator::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in src/Spout/Reader/CSV/RowIterator.php on line 87

Adding the #[\ReturnTypeWillChange] attribute to these methods fixes the issue. I can PR if appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions