clue · GitHub

@WyriHaximus @clue

These annotations will aid static analyses like PHPStan and Psalm to
enhance type-safety for this project and projects depending on it
These changes make the following example understandable by PHPStan:
```php
final readonly class User
{
    public function __construct(
        public string $name,
    )
}
/**
 * \React\Promise\PromiseInterface<User>
 */
function getCurrentUserFromDatabase(): \React\Promise\PromiseInterface
{
    // The following line would do the database query and fetch the
result from it
    // but keeping it simple for the sake of the example.
    return \React\Promise\resolve(new User('WyriHaximus'));
}
// For the sake of this example we're going to assume the following code
runs
// in \React\Async\async call
echo await(getCurrentUserFromDatabase())->name; // This echos:
WyriHaximus
```

Read the original on github.com ↗