PHP 8.1 deprecated notices

Created on 6 April 2023, over 1 year ago
Updated 15 December 2023, 11 months ago

Problem:

Using phpstan tool were found deprecated notices

  • in crumbs/lib/Container/MultiWildcardData.php:

line 50 Return type mixed of method crumbs_Container_MultiWildcardData::getIterator() is not covariant with tentative return type Traversable of method IteratorAggregate::getIterator()
line 58 Return type mixed of method crumbs_Container_MultiWildcardData::offsetGet() is not covariant with tentative return type mixed of method ArrayAccess::offsetGet()
line 67 Return type mixed of method crumbs_Container_MultiWildcardData::offsetSet() is not covariant with tentative return type void of method ArrayAccess::offsetSet()
line 75 Return type mixed of method crumbs_Container_MultiWildcardData::offsetExists() is not covariant with tentative return type bool of method ArrayAccess::offsetExists()
line 83 Return type mixed of method crumbs_Container_MultiWildcardData::offsetUnset() is not covariant with tentative return type void of method ArrayAccess::offsetUnset()

  • in crumbs/lib/Container/MultiWildcardDataIterator.php:

line 22 Return type mixed of method crumbs_Container_MultiWildcardDataIterator::current() is not covariant with tentative return type mixed of method Iterator::current()

  • in crumbs/lib/PluginSystem/PluginMethodIterator.php:

line 60 Return type mixed of method crumbs_PluginSystem_PluginMethodIterator::current() is not covariant with tentative return type mixed of method Iterator::current()
line 71 Return type mixed of method crumbs_PluginSystem_PluginMethodIterator::key() is not covariant with tentative return type mixed of method Iterator::key()
line 83 Return type mixed of method crumbs_PluginSystem_PluginMethodIterator::valid() is not covariant with tentative return type bool of method Iterator::valid()
line 93 Return type mixed of method crumbs_PluginSystem_PluginMethodIterator::next() is not covariant with tentative return type void of method Iterator::next()
line 132 Return type mixed of method crumbs_PluginSystem_PluginMethodIterator::rewind() is not covariant with tentative return type void of method Iterator::rewind()

Proposed resolution:

Update return type to match the root method return type.

πŸ› Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

πŸ‡§πŸ‡ΎBelarus alena_stanul

Live updates comments and jobs are added and updated live.
  • PHP 8.1

    The issue particularly affects sites running on PHP version 8.1.0 or later.

Sign in to follow issues

Comments & Activities

  • Issue created by @alena_stanul
  • @alena_stanul opened merge request.
  • Status changed to Needs review over 1 year ago
  • πŸ‡©πŸ‡ͺGermany donquixote

    Thank you! The changes look reasonable.

    I was thinking that for a minimal fix, we only need to declare "; \Iterator" as a return type, not ": crumbs_Container_MultiWildcardDataIterator". But it is probably better to add the more explicit return type.

    I will need to take some time to test this myself.
    Until then, people can user your PR as a patch.

  • πŸ‡©πŸ‡ͺGermany donquixote

    Another option would be the `#[\ReturnTypeWillChange]` attribute.
    I will have to think about which solution is better.

  • πŸ‡ΊπŸ‡ΈUnited States aubjr_drupal

    Thanks for posting this patch, @alena_stanul. I went with your version since there was no followup. Tested and worked for me.

Production build 0.71.5 2024