Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<issueHandlers>
<UndefinedAttributeClass errorLevel="suppress" />
</issueHandlers>
</psalm>
5 changes: 5 additions & 0 deletions src/Hash.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ enum Hash
case sha384;
case sha512;

#[\NoDiscard]
public function ofFile(File $file): Value
{
return $this->ofContent($file->content());
}

#[\NoDiscard]
public function ofContent(File\Content $content): Value
{
return $this->ofSequence(
Expand All @@ -32,6 +34,7 @@ public function ofContent(File\Content $content): Value
/**
* @param Sequence<Str> $chunks
*/
#[\NoDiscard]
public function ofSequence(Sequence $chunks): Value
{
return $chunks
Expand All @@ -45,11 +48,13 @@ public function ofSequence(Sequence $chunks): Value
/**
* @psalm-external-mutation-free
*/
#[\NoDiscard]
public function start(): Incremental
{
return Incremental::start($this);
}

#[\NoDiscard]
public function toString(): string
{
return $this->name;
Expand Down
3 changes: 3 additions & 0 deletions src/Incremental.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ private function __construct(\HashContext $context)
$this->context = $context;
}

#[\NoDiscard]
public static function start(Hash $hash): self
{
return new self(\hash_init($hash->toString()));
Expand All @@ -26,6 +27,7 @@ public static function start(Hash $hash): self
*
* @psalm-external-mutation-free
*/
#[\NoDiscard]
public function add(Str $chunk): self
{
/** @psalm-suppress ImpureFunctionCall */
Expand All @@ -39,6 +41,7 @@ public function add(Str $chunk): self
*
* @psalm-external-mutation-free
*/
#[\NoDiscard]
public function finish(): Value
{
return Value::of(\hash_final($this->context));
Expand Down
3 changes: 3 additions & 0 deletions src/Value.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ private function __construct(string $hex)
*
* @param non-empty-string $hex
*/
#[\NoDiscard]
public static function of(string $hex): self
{
return new self($hex);
Expand All @@ -32,11 +33,13 @@ public static function of(string $hex): self
/**
* @return non-empty-string
*/
#[\NoDiscard]
public function hex(): string
{
return $this->hex;
}

#[\NoDiscard]
public function binary(): string
{
/** @var string */
Expand Down