Skip to content

Recurly\Pager::key(): Return value must be of type mixed, none returned #786

@davedevelopment

Description

@davedevelopment

Describe the bug

The Pager implements the Iterator interface, but does not meet the contract. If this is a limitation, it could be noted in the docblock comments.

To Reproduce

    // Pager_Test.php

     public function testIteratorComaptability(): void                                                                                                                                                                                                                       
     {                                                                                                                                                                                                                                                                       
         $array = iterator_to_array($this->pager);                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                                             
         $this->assertEquals(3, count($array));                                                                                                                                                                                                                              
     }
1) PagerTest::testIteratorComaptability
TypeError: Recurly\Pager::key(): Return value must be of type mixed, none returned

/home/davem/src/recurly-client-php/lib/recurly/pager.php:113
/home/davem/src/recurly-client-php/tests/Pager_Test.php:138

Expected behavior

iterator_to_array($pager) to return an array or the documentation to make it clear that the Pager is not actually an Iterator etc.

Your Environment

  • Which version of this library are you using?
davem@wes:recurly-client-php:v3-v2021-02-25$ git rev-parse HEAD
1a02d110b61a77163027156f574f494fb8c0305e
  • Which version of php are you using?
davem@wes:recurly-client-php:v3-v2021-02-25$ php -v
PHP 8.2.8 (cli) (built: Jul 21 2023 11:32:32) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.8, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.8, Copyright (c), by Zend Technologies

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions