clue · GitHub

@clue

@clue

WyriHaximus

@clue

SimonFrings

WyriHaximus

@WyriHaximus

@clue

clue deleted the phpstan-v3 branch

June 21, 2023 15:19

WyriHaximus pushed a commit to WyriHaximus-secret-labs/promise that referenced this pull request

Jun 28, 2023
Adds template annotations turning the `PromiseInterface` into a generic.
Variables `$p1` and `$p2` in the following code example both are `PromiseInterface<int|string>`.
```php
$f = function (): int|string {
    return time() % 2 ? 'string' : time();
};
/**
 * @return PromiseInterface<int|string>
 */
$fp = function (): PromiseInterface {
    return resolve(time() % 2 ? 'string' : time());
};
$p1 = resolve($f());
$p2 = $fp();
```
When calling `then` on `$p1` or `$p2`, PHPStan understand that function `$f1` is type hinting its parameter fine, but `$f2` will throw during runtime:
```php
$p2->then(static function (int|string $a) {});
$p2->then(static function (bool $a) {});
```
Builds on top of reactphp#246 and reactphp#188 and is a requirement for reactphp/async#40

Merged

WyriHaximus pushed a commit to WyriHaximus-secret-labs/promise that referenced this pull request

Jul 2, 2023
Adds template annotations turning the `PromiseInterface` into a generic.
Variables `$p1` and `$p2` in the following code example both are `PromiseInterface<int|string>`.
```php
$f = function (): int|string {
    return time() % 2 ? 'string' : time();
};
/**
 * @return PromiseInterface<int|string>
 */
$fp = function (): PromiseInterface {
    return resolve(time() % 2 ? 'string' : time());
};
$p1 = resolve($f());
$p2 = $fp();
```
When calling `then` on `$p1` or `$p2`, PHPStan understand that function `$f1` is type hinting its parameter fine, but `$f2` will throw during runtime:
```php
$p2->then(static function (int|string $a) {});
$p2->then(static function (bool $a) {});
```
Builds on top of reactphp#246 and reactphp#188 and is a requirement for reactphp/async#40

WyriHaximus pushed a commit to WyriHaximus-secret-labs/promise that referenced this pull request

Jul 4, 2023
Adds template annotations turning the `PromiseInterface` into a generic.
Variables `$p1` and `$p2` in the following code example both are `PromiseInterface<int|string>`.
```php
$f = function (): int|string {
    return time() % 2 ? 'string' : time();
};
/**
 * @return PromiseInterface<int|string>
 */
$fp = function (): PromiseInterface {
    return resolve(time() % 2 ? 'string' : time());
};
$p1 = resolve($f());
$p2 = $fp();
```
When calling `then` on `$p1` or `$p2`, PHPStan understand that function `$f1` is type hinting its parameter fine, but `$f2` will throw during runtime:
```php
$p2->then(static function (int|string $a) {});
$p2->then(static function (bool $a) {});
```
Builds on top of reactphp#246 and reactphp#188 and is a requirement for reactphp/async#40

WyriHaximus pushed a commit to WyriHaximus-secret-labs/promise that referenced this pull request

Jul 4, 2023
Adds template annotations turning the `PromiseInterface` into a generic.
Variables `$p1` and `$p2` in the following code example both are `PromiseInterface<int|string>`.
```php
$f = function (): int|string {
    return time() % 2 ? 'string' : time();
};
/**
 * @return PromiseInterface<int|string>
 */
$fp = function (): PromiseInterface {
    return resolve(time() % 2 ? 'string' : time());
};
$p1 = resolve($f());
$p2 = $fp();
```
When calling `then` on `$p1` or `$p2`, PHPStan understand that function `$f1` is type hinting its parameter fine, but `$f2` will throw during runtime:
```php
$p2->then(static function (int|string $a) {});
$p2->then(static function (bool $a) {});
```
Builds on top of reactphp#246 and reactphp#188 and is a requirement for reactphp/async#40

WyriHaximus pushed a commit to WyriHaximus-secret-labs/promise that referenced this pull request

Jul 4, 2023
Adds template annotations turning the `PromiseInterface` into a generic.
Variables `$p1` and `$p2` in the following code example both are `PromiseInterface<int|string>`.
```php
$f = function (): int|string {
    return time() % 2 ? 'string' : time();
};
/**
 * @return PromiseInterface<int|string>
 */
$fp = function (): PromiseInterface {
    return resolve(time() % 2 ? 'string' : time());
};
$p1 = resolve($f());
$p2 = $fp();
```
When calling `then` on `$p1` or `$p2`, PHPStan understand that function `$f1` is type hinting its parameter fine, but `$f2` will throw during runtime:
```php
$p2->then(static function (int|string $a) {});
$p2->then(static function (bool $a) {});
```
Builds on top of reactphp#246 and reactphp#188 and is a requirement for reactphp/async#40

WyriHaximus pushed a commit to WyriHaximus-secret-labs/promise that referenced this pull request

Jul 4, 2023
Adds template annotations turning the `PromiseInterface` into a generic.
Variables `$p1` and `$p2` in the following code example both are `PromiseInterface<int|string>`.
```php
$f = function (): int|string {
    return time() % 2 ? 'string' : time();
};
/**
 * @return PromiseInterface<int|string>
 */
$fp = function (): PromiseInterface {
    return resolve(time() % 2 ? 'string' : time());
};
$p1 = resolve($f());
$p2 = $fp();
```
When calling `then` on `$p1` or `$p2`, PHPStan understand that function `$f1` is type hinting its parameter fine, but `$f2` will throw during runtime:
```php
$p2->then(static function (int|string $a) {});
$p2->then(static function (bool $a) {});
```
Builds on top of reactphp#246 and reactphp#188 and is a requirement for reactphp/async#40

WyriHaximus pushed a commit to WyriHaximus-secret-labs/promise that referenced this pull request

Jul 5, 2023
Adds template annotations turning the `PromiseInterface` into a generic.
Variables `$p1` and `$p2` in the following code example both are `PromiseInterface<int|string>`.
```php
$f = function (): int|string {
    return time() % 2 ? 'string' : time();
};
/**
 * @return PromiseInterface<int|string>
 */
$fp = function (): PromiseInterface {
    return resolve(time() % 2 ? 'string' : time());
};
$p1 = resolve($f());
$p2 = $fp();
```
When calling `then` on `$p1` or `$p2`, PHPStan understand that function `$f1` is type hinting its parameter fine, but `$f2` will throw during runtime:
```php
$p2->then(static function (int|string $a) {});
$p2->then(static function (bool $a) {});
```
Builds on top of reactphp#246 and reactphp#188 and is a requirement for reactphp/async#40

WyriHaximus pushed a commit to WyriHaximus-secret-labs/promise that referenced this pull request

Jul 5, 2023
Adds template annotations turning the `PromiseInterface` into a generic.
Variables `$p1` and `$p2` in the following code example both are `PromiseInterface<int|string>`.
```php
$f = function (): int|string {
    return time() % 2 ? 'string' : time();
};
/**
 * @return PromiseInterface<int|string>
 */
$fp = function (): PromiseInterface {
    return resolve(time() % 2 ? 'string' : time());
};
$p1 = resolve($f());
$p2 = $fp();
```
When calling `then` on `$p1` or `$p2`, PHPStan understand that function `$f1` is type hinting its parameter fine, but `$f2` will throw during runtime:
```php
$p2->then(static function (int|string $a) {});
$p2->then(static function (bool $a) {});
```
Builds on top of reactphp#246 and reactphp#188 and is a requirement for reactphp/async#40

WyriHaximus pushed a commit to WyriHaximus-secret-labs/promise that referenced this pull request

Jul 5, 2023
Adds template annotations turning the `PromiseInterface` into a generic.
Variables `$p1` and `$p2` in the following code example both are `PromiseInterface<int|string>`.
```php
$f = function (): int|string {
    return time() % 2 ? 'string' : time();
};
/**
 * @return PromiseInterface<int|string>
 */
$fp = function (): PromiseInterface {
    return resolve(time() % 2 ? 'string' : time());
};
$p1 = resolve($f());
$p2 = $fp();
```
When calling `then` on `$p1` or `$p2`, PHPStan understand that function `$f1` is type hinting its parameter fine, but `$f2` will throw during runtime:
```php
$p2->then(static function (int|string $a) {});
$p2->then(static function (bool $a) {});
```
Builds on top of reactphp#246 and reactphp#188 and is a requirement for reactphp/async#40

@clue clue mentioned this pull request

Jul 6, 2023

Merged

WyriHaximus pushed a commit to WyriHaximus-secret-labs/promise that referenced this pull request

Jul 7, 2023
Adds template annotations turning the `PromiseInterface` into a generic.
Variables `$p1` and `$p2` in the following code example both are `PromiseInterface<int|string>`.
```php
$f = function (): int|string {
    return time() % 2 ? 'string' : time();
};
/**
 * @return PromiseInterface<int|string>
 */
$fp = function (): PromiseInterface {
    return resolve(time() % 2 ? 'string' : time());
};
$p1 = resolve($f());
$p2 = $fp();
```
When calling `then` on `$p1` or `$p2`, PHPStan understand that function `$f1` is type hinting its parameter fine, but `$f2` will throw during runtime:
```php
$p2->then(static function (int|string $a) {});
$p2->then(static function (bool $a) {});
```
Builds on top of reactphp#246 and reactphp#188 and is a requirement for reactphp/async#40

WyriHaximus pushed a commit to WyriHaximus-secret-labs/promise that referenced this pull request

Jul 8, 2023
Adds template annotations turning the `PromiseInterface` into a generic.
Variables `$p1` and `$p2` in the following code example both are `PromiseInterface<int|string>`.
```php
$f = function (): int|string {
    return time() % 2 ? 'string' : time();
};
/**
 * @return PromiseInterface<int|string>
 */
$fp = function (): PromiseInterface {
    return resolve(time() % 2 ? 'string' : time());
};
$p1 = resolve($f());
$p2 = $fp();
```
When calling `then` on `$p1` or `$p2`, PHPStan understand that function `$f1` is type hinting its parameter fine, but `$f2` will throw during runtime:
```php
$p2->then(static function (int|string $a) {});
$p2->then(static function (bool $a) {});
```
Builds on top of reactphp#246 and reactphp#188 and is a requirement for reactphp/async#40

WyriHaximus pushed a commit to WyriHaximus-secret-labs/promise that referenced this pull request

Jul 8, 2023
Adds template annotations turning the `PromiseInterface` into a generic.
Variables `$p1` and `$p2` in the following code example both are `PromiseInterface<int|string>`.
```php
$f = function (): int|string {
    return time() % 2 ? 'string' : time();
};
/**
 * @return PromiseInterface<int|string>
 */
$fp = function (): PromiseInterface {
    return resolve(time() % 2 ? 'string' : time());
};
$p1 = resolve($f());
$p2 = $fp();
```
When calling `then` on `$p1` or `$p2`, PHPStan understand that function `$f1` is type hinting its parameter fine, but `$f2` will throw during runtime:
```php
$p2->then(static function (int|string $a) {});
$p2->then(static function (bool $a) {});
```
Builds on top of reactphp#246 and reactphp#188 and is a requirement for reactphp/async#40

WyriHaximus pushed a commit to WyriHaximus-secret-labs/promise that referenced this pull request

Jul 8, 2023
Adds template annotations turning the `PromiseInterface` into a generic.
Variables `$p1` and `$p2` in the following code example both are `PromiseInterface<int|string>`.
```php
$f = function (): int|string {
    return time() % 2 ? 'string' : time();
};
/**
 * @return PromiseInterface<int|string>
 */
$fp = function (): PromiseInterface {
    return resolve(time() % 2 ? 'string' : time());
};
$p1 = resolve($f());
$p2 = $fp();
```
When calling `then` on `$p1` or `$p2`, PHPStan understand that function `$f1` is type hinting its parameter fine, but `$f2` will throw during runtime:
```php
$p2->then(static function (int|string $a) {});
$p2->then(static function (bool $a) {});
```
Builds on top of reactphp#246 and reactphp#188 and is a requirement for reactphp/async#40

WyriHaximus pushed a commit to WyriHaximus-secret-labs/promise that referenced this pull request

Jul 8, 2023
Adds template annotations turning the `PromiseInterface` into a generic.
Variables `$p1` and `$p2` in the following code example both are `PromiseInterface<int|string>`.
```php
$f = function (): int|string {
    return time() % 2 ? 'string' : time();
};
/**
 * @return PromiseInterface<int|string>
 */
$fp = function (): PromiseInterface {
    return resolve(time() % 2 ? 'string' : time());
};
$p1 = resolve($f());
$p2 = $fp();
```
When calling `then` on `$p1` or `$p2`, PHPStan understand that function `$f1` is type hinting its parameter fine, but `$f2` will throw during runtime:
```php
$p2->then(static function (int|string $a) {});
$p2->then(static function (bool $a) {});
```
Builds on top of reactphp#246 and reactphp#188 and is a requirement for reactphp/async#40

WyriHaximus pushed a commit to WyriHaximus-secret-labs/promise that referenced this pull request

Jul 8, 2023
Adds template annotations turning the `PromiseInterface` into a generic.
Variables `$p1` and `$p2` in the following code example both are `PromiseInterface<int|string>`.
```php
$f = function (): int|string {
    return time() % 2 ? 'string' : time();
};
/**
 * @return PromiseInterface<int|string>
 */
$fp = function (): PromiseInterface {
    return resolve(time() % 2 ? 'string' : time());
};
$p1 = resolve($f());
$p2 = $fp();
```
When calling `then` on `$p1` or `$p2`, PHPStan understand that function `$f1` is type hinting its parameter fine, but `$f2` will throw during runtime:
```php
$p2->then(static function (int|string $a) {});
$p2->then(static function (bool $a) {});
```
Builds on top of reactphp#246 and reactphp#188 and is a requirement for reactphp/async#40

WyriHaximus pushed a commit to WyriHaximus-secret-labs/promise that referenced this pull request

Jul 8, 2023
Adds template annotations turning the `PromiseInterface` into a generic.
Variables `$p1` and `$p2` in the following code example both are `PromiseInterface<int|string>`.
```php
$f = function (): int|string {
    return time() % 2 ? 'string' : time();
};
/**
 * @return PromiseInterface<int|string>
 */
$fp = function (): PromiseInterface {
    return resolve(time() % 2 ? 'string' : time());
};
$p1 = resolve($f());
$p2 = $fp();
```
When calling `then` on `$p1` or `$p2`, PHPStan understand that function `$f1` is type hinting its parameter fine, but `$f2` will throw during runtime:
```php
$p2->then(static function (int|string $a) {});
$p2->then(static function (bool $a) {});
```
Builds on top of reactphp#246 and reactphp#188 and is a requirement for reactphp/async#40

WyriHaximus pushed a commit to WyriHaximus-secret-labs/promise that referenced this pull request

Jul 9, 2023
Adds template annotations turning the `PromiseInterface` into a generic.
Variables `$p1` and `$p2` in the following code example both are `PromiseInterface<int|string>`.
```php
$f = function (): int|string {
    return time() % 2 ? 'string' : time();
};
/**
 * @return PromiseInterface<int|string>
 */
$fp = function (): PromiseInterface {
    return resolve(time() % 2 ? 'string' : time());
};
$p1 = resolve($f());
$p2 = $fp();
```
When calling `then` on `$p1` or `$p2`, PHPStan understand that function `$f1` is type hinting its parameter fine, but `$f2` will throw during runtime:
```php
$p2->then(static function (int|string $a) {});
$p2->then(static function (bool $a) {});
```
Builds on top of reactphp#246 and reactphp#188 and is a requirement for reactphp/async#40

WyriHaximus pushed a commit to WyriHaximus-secret-labs/promise that referenced this pull request

Jul 9, 2023
Adds template annotations turning the `PromiseInterface` into a generic.
Variables `$p1` and `$p2` in the following code example both are `PromiseInterface<int|string>`.
```php
$f = function (): int|string {
    return time() % 2 ? 'string' : time();
};
/**
 * @return PromiseInterface<int|string>
 */
$fp = function (): PromiseInterface {
    return resolve(time() % 2 ? 'string' : time());
};
$p1 = resolve($f());
$p2 = $fp();
```
When calling `then` on `$p1` or `$p2`, PHPStan understand that function `$f1` is type hinting its parameter fine, but `$f2` will throw during runtime:
```php
$p2->then(static function (int|string $a) {});
$p2->then(static function (bool $a) {});
```
Builds on top of reactphp#246 and reactphp#188 and is a requirement for reactphp/async#40

WyriHaximus pushed a commit to WyriHaximus-secret-labs/promise that referenced this pull request

Jul 9, 2023
Adds template annotations turning the `PromiseInterface` into a generic.
Variables `$p1` and `$p2` in the following code example both are `PromiseInterface<int|string>`.
```php
$f = function (): int|string {
    return time() % 2 ? 'string' : time();
};
/**
 * @return PromiseInterface<int|string>
 */
$fp = function (): PromiseInterface {
    return resolve(time() % 2 ? 'string' : time());
};
$p1 = resolve($f());
$p2 = $fp();
```
When calling `then` on `$p1` or `$p2`, PHPStan understand that function `$f1` is type hinting its parameter fine, but `$f2` will throw during runtime:
```php
$p2->then(static function (int|string $a) {});
$p2->then(static function (bool $a) {});
```
Builds on top of reactphp#246 and reactphp#188 and is a requirement for reactphp/async#40

WyriHaximus pushed a commit to WyriHaximus-secret-labs/promise that referenced this pull request

Jul 9, 2023
Adds template annotations turning the `PromiseInterface` into a generic.
Variables `$p1` and `$p2` in the following code example both are `PromiseInterface<int|string>`.
```php
$f = function (): int|string {
    return time() % 2 ? 'string' : time();
};
/**
 * @return PromiseInterface<int|string>
 */
$fp = function (): PromiseInterface {
    return resolve(time() % 2 ? 'string' : time());
};
$p1 = resolve($f());
$p2 = $fp();
```
When calling `then` on `$p1` or `$p2`, PHPStan understand that function `$f1` is type hinting its parameter fine, but `$f2` will throw during runtime:
```php
$p2->then(static function (int|string $a) {});
$p2->then(static function (bool $a) {});
```
Builds on top of reactphp#246 and reactphp#188 and is a requirement for reactphp/async#40

WyriHaximus pushed a commit to WyriHaximus-secret-labs/promise that referenced this pull request

Jul 9, 2023
Adds template annotations turning the `PromiseInterface` into a generic.
Variables `$p1` and `$p2` in the following code example both are `PromiseInterface<int|string>`.
```php
$f = function (): int|string {
    return time() % 2 ? 'string' : time();
};
/**
 * @return PromiseInterface<int|string>
 */
$fp = function (): PromiseInterface {
    return resolve(time() % 2 ? 'string' : time());
};
$p1 = resolve($f());
$p2 = $fp();
```
When calling `then` on `$p1` or `$p2`, PHPStan understand that function `$f1` is type hinting its parameter fine, but `$f2` will throw during runtime:
```php
$p2->then(static function (int|string $a) {});
$p2->then(static function (bool $a) {});
```
Builds on top of reactphp#246 and reactphp#188 and is a requirement for reactphp/async#40

WyriHaximus pushed a commit to WyriHaximus-secret-labs/promise that referenced this pull request

Jul 9, 2023
Adds template annotations turning the `PromiseInterface` into a generic.
Variables `$p1` and `$p2` in the following code example both are `PromiseInterface<int|string>`.
```php
$f = function (): int|string {
    return time() % 2 ? 'string' : time();
};
/**
 * @return PromiseInterface<int|string>
 */
$fp = function (): PromiseInterface {
    return resolve(time() % 2 ? 'string' : time());
};
$p1 = resolve($f());
$p2 = $fp();
```
When calling `then` on `$p1` or `$p2`, PHPStan understand that function `$f1` is type hinting its parameter fine, but `$f2` will throw during runtime:
```php
$p2->then(static function (int|string $a) {});
$p2->then(static function (bool $a) {});
```
Builds on top of reactphp#246 and reactphp#188 and is a requirement for reactphp/async#40

WyriHaximus pushed a commit to WyriHaximus-secret-labs/promise that referenced this pull request

Jul 9, 2023
Adds template annotations turning the `PromiseInterface` into a generic.
Variables `$p1` and `$p2` in the following code example both are `PromiseInterface<int|string>`.
```php
$f = function (): int|string {
    return time() % 2 ? 'string' : time();
};
/**
 * @return PromiseInterface<int|string>
 */
$fp = function (): PromiseInterface {
    return resolve(time() % 2 ? 'string' : time());
};
$p1 = resolve($f());
$p2 = $fp();
```
When calling `then` on `$p1` or `$p2`, PHPStan understand that function `$f1` is type hinting its parameter fine, but `$f2` will throw during runtime:
```php
$p2->then(static function (int|string $a) {});
$p2->then(static function (bool $a) {});
```
Builds on top of reactphp#246 and reactphp#188 and is a requirement for reactphp/async#40

WyriHaximus pushed a commit to WyriHaximus-secret-labs/promise that referenced this pull request

Jul 9, 2023
Adds template annotations turning the `PromiseInterface` into a generic.
Variables `$p1` and `$p2` in the following code example both are `PromiseInterface<int|string>`.
```php
$f = function (): int|string {
    return time() % 2 ? 'string' : time();
};
/**
 * @return PromiseInterface<int|string>
 */
$fp = function (): PromiseInterface {
    return resolve(time() % 2 ? 'string' : time());
};
$p1 = resolve($f());
$p2 = $fp();
```
When calling `then` on `$p1` or `$p2`, PHPStan understand that function `$f1` is type hinting its parameter fine, but `$f2` will throw during runtime:
```php
$p2->then(static function (int|string $a) {});
$p2->then(static function (bool $a) {});
```
Builds on top of reactphp#246 and reactphp#188 and is a requirement for reactphp/async#40

WyriHaximus pushed a commit to WyriHaximus-secret-labs/promise that referenced this pull request

Jul 9, 2023
Adds template annotations turning the `PromiseInterface` into a generic.
Variables `$p1` and `$p2` in the following code example both are `PromiseInterface<int|string>`.
```php
$f = function (): int|string {
    return time() % 2 ? 'string' : time();
};
/**
 * @return PromiseInterface<int|string>
 */
$fp = function (): PromiseInterface {
    return resolve(time() % 2 ? 'string' : time());
};
$p1 = resolve($f());
$p2 = $fp();
```
When calling `then` on `$p1` or `$p2`, PHPStan understand that function `$f1` is type hinting its parameter fine, but `$f2` will throw during runtime:
```php
$p2->then(static function (int|string $a) {});
$p2->then(static function (bool $a) {});
```
Builds on top of reactphp#246 and reactphp#188 and is a requirement for reactphp/async#40

WyriHaximus pushed a commit to WyriHaximus-secret-labs/promise that referenced this pull request

Jul 9, 2023
Adds template annotations turning the `PromiseInterface` into a generic.
Variables `$p1` and `$p2` in the following code example both are `PromiseInterface<int|string>`.
```php
$f = function (): int|string {
    return time() % 2 ? 'string' : time();
};
/**
 * @return PromiseInterface<int|string>
 */
$fp = function (): PromiseInterface {
    return resolve(time() % 2 ? 'string' : time());
};
$p1 = resolve($f());
$p2 = $fp();
```
When calling `then` on `$p1` or `$p2`, PHPStan understand that function `$f1` is type hinting its parameter fine, but `$f2` will throw during runtime:
```php
$p2->then(static function (int|string $a) {});
$p2->then(static function (bool $a) {});
```
Builds on top of reactphp#246 and reactphp#188 and is a requirement for reactphp/async#40

WyriHaximus pushed a commit to WyriHaximus-secret-labs/promise that referenced this pull request

Jul 9, 2023
Adds template annotations turning the `PromiseInterface` into a generic.
Variables `$p1` and `$p2` in the following code example both are `PromiseInterface<int|string>`.
```php
$f = function (): int|string {
    return time() % 2 ? 'string' : time();
};
/**
 * @return PromiseInterface<int|string>
 */
$fp = function (): PromiseInterface {
    return resolve(time() % 2 ? 'string' : time());
};
$p1 = resolve($f());
$p2 = $fp();
```
When calling `then` on `$p1` or `$p2`, PHPStan understand that function `$f1` is type hinting its parameter fine, but `$f2` will throw during runtime:
```php
$p2->then(static function (int|string $a) {});
$p2->then(static function (bool $a) {});
```
Builds on top of reactphp#246 and reactphp#188 and is a requirement for reactphp/async#40

WyriHaximus pushed a commit to WyriHaximus-secret-labs/promise that referenced this pull request

Jul 9, 2023
Adds template annotations turning the `PromiseInterface` into a generic.
Variables `$p1` and `$p2` in the following code example both are `PromiseInterface<int|string>`.
```php
$f = function (): int|string {
    return time() % 2 ? 'string' : time();
};
/**
 * @return PromiseInterface<int|string>
 */
$fp = function (): PromiseInterface {
    return resolve(time() % 2 ? 'string' : time());
};
$p1 = resolve($f());
$p2 = $fp();
```
When calling `then` on `$p1` or `$p2`, PHPStan understand that function `$f1` is type hinting its parameter fine, but `$f2` will throw during runtime:
```php
$p2->then(static function (int|string $a) {});
$p2->then(static function (bool $a) {});
```
Builds on top of reactphp#246 and reactphp#188 and is a requirement for reactphp/async#40

WyriHaximus pushed a commit to WyriHaximus-secret-labs/promise that referenced this pull request

Jul 9, 2023
Adds template annotations turning the `PromiseInterface` into a generic.
Variables `$p1` and `$p2` in the following code example both are `PromiseInterface<int|string>`.
```php
$f = function (): int|string {
    return time() % 2 ? 'string' : time();
};
/**
 * @return PromiseInterface<int|string>
 */
$fp = function (): PromiseInterface {
    return resolve(time() % 2 ? 'string' : time());
};
$p1 = resolve($f());
$p2 = $fp();
```
When calling `then` on `$p1` or `$p2`, PHPStan understand that function `$f1` is type hinting its parameter fine, but `$f2` will throw during runtime:
```php
$p2->then(static function (int|string $a) {});
$p2->then(static function (bool $a) {});
```
Builds on top of reactphp#246 and reactphp#188 and is a requirement for reactphp/async#40

@clue clue mentioned this pull request

Jul 10, 2023

Merged

WyriHaximus pushed a commit to WyriHaximus-secret-labs/promise that referenced this pull request

Jul 10, 2023
Adds template annotations turning the `PromiseInterface` into a generic.
Variables `$p1` and `$p2` in the following code example both are `PromiseInterface<int|string>`.
```php
$f = function (): int|string {
    return time() % 2 ? 'string' : time();
};
/**
 * @return PromiseInterface<int|string>
 */
$fp = function (): PromiseInterface {
    return resolve(time() % 2 ? 'string' : time());
};
$p1 = resolve($f());
$p2 = $fp();
```
When calling `then` on `$p1` or `$p2`, PHPStan understand that function `$f1` is type hinting its parameter fine, but `$f2` will throw during runtime:
```php
$p2->then(static function (int|string $a) {});
$p2->then(static function (bool $a) {});
```
Builds on top of reactphp#246 and reactphp#188 and is a requirement for reactphp/async#40

WyriHaximus pushed a commit to WyriHaximus-secret-labs/promise that referenced this pull request

Jul 10, 2023
Adds template annotations turning the `PromiseInterface` into a generic.
Variables `$p1` and `$p2` in the following code example both are `PromiseInterface<int|string>`.
```php
$f = function (): int|string {
    return time() % 2 ? 'string' : time();
};
/**
 * @return PromiseInterface<int|string>
 */
$fp = function (): PromiseInterface {
    return resolve(time() % 2 ? 'string' : time());
};
$p1 = resolve($f());
$p2 = $fp();
```
When calling `then` on `$p1` or `$p2`, PHPStan understand that function `$f1` is type hinting its parameter fine, but `$f2` will throw during runtime:
```php
$p2->then(static function (int|string $a) {});
$p2->then(static function (bool $a) {});
```
Builds on top of reactphp#246 and reactphp#188 and is a requirement for reactphp/async#40

WyriHaximus pushed a commit to WyriHaximus-secret-labs/promise that referenced this pull request

Jul 10, 2023
Adds template annotations turning the `PromiseInterface` into a generic.
Variables `$p1` and `$p2` in the following code example both are `PromiseInterface<int|string>`.
```php
$f = function (): int|string {
    return time() % 2 ? 'string' : time();
};
/**
 * @return PromiseInterface<int|string>
 */
$fp = function (): PromiseInterface {
    return resolve(time() % 2 ? 'string' : time());
};
$p1 = resolve($f());
$p2 = $fp();
```
When calling `then` on `$p1` or `$p2`, PHPStan understand that function `$f1` is type hinting its parameter fine, but `$f2` will throw during runtime:
```php
$p2->then(static function (int|string $a) {});
$p2->then(static function (bool $a) {});
```
Builds on top of reactphp#246 and reactphp#188 and is a requirement for reactphp/async#40

WyriHaximus pushed a commit to WyriHaximus-secret-labs/promise that referenced this pull request

Jul 11, 2023
Adds template annotations turning the `PromiseInterface` into a generic.
Variables `$p1` and `$p2` in the following code example both are `PromiseInterface<int|string>`.
```php
$f = function (): int|string {
    return time() % 2 ? 'string' : time();
};
/**
 * @return PromiseInterface<int|string>
 */
$fp = function (): PromiseInterface {
    return resolve(time() % 2 ? 'string' : time());
};
$p1 = resolve($f());
$p2 = $fp();
```
When calling `then` on `$p1` or `$p2`, PHPStan understand that function `$f1` is type hinting its parameter fine, but `$f2` will throw during runtime:
```php
$p2->then(static function (int|string $a) {});
$p2->then(static function (bool $a) {});
```
Builds on top of reactphp#246 and reactphp#188 and is a requirement for reactphp/async#40

clue pushed a commit to WyriHaximus-secret-labs/promise that referenced this pull request

Jul 11, 2023
Adds template annotations turning the `PromiseInterface` into a generic.
Variables `$p1` and `$p2` in the following code example both are
`PromiseInterface<int|string>`.
```php
$f = function (): int|string {
    return time() % 2 ? 'string' : time();
};
/**
 * @return PromiseInterface<int|string>
 */
$fp = function (): PromiseInterface {
    return resolve(time() % 2 ? 'string' : time());
};
$p1 = resolve($f());
$p2 = $fp();
```
When calling `then` on `$p1` or `$p2`, PHPStan understand that function
`$f1` is type hinting its parameter fine, but `$f2` will throw during
runtime:
```php
$p2->then(static function (int|string $a) {});
$p2->then(static function (bool $a) {});
```
Builds on top of reactphp#246 and
reactphp#188 and is a requirement for
reactphp/async#40

clue pushed a commit to WyriHaximus-secret-labs/promise that referenced this pull request

Jul 11, 2023
Adds template annotations turning the `PromiseInterface` into a generic.
Variables `$p1` and `$p2` in the following code example both are
`PromiseInterface<int|string>`.
```php
$f = function (): int|string {
    return time() % 2 ? 'string' : time();
};
/**
 * @return PromiseInterface<int|string>
 */
$fp = function (): PromiseInterface {
    return resolve(time() % 2 ? 'string' : time());
};
$p1 = resolve($f());
$p2 = $fp();
```
When calling `then` on `$p1` or `$p2`, PHPStan understand that function
`$f1` is type hinting its parameter fine, but `$f2` will throw during
runtime:
```php
$p2->then(static function (int|string $a) {});
$p2->then(static function (bool $a) {});
```
Builds on top of reactphp#246 and
reactphp#188 and is a requirement for
reactphp/async#40

Merged

This was referenced

Sep 4, 2023

Closed

Merged

@clue clue mentioned this pull request

Oct 29, 2023

Merged

This was referenced

Mar 21, 2024

Merged

Closed

@clue clue mentioned this pull request

Mar 29, 2024

Merged

Closed

Closed

Read the original on github.com ↗