Skip to content
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

Small changes so tests run smoothly #253

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions src/Functional/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ function group($collection, callable $callback)

InvalidArgumentException::assertValidArrayKey($groupKey, __FUNCTION__);

// Avoid implicit conversion, since float numbers cannot be used as
// array keys:
if (is_numeric($groupKey)) {
$groupKey = intval($groupKey);
}

if (!isset($groups[$groupKey])) {
$groups[$groupKey] = [];
}
Expand Down
10 changes: 5 additions & 5 deletions src/Functional/Sequences/ExponentialSequence.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,28 @@ public function __construct($start, $percentage)
$this->percentage = $percentage;
}

public function current()
public function current(): mixed
{
return $this->value;
}

public function next()
public function next(): void
{
$this->value = (int) \round(\pow($this->start * (1 + $this->percentage / 100), $this->times));
$this->times++;
}

public function key()
public function key(): mixed
{
return null;
}

public function valid()
public function valid(): bool
{
return true;
}

public function rewind()
public function rewind(): void
{
$this->times = 1;
$this->value = $this->start;
Expand Down
10 changes: 5 additions & 5 deletions src/Functional/Sequences/LinearSequence.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,27 @@ public function __construct($start, $amount)
$this->amount = $amount;
}

public function current()
public function current(): mixed
{
return $this->value;
}

public function next()
public function next(): void
{
$this->value += $this->amount;
}

public function key()
public function key(): mixed
{
return 0;
}

public function valid()
public function valid(): bool
{
return true;
}

public function rewind()
public function rewind(): void
{
$this->value = $this->start;
}
Expand Down