-
-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[2.x] Add basic template annotations #227
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
/.gitattributes export-ignore | ||
/.github/ export-ignore | ||
/.gitignore export-ignore | ||
/phpstan.neon.dist export-ignore | ||
/phpunit.xml.dist export-ignore | ||
/phpunit.xml.legacy export-ignore | ||
/tests/ export-ignore | ||
/types/ export-ignore |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
parameters: | ||
paths: | ||
- types | ||
level: max |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,9 @@ | |
|
||
namespace React\Promise; | ||
|
||
/** | ||
* @template T | ||
*/ | ||
interface PromiseInterface | ||
{ | ||
/** | ||
|
@@ -32,10 +35,11 @@ interface PromiseInterface | |
* than once. | ||
* 3. `$onProgress` (deprecated) may be called multiple times. | ||
* | ||
* @param callable|null $onFulfilled | ||
* @template TReturn of mixed | ||
* @param callable(T): TReturn $onFulfilled | ||
* @param callable|null $onRejected | ||
* @param callable|null $onProgress This argument is deprecated and should not be used anymore. | ||
* @return PromiseInterface | ||
* @return (TReturn is PromiseInterface ? TReturn : PromiseInterface<TReturn>) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How should we handle cases such as this?
I see you did some work regarding type assertions in phpstan/phpstan#7371, perhaps this is something we should include as part of this PR? 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could do that, but then just the basics, and not the more complicated cases 👍 . |
||
*/ | ||
public function then(callable $onFulfilled = null, callable $onRejected = null, callable $onProgress = null); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see this currently only affects the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is purposely only covering |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
use function PHPStan\Testing\assertType; | ||
use function React\Promise\resolve; | ||
|
||
$passThroughBoolFn = static fn (bool $bool): bool => $bool; | ||
|
||
assertType('React\Promise\PromiseInterface<bool>', resolve(true)); | ||
assertType('React\Promise\PromiseInterface<bool>', resolve(true)->then($passThroughBoolFn)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No longer marked as nullable?