stripe / stripe-php

PHP library for the Stripe API.

Home Page:https://stripe.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

@throws missing from autoPagingIterator()

ZacharyDuBois opened this issue · comments

Describe the bug

Right now, there is now @throws in the PHPDoc for the autoPagingIterator() method. This method makes calls to nextPage() and previousPage() which subsequently both call all() which throws ApiErrorException.

This should be added to all of the parent methods to hint when there is an unhandled exception point in IDEs. Right now, when I wrap an autoPagingIterator() loop in a try { } catch() {} block, there is nothing hinting to the IDE that exceptions can be thrown there.

Screenshot 2024-04-11 at 10 51 48 Screenshot 2024-04-11 at 10 52 02

To Reproduce

Use code snippet below with an IDE with decent PHP language support.

Expected behavior

IDE to complain when there is an unhandled exception.

Screenshot 2024-04-11 at 10 56 06

Code snippets

try {
    foreach ($balanceTransactions->autoPagingIterator() as $balanceTransaction) {
        // Do work
    }
} catch (RateLimitException|ApiErrorException $exception) {
    // IDE thinks this is unreachable/not thrown in anything above.
}

OS

macOS

PHP version

PHP8.3

Library version

13.17.0

API version

2023-10-16

Additional context

Using PhpStorm 2024.1

Related to #605 but different section of the codebase.

Thanks for reporting @ZacharyDuBois
The fix is out in today's release - version 14.3.0

Wooo! Thank you! Worked over here!