PHPackages                             rikudou/aws-sdk-phpstan - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. rikudou/aws-sdk-phpstan

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

rikudou/aws-sdk-phpstan
=======================

Allows strong typing for AWS SDK

v0.9.3(1y ago)1618.6k↑34.2%1MITPHPPHP ^8.0

Since Mar 9Pushed 1y ago2 watchersCompare

[ Source](https://github.com/RikudouSage/AwsSdkPhpstan)[ Packagist](https://packagist.org/packages/rikudou/aws-sdk-phpstan)[ RSS](/packages/rikudou-aws-sdk-phpstan/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (5)Versions (5)Used By (0)

AWS SDK PHPStan extension
=========================

[](#aws-sdk-phpstan-extension)

This extension helps PHPStan to correctly determine the return type of all the SDK api calls.

**Table of contents**

- [AWS SDK PHPStan extension](#aws-sdk-phpstan-extension)
    - [Installation](#installation)
    - [Usage](#usage)
    - [How does it work?](#how-does-it-work)
    - [Fine-tuning](#fine-tuning)

Installation
------------

[](#installation)

`composer require --dev rikudou/aws-sdk-phpstan`

If you also install [phpstan/extension-installer](https://github.com/phpstan/extension-installer) then you're all set!

 Manual installationIf you don't want to use `phpstan/extension-installer`, include extension.neon in your project's PHPStan config:

```
includes:
    - vendor/rikudou/aws-sdk-phpstan/extension.neon

```

Usage
-----

[](#usage)

You can simply use AWS SDK as usual, except all return types are strongly typed and PHPStan knows exactly what type each key is.

> Note that using `treatPhpDocTypesAsCertain: false` in your phpstan.neon makes this extension entirely useless as all errors reported by the strong typing will be ignored.

For example:

```
$object = $this->s3Client->getObject([
    'Bucket' => 'my-cool-bucket',
    'Key' => 'test-file',
]);
if ($object->get('Name') === 'SomeName') {
    // todo do something
}
```

This prints the following:

`Strict comparison using === between null and 'SomeName' will always evaluate to false.`

That's because PHPStan knows that there's no property called `Name`!

Or something more specific:

```
$object = $this->s3Client->getObject([
    'Bucket' => 'my-cool-bucket',
    'Key' => 'test-file',
]);
if ($object->get('ChecksumType') === 'md5') {
    // todo do something
}
```

ChecksumType indeed exists, but it's very strictly typed to only two possible values, neither of which is md5. And indeed, PHPStan tells us:

`Strict comparison using === between 'COMPOSITE'|'FULL_OBJECT' and 'md5' will always evaluate to false.`

If you were to dump the PHPStan type of the `$object` variable, you'd get the following:

```
Aws\Result

```

How does it work?
-----------------

[](#how-does-it-work)

There's a build script that traverses the official AWS SDK for PHP data and extracts type information from them. Afterwards it converts the information to a PHPStan extension class that provides dynamic types based on the method being called (for example the [S3ClientReturnTypeExtension.](src/Types/S3ClientReturnTypeExtension.php)).

Additionally, the AWS `Result` class is made generic using a [stub file](stubs/Result.stub).

Fine-tuning
-----------

[](#fine-tuning)

By default, every single one of AWS clients is generated which can slow down PHPStan significantly and is rarely needed. The build script is included as part of the package, so you can automatically generate only the classes that interest you, for example if you wanted to only work with `S3Client` and `CloudFrontClient`, you could do the following:

**composer.json**:

```
{
  // your other settings
  "extra": {
    "aws-sdk-phpstan": {
      "only": [
        "Aws\\S3\\S3Client",
        "Aws\\CloudFront\\CloudFrontClient"
      ]
    }
  },
  // your other settings
}
```

Then, as part of your process, run the `vendor/bin/generate-aws-phpstan`. For example using the post install script of composer.json:

```
{
  // your other settings
  "extra": {
    "aws-sdk-phpstan": {
      "only": [
        "Aws\\S3\\S3Client",
        "Aws\\CloudFront\\CloudFrontClient"
      ]
    }
  },
  "scripts": {
    "post-install-cmd": [
      // your other post install scripts
      "generate-aws-phpstan"
    ],
    "post-update-cmd": [
      // your other post update scripts
      "generate-aws-phpstan"
    ]
  }
  // your other settings
}
```

If you now check the `vendor/rikudou/aws-sdk-phpstan/src/Types` directory, you should only see the following two files:

- `CloudFrontClientReturnTypeExtension.php`
- `S3ClientReturnTypeExtension.php`

Additionally, the `vendor/rikudou/aws-sdk-phpstan/extension.neon` should now only include the two above services.

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance49

Moderate activity, may be stable

Popularity35

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~35 days

Total

4

Last Release

374d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/34494ac1f08edc3758e51d84236ca1bdf384927e6444f2edb884e8cc585691b2?d=identicon)[RikudouSage](/maintainers/RikudouSage)

---

Top Contributors

[![RikudouSage](https://avatars.githubusercontent.com/u/13106547?v=4)](https://github.com/RikudouSage "RikudouSage (11 commits)")

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/rikudou-aws-sdk-phpstan/health.svg)

```
[![Health](https://phpackages.com/badges/rikudou-aws-sdk-phpstan/health.svg)](https://phpackages.com/packages/rikudou-aws-sdk-phpstan)
```

###  Alternatives

[symfony/symfony

The Symfony PHP framework

31.4k87.2M2.2k](/packages/symfony-symfony)[symfony/framework-bundle

Provides a tight integration between Symfony components and the Symfony full-stack framework

3.6k251.7M11.6k](/packages/symfony-framework-bundle)[symfony/security-bundle

Provides a tight integration of the Security component into the Symfony full-stack framework

2.5k185.6M2.4k](/packages/symfony-security-bundle)[symfony/web-profiler-bundle

Provides a development tool that gives detailed information about the execution of any request

2.3k160.5M1.2k](/packages/symfony-web-profiler-bundle)[pocketmine/pocketmine-mp

A server software for Minecraft: Bedrock Edition written in PHP

3.5k78.3k91](/packages/pocketmine-pocketmine-mp)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k43](/packages/civicrm-civicrm-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
