[wp-trac] [WordPress Trac] #57972: PHP Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /wp-includes/Requests/Utility/CaseInsensitiveDictionary.php

WordPress Trac noreply at wordpress.org
Thu Mar 23 02:15:31 UTC 2023


#57972: PHP Deprecated:  Return type of
Requests_Utility_CaseInsensitiveDictionary::getIterator() should either be
compatible with IteratorAggregate::getIterator(): Traversable, or the
#[\ReturnTypeWillChange] attribute should be used to temporarily suppress
the notice in /wp-includes/Requests/Utility/CaseInsensitiveDictionary.php
--------------------------+-----------------------------
 Reporter:  codelyfe      |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Here is the fix:

 {{{
 public function getIterator(): iterable { // Add 'iterable' to the return
 type
     return new \ArrayIterator($this->data);
 }
 #[\ReturnTypeWillChange] // Add the #[\ReturnTypeWillChange] attribute
 before the method declaration
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57972>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list