-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
- Loading branch information
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,14 +6,12 @@ | |
|
||
use CuyZ\Valinor\Definition\Attributes; | ||
use CuyZ\Valinor\Definition\AttributesContainer; | ||
use CuyZ\Valinor\Mapper\Tree\Exception\CannotGetParentOfRootShell; | ||
use CuyZ\Valinor\Mapper\Tree\Exception\NewShellTypeDoesNotMatch; | ||
use CuyZ\Valinor\Mapper\Tree\Exception\ShellHasNoValue; | ||
use CuyZ\Valinor\Mapper\Tree\Exception\UnresolvableShellType; | ||
use CuyZ\Valinor\Type\Type; | ||
use CuyZ\Valinor\Type\Types\UnresolvableType; | ||
|
||
use function array_unshift; | ||
use function assert; | ||
use function implode; | ||
|
||
/** @internal */ | ||
|
@@ -31,9 +29,7 @@ final class Shell | |
|
||
private function __construct(private Type $type) | ||
{ | ||
if ($type instanceof UnresolvableType) { | ||
throw new UnresolvableShellType($type); | ||
} | ||
assert(! $type instanceof UnresolvableType); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
romm
Author
Member
|
||
} | ||
|
||
public static function root(Type $type, mixed $value): self | ||
|
@@ -64,22 +60,13 @@ public function isRoot(): bool | |
return ! isset($this->parent); | ||
} | ||
|
||
public function parent(): self | ||
{ | ||
if (! isset($this->parent)) { | ||
throw new CannotGetParentOfRootShell(); | ||
} | ||
|
||
return $this->parent; | ||
} | ||
|
||
public function withType(Type $newType): self | ||
{ | ||
$clone = clone $this; | ||
$clone->type = $newType; | ||
|
||
if (! $newType->matches($this->type)) { | ||
throw new NewShellTypeDoesNotMatch($this, $newType); | ||
throw new NewShellTypeDoesNotMatch($this, $newType); // @todo remove? | ||
} | ||
|
||
return $clone; | ||
|
@@ -106,9 +93,7 @@ public function hasValue(): bool | |
|
||
public function value(): mixed | ||
{ | ||
if (! $this->hasValue) { | ||
throw new ShellHasNoValue(); | ||
} | ||
assert($this->hasValue); | ||
|
||
return $this->value; | ||
} | ||
|
This file was deleted.
This file was deleted.
Note that the
assert
function may not always work, depending on how it is configured in php.ini.In fact, the default configuration specifies to only emit a warning, not throw an exception.