Skip to content

Commit

Permalink
style: use constructor property promotion style
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Mar 5, 2023
1 parent 517e1cc commit 2568d7f
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 29 deletions.
8 changes: 1 addition & 7 deletions src/FilterIterableAggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,12 @@
*/
final class FilterIterableAggregate implements IteratorAggregate
{
/**
* @var Closure(T, TKey, iterable<TKey, T>): bool
*/
private Closure $predicate;

/**
* @param iterable<TKey, T> $iterable
* @param (Closure(T, TKey, iterable<TKey, T>): bool) $predicate
*/
public function __construct(private iterable $iterable, Closure $predicate)
public function __construct(private iterable $iterable, private Closure $predicate)
{
$this->predicate = $predicate;
}

/**
Expand Down
8 changes: 1 addition & 7 deletions src/MapIterableAggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,12 @@
*/
final class MapIterableAggregate implements IteratorAggregate
{
/**
* @var Closure(T, TKey, iterable<TKey, T>): W
*/
private Closure $closure;

/**
* @param iterable<TKey, T> $iterable
* @param (Closure(T, TKey, iterable<TKey, T>): W) $closure
*/
public function __construct(private iterable $iterable, Closure $closure)
public function __construct(private iterable $iterable, private Closure $closure)
{
$this->closure = $closure;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/MersenneTwisterRNGIteratorAggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function getIterator(): Generator

// @phpstan-ignore-next-line
while (true) {
yield mt_rand($this->min, $this->max);
yield random_int($this->min, $this->max);
}
}

Expand Down
8 changes: 1 addition & 7 deletions src/ReduceIterableAggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,13 @@
*/
final class ReduceIterableAggregate implements IteratorAggregate
{
/**
* @var Closure(W, T, TKey, iterable<TKey, T>): W
*/
private Closure $closure;

/**
* @param iterable<TKey, T> $iterable
* @param (Closure(W, T, TKey, iterable<TKey, T>): W) $closure
* @param W $initial
*/
public function __construct(private iterable $iterable, Closure $closure, private mixed $initial)
public function __construct(private iterable $iterable, private Closure $closure, private mixed $initial)
{
$this->closure = $closure;
}

/**
Expand Down
8 changes: 1 addition & 7 deletions src/ReductionIterableAggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,13 @@
*/
final class ReductionIterableAggregate implements IteratorAggregate
{
/**
* @var Closure(W, T, TKey, iterable<TKey, T>): W
*/
private Closure $closure;

/**
* @param iterable<TKey, T> $iterable
* @param (Closure(W, T, TKey, iterable<TKey, T>): W) $closure
* @param W $initial
*/
public function __construct(private iterable $iterable, Closure $closure, private mixed $initial)
public function __construct(private iterable $iterable, private Closure $closure, private mixed $initial)
{
$this->closure = $closure;
}

/**
Expand Down

0 comments on commit 2568d7f

Please sign in to comment.