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

bump and unlock phpstan #104

Merged
merged 1 commit into from
May 28, 2024
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"friendsofphp/php-cs-fixer": "^3.27",
"nette/php-generator": "^4.0",
"phpunit/phpunit": "^9.6.13",
"phpstan/phpstan": "1.11.1"
"phpstan/phpstan": "^1.11.2"
},
"autoload": {
"psr-4": {
Expand Down
20 changes: 8 additions & 12 deletions src/Collection/Stream/Collector/GenericCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ final class GenericCollector implements Collector
private $supplier;

/**
* @var callable
* @var callable(R,T):R
*/
private $accumulator;

/**
* @var callable
* @var callable(R):R
*/
private $finisher;

Expand All @@ -52,29 +52,25 @@ public function __construct($supplier, callable $accumulator, callable $finisher
*/
public static function of($supplier, callable $accumulator): self
{
return new self($supplier, $accumulator,
/**
* @param W $supplier
*
* @return W
*/
function ($supplier) {return $supplier; }
);
/** @var self<U,W> $instance */
$instance = new self($supplier, $accumulator, fn ($s) => $s);

return $instance;
}

/**
* @param T $value
*/
public function accumulate($value): void
{
$this->supplier = call_user_func($this->accumulator, $this->supplier, $value);
$this->supplier = ($this->accumulator)($this->supplier, $value);
}

/**
* @return R
*/
public function finish()
{
return call_user_func($this->finisher, $this->supplier);
return ($this->finisher)($this->supplier);
}
}
20 changes: 2 additions & 18 deletions src/Collection/Traversable.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,15 +339,7 @@ public function min(): Option
return Option::none();
}

return Option::of($this->fold($this->head(),
/**
* @param T $min
* @param T $x
*/
function ($min, $x) {
return $min <= $x ? $min : $x;
}
));
return Option::of($this->fold($this->head(), min(...)));
}

/**
Expand All @@ -359,15 +351,7 @@ public function max(): Option
return Option::none();
}

return Option::of($this->fold($this->head(),
/**
* @param T $max
* @param T $x
*/
function ($max, $x) {
return $max >= $x ? $max : $x;
}
));
return Option::of($this->fold($this->head(), max(...)));
}

/**
Expand Down
Loading