-
-
Notifications
You must be signed in to change notification settings - Fork 209
Add phpstan typing annotations #250
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
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 |
|---|---|---|
|
|
@@ -11,11 +11,15 @@ | |
| namespace Functional; | ||
|
|
||
| /** | ||
| * Return a new function that captures the return value of $callback in $result and returns the callbacks return value | ||
| * Return a new function that captures the return value of $callback in $result and returns the callback's return value | ||
| * | ||
| * @template T | ||
| * | ||
| * @param callable():T $callback | ||
| * @param T $result | ||
| * | ||
| * @return callable():T | ||
|
Comment on lines
+16
to
+21
Owner
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. Would be great to indicate with types that the callback given is type-wise identical. But this depends on phpstan/phpstan#8964 and phpstan/phpstan#8214 |
||
| * | ||
| * @param callable $callback | ||
| * @param mixed $result | ||
| * @return callable | ||
| * @no-named-arguments | ||
| */ | ||
| function capture(callable $callback, &$result) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,16 +11,20 @@ | |
| namespace Functional; | ||
|
|
||
| use Functional\Exceptions\InvalidArgumentException; | ||
| use Traversable; | ||
|
|
||
| /** | ||
| * Returns true if the collection contains the given value. If the third parameter is | ||
| * true values will be compared in strict mode | ||
| * | ||
| * @param Traversable|array $collection | ||
| * @param mixed $value | ||
| * @template V | ||
| * @template V2 of V | ||
| * | ||
| * @param iterable<V> $collection | ||
| * @param V2 $value | ||
| * @param bool $strict | ||
| * | ||
| * @return bool | ||
| * | ||
|
Owner
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 needs to be a bit more complicated, to properly type the strictness. We need a conditional type here where V2 is of V if strict is true but otherwise V2 is independent of V
Author
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. Good catch. |
||
| * @no-named-arguments | ||
| */ | ||
| function contains($collection, $value, $strict = true) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,9 +16,15 @@ | |
| * The results of each branching function are passed as arguments | ||
| * to the converging function to produce the return value. | ||
| * | ||
| * @param callable $convergingFunction Will be invoked with the return values of all branching functions as its arguments | ||
| * @param callable[] $branchingFunctions A list of functions | ||
| * @return callable A flipped version of the given function | ||
| * @template V | ||
| * @template R | ||
| * @template R2 | ||
| * | ||
| * @param callable(R...):R2 $convergingFunction Will be invoked with the return values of all branching functions as its arguments | ||
| * @param array<callable(V):R> $branchingFunctions A list of functions | ||
| * | ||
| * @return callable(V...):R2 A flipped version of the given function | ||
|
||
| * | ||
| * @no-named-arguments | ||
| */ | ||
| function converge($convergingFunction, array $branchingFunctions) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.