Skip to content

fix: Option/functions.php の PHPDoc を修正(ただしく型推論されるように) #46

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

Merged
merged 1 commit into from
Jul 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Option/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@
* It will be a `Some` option containing `$value` if `$value` is different from `$noneValue` (default `null`)
*
* @template U
* @param U $value
* @param U|null $value
* @return Option<U>
*/
function fromValue(mixed $value, mixed $noneValue = null, bool $strict = true): Option
function fromValue($value, mixed $noneValue = null, bool $strict = true): Option
{
$same = $strict
? ($value === $noneValue)
: ($value == $noneValue);

return $same

Check failure on line 48 in src/Option/functions.php

View workflow job for this annotation

GitHub Actions / PHPStan and PHPUnit (PHP 8.4 on ubuntu-latest)

Function WizDevelop\PhpMonad\Option\fromValue() should return WizDevelop\PhpMonad\Option<U> but returns WizDevelop\PhpMonad\Option\None|WizDevelop\PhpMonad\Option\Some<U|null>.
? Option\none()
: Option\some($value);
}
Expand All @@ -55,10 +55,10 @@
* It will be a `Some` option containing the result if it is different from `$noneValue` (default `null`).
*
* @template U
* @param callable():U $callback
* @param callable():U|null $callback
* @return Option<U>
*/
function of(callable $callback, mixed $noneValue = null, bool $strict = true): Option

Check failure on line 61 in src/Option/functions.php

View workflow job for this annotation

GitHub Actions / PHPStan and PHPUnit (PHP 8.4 on ubuntu-latest)

Template type U of function WizDevelop\PhpMonad\Option\of() is not referenced in a parameter.

Check failure on line 61 in src/Option/functions.php

View workflow job for this annotation

GitHub Actions / PHPStan and PHPUnit (PHP 8.4 on ubuntu-latest)

PHPDoc tag @param for parameter $callback with type (callable)|null is not subtype of native type callable.
{
return Option\fromValue($callback(), $noneValue, $strict);
}
Expand All @@ -69,12 +69,12 @@
*
* @template U
* @template E of \Throwable
* @param callable():U $callback
* @param callable():U|null $callback
* @param class-string<E> $exceptionClass
* @return Option<U>
* @throws Throwable
*/
function tryOf(

Check failure on line 77 in src/Option/functions.php

View workflow job for this annotation

GitHub Actions / PHPStan and PHPUnit (PHP 8.4 on ubuntu-latest)

Template type U of function WizDevelop\PhpMonad\Option\tryOf() is not referenced in a parameter.

Check failure on line 77 in src/Option/functions.php

View workflow job for this annotation

GitHub Actions / PHPStan and PHPUnit (PHP 8.4 on ubuntu-latest)

PHPDoc tag @param for parameter $callback with type (callable)|null is not subtype of native type callable.
callable $callback,
mixed $noneValue = null,
bool $strict = true,
Expand Down
Loading