Feat: Upgrading Lunar to 1.5
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
|
||||
namespace Modules\Core\Option;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Exception;
|
||||
use RuntimeException;
|
||||
use Traversable;
|
||||
|
||||
/**
|
||||
@@ -39,7 +42,7 @@ final class LazyOption extends Option
|
||||
public function __construct($callback, array $arguments = [])
|
||||
{
|
||||
if (!is_callable($callback)) {
|
||||
throw new \InvalidArgumentException("Invalid callback given");
|
||||
throw new InvalidArgumentException("Invalid callback given");
|
||||
}
|
||||
|
||||
$this->callback = $callback;
|
||||
@@ -71,7 +74,7 @@ final class LazyOption extends Option
|
||||
return $this->option()->getOrCall($callable);
|
||||
}
|
||||
|
||||
public function getOrThrow(\Exception $ex)
|
||||
public function getOrThrow(Exception $ex)
|
||||
{
|
||||
return $this->option()->getOrThrow($ex);
|
||||
}
|
||||
@@ -146,7 +149,7 @@ final class LazyOption extends Option
|
||||
if ($option instanceof Option) {
|
||||
$this->option = $option;
|
||||
} else {
|
||||
throw new \RuntimeException(
|
||||
throw new RuntimeException(
|
||||
sprintf("Expected instance of %s", Option::class),
|
||||
);
|
||||
}
|
||||
|
||||
+4
-2
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Modules\Core\Option;
|
||||
|
||||
use RuntimeException;
|
||||
use Exception;
|
||||
use EmptyIterator;
|
||||
|
||||
/**
|
||||
@@ -24,7 +26,7 @@ final class None extends Option
|
||||
|
||||
public function get()
|
||||
{
|
||||
throw new \RuntimeException("None has no value.");
|
||||
throw new RuntimeException("None has no value.");
|
||||
}
|
||||
|
||||
public function getOrCall($callable)
|
||||
@@ -37,7 +39,7 @@ final class None extends Option
|
||||
return $default;
|
||||
}
|
||||
|
||||
public function getOrThrow(\Exception $ex)
|
||||
public function getOrThrow(Exception $ex)
|
||||
{
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Modules\Core\Option;
|
||||
|
||||
use Exception;
|
||||
use ArrayAccess;
|
||||
use IteratorAggregate;
|
||||
|
||||
@@ -164,7 +165,7 @@ abstract class Option implements IteratorAggregate
|
||||
abstract public function getOrCall($callable);
|
||||
|
||||
/** @return T */
|
||||
abstract public function getOrThrow(\Exception $ex);
|
||||
abstract public function getOrThrow(Exception $ex);
|
||||
|
||||
abstract public function isEmpty(): bool;
|
||||
|
||||
|
||||
+3
-2
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Modules\Core\Option;
|
||||
|
||||
use RuntimeException;
|
||||
use ArrayIterator;
|
||||
use Exception;
|
||||
|
||||
@@ -56,7 +57,7 @@ final class Some extends Option
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function getOrThrow(\Exception $ex)
|
||||
public function getOrThrow(Exception $ex)
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
@@ -88,7 +89,7 @@ final class Some extends Option
|
||||
/** @var mixed */
|
||||
$rs = $callable($this->value);
|
||||
if (!$rs instanceof Option) {
|
||||
throw new \RuntimeException(
|
||||
throw new RuntimeException(
|
||||
"Callables passed to flatMap() must return an Option. Maybe you should use map() instead?",
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user