Skip to content

Document arguments of various clients via proper detailed type definitions #3309

Description

@Ocramius

Describe the feature

Context

Today, I wrote this:

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:

/**
 * @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:

/**
 * @method \Aws\Result<list<array{
 *   foo: detailed-type-of-foo,
 *   bar: detailed-type-type-of-bar
 * }>> 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

Metadata

Metadata

Assignees

Labels

feature-requestA feature should be added or improved.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions