Skip to content

Conversation

@clue
Copy link
Member

@clueclue commented Oct 29, 2023

This changeset backports #40 from 4.x to 3.x to add type annotations to aid with static analysis. Most changes have been applied as-is, but v3 requires a number of workarounds to support legacy PHP versions.

If this PR is merged, we could backport most of the changes from v3 to v2. The changes are somewhat similar across all versions, but v2 still supports legacy PHP and doesn't currently employ PHPStan as discussed in #77. Let's continue this discussion outside of this PR.

Builds on top of #40 and #77

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 ```
@clueclue added the new feature New feature or request label Oct 29, 2023
@clueclue added this to the v3.2.0 milestone Oct 29, 2023
Copy link
Member

@WyriHaximusWyriHaximus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new featureNew feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@clue@WyriHaximus@SimonFrings