Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] Add PHPDoc generics to Collection #1159

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
* @property string $url
* @property bool $has_more
* @property \Stripe\StripeObject[] $data
*
* @template TStripeObject of StripeObject
* @template-implements \IteratorAggregate<TStripeObject>
*/
class Collection extends StripeObject implements \Countable, \IteratorAggregate
{
Expand Down Expand Up @@ -60,6 +63,9 @@ public function offsetGet($k)
throw new Exception\InvalidArgumentException($msg);
}

/**
* @return Collection<TStripeObject>
*/
public function all($params = null, $opts = null)
{
self::_validateParams($params);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/InvoiceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down