Skip to content

Commit

Permalink
Make constructors of Option child types protected
Browse files Browse the repository at this point in the history
It is not possible to call directly constructor
on a child type from outer context.
  • Loading branch information
piku235 committed Aug 21, 2021
1 parent 7944278 commit ac6f84d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Option.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ final class Some extends Option
/**
* @param T $value
*/
public function __construct($value)
protected function __construct($value)
{
$this->value = $value;
}
Expand Down Expand Up @@ -223,6 +223,8 @@ public function asOkOr($err): Result
*/
final class None extends Option
{
protected function __construct() {}

public function isSome(): bool
{
return false;
Expand Down

0 comments on commit ac6f84d

Please sign in to comment.