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. rikudou/aws-sdk-phpstan

ActiveLibrary

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

Allows strong typing for AWS SDK

v0.9.3(10mo ago)1613.8k↑184.4%1MITPHPPHP ^8.0

Since Mar 9Pushed 10mo 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 1mo ago

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

36

—

LowBetter than 82% of packages

Maintenance53

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

328d 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

[laravel/framework

The Laravel Framework.

34.7k509.9M17.0k](/packages/laravel-framework)[symfony/framework-bundle

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

3.6k235.4M9.7k](/packages/symfony-framework-bundle)[vimeo/psalm

A static analysis tool for finding errors in PHP applications

5.8k77.5M6.7k](/packages/vimeo-psalm)[behat/behat

Scenario-oriented BDD framework for PHP

4.0k96.8M2.0k](/packages/behat-behat)[symfony/security-bundle

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

2.5k172.9M1.8k](/packages/symfony-security-bundle)[robmorgan/phinx

Phinx makes it ridiculously easy to manage the database migrations for your PHP app.

4.5k46.2M405](/packages/robmorgan-phinx)

PHPackages © 2026

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