From 171da9afda7fc31b26a21c23459537a1104ed1ca Mon Sep 17 00:00:00 2001 From: Fran Moreno Date: Tue, 13 Jul 2021 09:05:59 +0200 Subject: [PATCH] Add generics to Collection --- lib/Collection.php | 12 ++++++++++++ lib/Service/InvoiceService.php | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/Collection.php b/lib/Collection.php index 899299d3d..6943fc524 100644 --- a/lib/Collection.php +++ b/lib/Collection.php @@ -9,6 +9,9 @@ * @property string $url * @property bool $has_more * @property \Stripe\StripeObject[] $data + * + * @template TStripeObject of StripeObject + * @template-implements \IteratorAggregate */ class Collection extends StripeObject implements \Countable, \IteratorAggregate { @@ -60,6 +63,9 @@ public function offsetGet($k) throw new Exception\InvalidArgumentException($msg); } + /** + * @return Collection + */ public function all($params = null, $opts = null) { self::_validateParams($params); @@ -77,6 +83,9 @@ public function all($params = null, $opts = null) return $obj; } + /** + * @return TStripeObject + */ public function create($params = null, $opts = null) { self::_validateParams($params); @@ -87,6 +96,9 @@ public function create($params = null, $opts = null) return Util\Util::convertToStripeObject($response, $opts); } + /** + * @return TStripeObject + */ public function retrieve($id, $params = null, $opts = null) { self::_validateParams($params); diff --git a/lib/Service/InvoiceService.php b/lib/Service/InvoiceService.php index 4e2efe696..b3abcbed8 100644 --- a/lib/Service/InvoiceService.php +++ b/lib/Service/InvoiceService.php @@ -16,7 +16,7 @@ class InvoiceService extends \Stripe\Service\AbstractService * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return \Stripe\Collection + * @return \Stripe\Collection<\Stripe\Invoice> */ public function all($params = null, $opts = null) {