aws / aws/aws-sdk-php

Document arguments of various clients via proper detailed type definitions

Open
#3,309 9 comments 5 reactions 1 assignee Claimed by @stobrien89 View on GitHub
feature-request
Dominant language
PHP
Stars
6.2k
Forks
1.3k
Avg merge
2h 53m
Merged PRs (30d)
7

Description

### Describe the feature

## Context

Today, I wrote this:

```php
private function instancesToDelete($tags) {
return $this->rds->describeDBInstances(['Tags' => $tags])
}
```

This almost got me to delete production DBs by accident: `Tags` is completely ignored by `RdsClient#describeDBInstances()`.

/cc @marcostagno @albertomolinari

## The current API "documentation"

This proposal is about documenting clear array shapes for each API endpoint.

Currently, most API endpoints are documented as:

```php
/**
* @method \Aws\Result describeDBInstances(array $args = [])
*/
```

It suffices to say that **this is absolutely useless rubbish**.

## The proposal

The generated API documentation should change, and become:

```php
/**
* @method \Aws\Result> describeDBInstances(array{
* baz?: detailed-type-of-baz,
* taz?: detailed-rtype-of-taz
* } $args = [])
*/
```

This is **actually useful**, self-documenting, and helpful for static analysis tooling (Psalm, PHPStan, Mago, Phan).

### Use Case

This feature removes the need for jumping around web documentation when using the AWS SDK.

### Proposed Solution

The code generator should convert documented types that are used under the hood into PHP types:

* arrays
* lists
* non-empty-lists
* string
* non-empty-string
* int
* int<1, max>
* etc.

### Other Information

_No response_

### Acknowledgements

- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change

### SDK version used

3.379.0

### Environment details (Version of PHP (`php -v`)? OS name and version, etc.)

PHP 8.4

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.